]> git.ipfire.org Git - people/ms/dnsmasq.git/blob - debian/rules
Make Debian build reproducible.
[people/ms/dnsmasq.git] / debian / rules
1 #!/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
12 package=dnsmasq-base
13
14 dpkg_buildflags := DEB_BUILD_MAINT_OPTIONS="hardening=+all" dpkg-buildflags
15
16 CFLAGS = $(shell $(dpkg_buildflags) --get CFLAGS)
17 CFLAGS += $(shell $(dpkg_buildflags) --get CPPFLAGS)
18 CFLAGS += -Wall -W
19
20 LDFLAGS = $(shell $(dpkg_buildflags) --get LDFLAGS)
21
22 DEB_COPTS = $(COPTS)
23
24 TARGET = install-i18n
25
26 DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
27
28 # Force package version based on git tags.
29 ifneq (,$(filter gitversion,$(DEB_BUILD_OPTIONS)))
30 PACKAGE_VERSION = $(shell bld/get-version `pwd` | sed 's/test/~&/; s/[a-z]/~&/; s/-/./g; s/$$/-1/; s/^/-v/';)
31 endif
32
33 ifeq (,$(filter nodbus,$(DEB_BUILD_OPTIONS)))
34 DEB_COPTS += -DHAVE_DBUS
35 endif
36
37 ifeq (,$(filter noconntrack,$(DEB_BUILD_OPTIONS)))
38 ifeq ($(DEB_HOST_ARCH_OS),linux)
39 DEB_COPTS += -DHAVE_CONNTRACK
40 endif
41 endif
42
43 ifneq (,$(filter noipset,$(DEB_BUILD_OPTIONS)))
44 DEB_COPTS += -DNO_IPSET
45 endif
46
47 ifneq (,$(filter nodhcp6,$(DEB_BUILD_OPTIONS)))
48 DEB_COPTS += -DNO_DHCP6
49 endif
50
51 ifneq (,$(filter noipv6,$(DEB_BUILD_OPTIONS)))
52 DEB_COPTS += -DNO_IPV6
53 endif
54
55 ifneq (,$(filter notftp,$(DEB_BUILD_OPTIONS)))
56 DEB_COPTS += -DNO_TFTP
57 endif
58
59 ifneq (,$(filter nodhcp,$(DEB_BUILD_OPTIONS)))
60 DEB_COPTS += -DNO_DHCP
61 endif
62
63 ifneq (,$(filter noscript,$(DEB_BUILD_OPTIONS)))
64 DEB_COPTS += -DNO_SCRIPT
65 endif
66
67 ifneq (,$(filter nortc,$(DEB_BUILD_OPTIONS)))
68 DEB_COPTS += -DHAVE_BROKEN_RTC
69 endif
70
71 ifneq (,$(filter noi18n,$(DEB_BUILD_OPTIONS)))
72 TARGET = install
73 ifeq (,$(filter noidn, $(DEB_BUILD_OPTIONS)))
74 DEB_COPTS += -DHAVE_IDN
75 endif
76 endif
77
78 ifneq (,$(filter uselua,$(DEB_BUILD_OPTIONS)))
79 DEB_COPTS += -DHAVE_LUASCRIPT
80 endif
81
82 ifeq (,$(filter nodnssec,$(DEB_BUILD_OPTIONS)))
83 DEB_COPTS += -DHAVE_DNSSEC
84 endif
85
86 ifneq ($(DEB_HOST_ARCH_OS),linux)
87 # For strlcpy in FreeBSD
88 LDFLAGS += -lbsd
89 endif
90
91 clean:
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
97 binary-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 \
108 -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
118 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
122 dpkg-gencontrol $(PACKAGE_VERSION) -T -pdnsmasq -Pdebian/daemon
123 chown -R root.root debian/daemon
124 chmod -R g-ws debian/daemon
125 dpkg --build debian/daemon ..
126
127 binary-arch: checkroot
128 $(checkdir)
129 rm -rf debian/base
130 install -m 755 \
131 -d debian/base/DEBIAN \
132 -d debian/base/etc/dbus-1/system.d \
133 -d debian/base/usr/share/doc/$(package) \
134 -d debian/base/usr/share/doc/$(package)/examples \
135 -d debian/base/var/run \
136 -d debian/base/usr/share/$(package) \
137 -d debian/base/var/lib/misc
138 make $(TARGET) PREFIX=/usr DESTDIR=`pwd`/debian/base CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=gcc
139 ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
140 # 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
143 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/.
145 install -m 644 trust-anchors.conf debian/base/usr/share/$(package)/.
146 install -m 644 FAQ debian/base/usr/share/doc/$(package)/.
147 gzip -9n debian/base/usr/share/doc/$(package)/FAQ
148 install -m 644 CHANGELOG debian/base/usr/share/doc/$(package)/changelog
149 gzip -9n debian/base/usr/share/doc/$(package)/changelog
150 install -m 644 CHANGELOG.archive debian/base/usr/share/doc/$(package)/changelog.archive
151 gzip -9n debian/base/usr/share/doc/$(package)/changelog.archive
152 install -m 644 dbus/DBus-interface debian/base/usr/share/doc/$(package)/.
153 gzip -9n debian/base/usr/share/doc/$(package)/DBus-interface
154 endif
155 install -m 644 debian/dnsmasq-base.conffiles debian/base/DEBIAN/conffiles
156 install -m 755 debian/dnsmasq-base.postinst debian/base/DEBIAN/postinst
157 install -m 755 debian/dnsmasq-base.postrm debian/base/DEBIAN/postrm
158 install -m 644 debian/changelog debian/base/usr/share/doc/$(package)/changelog.Debian
159 gzip -9n 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
162 install -m 644 debian/dbus.conf debian/base/etc/dbus-1/system.d/dnsmasq.conf
163 gzip -9n 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 -9n $$f/man8/dnsmasq.8 ; \
167 fi \
168 done
169 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
170 strip -R .note -R .comment debian/base/usr/sbin/dnsmasq
171 endif
172 cd debian/base && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
173 dpkg-shlibdeps --warnings=1 debian/base/usr/sbin/dnsmasq
174 dpkg-gencontrol $(PACKAGE_VERSION) -pdnsmasq-base -Pdebian/base
175 chown -R root.root debian/base
176 chmod -R g-ws debian/base
177 dpkg --build debian/base ..
178
179 ifeq ($(DEB_HOST_ARCH_OS),linux)
180 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
185 make -C contrib/wrt PREFIX=/usr DESTDIR=`pwd`/debian/utils CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=gcc
186 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 -9n 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 -9n debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
194 gzip -9n debian/utils/usr/share/man/man1/dhcp_lease_time.1
195 ifeq (,$(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
198 endif
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
201 dpkg-gencontrol $(PACKAGE_VERSION) -Tdebian/utils-substvars -pdnsmasq-utils -Pdebian/utils
202 chown -R root.root debian/utils
203 chmod -R g-ws debian/utils
204 dpkg --build debian/utils ..
205 endif
206
207 define checkdir
208 test -f Makefile -a -f debian/rules
209 endef
210
211 # Below here is fairly generic really
212
213 binary: binary-arch binary-indep
214
215 build:
216 build-arch:
217 build-indep:
218
219 checkroot:
220 test root = "`whoami`"
221
222 .PHONY: binary binary-arch binary-indep clean checkroot
223
224