summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 0dcbb30d1a7f7362f31dceca7287fe63f051f2bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/usr/bin/make -f
# debian/rules file - for dnsmasq.
# Copyright 2001-2011 by Simon Kelley
# Based on the sample in the debian hello package which carries the following:
# Copyright 1994,1995 by Ian Jackson.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself.  (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)
# This file may have to be extensively modified

package=dnsmasq-base

dpkg_buildflags := DEB_BUILD_MAINT_OPTIONS="hardening=+all" dpkg-buildflags

CFLAGS = $(shell $(dpkg_buildflags) --get CFLAGS)
CFLAGS += $(shell $(dpkg_buildflags) --get CPPFLAGS)
CFLAGS += -Wall -W

LDFLAGS = $(shell $(dpkg_buildflags) --get LDFLAGS)

DEB_COPTS = $(COPTS)

TARGET = install-i18n

DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)

# Force package version based on git tags.
ifneq (,$(filter gitversion,$(DEB_BUILD_OPTIONS)))
     PACKAGE_VERSION = $(shell bld/get-version `pwd` |  sed 's/test/~&/; s/[a-z]/~&/;  s/-/./g; s/$$/-1/; s/^/-v/';)
endif

ifeq (,$(filter nodbus,$(DEB_BUILD_OPTIONS)))
     DEB_COPTS += -DHAVE_DBUS
endif

ifeq (,$(filter noconntrack,$(DEB_BUILD_OPTIONS)))
ifeq ($(DEB_HOST_ARCH_OS),linux)
     DEB_COPTS += -DHAVE_CONNTRACK
endif
endif

ifneq (,$(filter noipset,$(DEB_BUILD_OPTIONS)))
     DEB_COPTS += -DNO_IPSET
endif

ifneq (,$(filter nodhcp6,$(DEB_BUILD_OPTIONS)))
     DEB_COPTS += -DNO_DHCP6
endif

ifneq (,$(filter noipv6,$(DEB_BUILD_OPTIONS)))
     DEB_COPTS += -DNO_IPV6
endif

ifneq (,$(filter notftp,$(DEB_BUILD_OPTIONS)))
     DEB_COPTS += -DNO_TFTP
endif

ifneq (,$(filter nodhcp,$(DEB_BUILD_OPTIONS)))
     DEB_COPTS += -DNO_DHCP
endif

ifneq (,$(filter noscript,$(DEB_BUILD_OPTIONS)))
     DEB_COPTS += -DNO_SCRIPT
endif

ifneq (,$(filter nortc,$(DEB_BUILD_OPTIONS)))
     DEB_COPTS += -DHAVE_BROKEN_RTC
endif

ifneq (,$(filter noi18n,$(DEB_BUILD_OPTIONS)))
     TARGET = install
     ifeq (,$(filter noidn, $(DEB_BUILD_OPTIONS)))
	DEB_COPTS += -DHAVE_IDN
     endif	
endif

ifneq (,$(filter uselua,$(DEB_BUILD_OPTIONS)))
     DEB_COPTS += -DHAVE_LUASCRIPT
endif

ifeq (,$(filter nodnssec,$(DEB_BUILD_OPTIONS)))
     DEB_COPTS += -DHAVE_DNSSEC
endif

ifneq ($(DEB_HOST_ARCH_OS),linux)
     # For strlcpy in FreeBSD
     LDFLAGS += -lbsd
endif

clean:
	$(checkdir)
	rm -rf debian/daemon debian/base debian/utils debian/*~ debian/files debian/substvars debian/utils-substvars
	make clean
	make -C contrib/wrt clean

binary-indep:	checkroot
	$(checkdir)
	rm -rf debian/daemon
	install -m 755 \
	        -d debian/daemon/DEBIAN \
		-d debian/daemon/usr/share/doc \
	        -d debian/daemon/etc/init.d \
		-d debian/daemon/etc/dnsmasq.d \
	        -d debian/daemon/etc/resolvconf/update.d \
		-d debian/daemon/usr/lib/resolvconf/dpkg-event.d \
	        -d debian/daemon/etc/default \
		-d debian/daemon/lib/systemd/system \
                -d debian/daemon/etc/insserv.conf.d
	install -m 644 debian/conffiles debian/daemon/DEBIAN
	install -m 755 debian/postinst debian/postrm debian/prerm debian/daemon/DEBIAN
	install -m 755 debian/init debian/daemon/etc/init.d/dnsmasq
	install -m 755 debian/resolvconf debian/daemon/etc/resolvconf/update.d/dnsmasq
	install -m 755 debian/resolvconf-package debian/daemon/usr/lib/resolvconf/dpkg-event.d/dnsmasq
	install -m 644 debian/default debian/daemon/etc/default/dnsmasq
	install -m 644 dnsmasq.conf.example debian/daemon/etc/dnsmasq.conf
	install -m 644 debian/readme.dnsmasq.d debian/daemon/etc/dnsmasq.d/README
	install -m 644 debian/systemd.service debian/daemon/lib/systemd/system/dnsmasq.service
	install -m 644 debian/insserv debian/daemon/etc/insserv.conf.d/dnsmasq
	ln -s $(package) debian/daemon/usr/share/doc/dnsmasq
	cd debian/daemon && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums	
	dpkg-gencontrol $(PACKAGE_VERSION) -T -pdnsmasq -Pdebian/daemon
	chown -R root.root debian/daemon
	chmod -R g-ws debian/daemon
	dpkg --build debian/daemon ..

binary-arch:	checkroot 
	$(checkdir)
	rm -rf debian/base
	install -m 755 \
		-d debian/base/DEBIAN \
		-d debian/base/etc/dbus-1/system.d \
	        -d debian/base/usr/share/doc/$(package) \
		-d debian/base/usr/share/doc/$(package)/examples \
	        -d debian/base/var/run \
		-d debian/base/usr/share/$(package) \
	        -d debian/base/var/lib/misc
	make $(TARGET) PREFIX=/usr DESTDIR=`pwd`/debian/base CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=gcc
ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
# Need to remove paypal links in Debian Package for policy reasons.
	sed -e /\<H2\>Donations/Q -e /icon.png/d doc.html -e /favicon.ico/d >debian/base/usr/share/doc/$(package)/doc.html
	echo "</BODY>" >>debian/base/usr/share/doc/$(package)/doc.html 
	install -m 644 setup.html debian/base/usr/share/doc/$(package)/.
	install -m 644 dnsmasq.conf.example debian/base/usr/share/doc/$(package)/examples/.
	install -m 644 trust-anchors.conf debian/base/usr/share/$(package)/.
	install -m 644 FAQ debian/base/usr/share/doc/$(package)/.
	gzip -9 debian/base/usr/share/doc/$(package)/FAQ
	install -m 644 CHANGELOG debian/base/usr/share/doc/$(package)/changelog
	gzip -9 debian/base/usr/share/doc/$(package)/changelog
	install -m 644 CHANGELOG.archive debian/base/usr/share/doc/$(package)/changelog.archive
	gzip -9 debian/base/usr/share/doc/$(package)/changelog.archive
	install -m 644 dbus/DBus-interface debian/base/usr/share/doc/$(package)/.
	gzip -9 debian/base/usr/share/doc/$(package)/DBus-interface	
endif
	install -m 644 debian/dnsmasq-base.conffiles debian/base/DEBIAN/conffiles
	install -m 755 debian/dnsmasq-base.postinst debian/base/DEBIAN/postinst
	install -m 755 debian/dnsmasq-base.postrm  debian/base/DEBIAN/postrm
	install -m 644 debian/changelog debian/base/usr/share/doc/$(package)/changelog.Debian
	gzip -9 debian/base/usr/share/doc/$(package)/changelog.Debian
	install -m 644 debian/readme debian/base/usr/share/doc/$(package)/README.Debian
	install -m 644 debian/copyright debian/base/usr/share/doc/$(package)/copyright
	install -m 644 debian/dbus.conf debian/base/etc/dbus-1/system.d/dnsmasq.conf
	gzip -9 debian/base/usr/share/man/man8/dnsmasq.8
	for f in debian/base/usr/share/man/*; do \
		if [ -f $$f/man8/dnsmasq.8 ]; then \
                       gzip -9 $$f/man8/dnsmasq.8 ; \
                fi \
	done
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	strip -R .note -R .comment debian/base/usr/sbin/dnsmasq
endif
	cd debian/base && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
	dpkg-shlibdeps --warnings=1 debian/base/usr/sbin/dnsmasq
	dpkg-gencontrol $(PACKAGE_VERSION) -pdnsmasq-base -Pdebian/base
	chown -R root.root debian/base
	chmod -R g-ws debian/base 
	dpkg --build debian/base ..

ifeq ($(DEB_HOST_ARCH_OS),linux)
	rm -rf debian/utils
	install -m 755 -d debian/utils/DEBIAN \
                       -d debian/utils/usr/share/man/man1 \
	               -d debian/utils/usr/bin \
                       -d debian/utils/usr/share/doc/dnsmasq-utils
	make -C contrib/wrt PREFIX=/usr DESTDIR=`pwd`/debian/utils CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=gcc
	install -m 755 contrib/wrt/dhcp_release debian/utils/usr/bin/dhcp_release
	install -m 644 contrib/wrt/dhcp_release.1 debian/utils/usr/share/man/man1/dhcp_release.1
	gzip -9 debian/utils/usr/share/man/man1/dhcp_release.1
	install -m 755 contrib/wrt/dhcp_lease_time debian/utils/usr/bin/dhcp_lease_time
	install -m 644 contrib/wrt/dhcp_lease_time.1 debian/utils/usr/share/man/man1/dhcp_lease_time.1
	install -m 644 debian/copyright debian/utils/usr/share/doc/dnsmasq-utils/copyright
	install -m 644 debian/changelog debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
	gzip -9 debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
	gzip -9 debian/utils/usr/share/man/man1/dhcp_lease_time.1
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	strip -R .note -R .comment debian/utils/usr/bin/dhcp_release
	strip -R .note -R .comment debian/utils/usr/bin/dhcp_lease_time
endif	
	cd debian/utils && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
	dpkg-shlibdeps -Tdebian/utils-substvars debian/utils/usr/bin/dhcp_release debian/utils/usr/bin/dhcp_lease_time
	dpkg-gencontrol $(PACKAGE_VERSION) -Tdebian/utils-substvars -pdnsmasq-utils -Pdebian/utils
	chown -R root.root debian/utils
	chmod -R g-ws debian/utils 
	dpkg --build debian/utils ..
endif

define checkdir
	test -f Makefile -a -f debian/rules
endef

# Below here is fairly generic really

binary:		binary-arch binary-indep

build:		
build-arch:
build-indep:

checkroot:
	test root = "`whoami`"

.PHONY: binary binary-arch binary-indep clean checkroot