* Fix building to properly support binNMUs. Thanks to Daniel Schepler
[ntk/apt.git] / debian / rules
CommitLineData
2d18d44e
AL
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.
915f3b1c 5# $Id: rules,v 1.68 2004/05/30 18:21:43 mdz Exp $
0f6b2443 6
1b955876
AL
7# LD_LIBRARY_PATH=pwd/debian/apt/usr/lib dh_shlibdeps -papt
8# dpkg: /home/jgg/work/apt2/debian/apt/usr/lib/libapt-pkg.so.2.9 not found.
0f6b2443
AL
9
10# For the deb builder, you can run 'debian/rules cvs-build', which does all
11# steps nescessary to produce a proper source tarball with the CVS/ removed.
12# It builds in debian/cvs-build/apt-<VER>/, and places files in
13# debian/cvs-build/. Optionally, you can run 'debian/rules cvs-mkul' to
14# create ../upload-<VER>, with all the files needed to be uploaded placed
15# in it.
2d18d44e 16
045ba613
AL
17export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
18export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
19
20# FOR AUTOCONF 2.52 AND NEWER ONLY
21ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
22 confflags += --build $(DEB_HOST_GNU_TYPE)
23else
24 confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
25endif
26
b2e465d6 27# See below
0b3e8849 28-include build/environment.mak
b2e465d6 29
bab7c2cb 30ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
bad95184 31 export CXXFLAGS = -O0 -g -Wall
bab7c2cb 32else
bad95184 33 export CXXFLAGS = -O2 -g -Wall
bab7c2cb
AL
34endif
35
b2e465d6
AL
36# Default rule
37build:
38
4d745d64 39PKG=apt
a789b983 40DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS)
da78c57f 41APT_DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p' | sed -e 's/\+.*$$//')
3a42cc3c 42APT_CONFVER=$(shell sed -n -e 's/^AC_DEFINE_UNQUOTED(VERSION,"\(.*\)")/\1/p' configure.in)
c6baaffe 43APT_CVSTAG=$(shell echo "$(APT_DEBVER)" | sed -e 's/^/v/' -e 's/\./_/g')
3a42cc3c 44
cf6371d0
AL
45# Determine the build directory to use
46BASE=.
47ifdef BUILD
48BUILD_POSSIBLE := $(BUILD) $(BASE)/$(BUILD)
49else
50BUILD_POSSIBLE := $(BASE) $(BASE)/build-$(shell uname -m) $(BASE)/build
51endif
52BUILDX:= $(foreach i,$(BUILD_POSSIBLE),$(wildcard $(i)/environment.mak*))
53BUILDX:= $(patsubst %/,%,$(firstword $(dir $(BUILDX))))
54override BLD := $(BUILDX)
55
b024fa25
AL
56ifeq ($(words $(BLD)),0)
57override BLD := ./build
58endif
59
b2e465d6 60# Rebuild configure.in to have the correct version from the change log
3a42cc3c 61ifneq ($(APT_DEBVER),$(APT_CONFVER))
3d851670 62ifneq ($(APT_DEBVER),)
3a42cc3c
AL
63.PHONY: configure.in
64configure.in:
eef77d37 65 sed -e 's/$(APT_CONFVER)/$(APT_DEBVER)/' $@ > $@.$$$$ && mv $@.$$$$ $@
9daf15d6 66endif
3a42cc3c
AL
67else
68configure.in:
69endif
2d18d44e 70
b2e465d6 71# APT Programs in apt-utils
fcc0e9d6 72APT_UTILS=ftparchive sortpkgs extracttemplates
b2e465d6 73
2d18d44e
AL
74# Uncomment this to turn on verbose mode.
75#export DH_VERBOSE=1
76
d153f53f 77# Find the libapt-pkg major version for use in other control files
b2e465d6
AL
78export LIBAPTPKG_MAJOR:=$(shell egrep '^MAJOR=' apt-pkg/makefile |cut -d '=' -f 2)
79export LIBAPTINST_MAJOR:=$(shell egrep '^MAJOR=' apt-inst/makefile |cut -d '=' -f 2)
a5b7cd82
AL
80
81# Determine which package we should provide in the control files
82LIBAPTPKG_PROVIDE=libapt-pkg$(GLIBC_VER)$(LIBSTDCPP_VER)-$(LIBAPTPKG_MAJOR)
83LIBAPTINST_PROVIDE=libapt-inst$(GLIBC_VER)$(LIBSTDCPP_VER)-$(LIBAPTINST_MAJOR)
84
3fb71b27 85debian/shlibs.local: apt-pkg/makefile
a5b7cd82 86 # We have 3 shlibs.local files.. One for 'apt', one for 'apt-utils' and
b2e465d6
AL
87 # one for the rest of the packages. This ensures that each package gets
88 # the right overrides..
89 rm -rf $@ $@.apt $@.apt-utils
a5b7cd82 90 echo "libapt-pkg$(GLIBC_VER)$(LIBSTDCPP_VER) $(LIBAPTPKG_MAJOR)" > $@.apt
b2e465d6 91
a5b7cd82
AL
92 echo "libapt-pkg$(GLIBC_VER)$(LIBSTDCPP_VER) $(LIBAPTPKG_MAJOR) $(LIBAPTPKG_PROVIDE)" > $@.apt-utils
93 echo "libapt-inst$(GLIBC_VER)$(LIBSTDCPP_VER) $(LIBAPTINST_MAJOR)" >> $@.apt-utils
d153f53f 94
a5b7cd82
AL
95 echo "libapt-pkg$(GLIBC_VER)$(LIBSTDCPP_VER) $(LIBAPTPKG_MAJOR) $(LIBAPTPKG_PROVIDE)" > $@
96 echo "libapt-inst$(GLIBC_VER)$(LIBSTDCPP_VER) $(LIBAPTINST_MAJOR) $(LIBAPTINST_PROVIDE)" >> $@
201eaabd 97
b2e465d6 98build: build/build-stamp
16c76dd2 99build-doc: build/build-doc-stamp
b2e465d6
AL
100
101# Note that this is unconditionally done first as part of loading environment.mak
102# The true is needed to force make to reload environment.mak after running
103# configure-stamp. Otherwise we can get stale or invalid, or missing config data.
104build/environment.mak: build/configure-stamp
105 @true
201eaabd 106
b2e465d6
AL
107configure: configure.in
108build/configure-stamp: configure
2d18d44e 109 dh_testdir
2ee6f3cb 110 -mkdir build
9b2e67eb 111 cp COPYING debian/copyright
b3d44315 112 cd build && CXXFLAGS="$(confcxxflags)" ../configure $(confflags)
b2e465d6 113 touch $@
0b5c85b5 114
b2e465d6 115build/build-stamp: build/configure-stamp
2d18d44e 116 # Add here commands to compile the package.
16c76dd2
AL
117 $(MAKE) binary
118 touch $@
119
120build/build-doc-stamp: build/configure-stamp
121 # Add here commands to compile the package.
122 $(MAKE) doc
cf58a7e1 123 touch $@
2d18d44e
AL
124
125clean:
126 dh_testdir
127# dh_testroot
e184b9df
AL
128 -$(MAKE) clean
129 -$(MAKE) distclean
130
2d18d44e 131 rm -rf build
201eaabd 132
2d18d44e 133 # Add here commands to clean up after the build process.
e184b9df 134 dh_clean debian/copyright debian/shlibs.local debian/shlibs.local.apt debian/shlibs.local.apt-utils
2d18d44e 135
16c76dd2 136binary-indep: apt-doc libapt-pkg-doc
2d18d44e 137# Build architecture-independent files here.
16c76dd2 138libapt-pkg-doc: build-doc debian/shlibs.local
c64bcd92
AL
139 dh_testdir -p$@
140 dh_testroot -p$@
141 dh_clean -p$@ -k
142 dh_installdirs -p$@
3a42cc3c
AL
143#
144# libapt-pkg-doc install
0b5c85b5
AL
145#
146 dh_installdocs -p$@ $(BLD)/docs/cache* $(BLD)/docs/design* $(BLD)/docs/dpkg-tech* \
b2e465d6
AL
147 $(BLD)/docs/files* $(BLD)/docs/method* \
148 doc/libapt-pkg2_to_3.txt doc/style.txt
c64bcd92
AL
149 dh_installexamples -p$@
150# dh_installmenu -p$@
151# dh_installinit -p$@
152# dh_installcron -p$@
3c0e4977 153# dh_installman -p$@
c64bcd92
AL
154
155# dh_undocumented -p$@
156 dh_installchangelogs -p$@
157 dh_strip -p$@
158 dh_compress -p$@
159 dh_fixperms -p$@
160# dh_suidregister -p$@
161 dh_installdeb -p$@
a5b7cd82 162 dh_gencontrol -p$@ -u -Vlibapt-pkg:provides=$(LIBAPTPKG_PROVIDE)
c64bcd92
AL
163 dh_md5sums -p$@
164 dh_builddeb -p$@
2d18d44e 165
16c76dd2
AL
166apt-doc: build-doc
167 dh_testdir -p$@
168 dh_testroot -p$@
169 dh_clean -p$@ -k
170#
171# apt-doc install
172#
173 # Copy the guides
174 dh_installdocs -p$@ $(BLD)/docs/guide*.text $(BLD)/docs/guide*.html \
429465b2 175 $(BLD)/docs/offline*.text $(BLD)/docs/offline*.html
16c76dd2
AL
176 dh_installchangelogs -p$@
177 dh_compress -p$@
178 dh_fixperms -p$@
179 dh_installdeb -p$@
180 dh_gencontrol -p$@
181 dh_md5sums -p$@
182 dh_builddeb -p$@
183
184
2d18d44e 185
3a42cc3c 186# Build architecture-dependent files here.
3a42cc3c 187
d546f98d 188binary-arch: apt-transport-https apt libapt-pkg-dev apt-utils
c64bcd92
AL
189apt: build debian/shlibs.local
190 dh_testdir -p$@
191 dh_testroot -p$@
192 dh_clean -p$@ -k
b3d44315 193 dh_installdirs -p$@ /usr/share/bug/$@ /usr/share/$@
3a42cc3c
AL
194#
195# apt install
196#
b3d44315 197 cp $(BLD)/bin/apt-* debian/$@/usr/bin/
201eaabd 198
b2e465d6 199 # Remove the bits that are in apt-utils
b3d44315 200 rm $(addprefix debian/$@/usr/bin/apt-,$(APT_UTILS))
201eaabd 201
2553a569 202 # install the shared libs
b3d44315
MV
203 find $(BLD)/bin/ -type f -name "libapt-pkg*.so.*" -exec cp -a "{}" debian/$@/usr/lib/ \;
204 find $(BLD)/bin/ -type l -name "libapt-pkg*.so.*" -exec cp -a "{}" debian/$@/usr/lib/ \;
205
206 cp $(BLD)/bin/methods/* debian/$@/usr/lib/apt/methods/
2553a569 207
b3d44315
MV
208 cp $(BLD)/scripts/dselect/* debian/$@/usr/lib/dpkg/methods/apt/
209 cp -r $(BLD)/locale debian/$@/usr/share/
2d18d44e 210
b3d44315 211 cp debian/bugscript debian/$@/usr/share/bug/apt/script
2d18d44e 212
339690e4 213 cp share/debian-archive.gpg debian/$@/usr/share/$@
9d2938d4 214 cp debian/apt.conf.autoremove debian/$@/etc/apt/apt.conf.d/01autoremove
2d18d44e
AL
215# head -n 500 ChangeLog > debian/ChangeLog
216
be2d3759
MV
217 # make rosetta happy and remove pot files in po/ (but leave stuff
218 # in po/domains/* untouched) and cp *.po into each domain dir
219 rm -f build/po/*.pot
220 rm -f po/*.pot
221
3fb71b27 222 dh_installexamples -p$@ $(BLD)/docs/examples/*
3c0e4977 223 dh_installman -p$@
0c132682 224 dh_installcron -p$@
9e980be8 225 dh_installdocs -p$@
c64bcd92
AL
226 dh_installchangelogs -p$@
227 dh_strip -p$@
228 dh_compress -p$@
229 dh_fixperms -p$@
5e3c3a3c 230 dh_makeshlibs -p$@ -m$(LIBAPTPKG_MAJOR) -V '$(LIBAPTPKG_PROVIDE)'
c64bcd92 231 dh_installdeb -p$@
b3d44315 232 dh_shlibdeps -p$@ -l`pwd`/debian/apt/usr/lib:`pwd`/debian/$@/usr/lib -- -Ldebian/shlibs.local.apt
a5b7cd82 233 dh_gencontrol -p$@ -u -Vlibapt-pkg:provides=$(LIBAPTPKG_PROVIDE)
c64bcd92
AL
234 dh_md5sums -p$@
235 dh_builddeb -p$@
236
237libapt-pkg-dev: build debian/shlibs.local
238 dh_testdir -p$@
239 dh_testroot -p$@
240 dh_clean -p$@ -k
241 dh_installdirs -p$@
242#
243# libapt-pkg-dev install
244#
a5b7cd82
AL
245 cp -a $(BLD)/bin/libapt-pkg*.so debian/libapt-pkg-dev/usr/lib/
246 cp -a $(BLD)/bin/libapt-inst*.so debian/libapt-pkg-dev/usr/lib/
201eaabd 247# ln -s libapt-pkg.so.$(LIBAPTPKG_MAJOR) debian/libapt-pkg-dev/usr/lib/libapt-pkg.so
cf6371d0 248 cp $(BLD)/include/apt-pkg/*.h debian/libapt-pkg-dev/usr/include/apt-pkg/
c64bcd92
AL
249
250 dh_installdocs -p$@
3fb71b27
AL
251# dh_installmenu -p$@
252# dh_installinit -p$@
253# dh_installcron -p$@
3c0e4977 254# dh_installman -p$@
c64bcd92
AL
255
256 dh_installchangelogs -p$@
257 dh_strip -p$@
258 dh_compress -p$@
259 dh_fixperms -p$@
260# dh_suidregister -p$@
261 dh_installdeb -p$@
4334f918 262 dh_gencontrol -p$@ -u -Vlibapt-pkg:provides=$(LIBAPTPKG_PROVIDE) -Vlibapt-inst:provides=$(LIBAPTINST_PROVIDE)
b2e465d6
AL
263 dh_md5sums -p$@
264 dh_builddeb -p$@
265
266apt-utils: build debian/shlibs.local
267 dh_testdir -p$@
268 dh_testroot -p$@
269 dh_clean -p$@ -k
270 dh_installdirs -p$@
271
272 # install the shared libs
a5b7cd82
AL
273 find $(BLD)/bin/ -type f -name "libapt-inst*.so.*" -exec cp -a "{}" debian/$@/usr/lib/ \;
274 find $(BLD)/bin/ -type l -name "libapt-inst*.so.*" -exec cp -a "{}" debian/$@/usr/lib/ \;
b2e465d6
AL
275
276 cp $(addprefix $(BLD)/bin/apt-,$(APT_UTILS)) debian/$@/usr/bin/
277 dh_installdocs -p$@
53cd7e2b 278 dh_installexamples -p$@
201eaabd 279
b2e465d6 280 # Install the man pages..
3c0e4977 281 dh_installman -p$@
90ebe30c 282
b2e465d6
AL
283 dh_installchangelogs -p$@
284 dh_strip -p$@
285 dh_compress -p$@
286 dh_fixperms -p$@
47337f80 287 dh_makeshlibs -m$(LIBAPTINST_MAJOR) -V '$(LIBAPTINST_PROVIDE)' -p$@
b2e465d6 288 dh_installdeb -p$@
5e3c3a3c 289 dh_shlibdeps -p$@ -l`pwd`/debian/apt/usr/lib:`pwd`/debian/$@/usr/lib -- -Ldebian/shlibs.local.apt-utils
5d622d51 290 dh_gencontrol -p$@ -u -Vlibapt-inst:provides=$(LIBAPTINST_PROVIDE)
c64bcd92
AL
291 dh_md5sums -p$@
292 dh_builddeb -p$@
2d18d44e 293
d546f98d
MV
294apt-transport-https: build debian/shlibs.local
295 dh_testdir -p$@
296 dh_testroot -p$@
297 dh_clean -p$@ -k
298 dh_installdirs -p$@
299
300 # install the method
301 mkdir -p debian/$@/usr/lib/apt/methods
302 mv $(BLD)/bin/methods/https debian/$@/usr/lib/apt/methods
303
304 dh_installdocs -p$@
305 dh_installexamples -p$@
306
307 # Install the man pages..
308 dh_installman -p$@
309
310 dh_installchangelogs -p$@
311 dh_strip -p$@
312 dh_compress -p$@
313 dh_fixperms -p$@
314 dh_installdeb -p$@
315 dh_shlibdeps -p$@ -l`pwd`/debian/apt/usr/lib:`pwd`/debian/$@/usr/lib
316 dh_gencontrol -p$@
317 dh_md5sums -p$@
318 dh_builddeb -p$@
319
b2e465d6 320source diff:
2d18d44e
AL
321 @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
322
323# Update from CVS
324l33ch: really-clean
325 cvs update
7bf6fd0c 326 buildlib/mkChangeLog
2d18d44e
AL
327
328# Update from CVS and then configure for build
329super-l33ch: l33ch Makefile.in
330
331configure:
1d9fd7a2 332 $(MAKE) configure
2d18d44e
AL
333
334l33ch-stamp: super-l33ch
cf58a7e1 335 touch $@
2d18d44e
AL
336
337really-clean: clean
338 -find -name Makefile.in -print0 | xargs -0r rm -f
339 find -name ChangeLog | xargs rm -f
340 rm -f l33ch-stamp
341
342binary: binary-indep binary-arch
c64bcd92 343.PHONY: build clean binary-indep binary-arch binary debian/shlibs.local
3a42cc3c
AL
344
345
346# Done by the uploader.
347#cvs update..
348#edit debian/changelog
349# configure.in has the version automatically updated now.
350# edit configure.in
351# debian/rules cvs-build
352
c6baaffe
AL
353CVS_BUILDDIR=apt-$(APT_DEBVER)
354CVS_ROOT=$(shell cat CVS/Root)
355CVS_MODULE=$(shell cat CVS/Repository)
3a42cc3c
AL
356cvs-build:
357 rm -rf debian/cvs-build
c6baaffe
AL
358 mkdir -p debian/cvs-build
359 (cd debian/cvs-build;cvs -d $(CVS_ROOT) export -r$(APT_CVSTAG) -d apt-$(APT_DEBVER) $(CVS_MODULE))
360 $(MAKE) -C debian/cvs-build/$(CVS_BUILDDIR) startup doc
361 (cd debian/cvs-build/$(CVS_BUILDDIR);$(DEB_BUILD_PROG))
0f6b2443
AL
362
363cvs-mkul:
364 -mkdir -p ../upload-$(APT_DEBVER)
365 cp `find debian/cvs-build -maxdepth 1 -type f` ../upload-$(APT_DEBVER)
09c12281
MZ
366
367arch-build:
368 rm -rf debian/arch-build
369 mkdir -p debian/arch-build/apt-$(APT_DEBVER)
eda1bb3c 370 tar -c --exclude=arch-build --no-recursion -f - `bzr inventory` | (cd debian/arch-build/$(PKG)-$(APT_DEBVER);tar xf -)
09c12281 371 $(MAKE) -C debian/arch-build/apt-$(APT_DEBVER) startup doc
602afa46 372 (cd debian/arch-build/apt-$(APT_DEBVER); $(DEB_BUILD_PROG); dpkg-genchanges -S > ../apt_$(APT_DEBVER)_source.changes)