rules 12 KB

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