rules 12 KB

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