rules 12 KB

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