blob: 5ffa7cf99737ff50fe81d8e99599b64727c7f9c6 [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 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 Kelley62779782012-02-10 21:19:25 +000051ifeq (,$(filter noconntrack,$(DEB_BUILD_OPTIONS)))
Simon Kelley6ac3bc02014-10-03 08:48:11 +010052ifeq ($(DEB_HOST_ARCH_OS),linux)
Simon Kelley8f6213c2014-01-28 11:16:49 +000053 DEB_COPTS += -DHAVE_CONNTRACK
Simon Kelleyc72daea2012-01-05 21:33:27 +000054endif
55endif
56
Simon Kelley3ddad242013-03-21 17:56:06 +000057ifneq (,$(filter noipset,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000058 DEB_COPTS += -DNO_IPSET
Simon Kelley3b323bd2013-02-22 21:55:29 +000059endif
60
Simon Kelley96c38792012-02-16 20:07:17 +000061ifneq (,$(filter nodhcp6,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000062 DEB_COPTS += -DNO_DHCP6
Simon Kelley127ea402012-02-11 22:14:52 +000063endif
64
Simon Kelley62779782012-02-10 21:19:25 +000065ifneq (,$(filter noipv6,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000066 DEB_COPTS += -DNO_IPV6
Simon Kelleyc72daea2012-01-05 21:33:27 +000067endif
68
Simon Kelley62779782012-02-10 21:19:25 +000069ifneq (,$(filter notftp,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000070 DEB_COPTS += -DNO_TFTP
Simon Kelleyc72daea2012-01-05 21:33:27 +000071endif
72
Simon Kelley62779782012-02-10 21:19:25 +000073ifneq (,$(filter nodhcp,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000074 DEB_COPTS += -DNO_DHCP
Simon Kelleyc72daea2012-01-05 21:33:27 +000075endif
76
Simon Kelley62779782012-02-10 21:19:25 +000077ifneq (,$(filter noscript,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000078 DEB_COPTS += -DNO_SCRIPT
Simon Kelleyc72daea2012-01-05 21:33:27 +000079endif
80
Simon Kelley62779782012-02-10 21:19:25 +000081ifneq (,$(filter nortc,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000082 DEB_COPTS += -DHAVE_BROKEN_RTC
Simon Kelleyc72daea2012-01-05 21:33:27 +000083endif
84
Simon Kelley62779782012-02-10 21:19:25 +000085ifneq (,$(filter noi18n,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000086 TARGET = install
Simon Kelley62779782012-02-10 21:19:25 +000087 ifeq (,$(filter noidn, $(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000088 DEB_COPTS += -DHAVE_IDN
Simon Kelleyc72daea2012-01-05 21:33:27 +000089 endif
90endif
91
Simon Kelley62779782012-02-10 21:19:25 +000092ifneq (,$(filter uselua,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000093 DEB_COPTS += -DHAVE_LUASCRIPT
Simon Kelley62779782012-02-10 21:19:25 +000094endif
95
Simon Kelley160f6502014-02-04 16:49:41 +000096ifeq (,$(filter nodnssec,$(DEB_BUILD_OPTIONS)))
Simon Kelley8f6213c2014-01-28 11:16:49 +000097 DEB_COPTS += -DHAVE_DNSSEC
Simon Kelley00ec6932014-01-28 11:08:57 +000098endif
99
Simon Kelley6ac3bc02014-10-03 08:48:11 +0100100ifneq ($(DEB_HOST_ARCH_OS),linux)
101 # For strlcpy in FreeBSD
102 LDFLAGS += -lbsd
103endif
104
Simon Kelleyc72daea2012-01-05 21:33:27 +0000105clean:
106 $(checkdir)
107 rm -rf debian/daemon debian/base debian/utils debian/*~ debian/files debian/substvars debian/utils-substvars
108 make clean
Simon Kelleyc6cdf6b2016-05-03 21:14:14 +0100109 make -C contrib/lease-tools clean
Simon Kelleyc72daea2012-01-05 21:33:27 +0000110
111binary-indep: checkroot
112 $(checkdir)
113 rm -rf debian/daemon
114 install -m 755 \
115 -d debian/daemon/DEBIAN \
116 -d debian/daemon/usr/share/doc \
117 -d debian/daemon/etc/init.d \
118 -d debian/daemon/etc/dnsmasq.d \
119 -d debian/daemon/etc/resolvconf/update.d \
120 -d debian/daemon/usr/lib/resolvconf/dpkg-event.d \
Simon Kelley9bb39982016-07-16 22:06:01 +0100121 -d debian/daemon/usr/share/dnsmasq \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000122 -d debian/daemon/etc/default \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000123 -d debian/daemon/lib/systemd/system \
124 -d debian/daemon/etc/insserv.conf.d
125 install -m 644 debian/conffiles debian/daemon/DEBIAN
126 install -m 755 debian/postinst debian/postrm debian/prerm debian/daemon/DEBIAN
127 install -m 755 debian/init debian/daemon/etc/init.d/dnsmasq
128 install -m 755 debian/resolvconf debian/daemon/etc/resolvconf/update.d/dnsmasq
129 install -m 755 debian/resolvconf-package debian/daemon/usr/lib/resolvconf/dpkg-event.d/dnsmasq
Simon Kelley9bb39982016-07-16 22:06:01 +0100130 install -m 644 debian/installed-marker debian/daemon/usr/share/dnsmasq
Simon Kelleyc72daea2012-01-05 21:33:27 +0000131 install -m 644 debian/default debian/daemon/etc/default/dnsmasq
132 install -m 644 dnsmasq.conf.example debian/daemon/etc/dnsmasq.conf
133 install -m 644 debian/readme.dnsmasq.d debian/daemon/etc/dnsmasq.d/README
Simon Kelleyc72daea2012-01-05 21:33:27 +0000134 install -m 644 debian/systemd.service debian/daemon/lib/systemd/system/dnsmasq.service
135 install -m 644 debian/insserv debian/daemon/etc/insserv.conf.d/dnsmasq
136 ln -s $(package) debian/daemon/usr/share/doc/dnsmasq
Simon Kelley24e92072015-06-04 22:32:43 +0100137 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 +0100138 dpkg-gencontrol $(PACKAGE_VERSION) -T -pdnsmasq -Pdebian/daemon
Simon Kelley24e92072015-06-04 22:32:43 +0100139 find debian/daemon -depth -newermt '$(BUILD_DATE)' -print0 | xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
Simon Kelleyc72daea2012-01-05 21:33:27 +0000140 chown -R root.root debian/daemon
141 chmod -R g-ws debian/daemon
142 dpkg --build debian/daemon ..
143
144binary-arch: checkroot
145 $(checkdir)
146 rm -rf debian/base
147 install -m 755 \
148 -d debian/base/DEBIAN \
Simon Kelley4ba9b382012-07-29 17:07:48 +0100149 -d debian/base/etc/dbus-1/system.d \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000150 -d debian/base/usr/share/doc/$(package) \
151 -d debian/base/usr/share/doc/$(package)/examples \
Simon Kelleyda4f3722014-02-06 15:21:37 +0000152 -d debian/base/usr/share/$(package) \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000153 -d debian/base/var/lib/misc
Simon Kelleyc6af3a32016-08-31 22:38:48 +0100154 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 +0000155ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
Simon Kelley933878f2014-09-09 14:28:01 +0100156# Need to remove paypal links in Debian Package for policy reasons.
157 sed -e /\<H2\>Donations/Q -e /icon.png/d doc.html -e /favicon.ico/d >debian/base/usr/share/doc/$(package)/doc.html
158 echo "</BODY>" >>debian/base/usr/share/doc/$(package)/doc.html
Simon Kelleyc72daea2012-01-05 21:33:27 +0000159 install -m 644 setup.html debian/base/usr/share/doc/$(package)/.
160 install -m 644 dnsmasq.conf.example debian/base/usr/share/doc/$(package)/examples/.
Simon Kelleyda4f3722014-02-06 15:21:37 +0000161 install -m 644 trust-anchors.conf debian/base/usr/share/$(package)/.
Simon Kelleyc72daea2012-01-05 21:33:27 +0000162 install -m 644 FAQ debian/base/usr/share/doc/$(package)/.
Chris Lambb467a452015-02-09 11:52:30 +0000163 gzip -9n debian/base/usr/share/doc/$(package)/FAQ
Simon Kelleyc72daea2012-01-05 21:33:27 +0000164 install -m 644 CHANGELOG debian/base/usr/share/doc/$(package)/changelog
Chris Lambb467a452015-02-09 11:52:30 +0000165 gzip -9n debian/base/usr/share/doc/$(package)/changelog
Simon Kelleyc72daea2012-01-05 21:33:27 +0000166 install -m 644 CHANGELOG.archive debian/base/usr/share/doc/$(package)/changelog.archive
Chris Lambb467a452015-02-09 11:52:30 +0000167 gzip -9n debian/base/usr/share/doc/$(package)/changelog.archive
Simon Kelleyc72daea2012-01-05 21:33:27 +0000168 install -m 644 dbus/DBus-interface debian/base/usr/share/doc/$(package)/.
Chris Lambb467a452015-02-09 11:52:30 +0000169 gzip -9n debian/base/usr/share/doc/$(package)/DBus-interface
Simon Kelleyc72daea2012-01-05 21:33:27 +0000170endif
Simon Kelley4ba9b382012-07-29 17:07:48 +0100171 install -m 644 debian/dnsmasq-base.conffiles debian/base/DEBIAN/conffiles
Simon Kelleybc54ae32012-08-28 21:26:56 +0100172 install -m 755 debian/dnsmasq-base.postinst debian/base/DEBIAN/postinst
173 install -m 755 debian/dnsmasq-base.postrm debian/base/DEBIAN/postrm
Simon Kelleyc72daea2012-01-05 21:33:27 +0000174 install -m 644 debian/changelog debian/base/usr/share/doc/$(package)/changelog.Debian
Chris Lambb467a452015-02-09 11:52:30 +0000175 gzip -9n debian/base/usr/share/doc/$(package)/changelog.Debian
Simon Kelleyc72daea2012-01-05 21:33:27 +0000176 install -m 644 debian/readme debian/base/usr/share/doc/$(package)/README.Debian
177 install -m 644 debian/copyright debian/base/usr/share/doc/$(package)/copyright
Simon Kelley4ba9b382012-07-29 17:07:48 +0100178 install -m 644 debian/dbus.conf debian/base/etc/dbus-1/system.d/dnsmasq.conf
Chris Lambb467a452015-02-09 11:52:30 +0000179 gzip -9n debian/base/usr/share/man/man8/dnsmasq.8
Simon Kelleyc72daea2012-01-05 21:33:27 +0000180 for f in debian/base/usr/share/man/*; do \
181 if [ -f $$f/man8/dnsmasq.8 ]; then \
Chris Lambb467a452015-02-09 11:52:30 +0000182 gzip -9n $$f/man8/dnsmasq.8 ; \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000183 fi \
184 done
185ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc6af3a32016-08-31 22:38:48 +0100186 $(DEB_HOST_GNU_TYPE)-strip -R .note -R .comment debian/base/usr/sbin/dnsmasq
Simon Kelleyc72daea2012-01-05 21:33:27 +0000187endif
Simon Kelley24e92072015-06-04 22:32:43 +0100188 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 +0100189 dpkg-shlibdeps --warnings=1 debian/base/usr/sbin/dnsmasq
Simon Kelley02ed24d2013-09-09 18:06:45 +0100190 dpkg-gencontrol $(PACKAGE_VERSION) -pdnsmasq-base -Pdebian/base
Simon Kelley24e92072015-06-04 22:32:43 +0100191 find debian/base -depth -newermt '$(BUILD_DATE)' -print0 | xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
Simon Kelleyc72daea2012-01-05 21:33:27 +0000192 chown -R root.root debian/base
193 chmod -R g-ws debian/base
194 dpkg --build debian/base ..
195
Simon Kelley6ac3bc02014-10-03 08:48:11 +0100196ifeq ($(DEB_HOST_ARCH_OS),linux)
Simon Kelleyc72daea2012-01-05 21:33:27 +0000197 rm -rf debian/utils
198 install -m 755 -d debian/utils/DEBIAN \
199 -d debian/utils/usr/share/man/man1 \
200 -d debian/utils/usr/bin \
201 -d debian/utils/usr/share/doc/dnsmasq-utils
Simon Kelleyc6af3a32016-08-31 22:38:48 +0100202 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 +0100203 install -m 755 contrib/lease-tools/dhcp_release debian/utils/usr/bin/dhcp_release
204 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 +0000205 gzip -9n debian/utils/usr/share/man/man1/dhcp_release.1
Simon Kelley69cbf782016-05-03 21:33:38 +0100206 install -m 755 contrib/lease-tools/dhcp_release6 debian/utils/usr/bin/dhcp_release6
207 install -m 644 contrib/lease-tools/dhcp_release6.1 debian/utils/usr/share/man/man1/dhcp_release6.1
208 gzip -9n debian/utils/usr/share/man/man1/dhcp_release6.1
Simon Kelleyc6cdf6b2016-05-03 21:14:14 +0100209 install -m 755 contrib/lease-tools/dhcp_lease_time debian/utils/usr/bin/dhcp_lease_time
210 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 +0000211 install -m 644 debian/copyright debian/utils/usr/share/doc/dnsmasq-utils/copyright
212 install -m 644 debian/changelog debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
Chris Lambb467a452015-02-09 11:52:30 +0000213 gzip -9n debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
214 gzip -9n debian/utils/usr/share/man/man1/dhcp_lease_time.1
Simon Kelleyc72daea2012-01-05 21:33:27 +0000215ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc6af3a32016-08-31 22:38:48 +0100216 $(DEB_HOST_GNU_TYPE)-strip -R .note -R .comment debian/utils/usr/bin/dhcp_release
217 $(DEB_HOST_GNU_TYPE)-strip -R .note -R .comment debian/utils/usr/bin/dhcp_lease_time
Simon Kelleyc72daea2012-01-05 21:33:27 +0000218endif
Simon Kelley24e92072015-06-04 22:32:43 +0100219 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 +0000220 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 +0100221 dpkg-gencontrol $(PACKAGE_VERSION) -Tdebian/utils-substvars -pdnsmasq-utils -Pdebian/utils
Simon Kelley24e92072015-06-04 22:32:43 +0100222 find debian/utils -depth -newermt '$(BUILD_DATE)' -print0 | xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
Simon Kelleyc72daea2012-01-05 21:33:27 +0000223 chown -R root.root debian/utils
224 chmod -R g-ws debian/utils
225 dpkg --build debian/utils ..
226endif
227
228define checkdir
229 test -f Makefile -a -f debian/rules
230endef
231
232# Below here is fairly generic really
233
234binary: binary-arch binary-indep
Simon Kelley760169f2012-03-09 14:27:49 +0000235
Simon Kelleyc72daea2012-01-05 21:33:27 +0000236build:
Simon Kelley760169f2012-03-09 14:27:49 +0000237build-arch:
238build-indep:
Simon Kelleyc72daea2012-01-05 21:33:27 +0000239
240checkroot:
241 test root = "`whoami`"
242
243.PHONY: binary binary-arch binary-indep clean checkroot
244
245