Makefile.am 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. # This file is part of GNU Stow.
  2. #
  3. # GNU Stow is free software: you can redistribute it and/or modify it
  4. # under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # GNU Stow is distributed in the hope that it will be useful, but
  9. # WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. # General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see https://www.gnu.org/licenses/.
  15. ## Process this file with Automake to produce Makefile.in
  16. bin_SCRIPTS = bin/stow bin/chkstow
  17. info_TEXINFOS = doc/stow.texi
  18. dist_man_MANS = doc/stow.8
  19. PDF = doc/manual.pdf
  20. HTML = doc/manual-single.html
  21. dist_doc_DATA = \
  22. README.md INSTALL.md \
  23. $(PDF) $(HTML) doc/version.texi \
  24. ChangeLog doc/ChangeLog.OLD
  25. # automake magic to define where *_DATA files get installed:
  26. pmdir = $(PMDIR)
  27. pmstowdir = $(pmdir)/Stow
  28. pm_DATA = lib/Stow.pm
  29. pmstow_DATA = lib/Stow/Util.pm
  30. TEXINFO_TEX = doc/texinfo.tex
  31. export TEXI2DVI_BUILD_MODE = clean
  32. AM_MAKEINFOFLAGS = -I $(srcdir)
  33. # We require this -I parameter to ensure that the include of the
  34. # default ignore list in the manual works. Unfortunately this is
  35. # the only way to do it:
  36. #
  37. # http://article.gmane.org/gmane.comp.sysutils.automake.bugs/4334/match=passing+parameters
  38. #
  39. # even though it annoyingly produces a warning with the -Wall option
  40. # to AM_INIT_AUTOMAKE which has to be silenced via -Wno-override.
  41. TEXI2DVI = texi2dvi $(AM_MAKEINFOFLAGS)
  42. doc_deps = $(info_TEXINFOS) doc/version.texi
  43. DEFAULT_IGNORE_LIST = $(srcdir)/default-ignore-list
  44. TESTS_DIR = $(srcdir)/t
  45. TESTS_OUT = tmp-testing-trees
  46. TESTS_ENVIRONMENT = $(PERL) -Ibin -Ilib -I$(TESTS_DIR)
  47. # This is a kind of hack; TESTS needs to be set to ensure that the
  48. # `check-am' target makes check-TESTS, but we override check-TESTS
  49. # so it doesn't really matter what it's set to, as long as it already
  50. # exists (otherwise automake will try to build it).
  51. TESTS = t
  52. # GNU autotools standardised on the 'check' target, but CPAN (and the
  53. # rest of the world) standardised on the 'test' target.
  54. test: check
  55. # required in vpath mode to ensure $build/t/ exists
  56. check_DATA = $(TESTS_OUT)
  57. # Test::Harness produces cleaner output than automake's default test
  58. # harness, albeit without the pretty colours provided by the
  59. # `color-tests' AM_INIT_AUTOMAKE option. This also dodges having to
  60. # set TESTS to the full list of tests, which is good because automake
  61. # doesn't support wildcards, and so it would be too easy to forget to
  62. # add a new one to the list.
  63. #
  64. # Note that automake's `check' rule cannot be overridden
  65. # for some weird reason:
  66. #
  67. # http://thread.gmane.org/gmane.comp.sysutils.automake.general/13040/focus=13041
  68. #
  69. # so we override check-TESTS instead which is where the real work is
  70. # done anyway. Unfortunately this produces a warning with the -Wall
  71. # option to AM_INIT_AUTOMAKE which has to be silenced via
  72. # -Wno-override.
  73. check-TESTS:
  74. dir=$(TESTS_DIR); \
  75. $(TESTS_ENVIRONMENT) -MTest::Harness -e 'runtests(@ARGV)' "$${dir#./}"/*.t
  76. $(TESTS_OUT):
  77. mkdir -p $@
  78. CPAN_FILES = MANIFEST MANIFEST.SKIP Build.PL META.yml META.json
  79. EXTRA_DIST = \
  80. bin/stow.in bin/chkstow.in lib/Stow.pm.in lib/Stow/Util.pm.in \
  81. doc/manual-split \
  82. $(TESTS) t/testutil.pm \
  83. $(TEXINFO_TEX) \
  84. $(DEFAULT_IGNORE_LIST) \
  85. $(CPAN_FILES)
  86. CLEANFILES = $(bin_SCRIPTS) $(pm_DATA) $(pmstow_DATA)
  87. DISTCLEANFILES = Makefile.in configure Build MYMETA.*
  88. MAINTAINERCLEANFILES = $(dist_man_MANS) $(HTML) $(PDF) ChangeLog
  89. # clean up auto-generated files
  90. clean-local:
  91. -rm -rf $(TESTS_OUT)
  92. maintainer-clean-local:
  93. -rm -rf doc/manual-split cover_db
  94. # this is more explicit and reliable than the config file trick
  95. edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \
  96. -e 's|[@]VERSION[@]|$(VERSION)|g' \
  97. -e "s|[@]USE_LIB_PMDIR[@]|$$use_lib_pmdir|g"
  98. pmdir_in_INC = \
  99. PERL5LIB= $(PERL) -V | \
  100. awk '/@INC/ {p=1; next} p==1 {print $$1}' | \
  101. grep -q "$(pmdir)"
  102. calc_use_lib_pmdir = \
  103. if $(pmdir_in_INC); then \
  104. use_lib_pmdir=""; \
  105. else \
  106. use_lib_pmdir="use lib \"$(pmdir)\";"; \
  107. fi
  108. check_pmdir = \
  109. echo; \
  110. echo "\# Perl modules will be installed to $(pmdir)"; \
  111. echo "\# "; \
  112. if $(pmdir_in_INC); then \
  113. echo "\# This is in $(PERL)'s built-in @INC, so everything"; \
  114. echo "\# should work fine with no extra effort."; \
  115. else \
  116. echo "\# This is not in $(PERL)'s built-in @INC, so the"; \
  117. echo "\# front-end scripts will have an appropriate \"use lib\""; \
  118. echo "\# line inserted to compensate."; \
  119. fi; \
  120. echo
  121. bin/stow: bin/stow.in Makefile.am
  122. [ -d bin ] || mkdir bin # required in vpath mode
  123. @$(check_pmdir)
  124. @$(calc_use_lib_pmdir); \
  125. $(edit) < $< > $@
  126. @echo "Generated $@ from $<"
  127. chmod +x $@
  128. bin/chkstow: bin/chkstow.in Makefile.am
  129. @[ -d bin ] || mkdir bin # required in vpath mode
  130. @$(edit) < $< > $@
  131. @echo "Generated $@ from $<"
  132. chmod +x $@
  133. lib/Stow.pm: lib/Stow.pm.in $(DEFAULT_IGNORE_LIST) Makefile.am
  134. @[ -d lib ] || mkdir lib # required in vpath mode
  135. @( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@
  136. @echo "Generated $@ from $< and $(DEFAULT_IGNORE_LIST)"
  137. lib/Stow/Util.pm: lib/Stow/Util.pm.in Makefile.am
  138. @[ -d lib/Stow ] || mkdir -p lib/Stow # required in vpath mode
  139. @$(edit) < $< > $@
  140. @echo "Generated $@ from $<"
  141. ##############################################################################
  142. # The below rules should only be needed by developers.
  143. ##############################################################################
  144. cpanm:
  145. cpanm --quiet --installdeps --notest .; \
  146. CPANM_RESULT=$$?; \
  147. if [ $$CPANM_RESULT != 0 ]; then \
  148. echo ---------------------------------------------------; \
  149. cat ~/.cpanm/build.log; \
  150. echo ---------------------------------------------------; \
  151. exit $$CPANM_RESULT; \
  152. fi
  153. doc/stow.8: bin/stow.in Makefile.am
  154. [ -d doc ] || mkdir doc # required in vpath mode
  155. $(edit) < $< | pod2man --name stow --section 8 > $@
  156. # We use automake's built-in rule to generate stow.info. The built-in
  157. # rules would also generate doc/stow.html and doc/stow.pdf, but after
  158. # installation we want $(docdir) (typically /usr/share/doc/stow/) to
  159. # contain manual-single.html, manual.pdf, and manual-split/*.html, to
  160. # make it explicitly obvious that these files contain the user manual
  161. # rather than some other Stow-related documentation.
  162. #
  163. # If it were not for a troublesome dependency on doc/$(am__dirstamp):
  164. #
  165. # http://article.gmane.org/gmane.comp.sysutils.automake.general/13192
  166. #
  167. # we could have achieved this using the built-in rules combined with
  168. # install-data-hook to rename from stow.pdf to manual.pdf etc. on
  169. # install. Instead, by overriding the built-in rules with modified
  170. # versions, we can kill both birds with one stone.
  171. # Generating the single-page HTML version used to be done with the old
  172. # texi2html, which is no longer maintained. This rule is not used,
  173. # but is kept to allow comparing of results during the transition, and
  174. # potentially longer for posterity.
  175. doc/manual-single-old-texi2html.html: $(doc_deps)
  176. texi2html --P=$(srcdir) --output=$@ -expandinfo -menu -monolithic -verbose $<
  177. # One alternative to the old texi2html approach is to use the texi2html
  178. # wrapper around texi2any which is provided as a partial drop-in replacement:
  179. #
  180. # https://www.gnu.org/software/texinfo/manual/texinfo/html_node/texi2html.html#texi2html
  181. #
  182. # Differences to the old texi2html:
  183. #
  184. # - Doesn't wrap @file{foo} paths with quotes, which looks better.
  185. # - Missing certain sections
  186. doc/manual-single-texi2html-wrapper.html: $(doc_deps)
  187. texi2any -P $(srcdir) --output=$@ --verbose \
  188. -c TEXI2HTML=1 -c SHOW_MENU=1 -c MONOLITHIC=1 $<
  189. .PHONY: manual-single-html-all
  190. manual-single-html-all: \
  191. $(HTML) \
  192. doc/manual-single-texi2html-wrapper.html \
  193. doc/manual-single-old-texi2html.html
  194. # Modern approach using $(MAKEINFOHTML) --no-split
  195. # Differences to the older two approaches:
  196. #
  197. # - Nicer navigation links between sections
  198. $(HTML): $(doc_deps)
  199. [ -d doc ] || mkdir doc # required in vpath mode
  200. -rm -f $@
  201. $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
  202. -c USE_TITLEPAGE_FOR_TITLE=1 --no-split -o $@ \
  203. `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi
  204. $(PDF): $(doc_deps)
  205. TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
  206. MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc' \
  207. $(TEXI2PDF) -o $@ `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi
  208. doc/manual-split: $(doc_deps)
  209. rm -rf $@.new
  210. if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
  211. -o $@.new `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi; \
  212. then \
  213. rm -rf $@; \
  214. mv $@.new $@; \
  215. else \
  216. rm -Rf $@.new $@; \
  217. exit 1; \
  218. fi
  219. # The split version of the manual is copied to $(docdir)/manual-split
  220. # by install-data-hook. The whole subdirectory is included via
  221. # EXTRA_DIST in order to avoid having to list each file explicitly in
  222. # dist_doc_DATA, since automake doesn't support wildcards, and
  223. # dist_doc_DATA cannot refer to directories while EXTRA_DIST can (go
  224. # figure ...)
  225. install-data-hook: doc/manual-split
  226. cp -r $(srcdir)/doc/manual-split $(DESTDIR)$(docdir)
  227. uninstall-hook:
  228. chmod u+w -R $(DESTDIR)$(docdir)/manual-split
  229. rm -rf $(DESTDIR)$(docdir)/manual-split
  230. # Using install-data-hook has the slightly annoying disadvantage that
  231. # by default the split version of the manual isn't automatically
  232. # rebuilt during development by a simple `make'. A workaround hack
  233. # for this is to piggy-back the dependency onto manual-single.html,
  234. # which *is* automatically rebuilt by `make':
  235. $(HTML): doc/manual-split
  236. # With the above hack, this probably isn't necessary but is safer to
  237. # keep in anyway:
  238. dist-hook: doc/manual-split
  239. dist-hook: $(dist_man_MANS)
  240. ## If we are creating a distribution from a git checkout, ensure
  241. ## the ChangeLog file is in sync the git repository.
  242. if test -d $(top_srcdir)/.git; then \
  243. rm -f ChangeLog \
  244. && $(MAKE) $(AM_MAKEFLAGS) ChangeLog \
  245. && cp -f ChangeLog $(distdir)/ChangeLog; \
  246. fi
  247. ChangeLog: doc/ChangeLog.OLD
  248. @if [ -d .git ]; then \
  249. ( \
  250. git log \
  251. --format="format:%ad %aN <%aE>%n%n * %w(70,0,4)%s%+b%n" \
  252. --name-status \
  253. v2.0.2..HEAD \
  254. | sed 's/^\([A-Z]\)\t/ \1 /'; \
  255. cat $< \
  256. ) > $@; \
  257. echo "Rebuilt $@ from git commit history."; \
  258. else \
  259. echo "Not in a git repository; can't update ChangeLog."; \
  260. fi