rules 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. #!/usr/bin/make -f
  2. # vim: nowrap ts=8
  3. # Build locations
  4. BUILD := $(CURDIR)/build
  5. TMP := $(CURDIR)/debian/tmp
  6. INSTALL_TMP := $(TMP)/install
  7. TMP_DPKG := $(TMP)/dpkg
  8. TMP_DPKG_DEV := $(TMP)/dpkg-dev
  9. TMP_DPKG_DOC := $(TMP)/dpkg-doc
  10. TMP_DSELECT := $(TMP)/dselect
  11. # We should really get this in a different way...
  12. DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE 2> /dev/null || true)
  13. DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE 2> /dev/null || true)
  14. arch := $(shell dpkg-architecture -qDEB_HOST_ARCH)
  15. GENCONTROL := perl -I $(CURDIR)/scripts $(BUILD)/scripts/dpkg-gencontrol -isp
  16. SHLIBDEPS := perl -I $(CURDIR)/scripts $(BUILD)/scripts/dpkg-shlibdeps
  17. ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
  18. config_arg := --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
  19. else
  20. config_arg :=
  21. endif
  22. BUILD-DIRS := $(BUILD) $(BUILD)-static
  23. aclocal.m4: $(wildcard automake/*.m4)
  24. aclocal -I automake
  25. # The following 2 rules should only be run, if their dependants have
  26. # been modified. For clean builds, this won't happen. Only if the
  27. # builder has modified these files after extraction.
  28. configure: configure.in aclocal.m4
  29. autoconf
  30. config.h.in: configure.in
  31. autoheader
  32. config.guess config.sub: %: /usr/share/misc/%
  33. cp -a $< $@.new
  34. mv $@.new $@
  35. # Setup the buildlocation
  36. $(BUILD)/configure-stamp: configure config.h.in config.guess config.sub
  37. $(checkdir)
  38. install -d $(@D)
  39. cd $(@D) && LDFLAGS=$(LDFLAGS) $(shell echo "$(patsubst $(CURDIR)/%,%,$(@D))" | sed -e 's,^[^/][^/]*$$,..,;s,/[^/][^/]*,/..,g' )/configure \
  40. --prefix=/usr \
  41. --datadir=/usr/share \
  42. --mandir=/usr/share/man \
  43. --infodir=/usr/share/info \
  44. --sysconfdir=/etc \
  45. --sharedstatedir=/var/lib \
  46. --localstatedir=/var/lib \
  47. --with-admindir=/var/lib/dpkg \
  48. --with-zlib=static \
  49. --with-static-progs \
  50. $(config_arg)
  51. touch $@
  52. clean:
  53. $(checkdir)
  54. rm -f debian/files debian/substvars
  55. rm -f debian/dpkg.substvars debian/dpkg-static.substvars
  56. rm -fr autom4te.cache
  57. rm -fr $(BUILD-DIRS) $(TMP)
  58. rm -f po/{cat-id-tbl.c,stamp-cat-id,*.gmo}
  59. rm -f stamp-build stamp-binary
  60. build: stamp-build
  61. stamp-build: $(BUILD)/configure-stamp
  62. $(MAKE) $(MFLAGS) -C $(BUILD)
  63. # touch $@
  64. binary-static: binary-arch-static
  65. binary: binary-arch binary-indep
  66. stamp-binary-static: stamp-binary
  67. stamp-binary: stamp-build
  68. $(checkdir)
  69. test "`id -u`" -eq 0
  70. rm -rf $(TMP)
  71. $(MAKE) $(MFLAGS) -C $(BUILD)$* \
  72. DESTDIR=$(INSTALL_TMP) \
  73. install
  74. find $(TMP) -type d | xargs chmod 755
  75. touch $@
  76. binary-dpkg-static-most: TMP_DPKG=$(TMP)/dpkg-static
  77. binary-dpkg-static-most: static=-static
  78. binary-dpkg-static: TMP_DPKG=$(TMP)/dpkg-static
  79. binary-dpkg-static: static=-static
  80. binary-dpkg-most binary-dpkg-static-most: binary-dpkg%-most: stamp-binary%
  81. rm -rf $(TMP_DPKG)
  82. install -d -m 755 -o root -g root $(TMP_DPKG)
  83. chmod g-s $(TMP_DPKG)
  84. install -d -m 755 -o root -g root $(TMP_DPKG)/usr/share/doc/dpkg$(static)
  85. install -d -m 755 -o root -g root $(TMP_DPKG)/usr/lib/dpkg
  86. install -d -m 755 -o root -g root $(TMP_DPKG)/usr/bin
  87. install -d -m 755 -o root -g root $(TMP_DPKG)/sbin
  88. install -d -m 755 -o root -g root $(TMP_DPKG)/var/lib/dpkg
  89. -test -d $(INSTALL_TMP)/etc && cp -a $(INSTALL_TMP)/etc $(TMP_DPKG)/
  90. set -e ; for i in info alternatives parts updates ; do \
  91. cp -a $(INSTALL_TMP)/var/lib/dpkg/$$i $(TMP_DPKG)/var/lib/dpkg/ ; \
  92. done
  93. cp -a $(INSTALL_TMP)/usr/sbin $(TMP_DPKG)/usr/
  94. mv $(TMP_DPKG)/usr/sbin/start-stop-daemon $(TMP_DPKG)/sbin/
  95. cp -a $(INSTALL_TMP)/usr/lib/dpkg/mksplit $(TMP_DPKG)/usr/lib/dpkg/
  96. cp -a $(INSTALL_TMP)/usr/lib/dpkg/enoent $(TMP_DPKG)/usr/lib/dpkg/
  97. cp -a $(INSTALL_TMP)/usr/share/locale $(TMP_DPKG)/usr/share/
  98. cp -a $(INSTALL_TMP)/usr/share/dpkg $(TMP_DPKG)/usr/share/
  99. set -e ; for i in dpkg-split dpkg-query ; do \
  100. cp -a $(INSTALL_TMP)/usr/bin/$$i $(TMP_DPKG)/usr/bin/ ; \
  101. done
  102. set -e ; for i in dpkg dpkg-deb md5sum ; do \
  103. cp -a $(INSTALL_TMP)/usr/bin/$$i$(static) $(TMP_DPKG)/usr/bin/$$i ; \
  104. done
  105. set -e ; for i in ChangeLog THANKS TODO copyright; do \
  106. cp -a $(INSTALL_TMP)/usr/share/doc/dpkg/$$i $(TMP_DPKG)/usr/share/doc/dpkg$(static)/ ; \
  107. done
  108. cp -a debian/pseudo-tags $(TMP_DPKG)/usr/share/doc/dpkg$(static)/
  109. set -e ; for i in "" de fr ja sv ; do \
  110. install -d -m 755 -o root -g root $(TMP_DPKG)/usr/share/man/$$i/man1 ; \
  111. for m in md5sum.1 dpkg-deb.1 ; do \
  112. if [ -f $(INSTALL_TMP)/usr/share/man/$$i/man1/$$m ] ; then \
  113. cp -a $(INSTALL_TMP)/usr/share/man/$$i/man1/$$m $(TMP_DPKG)/usr/share/man/$$i/man1/$$m ; \
  114. fi ; \
  115. done ; \
  116. install -d -m 755 -o root -g root $(TMP_DPKG)/usr/share/man/$$i/man5 ; \
  117. for m in dpkg.cfg.5 ; do \
  118. if [ -f $(INSTALL_TMP)/usr/share/man/$$i/man5/$$m ] ; then \
  119. cp -a $(INSTALL_TMP)/usr/share/man/$$i/man5/$$m $(TMP_DPKG)/usr/share/man/$$i/man5/$$m ; \
  120. fi ; \
  121. done ; \
  122. install -d -m 755 -o root -g root $(TMP_DPKG)/usr/share/man/$$i/man8 ; \
  123. for m in dpkg.8 dpkg-query.8 dpkg-split.8 start-stop-daemon.8 \
  124. cleanup-info.8 dpkg-divert.8 dpkg-statoverride.8 \
  125. install-info.8 update-alternatives.8 ; do \
  126. if [ -f $(INSTALL_TMP)/usr/share/man/$$i/man8/$$m ] ; then \
  127. cp -a $(INSTALL_TMP)/usr/share/man/$$i/man8/$$m $(TMP_DPKG)/usr/share/man/$$i/man8/$$m ; \
  128. fi ; \
  129. done ; \
  130. done
  131. # Now that dpkg has been installed, Debianize it
  132. # Policy stuff
  133. find $(TMP_DPKG)/usr/share/man -type f | xargs gzip -9f
  134. strip --remove-section=.comment --remove-section=.note \
  135. --strip-unneeded $(TMP_DPKG)/usr/bin/* $(TMP_DPKG)/sbin/* \
  136. $(TMP_DPKG)/usr/lib/dpkg/enoent
  137. mv $(TMP_DPKG)/usr/share/doc/dpkg$(static)/ChangeLog \
  138. $(TMP_DPKG)/usr/share/doc/dpkg$(static)/changelog
  139. install -p -m 644 -o root -g root debian/changelog \
  140. $(TMP_DPKG)/usr/share/doc/dpkg$(static)/changelog.Debian
  141. rm -f $(TMP_DPKG)/usr/share/doc/dpkg$(static)/copyright
  142. gzip -9 $(TMP_DPKG)/usr/share/doc/dpkg$(static)/*
  143. install -p -m 644 -o root -g root debian/dpkg.cfg \
  144. $(TMP_DPKG)/usr/share/doc/dpkg$(static)/
  145. install -p -m 644 -o root -g root debian/copyright \
  146. $(TMP_DPKG)/usr/share/doc/dpkg$(static)/
  147. # Final package creation
  148. install -d -m 755 -o root -g root $(TMP_DPKG)/DEBIAN
  149. install -p -m 644 -o root -g root debian/dpkg.conffiles $(TMP_DPKG)/DEBIAN/conffiles
  150. install -p -m 755 -o root -g root debian/dpkg.preinst $(TMP_DPKG)/DEBIAN/preinst
  151. install -p -m 755 -o root -g root debian/dpkg.prerm $(TMP_DPKG)/DEBIAN/prerm
  152. install -p -m 755 -o root -g root debian/dpkg.postinst $(TMP_DPKG)/DEBIAN/postinst
  153. install -p -m 755 -o root -g root debian/dpkg.postrm $(TMP_DPKG)/DEBIAN/postrm
  154. $(SHLIBDEPS) -dPre-Depends -Tdebian/dpkg$(static).substvars \
  155. $(TMP_DPKG)/sbin/start-stop-daemon \
  156. `test -z "$(static)" && echo $(TMP_DPKG)/usr/bin/dpkg $(TMP_DPKG)/usr/bin/md5sum $(TMP_DPKG)/usr/bin/dpkg-deb`
  157. binary-dpkg binary-dpkg-static: %: %-most
  158. $(GENCONTROL) -Tdebian/dpkg$(static).substvars -pdpkg$(static) -P$(TMP_DPKG)
  159. dpkg --build $(TMP_DPKG) ..
  160. binary-dpkg-dev: stamp-binary
  161. rm -rf $(TMP_DPKG_DEV)
  162. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)
  163. chmod g-s $(TMP_DPKG_DEV)
  164. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/etc/dpkg
  165. install -p -m 644 -o root -g root debian/shlibs.default \
  166. $(TMP_DPKG_DEV)/etc/dpkg/
  167. install -p -m 644 -o root -g root debian/shlibs.override \
  168. $(TMP_DPKG_DEV)/etc/dpkg/
  169. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/lib/dpkg
  170. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share
  171. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/bin
  172. mv $(INSTALL_TMP)/usr/lib/dpkg/parsechangelog $(TMP_DPKG_DEV)/usr/lib/dpkg/
  173. mv $(INSTALL_TMP)/usr/lib/dpkg/controllib.pl $(TMP_DPKG_DEV)/usr/lib/dpkg/
  174. set -e ; for i in dpkg-name dpkg-source dpkg-genchanges dpkg-gencontrol \
  175. dpkg-shlibdeps dpkg-buildpackage dpkg-distaddfile 822-date \
  176. dpkg-scanpackages dpkg-scansources dpkg-architecture \
  177. dpkg-parsechangelog dpkg-checkbuilddeps ; do \
  178. mv $(INSTALL_TMP)/usr/bin/$$i $(TMP_DPKG_DEV)/usr/bin/ ; \
  179. done
  180. set -e ; for i in "" de fr ja sv ; do \
  181. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/man/$$i/man1 ; \
  182. for m in dpkg-name.1 dpkg-source.1 822-date.1 dpkg-architecture.1 \
  183. dpkg-buildpackage.1 dpkg-distaddfile.1 dpkg-genchanges.1 \
  184. dpkg-gencontrol.1 dpkg-parsechangelog.1 dpkg-shlibdeps.1 \
  185. dpkg-checkbuilddeps.1 ; do \
  186. if [ -e $(INSTALL_TMP)/usr/share/man/$$i/man1/$$m ] ; then \
  187. mv $(INSTALL_TMP)/usr/share/man/$$i/man1/$$m $(TMP_DPKG_DEV)/usr/share/man/$$i/man1/$$m ; \
  188. fi ; \
  189. done ; \
  190. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/man/$$i/man5 ; \
  191. for m in deb.5 deb-control.5 deb-old.5 ; do \
  192. if [ -e $(INSTALL_TMP)/usr/share/man/$$i/man5/$$m ] ; then \
  193. mv $(INSTALL_TMP)/usr/share/man/$$i/man5/$$m $(TMP_DPKG_DEV)/usr/share/man/$$i/man5/$$m ; \
  194. fi ; \
  195. done ; \
  196. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/man/$$i/man8 ; \
  197. for m in dpkg-scanpackages.8 dpkg-scansources.8 ; do \
  198. if [ -e $(INSTALL_TMP)/usr/share/man/$$i/man8/$$m ] ; then \
  199. mv $(INSTALL_TMP)/usr/share/man/$$i/man8/$$m $(TMP_DPKG_DEV)/usr/share/man/$$i/man8/$$m ; \
  200. fi ; \
  201. done ; \
  202. done
  203. # Now that dpkg-dev has been installed, Debianize it
  204. # Policy stuff
  205. find $(TMP_DPKG_DEV)/usr/share/man -type f | xargs gzip -9f
  206. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/doc
  207. ln -s dpkg $(TMP_DPKG_DEV)/usr/share/doc/dpkg-dev
  208. # Final package creation
  209. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/DEBIAN
  210. install -p -m 644 -o root -g root debian/dpkg-dev.conffiles $(TMP_DPKG_DEV)/DEBIAN/conffiles
  211. $(GENCONTROL) -Tdebian/dpkg-dev.substvars -pdpkg-dev -P$(TMP_DPKG_DEV)
  212. dpkg --build $(TMP_DPKG_DEV) ..
  213. binary-dselect: stamp-binary
  214. rm -rf $(TMP_DSELECT)
  215. install -d -m 755 -o root -g root $(TMP_DSELECT)
  216. chmod g-s $(TMP_DSELECT)
  217. install -d -m 755 -o root -g root $(TMP_DSELECT)/usr/bin
  218. mv $(INSTALL_TMP)/usr/bin/dselect $(TMP_DSELECT)/usr/bin/
  219. install -d -m 755 -o root -g root $(TMP_DSELECT)/usr/lib/dpkg
  220. mv $(INSTALL_TMP)/usr/lib/dpkg/methods $(TMP_DSELECT)/usr/lib/dpkg/
  221. install -d -m 755 -o root -g root $(TMP_DSELECT)/var/lib/dpkg
  222. mv $(INSTALL_TMP)/var/lib/dpkg/methods $(TMP_DSELECT)/var/lib/dpkg/
  223. set -e ; for i in "" de fr ja sv ; do \
  224. install -d -m 755 -o root -g root $(TMP_DSELECT)/usr/share/man/$$i/man5 ; \
  225. for m in dselect.cfg.5 ; do \
  226. if [ -f $(INSTALL_TMP)/usr/share/man/$$i/man5/$$m ] ; then \
  227. cp -a $(INSTALL_TMP)/usr/share/man/$$i/man5/$$m $(TMP_DSELECT)/usr/share/man/$$i/man5/$$m ; \
  228. fi ; \
  229. done ; \
  230. install -d -m 755 -o root -g root $(TMP_DSELECT)/usr/share/man/$$i/man8 ; \
  231. for m in dselect.8 ; do \
  232. if [ -f $(INSTALL_TMP)/usr/share/man/$$i/man8/$$m ] ; then \
  233. cp -a $(INSTALL_TMP)/usr/share/man/$$i/man8/$$m $(TMP_DSELECT)/usr/share/man/$$i/man8/$$m ; \
  234. fi ; \
  235. done ; \
  236. done
  237. install -d -m 755 -o root -g root $(TMP_DSELECT)/etc/dpkg
  238. install -p -m 644 -o root -g root debian/dselect.cfg \
  239. $(TMP_DSELECT)/etc/dpkg/
  240. # Now do the usual Debian stuff
  241. find $(TMP_DSELECT)/usr/share/man -type f | xargs gzip -9f
  242. install -d -m 755 -o root -g root $(TMP_DSELECT)/usr/share/doc
  243. ln -s dpkg $(TMP_DSELECT)/usr/share/doc/dselect
  244. strip --remove-section=.comment --remove-section=.note \
  245. --strip-unneeded $(TMP_DSELECT)/usr/bin/*
  246. # Final package creation
  247. install -d -m 755 -o root -g root $(TMP_DSELECT)/DEBIAN
  248. install -p -m 644 -o root -g root debian/dselect.conffiles $(TMP_DSELECT)/DEBIAN/conffiles
  249. $(SHLIBDEPS) -Tdebian/dselect.substvars \
  250. $(TMP_DSELECT)/usr/bin/dselect
  251. $(GENCONTROL) -Tdebian/dselect.substvars -pdselect -P$(TMP_DSELECT)
  252. dpkg --build $(TMP_DSELECT) ..
  253. binary-dpkg-doc: stamp-binary
  254. rm -rf $(TMP_DPKG_DOC)
  255. install -d -m 755 -o root -g root $(TMP_DPKG_DOC)
  256. chmod g-s $(TMP_DPKG_DOC)
  257. install -d -m 755 -o root -g root $(TMP_DPKG_DOC)/usr/share/doc/dpkg
  258. mv $(INSTALL_TMP)/usr/share/doc/dpkg/internals $(TMP_DPKG_DOC)/usr/share/doc/dpkg/
  259. mv $(INSTALL_TMP)/usr/share/doc/dpkg/ChangeLog.manuals \
  260. $(TMP_DPKG_DOC)/usr/share/doc/dpkg/changelog.manuals
  261. # Now that dpkg-doc has been installed, Debianize it
  262. # Policy stuff
  263. gzip -9f $(TMP_DPKG_DOC)/usr/share/doc/dpkg/[!i]*
  264. ln -s dpkg $(TMP_DPKG_DOC)/usr/share/doc/dpkg-doc
  265. # Register documentation with doc-base
  266. install -d -m 755 -o root -g root $(TMP_DPKG_DOC)/usr/share/doc-base
  267. install -p -m 644 -o root -g root debian/dpkg-doc.doc-base \
  268. $(TMP_DPKG_DOC)/usr/share/doc-base/dpkg-doc
  269. # Final package creation
  270. install -d -m 755 -o root -g root $(TMP_DPKG_DOC)/DEBIAN
  271. install -p -m 755 -o root -g root debian/dpkg-doc.prerm $(TMP_DPKG_DOC)/DEBIAN/prerm
  272. install -p -m 755 -o root -g root debian/dpkg-doc.postinst $(TMP_DPKG_DOC)/DEBIAN/postinst
  273. $(GENCONTROL) -Tdebian/dpkg-doc.substvars -pdpkg-doc -P$(TMP_DPKG_DOC)
  274. dpkg --build $(TMP_DPKG_DOC) ..
  275. binary-arch-static: binary-dpkg-static
  276. binary-arch: binary-dpkg binary-dpkg-static-most binary-dselect
  277. binary-indep: binary-dpkg-dev binary-dpkg-doc
  278. define checkdir
  279. test -f include/dpkg.h.in
  280. endef
  281. .PHONY: clean build binary binary-arch binary-indep binary-dpkg binary-dpkg-dev
  282. .PHONY: binary-dpkg-doc binary-nondebbin