blob: b6671f4ee910eb45a69cf96bfc94587f4a133663 [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 Kelley97c83bb2012-05-28 18:21:59 +010014CFLAGS = $(shell export DEB_BUILD_OPTIONS=$(DEB_BUILD_OPTIONS); dpkg-buildflags --get CFLAGS)
15CFLAGS += $(shell dpkg-buildflags --get CPPFLAGS)
16CFLAGS += -Wall -W
17
18LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS)
Simon Kelleyc72daea2012-01-05 21:33:27 +000019
20COPTS =
Simon Kelley97c83bb2012-05-28 18:21:59 +010021
Simon Kelleyc72daea2012-01-05 21:33:27 +000022TARGET = install-i18n
23
24DEB_BUILD_ARCH_OS := $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
25
Simon Kelley02ed24d2013-09-09 18:06:45 +010026# Force package version based on git tags.
27ifneq (,$(filter gitversion,$(DEB_BUILD_OPTIONS)))
28 PACKAGE_VERSION = $(shell bld/get-version `pwd` | sed 's/[a-z]/~&/; s/$$/-1/; s/^/-v/')
29endif
30
Simon Kelley62779782012-02-10 21:19:25 +000031ifeq (,$(filter nodbus,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000032 COPTS += -DHAVE_DBUS
33endif
34
Simon Kelley62779782012-02-10 21:19:25 +000035ifeq (,$(filter noconntrack,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000036ifeq ($(DEB_BUILD_ARCH_OS),linux)
37 COPTS += -DHAVE_CONNTRACK
38endif
39endif
40
Simon Kelley3ddad242013-03-21 17:56:06 +000041ifneq (,$(filter noipset,$(DEB_BUILD_OPTIONS)))
42 COPTS += -DNO_IPSET
Simon Kelley3b323bd2013-02-22 21:55:29 +000043endif
44
Simon Kelley96c38792012-02-16 20:07:17 +000045ifneq (,$(filter nodhcp6,$(DEB_BUILD_OPTIONS)))
46 COPTS += -DNO_DHCP6
Simon Kelley127ea402012-02-11 22:14:52 +000047endif
48
Simon Kelley62779782012-02-10 21:19:25 +000049ifneq (,$(filter noipv6,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000050 COPTS += -DNO_IPV6
51endif
52
Simon Kelley62779782012-02-10 21:19:25 +000053ifneq (,$(filter notftp,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000054 COPTS += -DNO_TFTP
55endif
56
Simon Kelley62779782012-02-10 21:19:25 +000057ifneq (,$(filter nodhcp,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000058 COPTS += -DNO_DHCP
59endif
60
Simon Kelley62779782012-02-10 21:19:25 +000061ifneq (,$(filter noscript,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000062 COPTS += -DNO_SCRIPT
63endif
64
Simon Kelley62779782012-02-10 21:19:25 +000065ifneq (,$(filter nortc,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000066 COPTS += -DHAVE_BROKEN_RTC
67endif
68
Simon Kelley62779782012-02-10 21:19:25 +000069ifneq (,$(filter noi18n,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000070 TARGET = install
Simon Kelley62779782012-02-10 21:19:25 +000071 ifeq (,$(filter noidn, $(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000072 COPTS += -DHAVE_IDN
73 endif
74endif
75
Simon Kelley62779782012-02-10 21:19:25 +000076ifneq (,$(filter uselua,$(DEB_BUILD_OPTIONS)))
77 COPTS += -DHAVE_LUASCRIPT
78endif
79
Simon Kelleyc72daea2012-01-05 21:33:27 +000080clean:
81 $(checkdir)
82 rm -rf debian/daemon debian/base debian/utils debian/*~ debian/files debian/substvars debian/utils-substvars
83 make clean
84 make -C contrib/wrt clean
85
86binary-indep: checkroot
87 $(checkdir)
88 rm -rf debian/daemon
89 install -m 755 \
90 -d debian/daemon/DEBIAN \
91 -d debian/daemon/usr/share/doc \
92 -d debian/daemon/etc/init.d \
93 -d debian/daemon/etc/dnsmasq.d \
94 -d debian/daemon/etc/resolvconf/update.d \
95 -d debian/daemon/usr/lib/resolvconf/dpkg-event.d \
96 -d debian/daemon/etc/default \
Simon Kelleyc72daea2012-01-05 21:33:27 +000097 -d debian/daemon/lib/systemd/system \
98 -d debian/daemon/etc/insserv.conf.d
99 install -m 644 debian/conffiles debian/daemon/DEBIAN
100 install -m 755 debian/postinst debian/postrm debian/prerm debian/daemon/DEBIAN
101 install -m 755 debian/init debian/daemon/etc/init.d/dnsmasq
102 install -m 755 debian/resolvconf debian/daemon/etc/resolvconf/update.d/dnsmasq
103 install -m 755 debian/resolvconf-package debian/daemon/usr/lib/resolvconf/dpkg-event.d/dnsmasq
104 install -m 644 debian/default debian/daemon/etc/default/dnsmasq
105 install -m 644 dnsmasq.conf.example debian/daemon/etc/dnsmasq.conf
106 install -m 644 debian/readme.dnsmasq.d debian/daemon/etc/dnsmasq.d/README
Simon Kelleyc72daea2012-01-05 21:33:27 +0000107 install -m 644 debian/systemd.service debian/daemon/lib/systemd/system/dnsmasq.service
108 install -m 644 debian/insserv debian/daemon/etc/insserv.conf.d/dnsmasq
109 ln -s $(package) debian/daemon/usr/share/doc/dnsmasq
110 cd debian/daemon && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
Simon Kelleyaa985be2013-09-11 10:28:39 +0100111 dpkg-gencontrol $(PACKAGE_VERSION) -T -pdnsmasq -Pdebian/daemon
Simon Kelleyc72daea2012-01-05 21:33:27 +0000112 chown -R root.root debian/daemon
113 chmod -R g-ws debian/daemon
114 dpkg --build debian/daemon ..
115
116binary-arch: checkroot
117 $(checkdir)
118 rm -rf debian/base
119 install -m 755 \
120 -d debian/base/DEBIAN \
Simon Kelley4ba9b382012-07-29 17:07:48 +0100121 -d debian/base/etc/dbus-1/system.d \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000122 -d debian/base/usr/share/doc/$(package) \
123 -d debian/base/usr/share/doc/$(package)/examples \
124 -d debian/base/var/run \
125 -d debian/base/var/lib/misc
Simon Kelley43c271b2012-06-07 10:02:53 +0100126 make $(TARGET) PREFIX=/usr DESTDIR=`pwd`/debian/base CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(COPTS)" CC=gcc
Simon Kelleyc72daea2012-01-05 21:33:27 +0000127ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
128 install -m 644 doc.html debian/base/usr/share/doc/$(package)/.
129 install -m 644 setup.html debian/base/usr/share/doc/$(package)/.
130 install -m 644 dnsmasq.conf.example debian/base/usr/share/doc/$(package)/examples/.
131 install -m 644 FAQ debian/base/usr/share/doc/$(package)/.
132 gzip -9 debian/base/usr/share/doc/$(package)/FAQ
133 install -m 644 CHANGELOG debian/base/usr/share/doc/$(package)/changelog
134 gzip -9 debian/base/usr/share/doc/$(package)/changelog
135 install -m 644 CHANGELOG.archive debian/base/usr/share/doc/$(package)/changelog.archive
136 gzip -9 debian/base/usr/share/doc/$(package)/changelog.archive
137 install -m 644 dbus/DBus-interface debian/base/usr/share/doc/$(package)/.
138 gzip -9 debian/base/usr/share/doc/$(package)/DBus-interface
139endif
Simon Kelley4ba9b382012-07-29 17:07:48 +0100140 install -m 644 debian/dnsmasq-base.conffiles debian/base/DEBIAN/conffiles
Simon Kelleybc54ae32012-08-28 21:26:56 +0100141 install -m 755 debian/dnsmasq-base.postinst debian/base/DEBIAN/postinst
142 install -m 755 debian/dnsmasq-base.postrm debian/base/DEBIAN/postrm
Simon Kelleyc72daea2012-01-05 21:33:27 +0000143 install -m 644 debian/changelog debian/base/usr/share/doc/$(package)/changelog.Debian
144 gzip -9 debian/base/usr/share/doc/$(package)/changelog.Debian
145 install -m 644 debian/readme debian/base/usr/share/doc/$(package)/README.Debian
146 install -m 644 debian/copyright debian/base/usr/share/doc/$(package)/copyright
Simon Kelley4ba9b382012-07-29 17:07:48 +0100147 install -m 644 debian/dbus.conf debian/base/etc/dbus-1/system.d/dnsmasq.conf
Simon Kelleyc72daea2012-01-05 21:33:27 +0000148 gzip -9 debian/base/usr/share/man/man8/dnsmasq.8
149 for f in debian/base/usr/share/man/*; do \
150 if [ -f $$f/man8/dnsmasq.8 ]; then \
151 gzip -9 $$f/man8/dnsmasq.8 ; \
152 fi \
153 done
154ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
155 strip -R .note -R .comment debian/base/usr/sbin/dnsmasq
156endif
157 cd debian/base && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
Simon Kelleyaa985be2013-09-11 10:28:39 +0100158 dpkg-shlibdeps --warnings=1 debian/base/usr/sbin/dnsmasq
Simon Kelley02ed24d2013-09-09 18:06:45 +0100159 dpkg-gencontrol $(PACKAGE_VERSION) -pdnsmasq-base -Pdebian/base
Simon Kelleyc72daea2012-01-05 21:33:27 +0000160 chown -R root.root debian/base
161 chmod -R g-ws debian/base
162 dpkg --build debian/base ..
163
164ifeq ($(DEB_BUILD_ARCH_OS),linux)
165 rm -rf debian/utils
166 install -m 755 -d debian/utils/DEBIAN \
167 -d debian/utils/usr/share/man/man1 \
168 -d debian/utils/usr/bin \
169 -d debian/utils/usr/share/doc/dnsmasq-utils
Simon Kelley43c271b2012-06-07 10:02:53 +0100170 make -C contrib/wrt PREFIX=/usr DESTDIR=`pwd`/debian/utils CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(COPTS)" CC=gcc
Simon Kelleyc72daea2012-01-05 21:33:27 +0000171 install -m 755 contrib/wrt/dhcp_release debian/utils/usr/bin/dhcp_release
172 install -m 644 contrib/wrt/dhcp_release.1 debian/utils/usr/share/man/man1/dhcp_release.1
173 gzip -9 debian/utils/usr/share/man/man1/dhcp_release.1
174 install -m 755 contrib/wrt/dhcp_lease_time debian/utils/usr/bin/dhcp_lease_time
175 install -m 644 contrib/wrt/dhcp_lease_time.1 debian/utils/usr/share/man/man1/dhcp_lease_time.1
176 install -m 644 debian/copyright debian/utils/usr/share/doc/dnsmasq-utils/copyright
177 install -m 644 debian/changelog debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
178 gzip -9 debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
179 gzip -9 debian/utils/usr/share/man/man1/dhcp_lease_time.1
180ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
181 strip -R .note -R .comment debian/utils/usr/bin/dhcp_release
182 strip -R .note -R .comment debian/utils/usr/bin/dhcp_lease_time
183endif
184 cd debian/utils && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
185 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 +0100186 dpkg-gencontrol $(PACKAGE_VERSION) -Tdebian/utils-substvars -pdnsmasq-utils -Pdebian/utils
Simon Kelleyc72daea2012-01-05 21:33:27 +0000187 chown -R root.root debian/utils
188 chmod -R g-ws debian/utils
189 dpkg --build debian/utils ..
190endif
191
192define checkdir
193 test -f Makefile -a -f debian/rules
194endef
195
196# Below here is fairly generic really
197
198binary: binary-arch binary-indep
Simon Kelley760169f2012-03-09 14:27:49 +0000199
Simon Kelleyc72daea2012-01-05 21:33:27 +0000200build:
Simon Kelley760169f2012-03-09 14:27:49 +0000201build-arch:
202build-indep:
Simon Kelleyc72daea2012-01-05 21:33:27 +0000203
204checkroot:
205 test root = "`whoami`"
206
207.PHONY: binary binary-arch binary-indep clean checkroot
208
209