rules 12 KB

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