blob: 0dcbb30d1a7f7362f31dceca7287fe63f051f2bb [file] [log] [blame]
Simon Kelleyc72daea2012-01-05 21:33:27 +00001#!/usr/bin/make -f
2# debian/rules file - for dnsmasq.
3# Copyright 2001-2011 by Simon Kelley
4# Based on the sample in the debian hello package which carries the following:
5# Copyright 1994,1995 by Ian Jackson.
6# I hereby give you perpetual unlimited permission to copy,
7# modify and relicense this file, provided that you do not remove
8# my name from the file itself. (I assert my moral right of
9# paternity under the Copyright, Designs and Patents Act 1988.)
10# This file may have to be extensively modified
11
12package=dnsmasq-base
13
Simon Ruderich91f4a5e2014-05-20 20:27:31 +010014dpkg_buildflags := DEB_BUILD_MAINT_OPTIONS="hardening=+all" dpkg-buildflags
15
16CFLAGS = $(shell $(dpkg_buildflags) --get CFLAGS)
17CFLAGS += $(shell $(dpkg_buildflags) --get CPPFLAGS)
Simon Kelley97c83bb2012-05-28 18:21:59 +010018CFLAGS += -Wall -W
19
Simon Ruderich91f4a5e2014-05-20 20:27:31 +010020LDFLAGS = $(shell $(dpkg_buildflags) --get LDFLAGS)
Simon Kelleyc72daea2012-01-05 21:33:27 +000021
Simon Kelley8f6213c2014-01-28 11:16:49 +000022DEB_COPTS = $(COPTS)
Simon Kelley97c83bb2012-05-28 18:21:59 +010023
Simon Kelleyc72daea2012-01-05 21:33:27 +000024TARGET = install-i18n
25
Simon Kelley6ac3bc02014-10-03 08:48:11 +010026DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
Simon Kelleyc72daea2012-01-05 21:33:27 +000027
Simon Kelley02ed24d2013-09-09 18:06:45 +010028# Force package version based on git tags.
29ifneq (,$(filter gitversion,$(DEB_BUILD_OPTIONS)))
Simon Kelley1d1c7952013-10-02 14:52:23 +010030 PACKAGE_VERSION = $(shell bld/get-version `pwd` | sed 's/test/~&/; s/[a-z]/~&/; s/-/./g; s/$$/-1/; s/^/-v/';)
Simon Kelley02ed24d2013-09-09 18:06:45 +010031endif
32
Simon Kelley62779782012-02-10 21:19:25 +000033ifeq (,$(filter nodbus,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000034 DEB_COPTS += -DHAVE_DBUS
Simon Kelleyc72daea2012-01-05 21:33:27 +000035endif
36
Simon Kelley62779782012-02-10 21:19:25 +000037ifeq (,$(filter noconntrack,$(DEB_BUILD_OPTIONS)))
Simon Kelley6ac3bc02014-10-03 08:48:11 +010038ifeq ($(DEB_HOST_ARCH_OS),linux)
Simon Kelley8f6213c2014-01-28 11:16:49 +000039 DEB_COPTS += -DHAVE_CONNTRACK
Simon Kelleyc72daea2012-01-05 21:33:27 +000040endif
41endif
42
Simon Kelley3ddad242013-03-21 17:56:06 +000043ifneq (,$(filter noipset,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000044 DEB_COPTS += -DNO_IPSET
Simon Kelley3b323bd2013-02-22 21:55:29 +000045endif
46
Simon Kelley96c38792012-02-16 20:07:17 +000047ifneq (,$(filter nodhcp6,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000048 DEB_COPTS += -DNO_DHCP6
Simon Kelley127ea402012-02-11 22:14:52 +000049endif
50
Simon Kelley62779782012-02-10 21:19:25 +000051ifneq (,$(filter noipv6,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000052 DEB_COPTS += -DNO_IPV6
Simon Kelleyc72daea2012-01-05 21:33:27 +000053endif
54
Simon Kelley62779782012-02-10 21:19:25 +000055ifneq (,$(filter notftp,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000056 DEB_COPTS += -DNO_TFTP
Simon Kelleyc72daea2012-01-05 21:33:27 +000057endif
58
Simon Kelley62779782012-02-10 21:19:25 +000059ifneq (,$(filter nodhcp,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000060 DEB_COPTS += -DNO_DHCP
Simon Kelleyc72daea2012-01-05 21:33:27 +000061endif
62
Simon Kelley62779782012-02-10 21:19:25 +000063ifneq (,$(filter noscript,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000064 DEB_COPTS += -DNO_SCRIPT
Simon Kelleyc72daea2012-01-05 21:33:27 +000065endif
66
Simon Kelley62779782012-02-10 21:19:25 +000067ifneq (,$(filter nortc,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000068 DEB_COPTS += -DHAVE_BROKEN_RTC
Simon Kelleyc72daea2012-01-05 21:33:27 +000069endif
70
Simon Kelley62779782012-02-10 21:19:25 +000071ifneq (,$(filter noi18n,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000072 TARGET = install
Simon Kelley62779782012-02-10 21:19:25 +000073 ifeq (,$(filter noidn, $(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000074 DEB_COPTS += -DHAVE_IDN
Simon Kelleyc72daea2012-01-05 21:33:27 +000075 endif
76endif
77
Simon Kelley62779782012-02-10 21:19:25 +000078ifneq (,$(filter uselua,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000079 DEB_COPTS += -DHAVE_LUASCRIPT
Simon Kelley62779782012-02-10 21:19:25 +000080endif
81
Simon Kelley160f6502014-02-04 16:49:41 +000082ifeq (,$(filter nodnssec,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000083 DEB_COPTS += -DHAVE_DNSSEC
Simon Kelley00ec6932014-01-28 11:08:57 +000084endif
85
Simon Kelley6ac3bc02014-10-03 08:48:11 +010086ifneq ($(DEB_HOST_ARCH_OS),linux)
87 # For strlcpy in FreeBSD
88 LDFLAGS += -lbsd
89endif
90
Simon Kelleyc72daea2012-01-05 21:33:27 +000091clean:
92 $(checkdir)
93 rm -rf debian/daemon debian/base debian/utils debian/*~ debian/files debian/substvars debian/utils-substvars
94 make clean
95 make -C contrib/wrt clean
96
97binary-indep: checkroot
98 $(checkdir)
99 rm -rf debian/daemon
100 install -m 755 \
101 -d debian/daemon/DEBIAN \
102 -d debian/daemon/usr/share/doc \
103 -d debian/daemon/etc/init.d \
104 -d debian/daemon/etc/dnsmasq.d \
105 -d debian/daemon/etc/resolvconf/update.d \
106 -d debian/daemon/usr/lib/resolvconf/dpkg-event.d \
107 -d debian/daemon/etc/default \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000108 -d debian/daemon/lib/systemd/system \
109 -d debian/daemon/etc/insserv.conf.d
110 install -m 644 debian/conffiles debian/daemon/DEBIAN
111 install -m 755 debian/postinst debian/postrm debian/prerm debian/daemon/DEBIAN
112 install -m 755 debian/init debian/daemon/etc/init.d/dnsmasq
113 install -m 755 debian/resolvconf debian/daemon/etc/resolvconf/update.d/dnsmasq
114 install -m 755 debian/resolvconf-package debian/daemon/usr/lib/resolvconf/dpkg-event.d/dnsmasq
115 install -m 644 debian/default debian/daemon/etc/default/dnsmasq
116 install -m 644 dnsmasq.conf.example debian/daemon/etc/dnsmasq.conf
117 install -m 644 debian/readme.dnsmasq.d debian/daemon/etc/dnsmasq.d/README
Simon Kelleyc72daea2012-01-05 21:33:27 +0000118 install -m 644 debian/systemd.service debian/daemon/lib/systemd/system/dnsmasq.service
119 install -m 644 debian/insserv debian/daemon/etc/insserv.conf.d/dnsmasq
120 ln -s $(package) debian/daemon/usr/share/doc/dnsmasq
121 cd debian/daemon && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
Simon Kelleyaa985be2013-09-11 10:28:39 +0100122 dpkg-gencontrol $(PACKAGE_VERSION) -T -pdnsmasq -Pdebian/daemon
Simon Kelleyc72daea2012-01-05 21:33:27 +0000123 chown -R root.root debian/daemon
124 chmod -R g-ws debian/daemon
125 dpkg --build debian/daemon ..
126
127binary-arch: checkroot
128 $(checkdir)
129 rm -rf debian/base
130 install -m 755 \
131 -d debian/base/DEBIAN \
Simon Kelley4ba9b382012-07-29 17:07:48 +0100132 -d debian/base/etc/dbus-1/system.d \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000133 -d debian/base/usr/share/doc/$(package) \
134 -d debian/base/usr/share/doc/$(package)/examples \
135 -d debian/base/var/run \
Simon Kelleyda4f3722014-02-06 15:21:37 +0000136 -d debian/base/usr/share/$(package) \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000137 -d debian/base/var/lib/misc
Simon Kelley8f6213c2014-01-28 11:16:49 +0000138 make $(TARGET) PREFIX=/usr DESTDIR=`pwd`/debian/base CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=gcc
Simon Kelleyc72daea2012-01-05 21:33:27 +0000139ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
Simon Kelley933878f2014-09-09 14:28:01 +0100140# Need to remove paypal links in Debian Package for policy reasons.
141 sed -e /\<H2\>Donations/Q -e /icon.png/d doc.html -e /favicon.ico/d >debian/base/usr/share/doc/$(package)/doc.html
142 echo "</BODY>" >>debian/base/usr/share/doc/$(package)/doc.html
Simon Kelleyc72daea2012-01-05 21:33:27 +0000143 install -m 644 setup.html debian/base/usr/share/doc/$(package)/.
144 install -m 644 dnsmasq.conf.example debian/base/usr/share/doc/$(package)/examples/.
Simon Kelleyda4f3722014-02-06 15:21:37 +0000145 install -m 644 trust-anchors.conf debian/base/usr/share/$(package)/.
Simon Kelleyc72daea2012-01-05 21:33:27 +0000146 install -m 644 FAQ debian/base/usr/share/doc/$(package)/.
147 gzip -9 debian/base/usr/share/doc/$(package)/FAQ
148 install -m 644 CHANGELOG debian/base/usr/share/doc/$(package)/changelog
149 gzip -9 debian/base/usr/share/doc/$(package)/changelog
150 install -m 644 CHANGELOG.archive debian/base/usr/share/doc/$(package)/changelog.archive
151 gzip -9 debian/base/usr/share/doc/$(package)/changelog.archive
152 install -m 644 dbus/DBus-interface debian/base/usr/share/doc/$(package)/.
153 gzip -9 debian/base/usr/share/doc/$(package)/DBus-interface
154endif
Simon Kelley4ba9b382012-07-29 17:07:48 +0100155 install -m 644 debian/dnsmasq-base.conffiles debian/base/DEBIAN/conffiles
Simon Kelleybc54ae32012-08-28 21:26:56 +0100156 install -m 755 debian/dnsmasq-base.postinst debian/base/DEBIAN/postinst
157 install -m 755 debian/dnsmasq-base.postrm debian/base/DEBIAN/postrm
Simon Kelleyc72daea2012-01-05 21:33:27 +0000158 install -m 644 debian/changelog debian/base/usr/share/doc/$(package)/changelog.Debian
159 gzip -9 debian/base/usr/share/doc/$(package)/changelog.Debian
160 install -m 644 debian/readme debian/base/usr/share/doc/$(package)/README.Debian
161 install -m 644 debian/copyright debian/base/usr/share/doc/$(package)/copyright
Simon Kelley4ba9b382012-07-29 17:07:48 +0100162 install -m 644 debian/dbus.conf debian/base/etc/dbus-1/system.d/dnsmasq.conf
Simon Kelleyc72daea2012-01-05 21:33:27 +0000163 gzip -9 debian/base/usr/share/man/man8/dnsmasq.8
164 for f in debian/base/usr/share/man/*; do \
165 if [ -f $$f/man8/dnsmasq.8 ]; then \
166 gzip -9 $$f/man8/dnsmasq.8 ; \
167 fi \
168 done
169ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
170 strip -R .note -R .comment debian/base/usr/sbin/dnsmasq
171endif
172 cd debian/base && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
Simon Kelleyaa985be2013-09-11 10:28:39 +0100173 dpkg-shlibdeps --warnings=1 debian/base/usr/sbin/dnsmasq
Simon Kelley02ed24d2013-09-09 18:06:45 +0100174 dpkg-gencontrol $(PACKAGE_VERSION) -pdnsmasq-base -Pdebian/base
Simon Kelleyc72daea2012-01-05 21:33:27 +0000175 chown -R root.root debian/base
176 chmod -R g-ws debian/base
177 dpkg --build debian/base ..
178
Simon Kelley6ac3bc02014-10-03 08:48:11 +0100179ifeq ($(DEB_HOST_ARCH_OS),linux)
Simon Kelleyc72daea2012-01-05 21:33:27 +0000180 rm -rf debian/utils
181 install -m 755 -d debian/utils/DEBIAN \
182 -d debian/utils/usr/share/man/man1 \
183 -d debian/utils/usr/bin \
184 -d debian/utils/usr/share/doc/dnsmasq-utils
Simon Kelley8f6213c2014-01-28 11:16:49 +0000185 make -C contrib/wrt PREFIX=/usr DESTDIR=`pwd`/debian/utils CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=gcc
Simon Kelleyc72daea2012-01-05 21:33:27 +0000186 install -m 755 contrib/wrt/dhcp_release debian/utils/usr/bin/dhcp_release
187 install -m 644 contrib/wrt/dhcp_release.1 debian/utils/usr/share/man/man1/dhcp_release.1
188 gzip -9 debian/utils/usr/share/man/man1/dhcp_release.1
189 install -m 755 contrib/wrt/dhcp_lease_time debian/utils/usr/bin/dhcp_lease_time
190 install -m 644 contrib/wrt/dhcp_lease_time.1 debian/utils/usr/share/man/man1/dhcp_lease_time.1
191 install -m 644 debian/copyright debian/utils/usr/share/doc/dnsmasq-utils/copyright
192 install -m 644 debian/changelog debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
193 gzip -9 debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
194 gzip -9 debian/utils/usr/share/man/man1/dhcp_lease_time.1
195ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
196 strip -R .note -R .comment debian/utils/usr/bin/dhcp_release
197 strip -R .note -R .comment debian/utils/usr/bin/dhcp_lease_time
198endif
199 cd debian/utils && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
200 dpkg-shlibdeps -Tdebian/utils-substvars debian/utils/usr/bin/dhcp_release debian/utils/usr/bin/dhcp_lease_time
Simon Kelley02ed24d2013-09-09 18:06:45 +0100201 dpkg-gencontrol $(PACKAGE_VERSION) -Tdebian/utils-substvars -pdnsmasq-utils -Pdebian/utils
Simon Kelleyc72daea2012-01-05 21:33:27 +0000202 chown -R root.root debian/utils
203 chmod -R g-ws debian/utils
204 dpkg --build debian/utils ..
205endif
206
207define checkdir
208 test -f Makefile -a -f debian/rules
209endef
210
211# Below here is fairly generic really
212
213binary: binary-arch binary-indep
Simon Kelley760169f2012-03-09 14:27:49 +0000214
Simon Kelleyc72daea2012-01-05 21:33:27 +0000215build:
Simon Kelley760169f2012-03-09 14:27:49 +0000216build-arch:
217build-indep:
Simon Kelleyc72daea2012-01-05 21:33:27 +0000218
219checkroot:
220 test root = "`whoami`"
221
222.PHONY: binary binary-arch binary-indep clean checkroot
223
224