rules 10 KB

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