debian/rules: add hardening=+all
[ntk/apt.git] / debian / rules
1 #!/usr/bin/make -f
2 # Made with the aid of dh_make, by Craig Small
3 # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
4 # Some lines taken from debmake, by Christoph Lameter.
5
6 # build in verbose mode by default to make it easy to diangose issues
7 export NOISY=1
8
9 export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
10 export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
11 export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
12
13 # FOR AUTOCONF 2.52 AND NEWER ONLY
14 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
15 confflags += --build $(DEB_HOST_GNU_TYPE)
16 else
17 confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
18 endif
19
20 # See below
21 -include build/environment.mak
22
23 ifneq (,$(shell which dpkg-buildflags))
24 # make does not export to $(shell) so we need to workaround
25 # (http://savannah.gnu.org/bugs/?10593)
26 dpkg_buildflags = DEB_BUILD_MAINT_OPTIONS=hardening=+all dpkg-buildflags
27 export CXXFLAGS = $(shell $(dpkg_buildflags) --get CXXFLAGS)
28 export LDFLAGS = $(shell $(dpkg_buildflags) --get LDFLAGS)
29 export CPPFLAGS = $(shell $(dpkg_buildflags) --get CPPFLAGS)
30 else
31 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
32 export CXXFLAGS = -O0 -g -Wall
33 else
34 export CXXFLAGS = -O2 -g -Wall
35 endif
36 endif
37
38 # Default rule
39 build:
40
41 PKG=apt
42 DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS)
43
44 # Determine the build directory to use
45 BASE=.
46 ifdef BUILD
47 BUILD_POSSIBLE := $(BUILD) $(BASE)/$(BUILD)
48 else
49 BUILD_POSSIBLE := $(BASE) $(BASE)/build-$(shell uname --machine) $(BASE)/build
50 endif
51 BUILDX:= $(foreach i,$(BUILD_POSSIBLE),$(wildcard $(i)/environment.mak*))
52 BUILDX:= $(patsubst %/,%,$(firstword $(dir $(BUILDX))))
53 override BLD := $(BUILDX)
54
55 ifeq ($(words $(BLD)),0)
56 override BLD := ./build
57 endif
58
59 # APT Programs in apt-utils
60 APT_UTILS=ftparchive sortpkgs extracttemplates
61
62 # Uncomment this to turn on verbose mode.
63 #export DH_VERBOSE=1
64
65 # Find the libapt-pkg major version for use in other control files
66 include buildlib/libversion.mak
67
68 # Determine which library package names to use
69 LIBAPT_PKG=libapt-pkg$(LIBAPTPKG_MAJOR)
70 LIBAPT_INST=libapt-inst$(LIBAPTINST_MAJOR)
71
72 # do not fail as we are just experimenting with symbol files for now
73 export DPKG_GENSYMBOLS_CHECK_LEVEL=0
74
75 build-binary: build/build-binary-stamp
76 build-docbook: build/build-docbook-stamp
77 build-manpages: build/build-manpages-stamp
78
79 # Note that this is unconditionally done first as part of loading environment.mak
80 # The true is needed to force make to reload environment.mak after running
81 # configure-stamp. Otherwise we can get stale or invalid, or missing config data.
82 build/environment.mak: build/configure-stamp
83 @true
84
85 configure: configure.ac
86 build/configure-stamp: configure buildlib/config.sub buildlib/config.guess
87 dh_testdir
88 -mkdir build
89 cp COPYING debian/copyright
90 cd build && CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" CPPFLAGS="$(CPPFLAGS)" ../configure $(confflags)
91 touch $@
92
93 build/build-binary-stamp: build/configure-stamp
94 # Add here commands to compile the package.
95 $(MAKE) binary
96 # compat symlink for the locale split
97 mkdir -p build/usr/share
98 cd build/usr/share && ln -f -s ../../locale .
99 # compile and run tests
100 ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
101 $(MAKE) test
102 else
103 @echo "Tests DISABLED"
104 endif
105 touch $@
106
107 build/build-docbook-stamp: build/configure-stamp
108 # Add here commands to compile the package.
109 $(MAKE) docbook
110 touch $@
111
112 build/build-manpages-stamp: build/configure-stamp
113 # Add here commands to compile the package.
114 $(MAKE) manpages
115 touch $@
116
117 clean:
118 dh_testdir
119 dh_clean
120
121 [ ! -f Makefile ] || $(MAKE) clean distclean
122 rm -rf build
123 rm -f debian/$(LIBAPT_PKG).install debian/$(LIBAPT_INST).install \
124 debian/libapt-pkg-dev.install debian/apt.install
125 test ! -L buildlib/config.guess || rm -f buildlib/config.guess
126 test ! -L buildlib/config.sub || rm -f buildlib/config.sub
127
128 debian/%.install: debian/%.install.in
129 sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' $< > $@
130
131 # Build architecture-independent files here.
132 libapt-pkg-doc: build-docbook
133 dh_testdir -p$@
134 dh_testroot -p$@
135 dh_prep -p$@
136 dh_installdirs -p$@
137 #
138 # libapt-pkg-doc install
139 #
140 rm -f $(BLD)/doc/doxygen/html/*.map $(BLD)/doc/doxygen/html/*.md5
141 dh_installdocs -p$@ $(BLD)/docs/design* \
142 $(BLD)/docs/dpkg-tech* \
143 $(BLD)/docs/files* \
144 $(BLD)/docs/method* \
145 doc/libapt-pkg2_to_3.txt \
146 doc/style.txt \
147 $(BLD)/doc/doxygen/html
148 dh_installexamples -p$@
149
150 dh_installchangelogs -p$@
151 dh_strip -p$@
152 dh_compress -p$@ -X.xhtml
153 dh_fixperms -p$@
154 dh_installdeb -p$@
155 dh_gencontrol -p$@
156 dh_md5sums -p$@
157 dh_builddeb -p$@
158
159 apt-doc: build-docbook
160 dh_testdir -p$@
161 dh_testroot -p$@
162 dh_prep -p$@
163 #
164 # apt-doc install
165 #
166 # Copy the guides
167 dh_installdocs -p$@ $(BLD)/docs/guide*.text \
168 $(BLD)/docs/guide*.html \
169 $(BLD)/docs/offline*.text \
170 $(BLD)/docs/offline*.html
171 dh_installchangelogs -p$@
172 dh_compress -p$@
173 dh_fixperms -p$@
174 dh_installdeb -p$@
175 dh_gencontrol -p$@
176 dh_md5sums -p$@
177 dh_builddeb -p$@
178
179
180
181 # Build architecture-dependent files here.
182
183 apt_MANPAGES = apt apt-cache apt-cdrom apt-config apt-get apt-key apt-mark apt-secure apt apt.conf apt_preferences sources.list
184 apt: build-binary build-manpages debian/apt.install
185 dh_testdir -p$@
186 dh_testroot -p$@
187 dh_prep -p$@
188 dh_installdirs -p$@
189 #
190 # apt install
191 #
192 cp debian/apt.conf.autoremove debian/$@/etc/apt/apt.conf.d/01autoremove
193 cp debian/apt.auto-removal.sh debian/$@/etc/kernel/postinst.d/apt-auto-removal
194 chmod 755 debian/$@/etc/kernel/postinst.d/apt-auto-removal
195 # install vendor specific apt confs
196 find -L vendor/current -name 'apt.conf-*' | while read conf; do cp "$${conf}" "debian/$@/etc/apt/apt.conf.d/$${conf#*-}"; done
197
198 # make rosetta happy and remove pot files in po/ (but leave stuff
199 # in po/domains/* untouched) and cp *.po into each domain dir
200 rm -f build/po/*.pot
201 rm -f po/*.pot
202
203 dh_install -p$@ --sourcedir=$(BLD)
204
205 # Remove the bits that are in apt-utils
206 rm $(addprefix debian/$@/usr/bin/apt-,$(APT_UTILS) dump-solver internal-solver)
207
208 # https has its own package
209 rm debian/$@/usr/lib/apt/methods/https
210
211 # move the mirror failure script in place
212 #mv debian/$@/usr/bin/apt-report-mirror-failure \
213 # debian/$@/usr/lib/apt/apt-report-mirror-failure \
214
215 # move the apt-helper in place
216 mv debian/$@/usr/bin/apt-helper debian/$@/usr/lib/apt/apt-helper
217
218 dh_bugfiles -p$@
219 dh_lintian -p$@
220 dh_installexamples -p$@ $(BLD)/docs/examples/*
221 dh_installman -p$@ $(wildcard $(patsubst %,doc/en/%.[158],$(apt_MANPAGES)) $(patsubst %,doc/*/%.*.[158],$(apt_MANPAGES)))
222 dh_installcron -p$@
223 dh_installdocs -p$@
224 dh_installchangelogs -p$@
225 dh_installlogrotate -p$@
226 dh_strip -p$@
227 dh_compress -p$@
228 dh_fixperms -p$@
229 dh_makeshlibs -p$@
230 dh_installdeb -p$@
231 dh_shlibdeps -p$@
232 dh_gencontrol -p$@ -- -Vapt:keyring="$(shell ./vendor/getinfo keyring-package)"
233 dh_md5sums -p$@
234 dh_builddeb -p$@
235
236 libapt-pkg-dev: build-binary debian/libapt-pkg-dev.install
237 dh_testdir -p$@
238 dh_testroot -p$@
239 dh_prep -p$@
240 dh_installdirs -p$@
241 #
242 # libapt-pkg-dev install
243 #
244 dh_install -p$@ --sourcedir=$(BLD)
245 dh_installdocs -p$@
246 dh_installchangelogs -p$@
247 dh_strip -p$@
248 dh_compress -p$@
249 dh_fixperms -p$@
250 dh_installdeb -p$@
251 dh_gencontrol -p$@ -- -Vlibapt-pkg-name=$(LIBAPT_PKG) -Vlibapt-inst-name=$(LIBAPT_INST)
252 dh_md5sums -p$@
253 dh_builddeb -p$@
254
255 apt-utils_MANPAGES = apt-sortpkgs apt-ftparchive apt-extracttemplates
256 apt-utils: build-binary build-manpages
257 dh_testdir -p$@
258 dh_testroot -p$@
259 dh_prep -p$@
260 dh_installdirs -p$@
261
262 cp $(addprefix $(BLD)/bin/apt-,$(APT_UTILS)) debian/$@/usr/bin/
263 cp $(BLD)/bin/apt-dump-solver debian/$@/usr/lib/apt/solvers/dump
264 cp $(BLD)/bin/apt-internal-solver debian/$@/usr/lib/apt/solvers/apt
265
266 dh_install -p$@ --sourcedir=$(BLD)
267 dh_link -p$@
268 dh_installdocs -p$@
269 dh_installexamples -p$@
270
271 # Install the man pages..
272 dh_installman -p$@ $(wildcard $(patsubst %,doc/en/%.[158],$(apt-utils_MANPAGES)) $(patsubst %,doc/*/%.*.[158],$(apt-utils_MANPAGES)))
273
274 dh_installchangelogs -p$@
275 dh_strip -p$@
276 dh_compress -p$@
277 dh_fixperms -p$@
278 dh_makeshlibs -p$@
279 dh_installdeb -p$@
280 dh_shlibdeps -p$@
281 dh_gencontrol -p$@
282 dh_md5sums -p$@
283 dh_builddeb -p$@
284
285 $(LIBAPT_PKG): build-binary debian/$(LIBAPT_PKG).install
286 dh_testdir -p$@
287 dh_testroot -p$@
288 dh_prep -p$@
289 dh_installdirs -p$@
290
291 dh_install -p$@ --sourcedir=$(BLD)
292 dh_installdocs -p$@
293 dh_installchangelogs -p$@
294 dh_strip -p$@
295 dh_compress -p$@
296 dh_fixperms -p$@
297 dh_makeshlibs -p$@
298 dh_installdeb -p$@
299 dh_shlibdeps -p$@
300 dh_gencontrol -p$@
301 dh_md5sums -p$@
302 dh_builddeb -p$@
303
304 $(LIBAPT_INST): build-binary debian/$(LIBAPT_INST).install
305 dh_testdir -p$@
306 dh_testroot -p$@
307 dh_prep -p$@
308 dh_installdirs -p$@
309
310 dh_install -p$@ --sourcedir=$(BLD)
311 dh_installdocs -p$@
312 dh_installchangelogs -p$@
313 dh_strip -p$@
314 dh_compress -p$@
315 dh_fixperms -p$@
316 dh_makeshlibs -p$@
317 dh_installdeb -p$@
318 dh_shlibdeps -p$@
319 dh_gencontrol -p$@
320 dh_md5sums -p$@
321 dh_builddeb -p$@
322
323 apt-transport-https: build-binary libapt-pkg-dev
324 dh_testdir -p$@
325 dh_testroot -p$@
326 dh_prep -p$@
327 dh_installdirs -p$@
328
329 dh_install -p$@ --sourcedir=$(BLD)
330 dh_installdocs -p$@ debian/apt-transport-https.README
331 dh_installexamples -p$@
332
333 # Install the man pages..
334 dh_installman -p$@
335
336 dh_installchangelogs -p$@
337 dh_strip -p$@
338 dh_compress -p$@
339 dh_fixperms -p$@
340 dh_installdeb -p$@
341 dh_shlibdeps -p$@
342 dh_gencontrol -p$@
343 dh_md5sums -p$@
344 dh_builddeb -p$@
345
346 buildlib/config.guess buildlib/config.sub:
347 $(MAKE) "$@"
348
349 configure:
350 $(MAKE) configure
351
352 # translate targets to targets required by debian-policy
353 binary-arch: $(LIBAPT_PKG) $(LIBAPT_INST) apt libapt-pkg-dev apt-utils apt-transport-https
354 binary-indep: apt-doc libapt-pkg-doc
355 binary: binary-indep binary-arch
356 build-arch: build-binary
357 build-indep: build-manpages build-docbook
358 build: build-indep build-arch
359
360 .PHONY: build clean binary-indep binary-arch binary