rules 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. #!/usr/bin/make -f
  2. # debian/rules file for Guile.
  3. #
  4. # This file was derived from a public domain file, originally written
  5. # by Joey Hess (from file included in examples in debhelper package).
  6. #
  7. # You can build any of the binary packages independantly, via
  8. # binary-<package> targets.
  9. # New stable upstream release TODO:
  10. # s/A.B/C.D/go in debian/control.
  11. # Adjust debian/changelog.
  12. # Adjust "ver" variables below.
  13. # Adjust debian/guile-libs.lintian.
  14. # auto-update guile files so that changes to guile.* cause regen
  15. SHELL := /bin/bash
  16. # Uncomment this to turn on verbose mode.
  17. #export DH_VERBOSE := 1
  18. # This has to be exported to make some magic below work.
  19. export DH_OPTIONS
  20. deb_src_maj_ver := 1
  21. deb_src_min_ver := 8
  22. deb_src_mic_ver := 7
  23. deb_src_rev := 1
  24. upstream_ver := $(deb_src_maj_ver).$(deb_src_min_ver).$(deb_src_mic_ver)
  25. ifdef deb_src_rev
  26. deb_src_ver := $(upstream_ver)+$(deb_src_rev)
  27. else
  28. deb_src_ver := $(upstream_ver)
  29. endif
  30. deb_src_eff_ver := $(deb_src_maj_ver).$(deb_src_min_ver)
  31. deb_pkg_basename := guile-$(deb_src_eff_ver)
  32. deb_src_pkg := $(deb_pkg_basename)
  33. PACKAGE := $(deb_src_pkg)
  34. deb_src_archive := $(deb_src_pkg)_$(deb_src_ver).orig.tar.gz
  35. deb_src_archive_dir := guile-$(upstream_ver)
  36. deb_trash :=
  37. # If we ever need it, we can create a copy that doesn't assume ./debian/
  38. define deb_sub
  39. perl -p \
  40. -e "s|\@UPSTREAM_VER\@|$(upstream_ver)|go;" \
  41. -e "s|\@DEB_SRC_VER\@|$(deb_src_ver)|go;" \
  42. -e "s|\@DEB_SRC_MAJ_VER\@|$(deb_src_maj_ver)|go;" \
  43. -e "s|\@DEB_SRC_MIN_VER\@|$(deb_src_min_ver)|go;" \
  44. -e "s|\@DEB_SRC_MIC_VER\@|$(deb_src_mic_ver)|go;" \
  45. -e "s|\@DEB_SRC_EFF_VER\@|$(deb_src_eff_ver)|go;" \
  46. -e "s|\@DEB_PKG_BASENAME\@|$(deb_pkg_basename)|go;" \
  47. < debian/$(1) > debian/$(2)
  48. endef
  49. # These are used for cross-compiling and for saving the configure script
  50. # from having to guess our platform (since we know it already)
  51. DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
  52. DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
  53. ifeq (alpha,$(shell dpkg-architecture -qDEB_HOST_ARCH))
  54. # The -O2 option breaks make check on alpha right now.
  55. deb_cflags := -Os -g
  56. else ifeq (sh4,$(shell dpkg-architecture -qDEB_HOST_ARCH))
  57. # Renesas SH(sh4) needs -mieee. Without it, test-conversion fails.
  58. # (Bug: 531378)
  59. deb_cflags := -O2 -g -mieee
  60. else
  61. deb_cflags := -O2 -g
  62. endif
  63. quilt := QUILT_PATCHES=debian/patches quilt
  64. ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
  65. CFLAGS += -g
  66. endif
  67. ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
  68. INSTALL_PROGRAM += -s
  69. endif
  70. configure_args = \
  71. --host=$(DEB_HOST_GNU_TYPE) \
  72. --build=$(DEB_BUILD_GNU_TYPE) \
  73. --with-threads=no \
  74. --prefix=/usr
  75. # It looks like Debian's packaging tools can't handle an empty file,
  76. # so we use need-empty-autofiles-diff (non-empty) to know when we
  77. # should create an empty autofiles.diff.
  78. define checkdir
  79. @if ! test -e debian/patches/autofiles.diff; \
  80. then \
  81. if test -e debian/need-empty-autofiles-diff; \
  82. then \
  83. touch debian/patches/autofiles.diff; \
  84. else \
  85. echo; \
  86. echo "The Debian autofiles patch is not available."; \
  87. echo "Please run this command:"; \
  88. echo " debian/rules autofiles-sync"; \
  89. echo; \
  90. false; \
  91. fi; \
  92. fi
  93. dh_testdir debian/guile.postinst
  94. @if ! test -f libguile/guile.c; \
  95. then \
  96. echo; \
  97. echo -n "The upstream source does not appear to be available."; \
  98. echo " Please put the contents"; \
  99. echo -n "of $(deb_src_archive) into the"; \
  100. echo " current directory."; \
  101. echo; \
  102. false; \
  103. fi
  104. endef
  105. define patch
  106. $(quilt) push -a
  107. cd doc/tutorial && ln -sf guile-tut.texi guile-tut-1.8.texi
  108. endef
  109. deb_trash += doc/tutorial/guile-tut-1.8.texi
  110. define unpatch
  111. test -z "$$($(quilt) applied)" || $(quilt) pop -a
  112. rm -f debian/stamp/patch
  113. rm -rf .pc
  114. endef
  115. define cleanup_all
  116. # this goes first so we clean using patched code
  117. rm -f debian/stamp/build
  118. rm -f guile-procedures.txt
  119. -$(MAKE) clean
  120. rm -f debian/stamp/config
  121. -$(MAKE) -C doc/tutorial maintainer-clean-aminfo
  122. -$(MAKE) distclean
  123. dh_clean
  124. $(unpatch)
  125. # now clean up everything else (mostly ./debian related stuff)
  126. find -name '*~' | xargs --no-run-if-empty rm -f
  127. rm -rf $(deb_trash)
  128. test ! -e debian/stamp || rmdir debian/stamp
  129. endef
  130. define update_debian_autofiles_quilt
  131. $(cleanup_all)
  132. # Make sure autofiles.diff exists, otherwise patching will fail.
  133. # Also, start from scratch so that changed files (i.e. new upstream source)
  134. # won't cause the attempt to apply the old patch to fail.
  135. echo -n > debian/patches/autofiles.diff;
  136. $(patch)
  137. test "$$($(quilt) top)" = autofiles.diff
  138. $(quilt) pop
  139. mkdir -p debian/tmp-autofiles/old
  140. tar cpSf - --exclude ./debian --exclude ./.pc . \
  141. | tar -C debian/tmp-autofiles/old -xpSf -
  142. cp -a debian/tmp-autofiles/old debian/tmp-autofiles/new
  143. # rm aclocal.m4 so it doesn't confuse newer autoconfs, but touch it
  144. # so ./Makefile won't be upset if it's not recreated (b/c not needed).
  145. #cd debian/tmp-autofiles/new && rm -f aclocal.m4
  146. #cd debian/tmp-autofiles/new && touch aclocal.m4
  147. cd debian/tmp-autofiles/new && autoreconf -i --force
  148. cd debian/tmp-autofiles/new/guile-readline && autoreconf -i --force
  149. cd debian/tmp-autofiles/new && rm -rf autom4te.cache
  150. cd debian/tmp-autofiles/new/guile-readline && rm -rf autom4te.cache
  151. find debian/tmp-autofiles/new -name '*~' | xargs --no-run-if-empty rm -f
  152. cd debian/tmp-autofiles && diff -ruN old new > new.diff; \
  153. test $$? -eq 0 -o $$? -eq 1
  154. if test -s debian/tmp-autofiles/new.diff; \
  155. then \
  156. $(quilt) import -f -P autofiles.diff debian/tmp-autofiles/new.diff; \
  157. rm -f debian/need-empty-autofiles-diff; \
  158. else \
  159. echo yes > debian/need-empty-autofiles-diff; \
  160. echo -n > debian/patches/autofiles.diff; \
  161. fi
  162. $(patch)
  163. $(quilt) refresh --no-timestamps autofiles.diff
  164. $(cleanup_all)
  165. endef
  166. deb_trash += debian/tmp-autofiles
  167. # we don't sync this automatically on clean because it's expensive and
  168. # should only be done by a maintainer with time to deal with any mess
  169. # it might create.
  170. autofiles-sync:
  171. $(update_debian_autofiles_quilt)
  172. .PHONY: autofiles-sync
  173. .PHONY: check-diff
  174. check-diff:
  175. $(checkdir)
  176. $(cleanup_all)
  177. @test -r ../$(deb_src_archive)
  178. @rm -rf debian/tmp-diff && mkdir debian/tmp-diff
  179. @cd debian/tmp-diff && tar xzpSf ../../../$(deb_src_archive)
  180. @cd debian/tmp-diff && mv $(deb_src_archive_dir) orig
  181. mkdir debian/tmp-diff/new
  182. tar cpf - --exclude './debian' --exclude './.pc' . \
  183. | (cd debian/tmp-diff/new && tar xpf -)
  184. rm -f debian/tmp-diff/{orig,new}/benchmark-suite/Makefile
  185. @echo
  186. @echo "########################################"
  187. @echo "### Diffs outside ./debian"
  188. @cd debian/tmp-diff && diff -ruN orig new
  189. @echo "########################################"
  190. @echo "### Empty file list differences"
  191. @diff -u \
  192. <(cd debian/tmp-diff/orig && find -size 0) \
  193. <(cd debian/tmp-diff/new && find -size 0) \
  194. > debian/tmp-diff/empty-files.diff || test $$? -eq 1
  195. @cat debian/tmp-diff/empty-files.diff
  196. @test ! -s debian/tmp-diff/empty-files.diff || false
  197. @echo "########################################"
  198. @rm -rf debian/tmp-diff
  199. deb_trash += debian/tmp-diff
  200. buildpackage:
  201. $(checkdir)
  202. dpkg-buildpackage -D -us -uc -rfakeroot -i'\.git|\.pc'
  203. .PHONY: buildpackage
  204. .PHONY: check-vars
  205. check-vars:
  206. @echo UPSTREAM_VER: $(upstream_ver)
  207. @echo DEB_SRC_VER: $(deb_src_ver)
  208. @echo DEB_SRC_MAJ_VER: $(deb_src_maj_ver)
  209. @echo DEB_SRC_MIN_VER: $(deb_src_min_ver)
  210. @echo DEB_SRC_MIC_VER: $(deb_src_mic_ver)
  211. @echo DEB_SRC_EFF_VER: $(deb_src_eff_ver)
  212. @echo DEB_PKG_BASENAME: $(deb_pkg_basename)
  213. @echo
  214. @echo deb_src_ver: $(deb_src_ver)
  215. @echo deb_src_maj_ver: $(deb_src_maj_ver)
  216. @echo deb_src_min_ver: $(deb_src_min_ver)
  217. @echo deb_src_mic_ver: $(deb_src_mic_ver)
  218. @echo deb_pkg_basenmae: $(deb_pkg_basename)
  219. @echo deb_src_archive: $(deb_src_archive)
  220. @echo deb_src_archive_dir: $(deb_src_archive_dir)
  221. debian/stamp/patch:
  222. $(checkdir)
  223. $(patch)
  224. mkdir -p $(dir $@) && touch $@
  225. .PHONY: update-debhelper-files
  226. update-debhelper-files:
  227. # guile
  228. $(call deb_sub,guile.install,$(deb_pkg_basename).install)
  229. $(call deb_sub,guile.menu,$(deb_pkg_basename).menu)
  230. $(call deb_sub,guile.postinst,$(deb_pkg_basename).postinst)
  231. $(call deb_sub,guile.prerm,$(deb_pkg_basename).prerm)
  232. $(call deb_sub,guile.undocumented,$(deb_pkg_basename).undocumented)
  233. # guile-dev
  234. $(call deb_sub,guile-dev.install,$(deb_pkg_basename)-dev.install)
  235. $(call deb_sub,guile-dev.lintian,$(deb_pkg_basename)-dev.lintian)
  236. # guile-doc
  237. $(call deb_sub,guile-doc.info,$(deb_pkg_basename)-doc.info)
  238. $(call deb_sub,guile-doc.install,$(deb_pkg_basename)-doc.install)
  239. # guile-libs
  240. $(call deb_sub,guile-libs.README,$(deb_pkg_basename)-libs.README.Debian)
  241. $(call deb_sub,guile-libs.install,$(deb_pkg_basename)-libs.install)
  242. $(call deb_sub,guile-libs.lintian,$(deb_pkg_basename)-libs.lintian)
  243. # # guile-slib
  244. # $(call deb_sub,guile-slib.postinst,$(deb_pkg_basename)-slib.postinst)
  245. # $(call deb_sub,guile-slib.prerm,$(deb_pkg_basename)-slib.prerm)
  246. deb_trash += debian/$(deb_pkg_basename).install
  247. deb_trash += debian/$(deb_pkg_basename).menu
  248. deb_trash += debian/$(deb_pkg_basename).postinst
  249. deb_trash += debian/$(deb_pkg_basename).prerm
  250. deb_trash += debian/$(deb_pkg_basename).undocumented
  251. deb_trash += debian/$(deb_pkg_basename)-dev.install
  252. deb_trash += debian/$(deb_pkg_basename)-dev.lintian
  253. deb_trash += debian/$(deb_pkg_basename)-doc.info
  254. deb_trash += debian/$(deb_pkg_basename)-doc.install
  255. deb_trash += debian/$(deb_pkg_basename)-libs.README.Debian
  256. deb_trash += debian/$(deb_pkg_basename)-libs.install
  257. deb_trash += debian/$(deb_pkg_basename)-libs.lintian
  258. #deb_trash += debian/$(deb_pkg_basename)-slib.postinst
  259. #deb_trash += debian/$(deb_pkg_basename)-slib.prerm
  260. debian/stamp/config: debian/stamp/patch
  261. CFLAGS="$(deb_cflags)" ./configure ${configure_args}
  262. mkdir -p $(dir $@) && touch $@
  263. build: debian/stamp/build
  264. debian/stamp/build: debian/stamp/config
  265. $(checkdir)
  266. $(MAKE)
  267. unset SHELL && $(MAKE) check
  268. mkdir -p $(dir $@) && touch $@
  269. clean:
  270. $(checkdir)
  271. dh_testroot
  272. $(cleanup_all)
  273. deb_guile_bin_path := /usr/bin/guile-$(deb_src_eff_ver)
  274. install: DH_OPTIONS=
  275. install: build
  276. $(checkdir)
  277. $(MAKE) -f debian/rules update-debhelper-files
  278. dh_testroot
  279. dh_clean -k
  280. dh_installdirs
  281. $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
  282. gzip -9v < NEWS > NEWS.gz
  283. mkdir -p debian/tmp/usr/share/lintian/overrides/
  284. install --mode=0644 \
  285. debian/$(deb_pkg_basename)-dev.lintian \
  286. debian/tmp/usr/share/lintian/overrides/$(deb_pkg_basename)-dev
  287. mkdir -p debian/tmp/usr/share/lintian/overrides/
  288. install --mode=0644 \
  289. debian/$(deb_pkg_basename)-libs.lintian \
  290. debian/tmp/usr/share/lintian/overrides/$(deb_pkg_basename)-libs
  291. # Ignore gds files for the moment.
  292. dh_install --fail-missing \
  293. -Xusr/share/info/dir \
  294. -Xusr/share/info/r5rs.info \
  295. -Xusr/share/emacs/site-lisp/gds-server.el \
  296. -Xusr/share/emacs/site-lisp/gds.el \
  297. -Xusr/share/emacs/site-lisp/gds-scheme.el
  298. perl -pi \
  299. -e "s|^#!\s*/usr/bin/guile([^-])|#!$(deb_guile_bin_path)\$$1|o" \
  300. -e ' if $$. == 1;' \
  301. debian/$(deb_pkg_basename)-dev/usr/bin/guile-config \
  302. debian/$(deb_pkg_basename)-dev/usr/bin/guile-snarf \
  303. debian/$(deb_pkg_basename)-dev/usr/bin/guile-tools
  304. cd debian/$(deb_pkg_basename)/usr/bin/ \
  305. && mv guile guile-$(deb_src_eff_ver)
  306. # mkdir -p \
  307. # debian/$(deb_pkg_basename)-slib/usr/share/guile/$(deb_src_eff_ver)
  308. # cd debian/$(deb_pkg_basename)-slib/usr/share/guile/$(deb_src_eff_ver) \
  309. # && ln -s ../../slib .
  310. deb_trash += NEWS.gz
  311. # This single target is used to build all the packages, all at once, or
  312. # one at a time. So keep in mind: any options passed to commands here will
  313. # affect _all_ packages. Anything you want to only affect one package
  314. # should be put in another target, such as the install target.
  315. binary-common:
  316. $(checkdir)
  317. dh_testroot
  318. dh_installchangelogs
  319. dh_installdocs
  320. dh_installexamples
  321. dh_installmenu
  322. # dh_installdebconf
  323. # dh_installlogrotate
  324. # dh_installemacsen
  325. # dh_installpam
  326. # dh_installmime
  327. # dh_installinit
  328. dh_installman
  329. # dh_installcron
  330. dh_installinfo
  331. # handle http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=337215
  332. perl -wpi -e 's/\\Q//gmo; s/\\E//gmo' \
  333. debian/guile-1.8-doc.postinst.debhelper
  334. dh_strip
  335. dh_link
  336. dh_compress
  337. dh_fixperms
  338. dh_makeshlibs
  339. dh_installdeb
  340. # dh_perl
  341. dh_shlibdeps
  342. dh_gencontrol
  343. dh_md5sums
  344. dh_builddeb
  345. # Build architecture independant packages using the common target.
  346. binary-indep: build install
  347. $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
  348. # Build architecture dependant packages using the common target.
  349. binary-arch: build install
  350. $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
  351. # Any other binary targets build just one binary package at a time.
  352. binary-%: build install
  353. make -f debian/rules binary-common DH_OPTIONS=-p$*
  354. binary: binary-indep binary-arch
  355. .PHONY: build clean binary-indep binary-arch binary install