Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 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 | |
Simon Ruderich | 91f4a5e | 2014-05-20 20:27:31 +0100 | [diff] [blame] | 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) |
Simon Kelley | 97c83bb | 2012-05-28 18:21:59 +0100 | [diff] [blame] | 18 | CFLAGS += -Wall -W |
| 19 | |
Simon Ruderich | 91f4a5e | 2014-05-20 20:27:31 +0100 | [diff] [blame] | 20 | LDFLAGS = $(shell $(dpkg_buildflags) --get LDFLAGS) |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 21 | |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 22 | DEB_COPTS = $(COPTS) |
Simon Kelley | 97c83bb | 2012-05-28 18:21:59 +0100 | [diff] [blame] | 23 | |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 24 | TARGET = install-i18n |
| 25 | |
Simon Kelley | 6ac3bc0 | 2014-10-03 08:48:11 +0100 | [diff] [blame^] | 26 | DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS) |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 27 | |
Simon Kelley | 02ed24d | 2013-09-09 18:06:45 +0100 | [diff] [blame] | 28 | # Force package version based on git tags. |
| 29 | ifneq (,$(filter gitversion,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 1d1c795 | 2013-10-02 14:52:23 +0100 | [diff] [blame] | 30 | PACKAGE_VERSION = $(shell bld/get-version `pwd` | sed 's/test/~&/; s/[a-z]/~&/; s/-/./g; s/$$/-1/; s/^/-v/';) |
Simon Kelley | 02ed24d | 2013-09-09 18:06:45 +0100 | [diff] [blame] | 31 | endif |
| 32 | |
Simon Kelley | 6277978 | 2012-02-10 21:19:25 +0000 | [diff] [blame] | 33 | ifeq (,$(filter nodbus,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 34 | DEB_COPTS += -DHAVE_DBUS |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 35 | endif |
| 36 | |
Simon Kelley | 6277978 | 2012-02-10 21:19:25 +0000 | [diff] [blame] | 37 | ifeq (,$(filter noconntrack,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 6ac3bc0 | 2014-10-03 08:48:11 +0100 | [diff] [blame^] | 38 | ifeq ($(DEB_HOST_ARCH_OS),linux) |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 39 | DEB_COPTS += -DHAVE_CONNTRACK |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 40 | endif |
| 41 | endif |
| 42 | |
Simon Kelley | 3ddad24 | 2013-03-21 17:56:06 +0000 | [diff] [blame] | 43 | ifneq (,$(filter noipset,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 44 | DEB_COPTS += -DNO_IPSET |
Simon Kelley | 3b323bd | 2013-02-22 21:55:29 +0000 | [diff] [blame] | 45 | endif |
| 46 | |
Simon Kelley | 96c3879 | 2012-02-16 20:07:17 +0000 | [diff] [blame] | 47 | ifneq (,$(filter nodhcp6,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 48 | DEB_COPTS += -DNO_DHCP6 |
Simon Kelley | 127ea40 | 2012-02-11 22:14:52 +0000 | [diff] [blame] | 49 | endif |
| 50 | |
Simon Kelley | 6277978 | 2012-02-10 21:19:25 +0000 | [diff] [blame] | 51 | ifneq (,$(filter noipv6,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 52 | DEB_COPTS += -DNO_IPV6 |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 53 | endif |
| 54 | |
Simon Kelley | 6277978 | 2012-02-10 21:19:25 +0000 | [diff] [blame] | 55 | ifneq (,$(filter notftp,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 56 | DEB_COPTS += -DNO_TFTP |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 57 | endif |
| 58 | |
Simon Kelley | 6277978 | 2012-02-10 21:19:25 +0000 | [diff] [blame] | 59 | ifneq (,$(filter nodhcp,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 60 | DEB_COPTS += -DNO_DHCP |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 61 | endif |
| 62 | |
Simon Kelley | 6277978 | 2012-02-10 21:19:25 +0000 | [diff] [blame] | 63 | ifneq (,$(filter noscript,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 64 | DEB_COPTS += -DNO_SCRIPT |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 65 | endif |
| 66 | |
Simon Kelley | 6277978 | 2012-02-10 21:19:25 +0000 | [diff] [blame] | 67 | ifneq (,$(filter nortc,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 68 | DEB_COPTS += -DHAVE_BROKEN_RTC |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 69 | endif |
| 70 | |
Simon Kelley | 6277978 | 2012-02-10 21:19:25 +0000 | [diff] [blame] | 71 | ifneq (,$(filter noi18n,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 72 | TARGET = install |
Simon Kelley | 6277978 | 2012-02-10 21:19:25 +0000 | [diff] [blame] | 73 | ifeq (,$(filter noidn, $(DEB_BUILD_OPTIONS))) |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 74 | DEB_COPTS += -DHAVE_IDN |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 75 | endif |
| 76 | endif |
| 77 | |
Simon Kelley | 6277978 | 2012-02-10 21:19:25 +0000 | [diff] [blame] | 78 | ifneq (,$(filter uselua,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 79 | DEB_COPTS += -DHAVE_LUASCRIPT |
Simon Kelley | 6277978 | 2012-02-10 21:19:25 +0000 | [diff] [blame] | 80 | endif |
| 81 | |
Simon Kelley | 160f650 | 2014-02-04 16:49:41 +0000 | [diff] [blame] | 82 | ifeq (,$(filter nodnssec,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 83 | DEB_COPTS += -DHAVE_DNSSEC |
Simon Kelley | 00ec693 | 2014-01-28 11:08:57 +0000 | [diff] [blame] | 84 | endif |
| 85 | |
Simon Kelley | 6ac3bc0 | 2014-10-03 08:48:11 +0100 | [diff] [blame^] | 86 | ifneq ($(DEB_HOST_ARCH_OS),linux) |
| 87 | # For strlcpy in FreeBSD |
| 88 | LDFLAGS += -lbsd |
| 89 | endif |
| 90 | |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 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 \ |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 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 |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 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 |
Simon Kelley | aa985be | 2013-09-11 10:28:39 +0100 | [diff] [blame] | 122 | dpkg-gencontrol $(PACKAGE_VERSION) -T -pdnsmasq -Pdebian/daemon |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 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 \ |
Simon Kelley | 4ba9b38 | 2012-07-29 17:07:48 +0100 | [diff] [blame] | 132 | -d debian/base/etc/dbus-1/system.d \ |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 133 | -d debian/base/usr/share/doc/$(package) \ |
| 134 | -d debian/base/usr/share/doc/$(package)/examples \ |
| 135 | -d debian/base/var/run \ |
Simon Kelley | da4f372 | 2014-02-06 15:21:37 +0000 | [diff] [blame] | 136 | -d debian/base/usr/share/$(package) \ |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 137 | -d debian/base/var/lib/misc |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 138 | make $(TARGET) PREFIX=/usr DESTDIR=`pwd`/debian/base CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=gcc |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 139 | ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS))) |
Simon Kelley | 933878f | 2014-09-09 14:28:01 +0100 | [diff] [blame] | 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 |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 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/. |
Simon Kelley | da4f372 | 2014-02-06 15:21:37 +0000 | [diff] [blame] | 145 | install -m 644 trust-anchors.conf debian/base/usr/share/$(package)/. |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 146 | install -m 644 FAQ debian/base/usr/share/doc/$(package)/. |
| 147 | gzip -9 debian/base/usr/share/doc/$(package)/FAQ |
| 148 | install -m 644 CHANGELOG debian/base/usr/share/doc/$(package)/changelog |
| 149 | gzip -9 debian/base/usr/share/doc/$(package)/changelog |
| 150 | install -m 644 CHANGELOG.archive debian/base/usr/share/doc/$(package)/changelog.archive |
| 151 | gzip -9 debian/base/usr/share/doc/$(package)/changelog.archive |
| 152 | install -m 644 dbus/DBus-interface debian/base/usr/share/doc/$(package)/. |
| 153 | gzip -9 debian/base/usr/share/doc/$(package)/DBus-interface |
| 154 | endif |
Simon Kelley | 4ba9b38 | 2012-07-29 17:07:48 +0100 | [diff] [blame] | 155 | install -m 644 debian/dnsmasq-base.conffiles debian/base/DEBIAN/conffiles |
Simon Kelley | bc54ae3 | 2012-08-28 21:26:56 +0100 | [diff] [blame] | 156 | install -m 755 debian/dnsmasq-base.postinst debian/base/DEBIAN/postinst |
| 157 | install -m 755 debian/dnsmasq-base.postrm debian/base/DEBIAN/postrm |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 158 | install -m 644 debian/changelog debian/base/usr/share/doc/$(package)/changelog.Debian |
| 159 | gzip -9 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 |
Simon Kelley | 4ba9b38 | 2012-07-29 17:07:48 +0100 | [diff] [blame] | 162 | install -m 644 debian/dbus.conf debian/base/etc/dbus-1/system.d/dnsmasq.conf |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 163 | gzip -9 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 -9 $$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 |
Simon Kelley | aa985be | 2013-09-11 10:28:39 +0100 | [diff] [blame] | 173 | dpkg-shlibdeps --warnings=1 debian/base/usr/sbin/dnsmasq |
Simon Kelley | 02ed24d | 2013-09-09 18:06:45 +0100 | [diff] [blame] | 174 | dpkg-gencontrol $(PACKAGE_VERSION) -pdnsmasq-base -Pdebian/base |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 175 | chown -R root.root debian/base |
| 176 | chmod -R g-ws debian/base |
| 177 | dpkg --build debian/base .. |
| 178 | |
Simon Kelley | 6ac3bc0 | 2014-10-03 08:48:11 +0100 | [diff] [blame^] | 179 | ifeq ($(DEB_HOST_ARCH_OS),linux) |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 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 |
Simon Kelley | 8f6213c | 2014-01-28 11:16:49 +0000 | [diff] [blame] | 185 | make -C contrib/wrt PREFIX=/usr DESTDIR=`pwd`/debian/utils CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=gcc |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 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 -9 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 -9 debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian |
| 194 | gzip -9 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 |
Simon Kelley | 02ed24d | 2013-09-09 18:06:45 +0100 | [diff] [blame] | 201 | dpkg-gencontrol $(PACKAGE_VERSION) -Tdebian/utils-substvars -pdnsmasq-utils -Pdebian/utils |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 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 |
Simon Kelley | 760169f | 2012-03-09 14:27:49 +0000 | [diff] [blame] | 214 | |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 215 | build: |
Simon Kelley | 760169f | 2012-03-09 14:27:49 +0000 | [diff] [blame] | 216 | build-arch: |
| 217 | build-indep: |
Simon Kelley | c72daea | 2012-01-05 21:33:27 +0000 | [diff] [blame] | 218 | |
| 219 | checkroot: |
| 220 | test root = "`whoami`" |
| 221 | |
| 222 | .PHONY: binary binary-arch binary-indep clean checkroot |
| 223 | |
| 224 | |