rules 13 KB

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