summaryrefslogtreecommitdiff
path: root/Makefile.am
blob: 30d33591d55d2b7302b9126d304f729f642c8f2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
## Process this file with Automake to produce Makefile.in

dist_bin_SCRIPTS = bin/stow bin/chkstow
info_TEXINFOS = doc/stow.texi
dist_man_MANS = doc/stow.8
dist_doc_DATA = \
	README \
	doc/stow.html doc/stow.pdf doc/version.texi \
	ChangeLog doc/ChangeLog.OLD

# Would be nice to include the split page HTML version of the manual
# in the distribution, but automake doesn't support wildcards and I'm
# loathe to explicitly list every single page here :-(
#nobase_dist_doc_DATA = doc/manual-split/*.html

pmdir = $(libdir)/perl5
dist_pm_DATA = lib/Stow.pm
pmstowdir = $(pmdir)/Stow
dist_pmstow_DATA = lib/Stow/Util.pm

TEXINFO_TEX = doc/texinfo.tex
export TEXI2DVI_BUILD_MODE = clean
AM_MAKEINFOFLAGS = -I $(srcdir)

# We require this -I parameter to ensure that the include of the
# default ignore list in the manual works.  Unfortunately this is
# the only way to do it:
#
#   http://article.gmane.org/gmane.comp.sysutils.automake.bugs/4334/match=passing+parameters
#
# even though it annoyingly produces a warning with the -Wall option
# to AM_INIT_AUTOMAKE which has to be silenced via -Wno-override.
TEXI2DVI = texi2dvi $(AM_MAKEINFOFLAGS)

DEFAULT_IGNORE_LIST = $(srcdir)/default-ignore-list

TESTS_DIR = $(srcdir)/t
TESTS_OUT = tmp-testing-trees
TESTS_ENVIRONMENT = $(PERL) -I$(srcdir)/bin -I$(srcdir)/lib -I$(TESTS_DIR)

# This is a kind of hack; TESTS needs to be set to ensure that the
# `check-am' target makes check-TESTS, but we override check-TESTS
# so it doesn't really matter what it's set to, as long as it already
# exists (otherwise automake will try to build it).
TESTS = t

# GNU autotools standardised on the 'check' target, but CPAN (and the
# rest of the world) standardised on the 'test' target.
test: check

# required in vpath mode to ensure $build/t/ exists
check_DATA = $(TESTS_OUT)

# Test::Harness produces cleaner output than automake's default test
# harness, albeit without the pretty colours provided by the
# `color-tests' AM_INIT_AUTOMAKE option.  This also dodges having to
# set TESTS to the full list of tests, which is good because automake
# doesn't support wildcards, and so it would be too easy to forget to
# add a new one to the list.
#
# Note that automake's `check' rule cannot be overridden
# for some weird reason:
#
#   http://thread.gmane.org/gmane.comp.sysutils.automake.general/13040/focus=13041
#
# so we override check-TESTS instead which is where the real work is
# done anyway.  Unfortunately this produces a warning with the -Wall
# option to AM_INIT_AUTOMAKE which has to be silenced via
# -Wno-override.
check-TESTS:
	dir=$(TESTS_DIR); \
	$(TESTS_ENVIRONMENT) -MTest::Harness -e 'runtests(@ARGV)' "$${dir#./}"/*.t

$(TESTS_OUT):
	mkdir -p $@

CPAN_FILES = MANIFEST MANIFEST.SKIP Build.PL META.yml META.json
EXTRA_DIST = \
	bin/stow.in bin/chkstow.in lib/Stow.pm.in \
	doc/stow.pdf \
	$(TESTS) t/testutil.pm \
	$(TEXINFO_TEX) \
	$(DEFAULT_IGNORE_LIST) \
	$(CPAN_FILES)
CLEANFILES = $(bin_SCRIPTS) $(dist_pm_DATA)

# clean up auto-generated files
clean-local:
	-rm -rf $(TESTS_OUT) \
		bin/stow bin/chkstow doc/stow.8 ChangeLog \
		doc/stow.html doc/stow.pdf

# this is more explicit and reliable than the config file trick
edit = sed -e 's|[@]PERL[@]|$(PERL)|g' \
	   -e 's|[@]VERSION[@]|$(VERSION)|g'

bin/stow: bin/stow.in Makefile
	[ -d bin ] || mkdir bin # required in vpath mode
	$(edit) < $< > $@
	chmod +x $@

bin/chkstow: bin/chkstow.in Makefile
	[ -d bin ] || mkdir bin # required in vpath mode
	$(edit) < $< > $@
	chmod +x $@

lib/Stow.pm: lib/Stow.pm.in Makefile $(DEFAULT_IGNORE_LIST)
	[ -d lib ] || mkdir lib # required in vpath mode
	( $(edit) < $<; cat $(DEFAULT_IGNORE_LIST) ) > $@

##############################################################################
# The below rules should only be needed by developers.
##############################################################################

doc/stow.html: doc/stow.texi
	[ -d doc ] || mkdir doc # required in vpath mode
	-rm -f $@
	texi2html --P=$(srcdir) --output=$@ -expandinfo -menu -monolithic -verbose $<

doc/stow.8: bin/stow Makefile
	[ -d doc ] || mkdir doc # required in vpath mode
	pod2man $< > $@

# It's conventional to generate $project.info, but it's also nicer to
# generate manual.html and manual.pdf (which ultimately go somewhere
# like /usr/share/doc/stow/) rather than stow.html and stow.pdf, to
# make it obvious that these files contain the manual.  So we have to
# jump through a few extra hoops.
install-data-hook:
	cd $(DESTDIR)$(docdir)      && \
	mv -f stow.html manual.html && \
	mv -f stow.pdf  manual.pdf

uninstall-hook:
	rm -f $(DESTDIR)$(docdir)/manual.{html,pdf}

ChangeLog: doc/ChangeLog.OLD Makefile
	@if [ -d .git ]; then \
	    ( \
	        git log \
		    --format="format:%ad  %aN <%aE>%n%n    * %w(70,0,4)%s%+b%n" \
		    --name-status \
		    v2.0.2..HEAD \
                | sed 's/^\([A-Z]\)\t/      \1 /'; \
	        cat $< \
	    ) > $@; \
	else \
	    echo "Not in a git repository; can't update ChangeLog."; \
	fi