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
93 CPAN_FILES = MANIFEST MANIFEST.SKIP Build.PL META.yml META.json
95 bin/stow.in bin/chkstow.in lib/Stow.pm.in lib/Stow/Util.pm.in \
97 $(TESTS) t/testutil.pm \
98 $(DEFAULT_IGNORE_LIST) \
100 CLEANFILES = $(bin_SCRIPTS) $(pm_DATA) $(pmstow_DATA)
101 DISTCLEANFILES = Makefile.in configure Build MYMETA.*
102 MAINTAINERCLEANFILES = $(dist_man_MANS) $(HTML) $(PDF) ChangeLog
104 # clean up auto-generated files
107 maintainer-clean-local:
108 -rm -rf doc/manual-split cover_db
110 # this is more explicit and reliable than the config file trick
111 edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \
112 -e 's|[@]VERSION[@]|$(VERSION)|g' \
113 -e "s|[@]USE_LIB_PMDIR[@]|$$use_lib_pmdir|g"
116 PERL5LIB= $(PERL) -V | \
117 awk '/@INC/ {p=1; next} p==1 {print $$1}' | \
120 calc_use_lib_pmdir = \
121 if $(pmdir_in_INC); then \
124 use_lib_pmdir="use lib \"$(pmdir)\";"; \
129 echo "\# Perl modules will be installed to $(pmdir)"; \
131 if $(pmdir_in_INC); then \
132 echo "\# This is in $(PERL)'s built-in @INC, so everything"; \
133 echo "\# should work fine with no extra effort."; \
135 echo "\# This is not in $(PERL)'s built-in @INC, so the"; \
136 echo "\# front-end scripts will have an appropriate \"use lib\""; \
137 echo "\# line inserted to compensate."; \
141 bin/stow: bin/stow.in Makefile.am
142 [ -d bin ] || mkdir bin # required in vpath mode
144 @$(calc_use_lib_pmdir); \
146 @echo "Generated $@ from $<"
149 bin/chkstow: bin/chkstow.in Makefile.am
150 @[ -d bin ] || mkdir bin # required in vpath mode
152 @echo "Generated $@ from $<"
155 lib/Stow.pm: lib/Stow.pm.in $(DEFAULT_IGNORE_LIST) Makefile.am
156 @[ -d lib ] || mkdir lib # required in vpath mode
157 @( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@
158 @echo "Generated $@ from $< and $(DEFAULT_IGNORE_LIST)"
160 lib/Stow/Util.pm: lib/Stow/Util.pm.in Makefile.am
161 @[ -d lib/Stow ] || mkdir -p lib/Stow # required in vpath mode
163 @echo "Generated $@ from $<"
165 ##############################################################################
166 # The below rules should only be needed by developers.
167 ##############################################################################
170 cpanm --quiet --installdeps --notest .; \
172 if [ $$CPANM_RESULT != 0 ]; then \
173 echo ---------------------------------------------------; \
174 cat ~/.cpanm/build.log; \
175 echo ---------------------------------------------------; \
176 exit $$CPANM_RESULT; \
179 doc/stow.8: bin/stow.in Makefile.am
180 [ -d doc ] || mkdir doc # required in vpath mode
181 $(edit) < $< | pod2man --name stow --section 8 > $@
183 # We use automake's built-in rule to generate stow.info. The built-in
184 # rules would also generate doc/stow.html and doc/stow.pdf, but after
185 # installation we want $(docdir) (typically /usr/share/doc/stow/) to
186 # contain manual-single.html, manual.pdf, and manual-split/*.html, to
187 # make it explicitly obvious that these files contain the user manual
188 # rather than some other Stow-related documentation.
190 # If it were not for a troublesome dependency on doc/$(am__dirstamp):
192 # https://lists.gnu.org/archive/html/automake/2011-11/msg00107.html
194 # we could have achieved this using the built-in rules combined with
195 # install-data-hook to rename from stow.pdf to manual.pdf etc. on
196 # install. Instead, by overriding the built-in rules with modified
197 # versions, we can kill both birds with one stone.
199 # Generating the single-page HTML version used to be done with the old
200 # texi2html, which is no longer maintained. This rule is not used,
201 # but is kept to allow comparing of results during the transition, and
202 # potentially longer for posterity.
203 doc/manual-single-old-texi2html.html: $(doc_deps)
204 texi2html --P=$(srcdir) --output=$@ -expandinfo -menu -monolithic -verbose $<
206 # One alternative to the old texi2html approach is to use the texi2html
207 # wrapper around texi2any which is provided as a partial drop-in replacement:
209 # https://www.gnu.org/software/texinfo/manual/texinfo/html_node/texi2html.html#texi2html
211 # Differences to the old texi2html:
213 # - Doesn't wrap @file{foo} paths with quotes, which looks better.
214 # - Missing certain sections
215 doc/manual-single-texi2html-wrapper.html: $(doc_deps)
216 texi2any -P $(srcdir) --output=$@ --verbose \
217 -c TEXI2HTML=1 -c SHOW_MENU=1 -c MONOLITHIC=1 $<
219 .PHONY: manual-single-html-all
220 manual-single-html-all: \
222 doc/manual-single-texi2html-wrapper.html \
223 doc/manual-single-old-texi2html.html
225 # Modern approach using $(MAKEINFOHTML) --no-split
226 # Differences to the older two approaches:
228 # - Nicer navigation links between sections
230 [ -d doc ] || mkdir doc # required in vpath mode
232 $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
233 -c USE_TITLEPAGE_FOR_TITLE=1 --no-split -o $@ \
234 `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi
237 TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
238 MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc' \
239 $(TEXI2PDF) -o $@ `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi
241 doc/manual-split: $(doc_deps)
243 if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
244 -o $@.new `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi; \
253 # The split version of the manual is copied to $(docdir)/manual-split
254 # by install-data-hook. The whole subdirectory is included via
255 # EXTRA_DIST in order to avoid having to list each file explicitly in
256 # dist_doc_DATA, since automake doesn't support wildcards, and
257 # dist_doc_DATA cannot refer to directories while EXTRA_DIST can (go
260 install-data-hook: doc/manual-split
261 cp -r $(srcdir)/doc/manual-split $(DESTDIR)$(docdir)
264 chmod u+w -R $(DESTDIR)$(docdir)/manual-split
265 rm -rf $(DESTDIR)$(docdir)/manual-split
267 # Using install-data-hook has the slightly annoying disadvantage that
268 # by default the split version of the manual isn't automatically
269 # rebuilt during development by a simple `make'. A workaround hack
270 # for this is to piggy-back the dependency onto manual-single.html,
271 # which *is* automatically rebuilt by `make':
272 $(HTML): doc/manual-split
274 # With the above hack, this probably isn't necessary but is safer to
276 dist-hook: doc/manual-split
278 dist-hook: $(dist_man_MANS)
279 ## If we are creating a distribution from a git checkout, ensure
280 ## the ChangeLog file is in sync the git repository.
281 if test -d $(top_srcdir)/.git; then \
283 && $(MAKE) $(AM_MAKEFLAGS) ChangeLog \
284 && cp -f ChangeLog $(distdir)/ChangeLog; \
287 ChangeLog: doc/ChangeLog.OLD
288 @if [ -d .git ]; then \
291 --format="format:%ad %aN <%aE>%n%n * %w(70,0,4)%s%+b%n" \
294 | sed 's/^\([A-Z]\)\t/ \1 /'; \
297 echo "Rebuilt $@ from git commit history."; \
299 echo "Not in a git repository; can't update ChangeLog."; \
302 # Watch for changes, and if any rebuilds are required, also do a
305 # If we solved https://github.com/aspiers/stow/issues/84, we could
306 # probably ditch this:
308 @echo "Watching for changes to program source files ..."
311 grep -vE 'make\[[1-9]\]: (Entering|Leaving) directory ' | \
312 grep -v 'Nothing to be done'; \
315 echo "-----------------------------------------------------"; \
316 echo "make found things to rebuild; doing $(MAKE) install ..."; \
320 echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; \
325 grep -vE 'make\[[1-9]\]: (Entering|Leaving) directory '