blob: 00028c6db07cb4eac1c9d403db0ae4e7d252bc4c [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 Kelley62779782012-02-10 21:19:25 +000026ifeq (,$(filter nodbus,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000027 COPTS += -DHAVE_DBUS
28endif
29
Simon Kelley62779782012-02-10 21:19:25 +000030ifeq (,$(filter noconntrack,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000031ifeq ($(DEB_BUILD_ARCH_OS),linux)
32 COPTS += -DHAVE_CONNTRACK
33endif
34endif
35
Simon Kelley96c38792012-02-16 20:07:17 +000036ifneq (,$(filter nodhcp6,$(DEB_BUILD_OPTIONS)))
37 COPTS += -DNO_DHCP6
Simon Kelley127ea402012-02-11 22:14:52 +000038endif
39
Simon Kelley62779782012-02-10 21:19:25 +000040ifneq (,$(filter noipv6,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000041 COPTS += -DNO_IPV6
42endif
43
Simon Kelley62779782012-02-10 21:19:25 +000044ifneq (,$(filter notftp,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000045 COPTS += -DNO_TFTP
46endif
47
Simon Kelley62779782012-02-10 21:19:25 +000048ifneq (,$(filter nodhcp,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000049 COPTS += -DNO_DHCP
50endif
51
Simon Kelley62779782012-02-10 21:19:25 +000052ifneq (,$(filter noscript,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000053 COPTS += -DNO_SCRIPT
54endif
55
Simon Kelley62779782012-02-10 21:19:25 +000056ifneq (,$(filter nortc,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000057 COPTS += -DHAVE_BROKEN_RTC
58endif
59
Simon Kelley62779782012-02-10 21:19:25 +000060ifneq (,$(filter noi18n,$(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000061 TARGET = install
Simon Kelley62779782012-02-10 21:19:25 +000062 ifeq (,$(filter noidn, $(DEB_BUILD_OPTIONS)))
Simon Kelleyc72daea2012-01-05 21:33:27 +000063 COPTS += -DHAVE_IDN
64 endif
65endif
66
Simon Kelley62779782012-02-10 21:19:25 +000067ifneq (,$(filter uselua,$(DEB_BUILD_OPTIONS)))
68 COPTS += -DHAVE_LUASCRIPT
69endif
70
Simon Kelleyc72daea2012-01-05 21:33:27 +000071clean:
72 $(checkdir)
73 rm -rf debian/daemon debian/base debian/utils debian/*~ debian/files debian/substvars debian/utils-substvars
74 make clean
75 make -C contrib/wrt clean
76
77binary-indep: checkroot
78 $(checkdir)
79 rm -rf debian/daemon
80 install -m 755 \
81 -d debian/daemon/DEBIAN \
82 -d debian/daemon/usr/share/doc \
83 -d debian/daemon/etc/init.d \
84 -d debian/daemon/etc/dnsmasq.d \
85 -d debian/daemon/etc/resolvconf/update.d \
86 -d debian/daemon/usr/lib/resolvconf/dpkg-event.d \
87 -d debian/daemon/etc/default \
Simon Kelleyc72daea2012-01-05 21:33:27 +000088 -d debian/daemon/lib/systemd/system \
89 -d debian/daemon/etc/insserv.conf.d
90 install -m 644 debian/conffiles debian/daemon/DEBIAN
91 install -m 755 debian/postinst debian/postrm debian/prerm debian/daemon/DEBIAN
92 install -m 755 debian/init debian/daemon/etc/init.d/dnsmasq
93 install -m 755 debian/resolvconf debian/daemon/etc/resolvconf/update.d/dnsmasq
94 install -m 755 debian/resolvconf-package debian/daemon/usr/lib/resolvconf/dpkg-event.d/dnsmasq
95 install -m 644 debian/default debian/daemon/etc/default/dnsmasq
96 install -m 644 dnsmasq.conf.example debian/daemon/etc/dnsmasq.conf
97 install -m 644 debian/readme.dnsmasq.d debian/daemon/etc/dnsmasq.d/README
Simon Kelleyc72daea2012-01-05 21:33:27 +000098 install -m 644 debian/systemd.service debian/daemon/lib/systemd/system/dnsmasq.service
99 install -m 644 debian/insserv debian/daemon/etc/insserv.conf.d/dnsmasq
100 ln -s $(package) debian/daemon/usr/share/doc/dnsmasq
101 cd debian/daemon && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
102 dpkg-gencontrol -pdnsmasq -Pdebian/daemon
103 chown -R root.root debian/daemon
104 chmod -R g-ws debian/daemon
105 dpkg --build debian/daemon ..
106
107binary-arch: checkroot
108 $(checkdir)
109 rm -rf debian/base
110 install -m 755 \
111 -d debian/base/DEBIAN \
Simon Kelley4ba9b382012-07-29 17:07:48 +0100112 -d debian/base/etc/dbus-1/system.d \
Simon Kelleyc72daea2012-01-05 21:33:27 +0000113 -d debian/base/usr/share/doc/$(package) \
114 -d debian/base/usr/share/doc/$(package)/examples \
115 -d debian/base/var/run \
116 -d debian/base/var/lib/misc
Simon Kelley43c271b2012-06-07 10:02:53 +0100117 make $(TARGET) PREFIX=/usr DESTDIR=`pwd`/debian/base CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(COPTS)" CC=gcc
Simon Kelleyc72daea2012-01-05 21:33:27 +0000118ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
119 install -m 644 doc.html debian/base/usr/share/doc/$(package)/.
120 install -m 644 setup.html debian/base/usr/share/doc/$(package)/.
121 install -m 644 dnsmasq.conf.example debian/base/usr/share/doc/$(package)/examples/.
122 install -m 644 FAQ debian/base/usr/share/doc/$(package)/.
123 gzip -9 debian/base/usr/share/doc/$(package)/FAQ
124 install -m 644 CHANGELOG debian/base/usr/share/doc/$(package)/changelog
125 gzip -9 debian/base/usr/share/doc/$(package)/changelog
126 install -m 644 CHANGELOG.archive debian/base/usr/share/doc/$(package)/changelog.archive
127 gzip -9 debian/base/usr/share/doc/$(package)/changelog.archive
128 install -m 644 dbus/DBus-interface debian/base/usr/share/doc/$(package)/.
129 gzip -9 debian/base/usr/share/doc/$(package)/DBus-interface
130endif
Simon Kelley4ba9b382012-07-29 17:07:48 +0100131 install -m 644 debian/dnsmasq-base.conffiles debian/base/DEBIAN/conffiles
Simon Kelleybc54ae32012-08-28 21:26:56 +0100132 install -m 755 debian/dnsmasq-base.postinst debian/base/DEBIAN/postinst
133 install -m 755 debian/dnsmasq-base.postrm debian/base/DEBIAN/postrm
Simon Kelleyc72daea2012-01-05 21:33:27 +0000134 install -m 644 debian/changelog debian/base/usr/share/doc/$(package)/changelog.Debian
135 gzip -9 debian/base/usr/share/doc/$(package)/changelog.Debian
136 install -m 644 debian/readme debian/base/usr/share/doc/$(package)/README.Debian
137 install -m 644 debian/copyright debian/base/usr/share/doc/$(package)/copyright
Simon Kelley4ba9b382012-07-29 17:07:48 +0100138 install -m 644 debian/dbus.conf debian/base/etc/dbus-1/system.d/dnsmasq.conf
Simon Kelleyc72daea2012-01-05 21:33:27 +0000139 gzip -9 debian/base/usr/share/man/man8/dnsmasq.8
140 for f in debian/base/usr/share/man/*; do \
141 if [ -f $$f/man8/dnsmasq.8 ]; then \
142 gzip -9 $$f/man8/dnsmasq.8 ; \
143 fi \
144 done
145ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
146 strip -R .note -R .comment debian/base/usr/sbin/dnsmasq
147endif
148 cd debian/base && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
149 dpkg-shlibdeps debian/base/usr/sbin/dnsmasq
150 dpkg-gencontrol -pdnsmasq-base -Pdebian/base
151 chown -R root.root debian/base
152 chmod -R g-ws debian/base
153 dpkg --build debian/base ..
154
155ifeq ($(DEB_BUILD_ARCH_OS),linux)
156 rm -rf debian/utils
157 install -m 755 -d debian/utils/DEBIAN \
158 -d debian/utils/usr/share/man/man1 \
159 -d debian/utils/usr/bin \
160 -d debian/utils/usr/share/doc/dnsmasq-utils
Simon Kelley43c271b2012-06-07 10:02:53 +0100161 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 +0000162 install -m 755 contrib/wrt/dhcp_release debian/utils/usr/bin/dhcp_release
163 install -m 644 contrib/wrt/dhcp_release.1 debian/utils/usr/share/man/man1/dhcp_release.1
164 gzip -9 debian/utils/usr/share/man/man1/dhcp_release.1
165 install -m 755 contrib/wrt/dhcp_lease_time debian/utils/usr/bin/dhcp_lease_time
166 install -m 644 contrib/wrt/dhcp_lease_time.1 debian/utils/usr/share/man/man1/dhcp_lease_time.1
167 install -m 644 debian/copyright debian/utils/usr/share/doc/dnsmasq-utils/copyright
168 install -m 644 debian/changelog debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
169 gzip -9 debian/utils/usr/share/doc/dnsmasq-utils/changelog.Debian
170 gzip -9 debian/utils/usr/share/man/man1/dhcp_lease_time.1
171ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
172 strip -R .note -R .comment debian/utils/usr/bin/dhcp_release
173 strip -R .note -R .comment debian/utils/usr/bin/dhcp_lease_time
174endif
175 cd debian/utils && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
176 dpkg-shlibdeps -Tdebian/utils-substvars debian/utils/usr/bin/dhcp_release debian/utils/usr/bin/dhcp_lease_time
177 dpkg-gencontrol -Tdebian/utils-substvars -pdnsmasq-utils -Pdebian/utils
178 chown -R root.root debian/utils
179 chmod -R g-ws debian/utils
180 dpkg --build debian/utils ..
181endif
182
183define checkdir
184 test -f Makefile -a -f debian/rules
185endef
186
187# Below here is fairly generic really
188
189binary: binary-arch binary-indep
Simon Kelley760169f2012-03-09 14:27:49 +0000190
Simon Kelleyc72daea2012-01-05 21:33:27 +0000191build:
Simon Kelley760169f2012-03-09 14:27:49 +0000192build-arch:
193build-indep:
Simon Kelleyc72daea2012-01-05 21:33:27 +0000194
195checkroot:
196 test root = "`whoami`"
197
198.PHONY: binary binary-arch binary-indep clean checkroot
199
200