* pre-build.sh:
[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.
2d18d44e 5
045ba613
AL
6export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
7export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
8
9# FOR AUTOCONF 2.52 AND NEWER ONLY
10ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
11 confflags += --build $(DEB_HOST_GNU_TYPE)
12else
13 confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
14endif
15
b2e465d6 16# See below
0b3e8849 17-include build/environment.mak
b2e465d6 18
39151234
DK
19ifneq (,$(shell which dpkg-buildflags))
20 export CXXFLAGS = $(shell dpkg-buildflags --get CXXFLAGS)
bab7c2cb 21else
39151234
DK
22 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
23 export CXXFLAGS = -O0 -g -Wall
24 else
25 export CXXFLAGS = -O2 -g -Wall
26 endif
bab7c2cb
AL
27endif
28
b2e465d6
AL
29# Default rule
30build:
31
4d745d64 32PKG=apt
a789b983 33DEB_BUILD_PROG:=debuild --preserve-envvar PATH --preserve-envvar CCACHE_DIR -us -uc $(DEB_BUILD_PROG_OPTS)
da78c57f 34APT_DEBVER=$(shell dpkg-parsechangelog |sed -n -e '/^Version:/s/^Version: //p' | sed -e 's/\+.*$$//')
3a42cc3c 35APT_CONFVER=$(shell sed -n -e 's/^AC_DEFINE_UNQUOTED(VERSION,"\(.*\)")/\1/p' configure.in)
c6baaffe 36APT_CVSTAG=$(shell echo "$(APT_DEBVER)" | sed -e 's/^/v/' -e 's/\./_/g')
3a42cc3c 37
cf6371d0
AL
38# Determine the build directory to use
39BASE=.
40ifdef BUILD
41BUILD_POSSIBLE := $(BUILD) $(BASE)/$(BUILD)
42else
70371bc8 43BUILD_POSSIBLE := $(BASE) $(BASE)/build-$(shell uname --machine) $(BASE)/build
cf6371d0
AL
44endif
45BUILDX:= $(foreach i,$(BUILD_POSSIBLE),$(wildcard $(i)/environment.mak*))
46BUILDX:= $(patsubst %/,%,$(firstword $(dir $(BUILDX))))
47override BLD := $(BUILDX)
48
b024fa25
AL
49ifeq ($(words $(BLD)),0)
50override BLD := ./build
51endif
52
b2e465d6 53# Rebuild configure.in to have the correct version from the change log
3a42cc3c 54ifneq ($(APT_DEBVER),$(APT_CONFVER))
3d851670 55ifneq ($(APT_DEBVER),)
3a42cc3c
AL
56.PHONY: configure.in
57configure.in:
eef77d37 58 sed -e 's/$(APT_CONFVER)/$(APT_DEBVER)/' $@ > $@.$$$$ && mv $@.$$$$ $@
9daf15d6 59endif
3a42cc3c
AL
60else
61configure.in:
62endif
2d18d44e 63
b2e465d6 64# APT Programs in apt-utils
fcc0e9d6 65APT_UTILS=ftparchive sortpkgs extracttemplates
b2e465d6 66
2d18d44e
AL
67# Uncomment this to turn on verbose mode.
68#export DH_VERBOSE=1
69
d153f53f 70# Find the libapt-pkg major version for use in other control files
23d84658 71include buildlib/libversion.mak
a5b7cd82
AL
72
73# Determine which package we should provide in the control files
9d378975
JAK
74LIBAPTPKG_PROVIDE=libapt-pkg$(LIBAPTPKG_MAJOR)
75LIBAPTINST_PROVIDE=libapt-inst$(LIBAPTINST_MAJOR)
a5b7cd82 76
3fb71b27 77debian/shlibs.local: apt-pkg/makefile
70371bc8 78 # We have 3 shlibs.local files: One for 'apt', one for 'apt-utils' and
b2e465d6 79 # one for the rest of the packages. This ensures that each package gets
70371bc8 80 # the right overrides…
b2e465d6 81 rm -rf $@ $@.apt $@.apt-utils
44c8b5df 82 echo "libapt-pkg $(LIBAPTPKG_MAJOR)" > $@.apt
b2e465d6 83
44c8b5df
DK
84 echo "libapt-pkg $(LIBAPTPKG_MAJOR) $(LIBAPTPKG_PROVIDE)" > $@.apt-utils
85 echo "libapt-inst $(LIBAPTINST_MAJOR)" >> $@.apt-utils
d153f53f 86
44c8b5df
DK
87 echo "libapt-pkg $(LIBAPTPKG_MAJOR) $(LIBAPTPKG_PROVIDE)" > $@
88 echo "libapt-inst $(LIBAPTINST_MAJOR) $(LIBAPTINST_PROVIDE)" >> $@
201eaabd 89
70371bc8
DK
90build: build/build-stamp
91build-doc: build/build-doc-stamp
b2e465d6
AL
92
93# Note that this is unconditionally done first as part of loading environment.mak
94# The true is needed to force make to reload environment.mak after running
95# configure-stamp. Otherwise we can get stale or invalid, or missing config data.
96build/environment.mak: build/configure-stamp
97 @true
201eaabd 98
b2e465d6
AL
99configure: configure.in
100build/configure-stamp: configure
2d18d44e 101 dh_testdir
2ee6f3cb 102 -mkdir build
9b2e67eb 103 cp COPYING debian/copyright
fdd739c7 104 cd build && CXXFLAGS="$(CXXFLAGS)" ../configure $(confflags)
b2e465d6 105 touch $@
0b5c85b5 106
b2e465d6 107build/build-stamp: build/configure-stamp
2d18d44e 108 # Add here commands to compile the package.
16c76dd2
AL
109 $(MAKE) binary
110 touch $@
111
112build/build-doc-stamp: build/configure-stamp
113 # Add here commands to compile the package.
114 $(MAKE) doc
cf58a7e1 115 touch $@
2d18d44e
AL
116
117clean:
118 dh_testdir
e184b9df 119
70371bc8 120 [ ! -f Makefile ] || $(MAKE) clean distclean
2d18d44e 121 rm -rf build
201eaabd 122
2d18d44e 123 # Add here commands to clean up after the build process.
e184b9df 124 dh_clean debian/copyright debian/shlibs.local debian/shlibs.local.apt debian/shlibs.local.apt-utils
2d18d44e 125
16c76dd2 126binary-indep: apt-doc libapt-pkg-doc
2d18d44e 127# Build architecture-independent files here.
16c76dd2 128libapt-pkg-doc: build-doc debian/shlibs.local
c64bcd92
AL
129 dh_testdir -p$@
130 dh_testroot -p$@
af7a92c3 131 dh_prep -p$@
c64bcd92 132 dh_installdirs -p$@
3a42cc3c
AL
133#
134# libapt-pkg-doc install
70371bc8
DK
135#
136 dh_installdocs -p$@ $(BLD)/docs/design* \
137 $(BLD)/docs/dpkg-tech* \
138 $(BLD)/docs/files* \
139 $(BLD)/docs/method* \
140 doc/libapt-pkg2_to_3.txt \
d1aa9162 141 doc/style.txt \
dc1e2a06 142 $(BLD)/doc/doxygen/html
c64bcd92 143 dh_installexamples -p$@
c64bcd92 144
c64bcd92
AL
145 dh_installchangelogs -p$@
146 dh_strip -p$@
147 dh_compress -p$@
148 dh_fixperms -p$@
c64bcd92 149 dh_installdeb -p$@
d0648096 150 dh_gencontrol -p$@ -- -Vlibapt-pkg:provides=$(LIBAPTPKG_PROVIDE)
c64bcd92
AL
151 dh_md5sums -p$@
152 dh_builddeb -p$@
2d18d44e 153
16c76dd2
AL
154apt-doc: build-doc
155 dh_testdir -p$@
156 dh_testroot -p$@
af7a92c3 157 dh_prep -p$@
16c76dd2
AL
158#
159# apt-doc install
160#
161 # Copy the guides
70371bc8
DK
162 dh_installdocs -p$@ $(BLD)/docs/guide*.text \
163 $(BLD)/docs/guide*.html \
164 $(BLD)/docs/offline*.text \
165 $(BLD)/docs/offline*.html
16c76dd2
AL
166 dh_installchangelogs -p$@
167 dh_compress -p$@
168 dh_fixperms -p$@
169 dh_installdeb -p$@
170 dh_gencontrol -p$@
171 dh_md5sums -p$@
172 dh_builddeb -p$@
173
174
2d18d44e 175
3a42cc3c 176# Build architecture-dependent files here.
3a42cc3c 177
e753b480 178binary-arch: apt libapt-pkg-dev apt-utils apt-transport-https
2a52e8c5 179apt_MANPAGES = apt-cache apt-cdrom apt-config apt-get apt-key apt-mark apt-secure apt apt.conf apt_preferences sources.list
425684e0 180apt: build build-doc debian/shlibs.local
c64bcd92
AL
181 dh_testdir -p$@
182 dh_testroot -p$@
af7a92c3 183 dh_prep -p$@
503a2291 184 dh_installdirs -p$@
3a42cc3c
AL
185#
186# apt install
187#
b3d44315 188 cp $(BLD)/bin/apt-* debian/$@/usr/bin/
201eaabd 189
b2e465d6 190 # Remove the bits that are in apt-utils
b3d44315 191 rm $(addprefix debian/$@/usr/bin/apt-,$(APT_UTILS))
201eaabd 192
2553a569 193 # install the shared libs
b3d44315
MV
194 find $(BLD)/bin/ -type f -name "libapt-pkg*.so.*" -exec cp -a "{}" debian/$@/usr/lib/ \;
195 find $(BLD)/bin/ -type l -name "libapt-pkg*.so.*" -exec cp -a "{}" debian/$@/usr/lib/ \;
196
197 cp $(BLD)/bin/methods/* debian/$@/usr/lib/apt/methods/
7ce6bd6a
MV
198 # https has its own package
199 rm debian/$@/usr/lib/apt/methods/https
2553a569 200
b3d44315
MV
201 cp $(BLD)/scripts/dselect/* debian/$@/usr/lib/dpkg/methods/apt/
202 cp -r $(BLD)/locale debian/$@/usr/share/
2d18d44e 203
b3d44315 204 cp debian/bugscript debian/$@/usr/share/bug/apt/script
b30aa0ec 205 cp debian/apt.logrotate debian/$@/etc/logrotate.d/apt
2d18d44e 206
9d2938d4 207 cp debian/apt.conf.autoremove debian/$@/etc/apt/apt.conf.d/01autoremove
2d18d44e 208
acbd8c84
EL
209 # copy lintian override
210 cp share/lintian-overrides debian/$@/usr/share/lintian/overrides/apt
211
be2d3759
MV
212 # make rosetta happy and remove pot files in po/ (but leave stuff
213 # in po/domains/* untouched) and cp *.po into each domain dir
214 rm -f build/po/*.pot
215 rm -f po/*.pot
216
3f599bb7 217 # move the mirror failure script in place
23c5897c
MV
218 #mv debian/$@/usr/bin/apt-report-mirror-failure \
219 # debian/$@/usr/lib/apt/apt-report-mirror-failure \
3f599bb7 220
3fb71b27 221 dh_installexamples -p$@ $(BLD)/docs/examples/*
2a52e8c5 222 dh_installman -p$@ $(wildcard $(patsubst %,doc/%.[158],$(apt_MANPAGES)) $(patsubst %,doc/*/%.*.[158],$(apt_MANPAGES)))
0c132682 223 dh_installcron -p$@
9e980be8 224 dh_installdocs -p$@
c64bcd92
AL
225 dh_installchangelogs -p$@
226 dh_strip -p$@
227 dh_compress -p$@
228 dh_fixperms -p$@
70371bc8 229 dh_makeshlibs -p$@ --major=$(LIBAPTPKG_MAJOR) --version-info='$(LIBAPTPKG_PROVIDE)'
c64bcd92 230 dh_installdeb -p$@
a59397c1 231 dh_shlibdeps -p$@ -l$(CURDIR)/debian/apt/usr/lib:$(CURDIR)/debian/$@/usr/lib -- -Ldebian/shlibs.local.apt
d0648096 232 dh_gencontrol -p$@ -- -Vlibapt-pkg:provides=$(LIBAPTPKG_PROVIDE)
c64bcd92
AL
233 dh_md5sums -p$@
234 dh_builddeb -p$@
235
236libapt-pkg-dev: build debian/shlibs.local
237 dh_testdir -p$@
238 dh_testroot -p$@
af7a92c3 239 dh_prep -p$@
c64bcd92
AL
240 dh_installdirs -p$@
241#
242# libapt-pkg-dev install
243#
a5b7cd82
AL
244 cp -a $(BLD)/bin/libapt-pkg*.so debian/libapt-pkg-dev/usr/lib/
245 cp -a $(BLD)/bin/libapt-inst*.so debian/libapt-pkg-dev/usr/lib/
201eaabd 246# ln -s libapt-pkg.so.$(LIBAPTPKG_MAJOR) debian/libapt-pkg-dev/usr/lib/libapt-pkg.so
cf6371d0 247 cp $(BLD)/include/apt-pkg/*.h debian/libapt-pkg-dev/usr/include/apt-pkg/
c64bcd92
AL
248
249 dh_installdocs -p$@
c64bcd92
AL
250
251 dh_installchangelogs -p$@
252 dh_strip -p$@
253 dh_compress -p$@
254 dh_fixperms -p$@
c64bcd92 255 dh_installdeb -p$@
d0648096 256 dh_gencontrol -p$@ -- -Vlibapt-pkg:provides=$(LIBAPTPKG_PROVIDE) -Vlibapt-inst:provides=$(LIBAPTINST_PROVIDE)
b2e465d6
AL
257 dh_md5sums -p$@
258 dh_builddeb -p$@
259
2a52e8c5 260apt-utils_MANPAGES = apt-sortpkgs apt-ftparchive apt-extracttemplates
b2e465d6
AL
261apt-utils: build debian/shlibs.local
262 dh_testdir -p$@
263 dh_testroot -p$@
af7a92c3 264 dh_prep -p$@
b2e465d6
AL
265 dh_installdirs -p$@
266
267 # install the shared libs
a5b7cd82
AL
268 find $(BLD)/bin/ -type f -name "libapt-inst*.so.*" -exec cp -a "{}" debian/$@/usr/lib/ \;
269 find $(BLD)/bin/ -type l -name "libapt-inst*.so.*" -exec cp -a "{}" debian/$@/usr/lib/ \;
b2e465d6
AL
270
271 cp $(addprefix $(BLD)/bin/apt-,$(APT_UTILS)) debian/$@/usr/bin/
272 dh_installdocs -p$@
53cd7e2b 273 dh_installexamples -p$@
201eaabd 274
b2e465d6 275 # Install the man pages..
2a52e8c5 276 dh_installman -p$@ $(wildcard $(patsubst %,doc/%.[158],$(apt-utils_MANPAGES)) $(patsubst %,doc/*/%.*.[158],$(apt-utils_MANPAGES)))
90ebe30c 277
b2e465d6
AL
278 dh_installchangelogs -p$@
279 dh_strip -p$@
280 dh_compress -p$@
281 dh_fixperms -p$@
70371bc8 282 dh_makeshlibs -p$@ --major=$(LIBAPTINST_MAJOR) --version-info='$(LIBAPTINST_PROVIDE)'
b2e465d6 283 dh_installdeb -p$@
a59397c1 284 dh_shlibdeps -p$@ -l$(CURDIR)/debian/apt/usr/lib:$(CURDIR)/debian/$@/usr/lib -- -Ldebian/shlibs.local.apt-utils
d0648096 285 dh_gencontrol -p$@ -- -Vlibapt-inst:provides=$(LIBAPTINST_PROVIDE)
c64bcd92
AL
286 dh_md5sums -p$@
287 dh_builddeb -p$@
2d18d44e 288
b5a6232d 289apt-transport-https: build debian/shlibs.local libapt-pkg-dev
d546f98d
MV
290 dh_testdir -p$@
291 dh_testroot -p$@
af7a92c3 292 dh_prep -p$@
d546f98d
MV
293 dh_installdirs -p$@
294
295 # install the method
70371bc8 296 mkdir --parents debian/$@/usr/lib/apt/methods
7ce6bd6a 297 cp $(BLD)/bin/methods/https debian/$@/usr/lib/apt/methods
d546f98d 298
370ad5e1 299 dh_installdocs -p$@ debian/apt-transport-https.README
d546f98d
MV
300 dh_installexamples -p$@
301
302 # Install the man pages..
303 dh_installman -p$@
304
305 dh_installchangelogs -p$@
306 dh_strip -p$@
307 dh_compress -p$@
308 dh_fixperms -p$@
309 dh_installdeb -p$@
a59397c1 310 dh_shlibdeps -p$@ -l$(CURDIR)/debian/apt/usr/lib:$(CURDIR)/debian/$@/usr/lib
d546f98d
MV
311 dh_gencontrol -p$@
312 dh_md5sums -p$@
313 dh_builddeb -p$@
314
2d18d44e 315configure:
1d9fd7a2 316 $(MAKE) configure
2d18d44e 317
2d18d44e 318really-clean: clean
70371bc8 319 -find . -name Makefile.in -print0 | xargs --null --no-run-if-empty -- rm -f
2d18d44e
AL
320 find -name ChangeLog | xargs rm -f
321 rm -f l33ch-stamp
322
323binary: binary-indep binary-arch
c64bcd92 324.PHONY: build clean binary-indep binary-arch binary debian/shlibs.local