Bump version to 2.4.1 for development of next release
[gnu-stow.git] / Makefile.am
blob96eedb160c1c93ccf8871df2a7f0d73c190fb917
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
21 PDF = doc/manual.pdf
22 HTML = doc/manual-single.html
23 dist_doc_DATA = \
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:
29 pmdir = $(PMDIR)
30 pmstowdir = $(pmdir)/Stow
32 pm_DATA = lib/Stow.pm
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).
61 TESTS = t
63 # GNU autotools standardised on the 'check' target, but CPAN (and the
64 # rest of the world) standardised on the 'test' target.
65 test: check
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
85 # -Wno-override.
86 check-TESTS:
87         dir=$(TESTS_DIR); \
88         $(TESTS_ENVIRONMENT) -MTest::Harness -e 'runtests(@ARGV)' "$${dir#./}"/*.t
90 coverage:
91         PERL5OPT=-MDevel::Cover $(MAKE) check-TESTS
92         cover
94 $(TESTS_OUT):
95         mkdir -p $@
97 CPAN_FILES = MANIFEST MANIFEST.SKIP Build.PL META.yml META.json
98 EXTRA_DIST = \
99         bin/stow.in bin/chkstow.in lib/Stow.pm.in lib/Stow/Util.pm.in \
100         doc/manual-split \
101         $(TESTS) t/testutil.pm \
102         $(DEFAULT_IGNORE_LIST) \
103         $(CPAN_FILES)
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
109 clean-local:
110         -rm -rf $(TESTS_OUT)
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"
119 pmdir_in_INC = \
120         PERL5LIB= $(PERL) -V | \
121             awk '/@INC/ {p=1; next} p==1 {print $$1}' | \
122             grep -q "$(pmdir)"
124 calc_use_lib_pmdir = \
125         if $(pmdir_in_INC); then \
126             use_lib_pmdir=""; \
127         else \
128             use_lib_pmdir="use lib \"$(pmdir)\";"; \
129         fi
131 check_pmdir = \
132         echo; \
133         echo "\# Perl modules will be installed to $(pmdir)"; \
134         echo "\# "; \
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."; \
138         else \
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."; \
142         fi; \
143         echo
145 bin/stow: bin/stow.in Makefile.am
146         [ -d bin ] || mkdir bin # required in vpath mode
147         @$(check_pmdir)
148         @$(calc_use_lib_pmdir); \
149         $(edit) < $< > $@
150         @echo "Generated $@ from $<"
151         chmod +x $@
153 bin/chkstow: bin/chkstow.in Makefile.am
154         @[ -d bin ] || mkdir bin # required in vpath mode
155         @$(edit) < $< > $@
156         @echo "Generated $@ from $<"
157         chmod +x $@
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
166         @$(edit) < $< > $@
167         @echo "Generated $@ from $<"
169 ##############################################################################
170 # The below rules should only be needed by developers.
171 ##############################################################################
173 cpanm:
174         cpanm --quiet --installdeps --notest .; \
175         CPANM_RESULT=$$?; \
176         if [ $$CPANM_RESULT != 0 ]; then \
177             echo ---------------------------------------------------; \
178             cat ~/.cpanm/build.log; \
179             echo ---------------------------------------------------; \
180             exit $$CPANM_RESULT; \
181         fi
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: \
225         $(HTML) \
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
233 $(HTML): $(doc_deps)
234         [ -d doc ] || mkdir doc # required in vpath mode
235         -rm -f $@
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
240 $(PDF): $(doc_deps)
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)
246         rm -rf $@.new
247         if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
248          -o $@.new `test -f 'doc/stow.texi' || echo '$(srcdir)/'`doc/stow.texi; \
249         then \
250           rm -rf $@; \
251           mv $@.new $@; \
252         else \
253           rm -Rf $@.new $@; \
254           exit 1; \
255         fi
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
262 # figure ...)
264 install-data-hook: doc/manual-split
265         cp -r $(srcdir)/doc/manual-split $(DESTDIR)$(docdir)
267 uninstall-hook:
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
279 # keep in anyway:
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 \
286           rm -f ChangeLog \
287             && $(MAKE) $(AM_MAKEFLAGS) ChangeLog \
288             && cp -f ChangeLog $(distdir)/ChangeLog; \
289         fi
291 ChangeLog: doc/ChangeLog.OLD
292         @if [ -d .git ]; then \
293             ( \
294                 git log \
295                     --format="format:%ad  %aN <%aE>%n%n    * %w(70,0,4)%s%+b%n" \
296                     --name-status \
297                     v2.0.2..HEAD \
298                 | sed 's/^\([A-Z]\)\t/      \1 /'; \
299                 cat $< \
300             ) > $@; \
301             echo "Rebuilt $@ from git commit history."; \
302         else \
303             echo "Not in a git repository; can't update ChangeLog."; \
304         fi
306 # Watch for changes, and if any rebuilds are required, also do a
307 # make install.
309 # If we solved https://github.com/aspiers/stow/issues/84, we could
310 # probably ditch this:
311 watch:
312         @echo "Watching for changes to program source files ..."
313         @while true; do \
314             if $(MAKE) 2>&1 | \
315                 grep -vE 'make\[[1-9]\]: (Entering|Leaving) directory ' | \
316                 grep -v 'Nothing to be done'; \
317             then \
318                 echo; \
319                 echo "-----------------------------------------------------"; \
320                 echo "make found things to rebuild; doing $(MAKE) install ..."; \
321                 echo; \
322                 $(MAKE) install; \
323                 echo; \
324                 echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; \
325                 echo; \
326             fi; \
327             sleep 1; \
328         done 2>&1 | \
329         grep -vE 'make\[[1-9]\]: (Entering|Leaving) directory '