rules 9.7 KB

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