1 # This file is part of GNU Stow.
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.
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.
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/.
16 ## Process this file with Automake to produce Makefile.in
18 bin_SCRIPTS = bin/stow bin/chkstow
19 info_TEXINFOS = doc/stow.texi
20 dist_man_MANS = doc/stow.8
22 HTML = doc/manual-single.html
24 README.md INSTALL.md \
25 $(PDF) $(HTML) doc/version.texi \
26 ChangeLog doc/ChangeLog.OLD
28 # automake magic to define where *_DATA files get installed:
30 pmstowdir = $(pmdir)/Stow
33 pmstow_DATA = lib/Stow/Util.pm
35 export TEXI2DVI_BUILD_MODE = clean
36 AM_MAKEINFOFLAGS = -I $(srcdir)
38 # We require this -I parameter to ensure that the include of the
39 # default ignore list in the manual works correctly, even when the
40 # manual is being built via make distcheck from a different directory.
41 # Unfortunately this is the only way to do it:
43 # https://lists.gnu.org/archive/html/bug-automake/2008-09/msg00040.html
45 # even though it annoyingly produces a warning with the -Wall option
46 # to AM_INIT_AUTOMAKE which has to be silenced via -Wno-override.
47 TEXI2DVI = texi2dvi $(AM_MAKEINFOFLAGS)
49 DEFAULT_IGNORE_LIST = $(srcdir)/default-ignore-list
51 doc_deps = $(info_TEXINFOS) doc/version.texi $(DEFAULT_IGNORE_LIST)
53 TESTS_DIR = $(srcdir)/t
54 TESTS_OUT = tmp-testing-trees tmp-testing-trees-compat
55 TESTS_ENVIRONMENT = $(PERL) -Ibin -Ilib -I$(TESTS_DIR)
57 # This is a kind of hack; TESTS needs to be set to ensure that the
58 # `check-am' target makes check-TESTS, but we override check-TESTS
59 # so it doesn't really matter what it's set to, as long as it already
60 # exists (otherwise automake will try to build it).
63 # GNU autotools standardised on the 'check' target, but CPAN (and the
64 # rest of the world) standardised on the 'test' target.
67 # required in vpath mode to ensure $build/t/ exists
68 check_DATA = $(TESTS_OUT)
70 # Test::Harness produces cleaner output than automake's default test
71 # harness, albeit without the pretty colours provided by the
72 # `color-tests' AM_INIT_AUTOMAKE option. This also dodges having to
73 # set TESTS to the full list of tests, which is good because automake
74 # doesn't support wildcards, and so it would be too easy to forget to
75 # add a new one to the list.
77 # Note that automake's `check' rule cannot be overridden
78 # for some weird reason:
80 # https://lists.gnu.org/archive/html/automake/2011-09/msg00029.html
82 # so we override check-TESTS instead which is where the real work is
83 # done anyway. Unfortunately this produces a warning with the -Wall
84 # option to AM_INIT_AUTOMAKE which has to be silenced via
88 $(TESTS_ENVIRONMENT) -MTest::Harness -e 'runtests(@ARGV)' "$${dir#./}"/*.t
91 PERL5OPT=-MDevel::Cover $(MAKE) check-TESTS
97 CPAN_FILES = MANIFEST MANIFEST.SKIP Build.PL META.yml META.json
99 bin/stow.in bin/chkstow.in lib/Stow.pm.in lib/Stow/Util.pm.in \
101 $(TESTS) t/testutil.pm \
102 $(DEFAULT_IGNORE_LIST) \
104 CLEANFILES = $(bin_SCRIPTS) $(pm_DATA) $(pmstow_DATA)
105 DISTCLEANFILES = Makefile.in configure Build MYMETA.*
106 MAINTAINERCLEANFILES = $(dist_man_MANS) $(HTML) $(PDF) ChangeLog
108 # clean up auto-generated files
111 maintainer-clean-local:
112 -rm -rf doc/manual-split cover_db
114 # this is more explicit and reliable than the config file trick
115 edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \
116 -e 's|[@]VERSION[@]|$(VERSION)|g' \
117 -e "s|[@]USE_LIB_PMDIR[@]|$$use_lib_pmdir|g"
120 PERL5LIB= $(PERL) -V | \
121 awk '/@INC/ {p=1; next} p==1 {print $$1}' | \
124 calc_use_lib_pmdir = \
125 if $(pmdir_in_INC); then \
128 use_lib_pmdir="use lib \"$(pmdir)\";"; \
133 echo "\# Perl modules will be installed to $(pmdir)"; \
135 if $(pmdir_in_INC); then \
136 echo "\# This is in $(PERL)'s built-in @INC, so everything"; \
137 echo "\# should work fine with no extra effort."; \
139 echo "\# This is not in $(PERL)'s built-in @INC, so the"; \
140 echo "\# front-end scripts will have an appropriate \"use lib\""; \
141 echo "\# line inserted to compensate."; \
145 bin/stow: bin/stow.in Makefile.am
146 [ -d bin ] || mkdir bin # required in vpath mode
148 @$(calc_use_lib_pmdir); \
150 @echo "Generated $@ from $<"
153 bin/chkstow: bin/chkstow.in Makefile.am
154 @[ -d bin ] || mkdir bin # required in vpath mode
156 @echo "Generated $@ from $<"
159 lib/Stow.pm: lib/Stow.pm.in $(DEFAULT_IGNORE_LIST) Makefile.am
160 @[ -d lib ] || mkdir lib # required in vpath mode
161 @( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@
162 @echo "Generated $@ from $< and $(DEFAULT_IGNORE_LIST)"
164 lib/Stow/Util.pm: lib/Stow/Util.pm.in Makefile.am
165 @[ -d lib/Stow ] || mkdir -p lib/Stow # required in vpath mode
167 @echo "Generated $@ from $<"
169 ##############################################################################
170 # The below rules should only be needed by developers.
171 ##############################################################################
174 cpanm --quiet --installdeps --notest .; \
176 if [ $$CPANM_RESULT != 0 ]; then \
177 echo ---------------------------------------------------; \
178 cat ~/.cpanm/build.log; \
179 echo ---------------------------------------------------; \
180 exit $$CPANM_RESULT; \
183 doc/stow.8: bin/stow.in Makefile.am
184 [ -d doc ] || mkdir doc # required in vpath mode
185 $(edit) < $< | pod2man --name stow --section 8 > $@
187 # We use automake's built-in rule to generate stow.info. The built-in
188 # rules would also generate doc/stow.html and doc/stow.pdf, but after
189 # installation we want $(docdir) (typically /usr/share/doc/stow/) to
190 # contain manual-single.html, manual.pdf, and manual-split/*.html, to
191 # make it explicitly obvious that these files contain the user manual
192 # rather than some other Stow-related documentation.
194 # If it were not for a troublesome dependency on doc/$(am__dirstamp):
196 # https://lists.gnu.org/archive/html/automake/2011-11/msg00107.html
198 # we could have achieved this using the built-in rules combined with
199 # install-data-hook to rename from stow.pdf to manual.pdf etc. on
200 # install. Instead, by overriding the built-in rules with modified
201 # versions, we can kill both birds with one stone.
203 # Generating the single-page HTML version used to be done with the old
204 # texi2html, which is no longer maintained. This rule is not used,
205 # but is kept to allow comparing of results during the transition, and
206 # potentially longer for posterity.
207 doc/manual-single-old-texi2html.html: $(doc_deps)
208 texi2html --P=$(srcdir) --output=$@ -expandinfo -menu -monolithic -verbose $<
210 # One alternative to the old texi2html approach is to use the texi2html
211 # wrapper around texi2any which is provided as a partial drop-in replacement:
213 # https://www.gnu.org/software/texinfo/manual/texinfo/html_node/texi2html.html#texi2html
215 # Differences to the old texi2html:
217 # - Doesn't wrap @file{foo} paths with quotes, which looks better.
218 # - Missing certain sections
219 doc/manual-single-texi2html-wrapper.html: $(doc_deps)
220 texi2any -P $(srcdir) --output=$@ --verbose \
221 -c TEXI2HTML=1 -c SHOW_MENU=1 -c MONOLITHIC=1 $<
223 .PHONY: manual-single-html-all
224 manual-single-html-all: \
226 doc/manual-single-texi2html-wrapper.html \
227 doc/manual-single-old-texi2html.html
229 # Modern approach using $(MAKEINFOHTML) --no-split
230 # Differences to the older two approaches:
232 # - Nicer navigation links between sections
234 [ -d doc ] || mkdir doc # required in vpath mode
236 $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
237 -c USE_TITLEPAGE_FOR_TITLE=1 --no-split -o $@ \
238 `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi
241 TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
242 MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc' \
243 $(TEXI2PDF) -o $@ `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi
245 doc/manual-split: $(doc_deps)
247 if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
248 -o $@.new `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi; \
257 # The split version of the manual is copied to $(docdir)/manual-split
258 # by install-data-hook. The whole subdirectory is included via
259 # EXTRA_DIST in order to avoid having to list each file explicitly in
260 # dist_doc_DATA, since automake doesn't support wildcards, and
261 # dist_doc_DATA cannot refer to directories while EXTRA_DIST can (go
264 install-data-hook: doc/manual-split
265 cp -r $(srcdir)/doc/manual-split $(DESTDIR)$(docdir)
268 chmod u+w -R $(DESTDIR)$(docdir)/manual-split
269 rm -rf $(DESTDIR)$(docdir)/manual-split
271 # Using install-data-hook has the slightly annoying disadvantage that
272 # by default the split version of the manual isn't automatically
273 # rebuilt during development by a simple `make'. A workaround hack
274 # for this is to piggy-back the dependency onto manual-single.html,
275 # which *is* automatically rebuilt by `make':
276 $(HTML): doc/manual-split
278 # With the above hack, this probably isn't necessary but is safer to
280 dist-hook: doc/manual-split
282 dist-hook: $(dist_man_MANS)
283 ## If we are creating a distribution from a git checkout, ensure
284 ## the ChangeLog file is in sync the git repository.
285 if test -d $(top_srcdir)/.git; then \
287 && $(MAKE) $(AM_MAKEFLAGS) ChangeLog \
288 && cp -f ChangeLog $(distdir)/ChangeLog; \
291 ChangeLog: doc/ChangeLog.OLD
292 @if [ -d .git ]; then \
295 --format="format:%ad %aN <%aE>%n%n * %w(70,0,4)%s%+b%n" \
298 | sed 's/^\([A-Z]\)\t/ \1 /'; \
301 echo "Rebuilt $@ from git commit history."; \
303 echo "Not in a git repository; can't update ChangeLog."; \
306 # Watch for changes, and if any rebuilds are required, also do a
309 # If we solved https://github.com/aspiers/stow/issues/84, we could
310 # probably ditch this:
312 @echo "Watching for changes to program source files ..."
315 grep -vE 'make\[[1-9]\]: (Entering|Leaving) directory ' | \
316 grep -v 'Nothing to be done'; \
319 echo "-----------------------------------------------------"; \
320 echo "make found things to rebuild; doing $(MAKE) install ..."; \
324 echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; \
329 grep -vE 'make\[[1-9]\]: (Entering|Leaving) directory '