blob: 2df656f867f4747eba195bad6d7f92f81a733b61 [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 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 Kelleyc72daea2012-01-05 21:33:27 +0000106clean:
107 $(checkdir)
108 rm -rf debian/daemon debian/base debian/utils debian/*~ debian/files debian/substvars debian/utils-substvars
109 make clean
Simon Kelleyc6cdf6b2016-05-03 21:14:14 +0100110 make -C contrib/lease-tools clean
Simon Kelleyc72daea2012-01-05 21:33:27 +0000111
112binary-indep: checkroot
113 $(checkdir)
114 rm -rf debian/daemon
115 install -m 755 \
116 -d debian/daemon/DEBIAN \
117 -d debian/daemon/usr/share/doc \
118 -d debian/daemon/etc/init.d \
119 -d debian/daemon/etc/dnsmasq.d \
120 -d debian/daemon/etc/resolvconf/update.d \
121 -d debian/daemon/usr/lib/resolvconf/dpkg-event.d \
Simon Kelley9bb39982016-07-16 22:06:01 +0100122 -d debian/daemon/usr/share/dnsmasq \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000123 -d debian/daemon/etc/default \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000124 -d debian/daemon/lib/systemd/system \
125 -d debian/daemon/etc/insserv.conf.d
126 install -m 644 debian/conffiles debian/daemon/DEBIAN
127 install -m 755 debian/postinst debian/postrm debian/prerm debian/daemon/DEBIAN
128 install -m 755 debian/init debian/daemon/etc/init.d/dnsmasq
129 install -m 755 debian/resolvconf debian/daemon/etc/resolvconf/update.d/dnsmasq
130 install -m 755 debian/resolvconf-package debian/daemon/usr/lib/resolvconf/dpkg-event.d/dnsmasq
Simon Kelley9bb39982016-07-16 22:06:01 +0100131 install -m 644 debian/installed-marker debian/daemon/usr/share/dnsmasq
Simon Kelleyc72daea2012-01-05 21:33:27 +0000132 install -m 644 debian/default debian/daemon/etc/default/dnsmasq
133 install -m 644 dnsmasq.conf.example debian/daemon/etc/dnsmasq.conf
134 install -m 644 debian/readme.dnsmasq.d debian/daemon/etc/dnsmasq.d/README
Simon Kelleyc72daea2012-01-05 21:33:27 +0000135 install -m 644 debian/systemd.service debian/daemon/lib/systemd/system/dnsmasq.service
136 install -m 644 debian/insserv debian/daemon/etc/insserv.conf.d/dnsmasq
137 ln -s $(package) debian/daemon/usr/share/doc/dnsmasq
Simon Kelley24e92072015-06-04 22:32:43 +0100138 cd debian/daemon && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | LC_ALL=C sort -z | xargs -r0 md5sum > DEBIAN/md5sums
Simon Kelleyaa985be2013-09-11 10:28:39 +0100139 dpkg-gencontrol $(PACKAGE_VERSION) -T -pdnsmasq -Pdebian/daemon
Simon Kelley24e92072015-06-04 22:32:43 +0100140 find debian/daemon -depth -newermt '$(BUILD_DATE)' -print0 | xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
Simon Kelleyc72daea2012-01-05 21:33:27 +0000141 chown -R root.root debian/daemon
142 chmod -R g-ws debian/daemon
143 dpkg --build debian/daemon ..
144
145binary-arch: checkroot
146 $(checkdir)
147 rm -rf debian/base
148 install -m 755 \
149 -d debian/base/DEBIAN \
Simon Kelley4ba9b382012-07-29 17:07:48 +0100150 -d debian/base/etc/dbus-1/system.d \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000151 -d debian/base/usr/share/doc/$(package) \
152 -d debian/base/usr/share/doc/$(package)/examples \
Simon Kelleyda4f3722014-02-06 15:21:37 +0000153 -d debian/base/usr/share/$(package) \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000154 -d debian/base/var/lib/misc
Simon Kelleyc6af3a32016-08-31 22:38:48 +0100155 make $(TARGET) PREFIX=/usr DESTDIR=`pwd`/debian/base CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=$(CC) PKG_CONFIG=$(PKG_CONFIG)
Simon Kelleyc72daea2012-01-05 21:33:27 +0000156ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
Simon Kelley933878f2014-09-09 14:28:01 +0100157# Need to remove paypal links in Debian Package for policy reasons.
158 sed -e /\<H2\>Donations/Q -e /icon.png/d doc.html -e /favicon.ico/d >debian/base/usr/share/doc/$(package)/doc.html
159 echo "</BODY>" >>debian/base/usr/share/doc/$(package)/doc.html
Simon Kelleyc72daea2012-01-05 21:33:27 +0000160 install -m 644 setup.html debian/base/usr/share/doc/$(package)/.
161 install -m 644 dnsmasq.conf.example debian/base/usr/share/doc/$(package)/examples/.
Simon Kelleyda4f3722014-02-06 15:21:37 +0000162 install -m 644 trust-anchors.conf debian/base/usr/share/$(package)/.
Simon Kelleyc72daea2012-01-05 21:33:27 +0000163 install -m 644 FAQ debian/base/usr/share/doc/$(package)/.
Chris Lambb467a452015-02-09 11:52:30 +0000164 gzip -9n debian/base/usr/share/doc/$(package)/FAQ
Simon Kelleyc72daea2012-01-05 21:33:27 +0000165 install -m 644 CHANGELOG debian/base/usr/share/doc/$(package)/changelog
Chris Lambb467a452015-02-09 11:52:30 +0000166 gzip -9n debian/base/usr/share/doc/$(package)/changelog
Simon Kelleyc72daea2012-01-05 21:33:27 +0000167 install -m 644 CHANGELOG.archive debian/base/usr/share/doc/$(package)/changelog.archive
Chris Lambb467a452015-02-09 11:52:30 +0000168 gzip -9n debian/base/usr/share/doc/$(package)/changelog.archive
Simon Kelleyc72daea2012-01-05 21:33:27 +0000169 install -m 644 dbus/DBus-interface debian/base/usr/share/doc/$(package)/.
Chris Lambb467a452015-02-09 11:52:30 +0000170 gzip -9n debian/base/usr/share/doc/$(package)/DBus-interface
Simon Kelleyc72daea2012-01-05 21:33:27 +0000171endif
Simon Kelley4ba9b382012-07-29 17:07:48 +0100172 install -m 644 debian/dnsmasq-base.conffiles debian/base/DEBIAN/conffiles
Simon Kelleybc54ae32012-08-28 21:26:56 +0100173 install -m 755 debian/dnsmasq-base.postinst debian/base/DEBIAN/postinst
174 install -m 755 debian/dnsmasq-base.postrm debian/base/DEBIAN/postrm
Simon Kelleyc72daea2012-01-05 21:33:27 +0000175 install -m 644 debian/changelog debian/base/usr/share/doc/$(package)/changelog.Debian
Chris Lambb467a452015-02-09 11:52:30 +0000176 gzip -9n debian/base/usr/share/doc/$(package)/changelog.Debian
Simon Kelleyc72daea2012-01-05 21:33:27 +0000177 install -m 644 debian/readme debian/base/usr/share/doc/$(package)/README.Debian
178 install -m 644 debian/copyright debian/base/usr/share/doc/$(package)/copyright
Simon Kelley4ba9b382012-07-29 17:07:48 +0100179 install -m 644 debian/dbus.conf debian/base/etc/dbus-1/system.d/dnsmasq.conf
Chris Lambb467a452015-02-09 11:52:30 +0000180 gzip -9n debian/base/usr/share/man/man8/dnsmasq.8
Simon Kelleyc72daea2012-01-05 21:33:27 +0000181 for f in debian/base/usr/share/man/*; do \
182 if [ -f $$f/man8/dnsmasq.8 ]; then \
Chris Lambb467a452015-02-09 11:52:30 +0000183 gzip -9n $$f/man8/dnsmasq.8 ; \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000184 fi \
185 done
186ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc6af3a32016-08-31 22:38:48 +0100187 $(DEB_HOST_GNU_TYPE)-strip -R .note -R .comment debian/base/usr/sbin/dnsmasq
Simon Kelleyc72daea2012-01-05 21:33:27 +0000188endif
Simon Kelley24e92072015-06-04 22:32:43 +0100189 cd debian/base && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | LC_ALL=C sort -z | xargs -r0 md5sum > DEBIAN/md5sums
Simon Kelleyaa985be2013-09-11 10:28:39 +0100190 dpkg-shlibdeps --warnings=1 debian/base/usr/sbin/dnsmasq
Simon Kelley02ed24d2013-09-09 18:06:45 +0100191 dpkg-gencontrol $(PACKAGE_VERSION) -pdnsmasq-base -Pdebian/base
Simon Kelley24e92072015-06-04 22:32:43 +0100192 find debian/base -depth -newermt '$(BUILD_DATE)' -print0 | xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
Simon Kelleyc72daea2012-01-05 21:33:27 +0000193 chown -R root.root debian/base
194 chmod -R g-ws debian/base
195 dpkg --build debian/base ..
196
Simon Kelley6ac3bc02014-10-03 08:48:11 +0100197ifeq ($(DEB_HOST_ARCH_OS),linux)
Simon Kelleyc72daea2012-01-05 21:33:27 +0000198 rm -rf debian/utils
199 install -m 755 -d debian/utils/DEBIAN \
200 -d debian/utils/usr/share/man/man1 \
201 -d debian/utils/usr/bin \
202 -d debian/utils/usr/share/doc/dnsmasq-utils
Simon Kelleyc6af3a32016-08-31 22:38:48 +0100203 make -C contrib/lease-tools PREFIX=/usr DESTDIR=`pwd`/debian/utils CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=$(CC) PKG_CONFIG=$(PKG_CONFIG)
Simon Kelleyc6cdf6b2016-05-03 21:14:14 +0100204 install -m 755 contrib/lease-tools/dhcp_release debian/utils/usr/bin/dhcp_release
205 install -m 644 contrib/lease-tools/dhcp_release.1 debian/utils/usr/share/man/man1/dhcp_release.1
Chris Lambb467a452015-02-09 11:52:30 +0000206 gzip -9n debian/utils/usr/share/man/man1/dhcp_release.1
Simon Kelley69cbf782016-05-03 21:33:38 +0100207 install -m 755 contrib/lease-tools/dhcp_release6 debian/utils/usr/bin/dhcp_release6
208 install -m 644 contrib/lease-tools/dhcp_release6.1 debian/utils/usr/share/man/man1/dhcp_release6.1
209 gzip -9n debian/utils/usr/share/man/man1/dhcp_release6.1
Simon Kelleyc6cdf6b2016-05-03 21:14:14 +0100210 install -m 755 contrib/lease-tools/dhcp_lease_time debian/utils/usr/bin/dhcp_lease_time
211 install -m 644 contrib/lease-tools/dhcp_lease_time.1 debian/utils/usr/share/man/man1/dhcp_lease_time.1
Simon Kelleyc72daea2012-01-05 21:33:27 +0000212 install -m 644 debian/copyright debian/utils/usr/share/doc/dnsmasq-utils/copyright
213 install -m 644 debian/changelog debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
Chris Lambb467a452015-02-09 11:52:30 +0000214 gzip -9n debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
215 gzip -9n debian/utils/usr/share/man/man1/dhcp_lease_time.1
Simon Kelleyc72daea2012-01-05 21:33:27 +0000216ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc6af3a32016-08-31 22:38:48 +0100217 $(DEB_HOST_GNU_TYPE)-strip -R .note -R .comment debian/utils/usr/bin/dhcp_release
Simon Kelleyb1cefa52017-04-11 15:55:26 +0100218 $(DEB_HOST_GNU_TYPE)-strip -R .note -R .comment debian/utils/usr/bin/dhcp_release6
Simon Kelleyc6af3a32016-08-31 22:38:48 +0100219 $(DEB_HOST_GNU_TYPE)-strip -R .note -R .comment debian/utils/usr/bin/dhcp_lease_time
Simon Kelleyc72daea2012-01-05 21:33:27 +0000220endif
Simon Kelley24e92072015-06-04 22:32:43 +0100221 cd debian/utils && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | LC_ALL=C sort -z | xargs -r0 md5sum > DEBIAN/md5sums
Simon Kelleyc72daea2012-01-05 21:33:27 +0000222 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 +0100223 dpkg-gencontrol $(PACKAGE_VERSION) -Tdebian/utils-substvars -pdnsmasq-utils -Pdebian/utils
Simon Kelley24e92072015-06-04 22:32:43 +0100224 find debian/utils -depth -newermt '$(BUILD_DATE)' -print0 | xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
Simon Kelleyc72daea2012-01-05 21:33:27 +0000225 chown -R root.root debian/utils
226 chmod -R g-ws debian/utils
227 dpkg --build debian/utils ..
228endif
229
230define checkdir
231 test -f Makefile -a -f debian/rules
232endef
233
234# Below here is fairly generic really
235
236binary: binary-arch binary-indep
Simon Kelley760169f2012-03-09 14:27:49 +0000237
Simon Kelleyc72daea2012-01-05 21:33:27 +0000238build:
Simon Kelley760169f2012-03-09 14:27:49 +0000239build-arch:
240build-indep:
Simon Kelleyc72daea2012-01-05 21:33:27 +0000241
242checkroot:
243 test root = "`whoami`"
244
245.PHONY: binary binary-arch binary-indep clean checkroot
246
247