rules 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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/enoent $(TMP_DPKG)/usr/lib/dpkg/
  78. mv $(TMP)/usr/lib/dpkg/methods $(TMP_DPKG)/usr/lib/dpkg/
  79. mv $(TMP)/usr/share/locale $(TMP_DPKG)/usr/share/
  80. set -e ; for i in dpkg dpkg-deb dpkg-split md5sum dselect ; do \
  81. mv $(TMP)/usr/bin/$$i $(TMP_DPKG)/usr/bin/ ; \
  82. done
  83. set -e ; for i in ChangeLog THANKS TODO copyright ; do \
  84. mv $(TMP)/usr/share/doc/dpkg/$$i $(TMP_DPKG)/usr/share/doc/dpkg/ ; \
  85. done
  86. set -e ; for i in "" fr ja sv ; do \
  87. install -d -m 755 -o root -g root $(TMP_DPKG)/usr/share/man/$$i/man1 ; \
  88. for m in md5sum.1 dpkg-deb.1 ; do \
  89. if [ -f $(TMP)/usr/share/man/$$i/man1/$$m ] ; then \
  90. mv $(TMP)/usr/share/man/$$i/man1/$$m $(TMP_DPKG)/usr/share/man/$$i/man1/$$m ; \
  91. fi ; \
  92. done ; \
  93. install -d -m 755 -o root -g root $(TMP_DPKG)/usr/share/man/$$i/man8 ; \
  94. for m in dpkg.8 dselect.8 dpkg-split.8 start-stop-daemon.8 \
  95. cleanup-info.8 dpkg-divert.8 dpkg-statoverride.8 \
  96. install-info.8 update-alternatives.8 update-rc.d.8 ; do \
  97. if [ -f $(TMP)/usr/share/man/$$i/man8/$$m ] ; then \
  98. mv $(TMP)/usr/share/man/$$i/man8/$$m $(TMP_DPKG)/usr/share/man/$$i/man8/$$m ; \
  99. fi ; \
  100. done ; \
  101. done
  102. install -d -m 755 -o root -g root $(TMP_DPKG)/etc/dpkg
  103. install -p -m 644 -o root -g root debian/dpkg.cfg \
  104. $(TMP_DPKG)/etc/dpkg/
  105. install -p -m 644 -o root -g root debian/dselect.cfg \
  106. $(TMP_DPKG)/etc/dpkg/
  107. # Now that dpkg has been installed, Debianize it
  108. # Policy stuff
  109. find $(TMP_DPKG)/usr/share/man -type f | xargs gzip -9f
  110. strip $(TMP_DPKG)/usr/bin/* $(TMP_DPKG)/sbin/*
  111. mv $(TMP_DPKG)/usr/share/doc/dpkg/ChangeLog \
  112. $(TMP_DPKG)/usr/share/doc/dpkg/changelog
  113. install -p -m 644 -o root -g root debian/changelog \
  114. $(TMP_DPKG)/usr/share/doc/dpkg/changelog.Debian
  115. rm -f $(TMP_DPKG)/usr/share/doc/dpkg/copyright
  116. gzip -9 $(TMP_DPKG)/usr/share/doc/dpkg/*
  117. install -p -m 644 -o root -g root debian/copyright \
  118. $(TMP_DPKG)/usr/share/doc/dpkg/
  119. # Final package creation
  120. install -d -m 755 -o root -g root $(TMP_DPKG)/DEBIAN
  121. install -p -m 644 -o root -g root debian/dpkg.conffiles $(TMP_DPKG)/DEBIAN/conffiles
  122. install -p -m 755 -o root -g root debian/dpkg.preinst $(TMP_DPKG)/DEBIAN/preinst
  123. install -p -m 755 -o root -g root debian/dpkg.prerm $(TMP_DPKG)/DEBIAN/prerm
  124. install -p -m 755 -o root -g root debian/dpkg.postinst $(TMP_DPKG)/DEBIAN/postinst
  125. dpkg-shlibdeps -dPre-Depends -Tdebian/dpkg.substvars \
  126. $(TMP_DPKG)/usr/bin/dpkg $(TMP_DPKG)/usr/bin/dselect \
  127. $(TMP_DPKG)/sbin/start-stop-daemon
  128. perl -I `pwd`/scripts scripts/dpkg-gencontrol.pl -isp \
  129. -Tdebian/dpkg.substvars -pdpkg -P$(TMP_DPKG)
  130. dpkg --build $(TMP_DPKG) ..
  131. binary-dpkg-dev: stamp-binary
  132. rm -rf $(TMP_DPKG_DEV)
  133. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)
  134. chmod g-s $(TMP_DPKG_DEV)
  135. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/etc/dpkg
  136. install -p -m 644 -o root -g root debian/shlibs.default \
  137. $(TMP_DPKG_DEV)/etc/dpkg/
  138. install -p -m 644 -o root -g root debian/shlibs.override \
  139. $(TMP_DPKG_DEV)/etc/dpkg/
  140. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/lib/dpkg
  141. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share
  142. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/bin
  143. mv $(TMP)/usr/lib/dpkg/parsechangelog $(TMP_DPKG_DEV)/usr/lib/dpkg/
  144. mv $(TMP)/usr/lib/dpkg/controllib.pl $(TMP_DPKG_DEV)/usr/lib/dpkg/
  145. set -e ; for i in dpkg-name dpkg-source dpkg-genchanges dpkg-gencontrol \
  146. dpkg-shlibdeps dpkg-buildpackage dpkg-distaddfile 822-date \
  147. dpkg-scanpackages dpkg-scansources dpkg-architecture \
  148. dpkg-parsechangelog dpkg-checkbuilddeps ; do \
  149. mv $(TMP)/usr/bin/$$i $(TMP_DPKG_DEV)/usr/bin/ ; \
  150. done
  151. set -e ; for i in "" fr ja sv ; do \
  152. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/man/$$i/man1 ; \
  153. for m in dpkg-name.1 dpkg-source.1 822-date.1 dpkg-architecture.1 \
  154. dpkg-buildpackage.1 dpkg-distaddfile.1 dpkg-genchanges.1 \
  155. dpkg-gencontrol.1 dpkg-parsechangelog.1 dpkg-shlibdeps.1 \
  156. dpkg-checkbuilddeps.1 ; do \
  157. if [ -e $(TMP)/usr/share/man/$$i/man1/$$m ] ; then \
  158. mv $(TMP)/usr/share/man/$$i/man1/$$m $(TMP_DPKG_DEV)/usr/share/man/$$i/man1/$$m ; \
  159. fi ; \
  160. done ; \
  161. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/man/$$i/man5 ; \
  162. for m in deb.5 deb-control.5 deb-old.5 ; do \
  163. if [ -e $(TMP)/usr/share/man/$$i/man5/$$m ] ; then \
  164. mv $(TMP)/usr/share/man/$$i/man5/$$m $(TMP_DPKG_DEV)/usr/share/man/$$i/man5/$$m ; \
  165. fi ; \
  166. done ; \
  167. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/man/$$i/man8 ; \
  168. for m in dpkg-scanpackages.8 dpkg-scansources.8 ; do \
  169. if [ -e $(TMP)/usr/share/man/$$i/man8/$$m ] ; then \
  170. mv $(TMP)/usr/share/man/$$i/man8/$$m $(TMP_DPKG_DEV)/usr/share/man/$$i/man8/$$m ; \
  171. fi ; \
  172. done ; \
  173. done
  174. # Now that dpkg-dev has been installed, Debianize it
  175. # Policy stuff
  176. find $(TMP_DPKG_DEV)/usr/share/man -type f | xargs gzip -9f
  177. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/doc
  178. ln -s dpkg $(TMP_DPKG_DEV)/usr/share/doc/dpkg-dev
  179. # Final package creation
  180. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/DEBIAN
  181. install -p -m 644 -o root -g root debian/dpkg-dev.conffiles $(TMP_DPKG_DEV)/DEBIAN/conffiles
  182. install -p -m 755 -o root -g root debian/dpkg-dev.prerm $(TMP_DPKG_DEV)/DEBIAN/prerm
  183. install -p -m 755 -o root -g root debian/dpkg-dev.postinst $(TMP_DPKG_DEV)/DEBIAN/postinst
  184. perl -I `pwd`/scripts scripts/dpkg-gencontrol.pl -isp \
  185. -Tdebian/dpkg-dev.substvars -pdpkg-dev -P$(TMP_DPKG_DEV)
  186. dpkg --build $(TMP_DPKG_DEV) ..
  187. binary-dpkg-doc: stamp-binary
  188. rm -rf $(TMP_DPKG_DOC)
  189. install -d -m 755 -o root -g root $(TMP_DPKG_DOC)
  190. chmod g-s $(TMP_DPKG_DOC)
  191. install -d -m 755 -o root -g root $(TMP_DPKG_DOC)/usr/share/doc/dpkg
  192. mv $(TMP)/usr/share/doc/dpkg/internals $(TMP_DPKG_DOC)/usr/share/doc/dpkg/
  193. mv $(TMP)/usr/share/doc/dpkg/ChangeLog.manuals \
  194. $(TMP_DPKG_DOC)/usr/share/doc/dpkg/changelog.manuals
  195. # Now that dpkg-dev has been installed, Debianize it
  196. # Policy stuff
  197. gzip -9f $(TMP_DPKG_DOC)/usr/share/doc/dpkg/[!i]*
  198. ln -s dpkg $(TMP_DPKG_DOC)/usr/share/doc/dpkg-doc
  199. # Register documentation with doc-base
  200. install -d -m 755 -o root -g root $(TMP_DPKG_DOC)/usr/share/doc-base
  201. install -p -m 644 -o root -g root debian/dpkg-doc.doc-base \
  202. $(TMP_DPKG_DOC)/usr/share/doc-base/dpkg-doc
  203. # Final package creation
  204. install -d -m 755 -o root -g root $(TMP_DPKG_DOC)/DEBIAN
  205. install -p -m 755 -o root -g root debian/dpkg-doc.prerm $(TMP_DPKG_DOC)/DEBIAN/prerm
  206. install -p -m 755 -o root -g root debian/dpkg-doc.postinst $(TMP_DPKG_DOC)/DEBIAN/postinst
  207. perl -I `pwd`/scripts scripts/dpkg-gencontrol.pl -isp \
  208. -Tdebian/dpkg-dev.substvars -pdpkg-doc -P$(TMP_DPKG_DOC)
  209. dpkg --build $(TMP_DPKG_DOC) ..
  210. binary-arch: binary-dpkg
  211. set -e ; \
  212. v=`sed -n 's/^Version: //p' $(TMP_DPKG)/DEBIAN/control`; \
  213. f=dpkg-$${v}_$(arch).nondebbin.tar ; \
  214. tar -C $(TMP_DPKG) -cf $(DIR)/../$$f usr var ; \
  215. gzip -9f ../$$f ; \
  216. dpkg-distaddfile -fdebian/files $$f.gz byhand -
  217. binary-indep: binary-dpkg-dev binary-dpkg-doc
  218. set -e ; set -x ; \
  219. v=`sed -n 's/^Version: //p' $(TMP_DPKG_DEV)/DEBIAN/control`; \
  220. f=dpkg-$${v}.tar.gz ; \
  221. if [ -f ../dpkg_$${v}.tar.gz ] ; then \
  222. cp ../dpkg_$${v}.tar.gz ../$$f ; \
  223. dpkg-distaddfile -fdebian/files $$f byhand - ; \
  224. fi
  225. define checkdir
  226. test -f include/dpkg.h.in
  227. endef
  228. .PHONY: clean build binary binary-arch binary-indep binary-dpkg binary-dpkg-dev
  229. .PHONY: binary-dpkg-doc binary-nondebbin