rules 12 KB

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