blob: b4ec4e9291157525356ecad58d46cffc3eb5357a [file] [log] [blame]
Simon Kelleyc72daea2012-01-05 21:33:27 +00001#!/usr/bin/make -f
2# debian/rules file - for dnsmasq.
Simon Kelley30e4a942018-02-16 19:56:56 +00003# Copyright 2001-2018 by Simon Kelley
Simon Kelleyc72daea2012-01-05 21:33:27 +00004# 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 Kelleya24c31e2017-04-16 22:45:53 +010014dpkg_buildflags := DEB_BUILD_MAINT_OPTIONS="hardening=+all,+pie,+bindnow" dpkg-buildflags
Simon Ruderich91f4a5e2014-05-20 20:27:31 +010015
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 Kelleyc6af3a32016-08-31 22:38:48 +010027DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
28DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
Simon Kelley24e92072015-06-04 22:32:43 +010029BUILD_DATE := $(shell dpkg-parsechangelog --show-field Date)
Simon Kelleyc72daea2012-01-05 21:33:27 +000030
Simon Kelleyc6af3a32016-08-31 22:38:48 +010031ifeq ($(origin CC),default)
32 CC = $(DEB_HOST_GNU_TYPE)-gcc
33endif
34
35# Support non-cross-builds on systems without gnu-triplet-binaries for pkg-config.
36ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
37 PKG_CONFIG=pkg-config
38else
39 PKG_CONFIG=$(DEB_HOST_GNU_TYPE)-pkg-config
40endif
41
Simon Kelley02ed24d2013-09-09 18:06:45 +010042# Force package version based on git tags.
43ifneq (,$(filter gitversion,$(DEB_BUILD_OPTIONS)))
Simon Kelley1d1c7952013-10-02 14:52:23 +010044 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 +010045endif
46
Simon Kelley62779782012-02-10 21:19:25 +000047ifeq (,$(filter nodbus,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000048 DEB_COPTS += -DHAVE_DBUS
Simon Kelleyc72daea2012-01-05 21:33:27 +000049endif
50
Simon Kelley43cdf1c2017-05-21 22:12:44 +010051ifeq (,$(filter noidn, $(DEB_BUILD_OPTIONS)))
52 DEB_COPTS += -DHAVE_IDN
53endif
54
Simon Kelley62779782012-02-10 21:19:25 +000055ifeq (,$(filter noconntrack,$(DEB_BUILD_OPTIONS)))
Simon Kelley6ac3bc02014-10-03 08:48:11 +010056ifeq ($(DEB_HOST_ARCH_OS),linux)
Simon Kelley8f6213c2014-01-28 11:16:49 +000057 DEB_COPTS += -DHAVE_CONNTRACK
Simon Kelleyc72daea2012-01-05 21:33:27 +000058endif
59endif
60
Simon Kelley3ddad242013-03-21 17:56:06 +000061ifneq (,$(filter noipset,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000062 DEB_COPTS += -DNO_IPSET
Simon Kelley3b323bd2013-02-22 21:55:29 +000063endif
64
Simon Kelley96c38792012-02-16 20:07:17 +000065ifneq (,$(filter nodhcp6,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000066 DEB_COPTS += -DNO_DHCP6
Simon Kelley127ea402012-02-11 22:14:52 +000067endif
68
Simon Kelley62779782012-02-10 21:19:25 +000069ifneq (,$(filter noipv6,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000070 DEB_COPTS += -DNO_IPV6
Simon Kelleyc72daea2012-01-05 21:33:27 +000071endif
72
Simon Kelley62779782012-02-10 21:19:25 +000073ifneq (,$(filter notftp,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000074 DEB_COPTS += -DNO_TFTP
Simon Kelleyc72daea2012-01-05 21:33:27 +000075endif
76
Simon Kelley62779782012-02-10 21:19:25 +000077ifneq (,$(filter nodhcp,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000078 DEB_COPTS += -DNO_DHCP
Simon Kelleyc72daea2012-01-05 21:33:27 +000079endif
80
Simon Kelley62779782012-02-10 21:19:25 +000081ifneq (,$(filter noscript,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000082 DEB_COPTS += -DNO_SCRIPT
Simon Kelleyc72daea2012-01-05 21:33:27 +000083endif
84
Simon Kelley62779782012-02-10 21:19:25 +000085ifneq (,$(filter nortc,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000086 DEB_COPTS += -DHAVE_BROKEN_RTC
Simon Kelleyc72daea2012-01-05 21:33:27 +000087endif
88
Simon Kelley62779782012-02-10 21:19:25 +000089ifneq (,$(filter noi18n,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000090 TARGET = install
Simon Kelleyc72daea2012-01-05 21:33:27 +000091endif
92
Simon Kelley62779782012-02-10 21:19:25 +000093ifneq (,$(filter uselua,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000094 DEB_COPTS += -DHAVE_LUASCRIPT
Simon Kelley62779782012-02-10 21:19:25 +000095endif
96
Simon Kelley160f6502014-02-04 16:49:41 +000097ifeq (,$(filter nodnssec,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000098 DEB_COPTS += -DHAVE_DNSSEC
Simon Kelley00ec6932014-01-28 11:08:57 +000099endif
100
Simon Kelley6ac3bc02014-10-03 08:48:11 +0100101ifneq ($(DEB_HOST_ARCH_OS),linux)
102 # For strlcpy in FreeBSD
103 LDFLAGS += -lbsd
104endif
105
Simon Kelley30e4a942018-02-16 19:56:56 +0000106define build_tree
107 rm -rf $1
Simon Kelleyc72daea2012-01-05 21:33:27 +0000108 install -m 755 \
Simon Kelley30e4a942018-02-16 19:56:56 +0000109 -d $1/DEBIAN \
110 -d $1/etc/dbus-1/system.d \
111 -d $1/usr/share/doc/$(package) \
112 -d $1/usr/share/doc/$(package)/examples \
113 -d $1/usr/share/$(package) \
114 -d $1/var/lib/misc
Simon Kelleyc72daea2012-01-05 21:33:27 +0000115
Simon Kelley30e4a942018-02-16 19:56:56 +0000116endef
117
118define add_docs
Simon Kelley933878f2014-09-09 14:28:01 +0100119# Need to remove paypal links in Debian Package for policy reasons.
Simon Kelley30e4a942018-02-16 19:56:56 +0000120 sed -e /\<H2\>Donations/Q -e /icon.png/d doc.html -e /favicon.ico/d >$1/usr/share/doc/$(package)/doc.html
121 echo "</BODY>" >>$1/usr/share/doc/$(package)/doc.html
122 install -m 644 setup.html $1/usr/share/doc/$(package)/.
123 install -m 644 dnsmasq.conf.example $1/usr/share/doc/$(package)/examples/.
124 install -m 644 FAQ $1/usr/share/doc/$(package)/.
125 gzip -9n $1/usr/share/doc/$(package)/FAQ
126 install -m 644 CHANGELOG $1/usr/share/doc/$(package)/changelog
127 gzip -9n $1/usr/share/doc/$(package)/changelog
128 install -m 644 CHANGELOG.archive $1/usr/share/doc/$(package)/changelog.archive
129 gzip -9n $1/usr/share/doc/$(package)/changelog.archive
130 install -m 644 dbus/DBus-interface $1/usr/share/doc/$(package)/.
131 gzip -9n $1/usr/share/doc/$(package)/DBus-interface
132 gzip -9n $1/usr/share/man/man8/dnsmasq.8
133 for f in $1/usr/share/man/*; do \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000134 if [ -f $$f/man8/dnsmasq.8 ]; then \
Chris Lambb467a452015-02-09 11:52:30 +0000135 gzip -9n $$f/man8/dnsmasq.8 ; \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000136 fi \
137 done
Simon Kelley30e4a942018-02-16 19:56:56 +0000138endef
139
140define add_files
141 install -m 644 trust-anchors.conf $1/usr/share/$(package)/.
142 install -m 644 debian/dnsmasq-base.conffiles $1/DEBIAN/conffiles
143 install -m 755 debian/dnsmasq-base.postinst $1/DEBIAN/postinst
144 install -m 755 debian/dnsmasq-base.postrm $1/DEBIAN/postrm
145 install -m 644 debian/changelog $1/usr/share/doc/$(package)/changelog.Debian
146 gzip -9n $1/usr/share/doc/$(package)/changelog.Debian
147 install -m 644 debian/readme $1/usr/share/doc/$(package)/README.Debian
148 install -m 644 debian/copyright $1/usr/share/doc/$(package)/copyright
149 install -m 644 debian/dbus.conf $1/etc/dbus-1/system.d/dnsmasq.conf
150endef
151
152clean:
153 $(checkdir)
154 make BUILDDIR=debian/build/no-lua clean
155 make BUILDDIR=debian/build/lua clean
156 make -C contrib/lease-tools clean
157 rm -rf debian/build debian/trees debian/*~ debian/files debian/substvars debian/utils-substvars
158
159binary-indep: checkroot
160 $(checkdir)
161 rm -rf debian/trees/daemon
162 install -m 755 \
163 -d debian/trees/daemon/DEBIAN \
164 -d debian/trees/daemon/usr/share/doc \
165 -d debian/trees/daemon/etc/init.d \
166 -d debian/trees/daemon/etc/dnsmasq.d \
167 -d debian/trees/daemon/etc/resolvconf/update.d \
168 -d debian/trees/daemon/usr/lib/resolvconf/dpkg-event.d \
169 -d debian/trees/daemon/usr/share/dnsmasq \
170 -d debian/trees/daemon/etc/default \
171 -d debian/trees/daemon/lib/systemd/system \
Simon Kelley118011f2018-09-17 23:15:37 +0100172 -d debian/trees/daemon/usr/lib/tmpfiles.d \
Simon Kelley30e4a942018-02-16 19:56:56 +0000173 -d debian/trees/daemon/etc/insserv.conf.d
174 install -m 644 debian/conffiles debian/trees/daemon/DEBIAN
175 install -m 755 debian/postinst debian/postrm debian/prerm debian/trees/daemon/DEBIAN
176 install -m 755 debian/init debian/trees/daemon/etc/init.d/dnsmasq
177 install -m 755 debian/resolvconf debian/trees/daemon/etc/resolvconf/update.d/dnsmasq
178 install -m 755 debian/resolvconf-package debian/trees/daemon/usr/lib/resolvconf/dpkg-event.d/dnsmasq
179 install -m 644 debian/installed-marker debian/trees/daemon/usr/share/dnsmasq
180 install -m 644 debian/default debian/trees/daemon/etc/default/dnsmasq
181 install -m 644 dnsmasq.conf.example debian/trees/daemon/etc/dnsmasq.conf
182 install -m 644 debian/readme.dnsmasq.d debian/trees/daemon/etc/dnsmasq.d/README
183 install -m 644 debian/systemd.service debian/trees/daemon/lib/systemd/system/dnsmasq.service
Simon Kelley118011f2018-09-17 23:15:37 +0100184 install -m 644 debian/tmpfiles.conf debian/trees/daemon/usr/lib/tmpfiles.d/dnsmasq.conf
Simon Kelley30e4a942018-02-16 19:56:56 +0000185 install -m 644 debian/insserv debian/trees/daemon/etc/insserv.conf.d/dnsmasq
186 ln -s $(package) debian/trees/daemon/usr/share/doc/dnsmasq
187 cd debian/trees/daemon && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | LC_ALL=C sort -z | xargs -r0 md5sum > DEBIAN/md5sums
188 dpkg-gencontrol $(PACKAGE_VERSION) -T -pdnsmasq -Pdebian/trees/daemon
189 find debian/trees/daemon -depth -newermt '$(BUILD_DATE)' -print0 | xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
190 chown -R root.root debian/trees/daemon
191 chmod -R g-ws debian/trees/daemon
192 dpkg --build debian/trees/daemon ..
193
194binary-arch: checkroot
195 $(call build_tree,debian/trees/base)
196 make $(TARGET) BUILDDIR=debian/build/no-lua PREFIX=/usr DESTDIR=`pwd`/debian/trees/base CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=$(CC) PKG_CONFIG=$(PKG_CONFIG)
197ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
198 $(call add_docs,debian/trees/base)
199else
200 rm -rf debian/trees/base/usr/share/man
Simon Kelleyc72daea2012-01-05 21:33:27 +0000201endif
Simon Kelley30e4a942018-02-16 19:56:56 +0000202 $(call add_files,debian/trees/base)
203ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
204 $(DEB_HOST_GNU_TYPE)-strip -R .note -R .comment debian/trees/base/usr/sbin/dnsmasq
205endif
206 cd debian/trees/base && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | LC_ALL=C sort -z | xargs -r0 md5sum > DEBIAN/md5sums
207 dpkg-shlibdeps --warnings=1 debian/trees/base/usr/sbin/dnsmasq
208 dpkg-gencontrol $(PACKAGE_VERSION) -pdnsmasq-base -Pdebian/trees/base
209 find debian/trees/base -depth -newermt '$(BUILD_DATE)' -print0 | xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
210 chown -R root.root debian/trees/base
211 chmod -R g-ws debian/trees/base
212 dpkg --build debian/trees/base ..
213
214 $(call build_tree,debian/trees/lua-base)
215 make $(TARGET) BUILDDIR=debian/build/lua PREFIX=/usr DESTDIR=`pwd`/debian/trees/lua-base CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="-DHAVE_LUASCRIPT $(DEB_COPTS)" CC=$(CC) PKG_CONFIG=$(PKG_CONFIG)
216ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
217 $(call add_docs,debian/trees/lua-base)
218else
219 rm -rf debian/trees/lua-base/usr/share/man
220endif
221 $(call add_files,debian/trees/lua-base)
Simon Kelley9a7be472018-03-23 20:43:53 +0000222 install -m 755 -d debian/trees/lua-base/usr/share/lintian/overrides
223 install -m 644 debian/lintian-override debian/trees/lua-base/usr/share/lintian/overrides/dnsmasq-base-lua
Simon Kelley30e4a942018-02-16 19:56:56 +0000224ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
225 $(DEB_HOST_GNU_TYPE)-strip -R .note -R .comment debian/trees/lua-base/usr/sbin/dnsmasq
226endif
Simon Kelley26e27d02018-03-18 17:29:12 +0000227 ln -s $(package) debian/trees/lua-base/usr/share/doc/dnsmasq-base-lua
Simon Kelley30e4a942018-02-16 19:56:56 +0000228 cd debian/trees/lua-base && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | LC_ALL=C sort -z | xargs -r0 md5sum > DEBIAN/md5sums
229 dpkg-shlibdeps --warnings=1 debian/trees/lua-base/usr/sbin/dnsmasq
230 dpkg-gencontrol $(PACKAGE_VERSION) -pdnsmasq-base-lua -Pdebian/trees/lua-base
231 find debian/trees/lua-base -depth -newermt '$(BUILD_DATE)' -print0 | xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
232 chown -R root.root debian/trees/lua-base
233 chmod -R g-ws debian/trees/lua-base
234 dpkg --build debian/trees/lua-base ..
235
Simon Kelleyc72daea2012-01-05 21:33:27 +0000236
Simon Kelley6ac3bc02014-10-03 08:48:11 +0100237ifeq ($(DEB_HOST_ARCH_OS),linux)
Simon Kelley30e4a942018-02-16 19:56:56 +0000238 rm -rf debian/trees/utils
239 install -m 755 -d debian/trees/utils/DEBIAN \
240 -d debian/trees/utils/usr/bin \
241 -d debian/trees/utils/usr/share/doc/dnsmasq-utils
242ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
243 install -m 755 -d debian/trees/utils/usr/share/man/man1
244endif
245 make -C contrib/lease-tools PREFIX=/usr DESTDIR=`pwd`/debian/trees/utils CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=$(CC) PKG_CONFIG=$(PKG_CONFIG)
246 install -m 755 contrib/lease-tools/dhcp_release debian/trees/utils/usr/bin/dhcp_release
247 install -m 755 contrib/lease-tools/dhcp_release6 debian/trees/utils/usr/bin/dhcp_release6
248 install -m 755 contrib/lease-tools/dhcp_lease_time debian/trees/utils/usr/bin/dhcp_lease_time
249ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
250 install -m 644 contrib/lease-tools/dhcp_release.1 debian/trees/utils/usr/share/man/man1/dhcp_release.1
251 gzip -9n debian/trees/utils/usr/share/man/man1/dhcp_release.1
252 install -m 644 contrib/lease-tools/dhcp_release6.1 debian/trees/utils/usr/share/man/man1/dhcp_release6.1
253 gzip -9n debian/trees/utils/usr/share/man/man1/dhcp_release6.1
254 install -m 644 contrib/lease-tools/dhcp_lease_time.1 debian/trees/utils/usr/share/man/man1/dhcp_lease_time.1
255 gzip -9n debian/trees/utils/usr/share/man/man1/dhcp_lease_time.1
256endif
257 install -m 644 debian/copyright debian/trees/utils/usr/share/doc/dnsmasq-utils/copyright
258 install -m 644 debian/changelog debian/trees/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
259 gzip -9n debian/trees/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
Simon Kelleyc72daea2012-01-05 21:33:27 +0000260ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
Simon Kelley30e4a942018-02-16 19:56:56 +0000261 $(DEB_HOST_GNU_TYPE)-strip -R .note -R .comment debian/trees/utils/usr/bin/dhcp_release
262 $(DEB_HOST_GNU_TYPE)-strip -R .note -R .comment debian/trees/utils/usr/bin/dhcp_release6
263 $(DEB_HOST_GNU_TYPE)-strip -R .note -R .comment debian/trees/utils/usr/bin/dhcp_lease_time
Simon Kelleyc72daea2012-01-05 21:33:27 +0000264endif
Simon Kelley30e4a942018-02-16 19:56:56 +0000265 cd debian/trees/utils && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | LC_ALL=C sort -z | xargs -r0 md5sum > DEBIAN/md5sums
266 dpkg-shlibdeps -Tdebian/utils-substvars debian/trees/utils/usr/bin/dhcp_release debian/trees/utils/usr/bin/dhcp_release6 debian/trees/utils/usr/bin/dhcp_lease_time
267 dpkg-gencontrol $(PACKAGE_VERSION) -Tdebian/utils-substvars -pdnsmasq-utils -Pdebian/trees/utils
268 find debian/trees/utils -depth -newermt '$(BUILD_DATE)' -print0 | xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
269 chown -R root.root debian/trees/utils
270 chmod -R g-ws debian/trees/utils
271 dpkg --build debian/trees/utils ..
Simon Kelleyc72daea2012-01-05 21:33:27 +0000272endif
273
274define checkdir
275 test -f Makefile -a -f debian/rules
276endef
277
278# Below here is fairly generic really
279
280binary: binary-arch binary-indep
Simon Kelley760169f2012-03-09 14:27:49 +0000281
Simon Kelleyc72daea2012-01-05 21:33:27 +0000282build:
Simon Kelley760169f2012-03-09 14:27:49 +0000283build-arch:
284build-indep:
Simon Kelleyc72daea2012-01-05 21:33:27 +0000285
286checkroot:
287 test root = "`whoami`"
288
289.PHONY: binary binary-arch binary-indep clean checkroot
290
291