rules 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. install -d -m 755 -o root -g root $(TMP_DPKG)/var/lib/dpkg
  83. -test -d $(INSTALL_TMP)/etc && cp -a $(INSTALL_TMP)/etc $(TMP_DPKG)/
  84. set -e ; for i in info alternatives parts updates ; do \
  85. mv $(INSTALL_TMP)/var/lib/dpkg/$$i $(TMP_DPKG)/var/lib/dpkg/ ; \
  86. done
  87. cp -a $(INSTALL_TMP)/usr/sbin/start-stop-daemon $(TMP_DPKG)/sbin/
  88. cp -a $(INSTALL_TMP)/usr/sbin $(TMP_DPKG)/usr/
  89. cp -a $(INSTALL_TMP)/usr/lib/dpkg/mksplit $(TMP_DPKG)/usr/lib/dpkg/
  90. cp -a $(INSTALL_TMP)/usr/lib/dpkg/enoent $(TMP_DPKG)/usr/lib/dpkg/
  91. cp -a $(INSTALL_TMP)/usr/share/locale $(TMP_DPKG)/usr/share/
  92. set -e ; for i in dpkg-split dpkg-query ; do \
  93. cp -a $(INSTALL_TMP)/usr/bin/$$i $(TMP_DPKG)/usr/bin/ ; \
  94. done
  95. set -e ; for i in dpkg dpkg-deb md5sum ; do \
  96. cp -a $(INSTALL_TMP)/usr/bin/$$i$(static) $(TMP_DPKG)/usr/bin/$$i ; \
  97. done
  98. set -e ; for i in ChangeLog THANKS TODO copyright ; do \
  99. cp -a $(INSTALL_TMP)/usr/share/doc/dpkg/$$i $(TMP_DPKG)/usr/share/doc/dpkg$(static)/ ; \
  100. done
  101. set -e ; for i in "" de fr ja sv ; do \
  102. install -d -m 755 -o root -g root $(TMP_DPKG)/usr/share/man/$$i/man1 ; \
  103. for m in md5sum.1 dpkg-deb.1 ; do \
  104. if [ -f $(INSTALL_TMP)/usr/share/man/$$i/man1/$$m ] ; then \
  105. cp -a $(INSTALL_TMP)/usr/share/man/$$i/man1/$$m $(TMP_DPKG)/usr/share/man/$$i/man1/$$m ; \
  106. fi ; \
  107. done ; \
  108. install -d -m 755 -o root -g root $(TMP_DPKG)/usr/share/man/$$i/man8 ; \
  109. for m in dpkg.8 dpkg-query.8 dpkg-split.8 start-stop-daemon.8 \
  110. cleanup-info.8 dpkg-divert.8 dpkg-statoverride.8 \
  111. install-info.8 update-alternatives.8 ; do \
  112. if [ -f $(INSTALL_TMP)/usr/share/man/$$i/man8/$$m ] ; then \
  113. cp -a $(INSTALL_TMP)/usr/share/man/$$i/man8/$$m $(TMP_DPKG)/usr/share/man/$$i/man8/$$m ; \
  114. fi ; \
  115. done ; \
  116. done
  117. # Now that dpkg has been installed, Debianize it
  118. # Policy stuff
  119. find $(TMP_DPKG)/usr/share/man -type f | xargs gzip -9f
  120. strip --remove-section=.comment --remove-section=.note \
  121. --strip-unneeded $(TMP_DPKG)/usr/bin/* $(TMP_DPKG)/sbin/* \
  122. $(TMP_DPKG)/usr/lib/dpkg/enoent
  123. mv $(TMP_DPKG)/usr/share/doc/dpkg$(static)/ChangeLog \
  124. $(TMP_DPKG)/usr/share/doc/dpkg$(static)/changelog
  125. install -p -m 644 -o root -g root debian/changelog \
  126. $(TMP_DPKG)/usr/share/doc/dpkg$(static)/changelog.Debian
  127. rm -f $(TMP_DPKG)/usr/share/doc/dpkg$(static)/copyright
  128. gzip -9 $(TMP_DPKG)/usr/share/doc/dpkg$(static)/*
  129. install -p -m 644 -o root -g root debian/dpkg.cfg \
  130. $(TMP_DPKG)/usr/share/doc/dpkg$(static)/
  131. install -p -m 644 -o root -g root debian/copyright \
  132. $(TMP_DPKG)/usr/share/doc/dpkg$(static)/
  133. # Final package creation
  134. install -d -m 755 -o root -g root $(TMP_DPKG)/DEBIAN
  135. install -p -m 644 -o root -g root debian/dpkg.conffiles $(TMP_DPKG)/DEBIAN/conffiles
  136. install -p -m 755 -o root -g root debian/dpkg.preinst $(TMP_DPKG)/DEBIAN/preinst
  137. install -p -m 755 -o root -g root debian/dpkg.prerm $(TMP_DPKG)/DEBIAN/prerm
  138. install -p -m 755 -o root -g root debian/dpkg.postinst $(TMP_DPKG)/DEBIAN/postinst
  139. install -p -m 755 -o root -g root debian/dpkg.postrm $(TMP_DPKG)/DEBIAN/postrm
  140. dpkg-shlibdeps -dPre-Depends -Tdebian/dpkg$(static).substvars \
  141. $(TMP_DPKG)/sbin/start-stop-daemon \
  142. `test -z "$(static)" && echo $(TMP_DPKG)/usr/bin/dpkg $(TMP_DPKG)/usr/bin/md5sum $(TMP_DPKG)/usr/bin/dpkg-deb`
  143. binary-dpkg binary-dpkg-static: %: %-most
  144. $(GENCONTROL) -Tdebian/dpkg$(static).substvars -pdpkg$(static) -P$(TMP_DPKG)
  145. dpkg --build $(TMP_DPKG) ..
  146. binary-dpkg-dev: stamp-binary
  147. rm -rf $(TMP_DPKG_DEV)
  148. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)
  149. chmod g-s $(TMP_DPKG_DEV)
  150. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/etc/dpkg
  151. install -p -m 644 -o root -g root debian/shlibs.default \
  152. $(TMP_DPKG_DEV)/etc/dpkg/
  153. install -p -m 644 -o root -g root debian/shlibs.override \
  154. $(TMP_DPKG_DEV)/etc/dpkg/
  155. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/lib/dpkg
  156. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share
  157. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/bin
  158. mv $(INSTALL_TMP)/usr/lib/dpkg/parsechangelog $(TMP_DPKG_DEV)/usr/lib/dpkg/
  159. mv $(INSTALL_TMP)/usr/lib/dpkg/controllib.pl $(TMP_DPKG_DEV)/usr/lib/dpkg/
  160. set -e ; for i in dpkg-name dpkg-source dpkg-genchanges dpkg-gencontrol \
  161. dpkg-shlibdeps dpkg-buildpackage dpkg-distaddfile 822-date \
  162. dpkg-scanpackages dpkg-scansources dpkg-architecture \
  163. dpkg-parsechangelog dpkg-checkbuilddeps ; do \
  164. mv $(INSTALL_TMP)/usr/bin/$$i $(TMP_DPKG_DEV)/usr/bin/ ; \
  165. done
  166. set -e ; for i in "" de fr ja sv ; do \
  167. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/man/$$i/man1 ; \
  168. for m in dpkg-name.1 dpkg-source.1 822-date.1 dpkg-architecture.1 \
  169. dpkg-buildpackage.1 dpkg-distaddfile.1 dpkg-genchanges.1 \
  170. dpkg-gencontrol.1 dpkg-parsechangelog.1 dpkg-shlibdeps.1 \
  171. dpkg-checkbuilddeps.1 ; do \
  172. if [ -e $(INSTALL_TMP)/usr/share/man/$$i/man1/$$m ] ; then \
  173. mv $(INSTALL_TMP)/usr/share/man/$$i/man1/$$m $(TMP_DPKG_DEV)/usr/share/man/$$i/man1/$$m ; \
  174. fi ; \
  175. done ; \
  176. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/man/$$i/man5 ; \
  177. for m in deb.5 deb-control.5 deb-old.5 ; do \
  178. if [ -e $(INSTALL_TMP)/usr/share/man/$$i/man5/$$m ] ; then \
  179. mv $(INSTALL_TMP)/usr/share/man/$$i/man5/$$m $(TMP_DPKG_DEV)/usr/share/man/$$i/man5/$$m ; \
  180. fi ; \
  181. done ; \
  182. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/man/$$i/man8 ; \
  183. for m in dpkg-scanpackages.8 dpkg-scansources.8 ; do \
  184. if [ -e $(INSTALL_TMP)/usr/share/man/$$i/man8/$$m ] ; then \
  185. mv $(INSTALL_TMP)/usr/share/man/$$i/man8/$$m $(TMP_DPKG_DEV)/usr/share/man/$$i/man8/$$m ; \
  186. fi ; \
  187. done ; \
  188. done
  189. # Now that dpkg-dev has been installed, Debianize it
  190. # Policy stuff
  191. find $(TMP_DPKG_DEV)/usr/share/man -type f | xargs gzip -9f
  192. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/usr/share/doc
  193. ln -s dpkg $(TMP_DPKG_DEV)/usr/share/doc/dpkg-dev
  194. # Final package creation
  195. install -d -m 755 -o root -g root $(TMP_DPKG_DEV)/DEBIAN
  196. install -p -m 644 -o root -g root debian/dpkg-dev.conffiles $(TMP_DPKG_DEV)/DEBIAN/conffiles
  197. install -p -m 755 -o root -g root debian/dpkg-dev.prerm $(TMP_DPKG_DEV)/DEBIAN/prerm
  198. install -p -m 755 -o root -g root debian/dpkg-dev.postinst $(TMP_DPKG_DEV)/DEBIAN/postinst
  199. $(GENCONTROL) -Tdebian/dpkg-dev.substvars -pdpkg-dev -P$(TMP_DPKG_DEV)
  200. dpkg --build $(TMP_DPKG_DEV) ..
  201. binary-dselect: stamp-binary
  202. rm -rf $(TMP_DSELECT)
  203. install -d -m 755 -o root -g root $(TMP_DSELECT)
  204. chmod g-s $(TMP_DSELECT)
  205. install -d -m 755 -o root -g root $(TMP_DSELECT)/usr/bin
  206. mv $(INSTALL_TMP)/usr/bin/dselect $(TMP_DSELECT)/usr/bin/
  207. install -d -m 755 -o root -g root $(TMP_DSELECT)/usr/lib
  208. mv $(INSTALL_TMP)/usr/lib/dpkg/methods $(TMP_DSELECT)/usr/lib/dpkg/
  209. install -d -m 755 -o root -g root $(TMP_DSELECT)/var/lib/dpkg
  210. mv $(INSTALL_TMP)/var/lib/dpkg/methods $(TMP_DSELECT)/var/lib/dpkg/
  211. set -e ; for i in "" de fr ja sv ; do \
  212. install -d -m 755 -o root -g root $(TMP_DSELECT)/usr/share/man/$$i/man8 ; \
  213. for m in dselect.8 ; do \
  214. if [ -f $(INSTALL_TMP)/usr/share/man/$$i/man8/$$m ] ; then \
  215. cp -a $(INSTALL_TMP)/usr/share/man/$$i/man8/$$m $(TMP_DSELECT)/usr/share/man/$$i/man8/$$m ; \
  216. fi ; \
  217. done ; \
  218. done
  219. install -d -m 755 -o root -g root $(TMP_DSELECT)/etc/dpkg
  220. install -p -m 644 -o root -g root debian/dselect.cfg \
  221. $(TMP_DSELECT)/etc/dpkg/
  222. # Now do the usual Debian stuff
  223. find $(TMP_DSELECT)/usr/share/man -type f | xargs gzip -9f
  224. install -d -m 755 -o root -g root $(TMP_DSELECT)/usr/share/doc
  225. ln -s dpkg $(TMP_DSELECT)/usr/share/doc/dselect
  226. strip --remove-section=.comment --remove-section=.note \
  227. --strip-unneeded $(TMP_DSELECT)/usr/bin/*
  228. # Final package creation
  229. install -d -m 755 -o root -g root $(TMP_DSELECT)/DEBIAN
  230. install -p -m 644 -o root -g root debian/dselect.conffiles $(TMP_DSELECT)/DEBIAN/prerm
  231. install -p -m 755 -o root -g root debian/dselect.prerm $(TMP_DSELECT)/DEBIAN/prerm
  232. install -p -m 755 -o root -g root debian/dselect.postinst $(TMP_DSELECT)/DEBIAN/postinst
  233. dpkg-shlibdeps -Tdebian/dselect.substvars \
  234. $(TMP_DSELECT)/usr/bin/dselect
  235. $(GENCONTROL) -Tdebian/dselect.substvars -pdselect -P$(TMP_DSELECT)
  236. dpkg --build $(TMP_DSELECT) ..
  237. binary-dpkg-doc: stamp-binary
  238. rm -rf $(TMP_DPKG_DOC)
  239. install -d -m 755 -o root -g root $(TMP_DPKG_DOC)
  240. chmod g-s $(TMP_DPKG_DOC)
  241. install -d -m 755 -o root -g root $(TMP_DPKG_DOC)/usr/share/doc/dpkg
  242. mv $(INSTALL_TMP)/usr/share/doc/dpkg/internals $(TMP_DPKG_DOC)/usr/share/doc/dpkg/
  243. mv $(INSTALL_TMP)/usr/share/doc/dpkg/ChangeLog.manuals \
  244. $(TMP_DPKG_DOC)/usr/share/doc/dpkg/changelog.manuals
  245. # Now that dpkg-doc has been installed, Debianize it
  246. # Policy stuff
  247. gzip -9f $(TMP_DPKG_DOC)/usr/share/doc/dpkg/[!i]*
  248. ln -s dpkg $(TMP_DPKG_DOC)/usr/share/doc/dpkg-doc
  249. # Register documentation with doc-base
  250. install -d -m 755 -o root -g root $(TMP_DPKG_DOC)/usr/share/doc-base
  251. install -p -m 644 -o root -g root debian/dpkg-doc.doc-base \
  252. $(TMP_DPKG_DOC)/usr/share/doc-base/dpkg-doc
  253. # Final package creation
  254. install -d -m 755 -o root -g root $(TMP_DPKG_DOC)/DEBIAN
  255. install -p -m 755 -o root -g root debian/dpkg-doc.prerm $(TMP_DPKG_DOC)/DEBIAN/prerm
  256. install -p -m 755 -o root -g root debian/dpkg-doc.postinst $(TMP_DPKG_DOC)/DEBIAN/postinst
  257. $(GENCONTROL) -Tdebian/dpkg-doc.substvars -pdpkg-doc -P$(TMP_DPKG_DOC)
  258. dpkg --build $(TMP_DPKG_DOC) ..
  259. binary-arch-static: binary-dpkg-static
  260. binary-arch: binary-dpkg binary-dpkg-static-most binary-dselect
  261. set -e ; \
  262. v=`sed -n 's/^Version: //p' $(TMP_DPKG)/DEBIAN/control`; \
  263. for type in "" -static; do\
  264. if [ -d $(TMP_DPKG)$$type ]; then\
  265. f=dpkg-$${v}_$(arch)$$type.nondebbin.tar ; \
  266. tar -C $(TMP_DPKG)$$type -cf $(CURDIR)/../$$f usr var ; \
  267. gzip -9f ../$$f ; \
  268. dpkg-distaddfile -fdebian/files $$f.gz byhand -; \
  269. fi;\
  270. done
  271. binary-indep: binary-dpkg-dev binary-dpkg-doc
  272. set -e ; set -x ; \
  273. v=`sed -n 's/^Version: //p' $(TMP_DPKG_DEV)/DEBIAN/control`; \
  274. f=dpkg-$${v}.tar.gz ; \
  275. if [ -f ../dpkg_$${v}.tar.gz ] ; then \
  276. cp ../dpkg_$${v}.tar.gz ../$$f ; \
  277. dpkg-distaddfile -fdebian/files $$f byhand - ; \
  278. fi
  279. define checkdir
  280. test -f include/dpkg.h.in
  281. endef
  282. .PHONY: clean build binary binary-arch binary-indep binary-dpkg binary-dpkg-dev
  283. .PHONY: binary-dpkg-doc binary-nondebbin