rules 13 KB

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