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
37 doc_deps = $(info_TEXINFOS) doc/version.texi
39 DEFAULT_IGNORE_LIST = $(srcdir)/default-ignore-list
41 TESTS_DIR = $(srcdir)/t
42 TESTS_OUT = tmp-testing-trees
43 TESTS_ENVIRONMENT = $(PERL) -Ibin -Ilib -I$(TESTS_DIR)
45 # This is a kind of hack; TESTS needs to be set to ensure that the
46 # `check-am' target makes check-TESTS, but we override check-TESTS
47 # so it doesn't really matter what it's set to, as long as it already
48 # exists (otherwise automake will try to build it).
51 # GNU autotools standardised on the 'check' target, but CPAN (and the
52 # rest of the world) standardised on the 'test' target.
55 # required in vpath mode to ensure $build/t/ exists
56 check_DATA = $(TESTS_OUT)
58 # Test::Harness produces cleaner output than automake's default test
59 # harness, albeit without the pretty colours provided by the
60 # `color-tests' AM_INIT_AUTOMAKE option. This also dodges having to
61 # set TESTS to the full list of tests, which is good because automake
62 # doesn't support wildcards, and so it would be too easy to forget to
63 # add a new one to the list.
65 # Note that automake's `check' rule cannot be overridden
66 # for some weird reason:
68 # https://lists.gnu.org/archive/html/automake/2011-09/msg00029.html
70 # so we override check-TESTS instead which is where the real work is
71 # done anyway. Unfortunately this produces a warning with the -Wall
72 # option to AM_INIT_AUTOMAKE which has to be silenced via
76 $(TESTS_ENVIRONMENT) -MTest::Harness -e 'runtests(@ARGV)' "$${dir#./}"/*.t
81 CPAN_FILES = MANIFEST MANIFEST.SKIP Build.PL META.yml META.json
83 bin/stow.in bin/chkstow.in lib/Stow.pm.in lib/Stow/Util.pm.in \
85 $(TESTS) t/testutil.pm \
86 $(DEFAULT_IGNORE_LIST) \
88 CLEANFILES = $(bin_SCRIPTS) $(pm_DATA) $(pmstow_DATA)
89 DISTCLEANFILES = Makefile.in configure Build MYMETA.*
90 MAINTAINERCLEANFILES = $(dist_man_MANS) $(HTML) $(PDF) ChangeLog
92 # clean up auto-generated files
95 maintainer-clean-local:
96 -rm -rf doc/manual-split cover_db
98 # this is more explicit and reliable than the config file trick
99 edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \
100 -e 's|[@]VERSION[@]|$(VERSION)|g' \
101 -e "s|[@]USE_LIB_PMDIR[@]|$$use_lib_pmdir|g"
104 PERL5LIB= $(PERL) -V | \
105 awk '/@INC/ {p=1; next} p==1 {print $$1}' | \
108 calc_use_lib_pmdir = \
109 if $(pmdir_in_INC); then \
112 use_lib_pmdir="use lib \"$(pmdir)\";"; \
117 echo "\# Perl modules will be installed to $(pmdir)"; \
119 if $(pmdir_in_INC); then \
120 echo "\# This is in $(PERL)'s built-in @INC, so everything"; \
121 echo "\# should work fine with no extra effort."; \
123 echo "\# This is not in $(PERL)'s built-in @INC, so the"; \
124 echo "\# front-end scripts will have an appropriate \"use lib\""; \
125 echo "\# line inserted to compensate."; \
129 bin/stow: bin/stow.in Makefile.am
130 [ -d bin ] || mkdir bin # required in vpath mode
132 @$(calc_use_lib_pmdir); \
134 @echo "Generated $@ from $<"
137 bin/chkstow: bin/chkstow.in Makefile.am
138 @[ -d bin ] || mkdir bin # required in vpath mode
140 @echo "Generated $@ from $<"
143 lib/Stow.pm: lib/Stow.pm.in $(DEFAULT_IGNORE_LIST) Makefile.am
144 @[ -d lib ] || mkdir lib # required in vpath mode
145 @( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@
146 @echo "Generated $@ from $< and $(DEFAULT_IGNORE_LIST)"
148 lib/Stow/Util.pm: lib/Stow/Util.pm.in Makefile.am
149 @[ -d lib/Stow ] || mkdir -p lib/Stow # required in vpath mode
151 @echo "Generated $@ from $<"
153 ##############################################################################
154 # The below rules should only be needed by developers.
155 ##############################################################################
158 cpanm --quiet --installdeps --notest .; \
160 if [ $$CPANM_RESULT != 0 ]; then \
161 echo ---------------------------------------------------; \
162 cat ~/.cpanm/build.log; \
163 echo ---------------------------------------------------; \
164 exit $$CPANM_RESULT; \
167 doc/stow.8: bin/stow.in Makefile.am
168 [ -d doc ] || mkdir doc # required in vpath mode
169 $(edit) < $< | pod2man --name stow --section 8 > $@
171 # We use automake's built-in rule to generate stow.info. The built-in
172 # rules would also generate doc/stow.html and doc/stow.pdf, but after
173 # installation we want $(docdir) (typically /usr/share/doc/stow/) to
174 # contain manual-single.html, manual.pdf, and manual-split/*.html, to
175 # make it explicitly obvious that these files contain the user manual
176 # rather than some other Stow-related documentation.
178 # If it were not for a troublesome dependency on doc/$(am__dirstamp):
180 # https://lists.gnu.org/archive/html/automake/2011-11/msg00107.html
182 # we could have achieved this using the built-in rules combined with
183 # install-data-hook to rename from stow.pdf to manual.pdf etc. on
184 # install. Instead, by overriding the built-in rules with modified
185 # versions, we can kill both birds with one stone.
187 # Generating the single-page HTML version used to be done with the old
188 # texi2html, which is no longer maintained. This rule is not used,
189 # but is kept to allow comparing of results during the transition, and
190 # potentially longer for posterity.
191 doc/manual-single-old-texi2html.html: $(doc_deps)
192 texi2html --P=$(srcdir) --output=$@ -expandinfo -menu -monolithic -verbose $<
194 # One alternative to the old texi2html approach is to use the texi2html
195 # wrapper around texi2any which is provided as a partial drop-in replacement:
197 # https://www.gnu.org/software/texinfo/manual/texinfo/html_node/texi2html.html#texi2html
199 # Differences to the old texi2html:
201 # - Doesn't wrap @file{foo} paths with quotes, which looks better.
202 # - Missing certain sections
203 doc/manual-single-texi2html-wrapper.html: $(doc_deps)
204 texi2any -P $(srcdir) --output=$@ --verbose \
205 -c TEXI2HTML=1 -c SHOW_MENU=1 -c MONOLITHIC=1 $<
207 .PHONY: manual-single-html-all
208 manual-single-html-all: \
210 doc/manual-single-texi2html-wrapper.html \
211 doc/manual-single-old-texi2html.html
213 # Modern approach using $(MAKEINFOHTML) --no-split
214 # Differences to the older two approaches:
216 # - Nicer navigation links between sections
218 [ -d doc ] || mkdir doc # required in vpath mode
220 $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
221 -c USE_TITLEPAGE_FOR_TITLE=1 --no-split -o $@ \
222 `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi
225 TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
226 MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc' \
227 $(TEXI2PDF) -o $@ `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi
229 doc/manual-split: $(doc_deps)
231 if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
232 -o $@.new `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi; \
241 # The split version of the manual is copied to $(docdir)/manual-split
242 # by install-data-hook. The whole subdirectory is included via
243 # EXTRA_DIST in order to avoid having to list each file explicitly in
244 # dist_doc_DATA, since automake doesn't support wildcards, and
245 # dist_doc_DATA cannot refer to directories while EXTRA_DIST can (go
248 install-data-hook: doc/manual-split
249 cp -r $(srcdir)/doc/manual-split $(DESTDIR)$(docdir)
252 chmod u+w -R $(DESTDIR)$(docdir)/manual-split
253 rm -rf $(DESTDIR)$(docdir)/manual-split
255 # Using install-data-hook has the slightly annoying disadvantage that
256 # by default the split version of the manual isn't automatically
257 # rebuilt during development by a simple `make'. A workaround hack
258 # for this is to piggy-back the dependency onto manual-single.html,
259 # which *is* automatically rebuilt by `make':
260 $(HTML): doc/manual-split
262 # With the above hack, this probably isn't necessary but is safer to
264 dist-hook: doc/manual-split
266 dist-hook: $(dist_man_MANS)
267 ## If we are creating a distribution from a git checkout, ensure
268 ## the ChangeLog file is in sync the git repository.
269 if test -d $(top_srcdir)/.git; then \
271 && $(MAKE) $(AM_MAKEFLAGS) ChangeLog \
272 && cp -f ChangeLog $(distdir)/ChangeLog; \
275 ChangeLog: doc/ChangeLog.OLD
276 @if [ -d .git ]; then \
279 --format="format:%ad %aN <%aE>%n%n * %w(70,0,4)%s%+b%n" \
282 | sed 's/^\([A-Z]\)\t/ \1 /'; \
285 echo "Rebuilt $@ from git commit history."; \
287 echo "Not in a git repository; can't update ChangeLog."; \
290 # Watch for changes, and if any rebuilds are required, also do a
293 # If we solved https://github.com/aspiers/stow/issues/84, we could
294 # probably ditch this:
296 @echo "Watching for changes to program source files ..."
299 grep -vE 'make\[[1-9]\]: (Entering|Leaving) directory ' | \
300 grep -v 'Nothing to be done'; \
303 echo "-----------------------------------------------------"; \
304 echo "make found things to rebuild; doing $(MAKE) install ..."; \
308 echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; \
313 grep -vE 'make\[[1-9]\]: (Entering|Leaving) directory '