]> git.draconx.ca Git - cdecl99.git/blob - Makefile.am
Mark dist hooks as phony.
[cdecl99.git] / Makefile.am
1 # Copyright © 2011 Nick Bowler
2 #
3 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 # This is free software: you are free to do what the fuck you want to.
5 # There is NO WARRANTY, to the extent permitted by law.
6
7 ACLOCAL_AMFLAGS = -I m4
8 AUTOMAKE_OPTIONS = nostdinc
9
10 # For Gnulib
11 MOSTLYCLEANFILES =
12 noinst_LTLIBRARIES =
13
14 AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
15         -I$(top_builddir)/lib -I$(top_srcdir)/lib \
16         -I$(top_builddir) -I$(top_srcdir) \
17         -DBISON_LOCALEDIR=\"$(BISON_LOCALEDIR)\" \
18         -DLOCALEDIR=\"$(localedir)\"
19
20 AM_CFLAGS = $(GSL_CFLAGS)
21
22 MAINTAINERCLEANFILES = src/scan.c src/scan.h src/scan.stamp \
23         src/parse.c src/parse.h src/parse.stamp
24
25 CLEANFILES = src/validtypes.h src/errtab.h src/namespecs.h src/ordspecs.h \
26         test/typegen.h
27
28 EXTRA_DIST = m4/gnulib-cache.m4 src/types.lst src/validtypes.sed \
29         src/specs.lst src/namespecs.sed src/ordspecs.sed \
30         src/errors.lst src/strtab.sed \
31         src/parse.stamp src/scan.stamp \
32         COPYING.WTFPL2
33
34 dist_man_MANS = doc/man/cdecl99.1 doc/man/libcdecl.3
35
36 include_HEADERS = src/cdecl.h
37 noinst_HEADERS = conf_post.h src/typemap.h src/output.h src/scan.h \
38         src/parse.h src/i18n.h src/normalize.h src/error.h
39
40 noinst_DATA = $(MOFILES)
41
42 lib_LTLIBRARIES = libcdecl.la
43 libcdecl_la_LDFLAGS = -no-undefined \
44         -export-symbols-regex '^cdecl_[[:lower:]]'
45 libcdecl_la_SOURCES = src/scan.c src/parse.c src/parse-decl.c src/typemap.c \
46         src/output.c src/explain.c src/declare.c src/i18n.c src/error.c \
47         src/normalize.c
48 libcdecl_la_LIBADD = libgnu.la $(LTLIBINTL) $(LTLIBTHREAD)
49 $(libcdecl_la_OBJECTS): $(gnulib_headers)
50
51 bin_PROGRAMS = cdecl99
52
53 check_PROGRAMS =
54 EXTRA_LTLIBRARIES = libtest.la
55 libtest_la_LIBADD = $(GSL_LIBS)
56 libtest_la_SOURCES = test/testlib.c
57
58 if HAVE_GSL
59 libtest_la_SOURCES += test/declgen.c
60 check_PROGRAMS += test/randomdecl
61 endif
62
63 cdecl99_SOURCES = src/cdecl99.c
64 cdecl99_LDADD = libcdecl.la libgnu.la $(LTLIBINTL) $(LTLIBREADLINE)
65 $(cdecl99_OBJECTS): $(gnulib_headers)
66
67 test_randomdecl_LDADD = libcdecl.la libtest.la libgnu.la
68 $(test_randomdecl_OBJECTS): $(gnulib_headers)
69
70 src/parse.lo: src/scan.h
71 src/scan.lo: src/parse.h
72 src/parse-decl.lo: src/scan.h src/parse.h
73 src/typemap.lo: src/validtypes.h
74 src/error.lo: src/errtab.h
75 src/normalize.lo: src/ordspecs.h
76 src/output.lo: src/namespecs.h
77 test/declgen.lo: test/typegen.h
78
79 src/validtypes.h: $(srcdir)/src/types.lst $(srcdir)/src/validtypes.sed
80         $(AM_V_GEN)sed -f $(srcdir)/src/validtypes.sed \
81                 < $(srcdir)/src/types.lst > $@.tmp
82         $(AM_V_at)mv -f $@.tmp $@
83
84 src/namespecs.h: $(srcdir)/src/specs.lst $(srcdir)/src/namespecs.sed
85         $(AM_V_GEN) sed -f $(srcdir)/src/namespecs.sed \
86                 < $(srcdir)/src/specs.lst > $@.tmp
87         $(AM_V_at) mv -f $@.tmp $@
88
89 src/ordspecs.h: $(srcdir)/src/specs.lst $(srcdir)/src/ordspecs.sed
90         $(AM_V_GEN) sed -f $(srcdir)/src/ordspecs.sed \
91                 < $(srcdir)/src/specs.lst > $@.tmp
92         $(AM_V_at) mv -f $@.tmp $@
93
94 src/errtab.h: $(srcdir)/src/errors.lst $(srcdir)/src/strtab.sed
95         $(AM_V_GEN)sed -f $(srcdir)/src/strtab.sed \
96                 < $(srcdir)/src/errors.lst > $@.tmp
97         $(AM_V_at)mv -f $@.tmp $@
98
99 test/typegen.h: $(srcdir)/src/types.lst $(srcdir)/test/typegen.sh
100         $(AM_V_GEN) $(SHELL) $(srcdir)/test/typegen.sh \
101                 < $(srcdir)/src/types.lst > $@.tmp
102         $(AM_V_at)mv -f $@.tmp $@
103
104 # Supporting rules for gettext.
105 ALL_MOFILES = $(POFILES:.po=.mo)
106 EXTRA_DIST += po/$(PACKAGE).pot po/LINGUAS $(POFILES) $(ALL_MOFILES)
107 MAINTAINERCLEANFILES += po/$(PACKAGE).pot $(ALL_MOFILES)
108 XGETTEXT_OPTS = -D $(builddir) -D $(srcdir) --from-code=utf-8 \
109         --add-comments=TRANSLATORS: --foreign-user \
110         --package-name=$(PACKAGE) --package-version=$(PACKAGE_VERSION) \
111         --msgid-bugs-address=$(PACKAGE_BUGREPORT) \
112         --keyword=_ --keyword=N_ --keyword=PN_:1c,2
113
114 po/$(PACKAGE).pot: $(SOURCES) src/errors.lst
115         $(AM_V_at)  $(MKDIR_P) $(@D)
116         $(AM_V_GEN) $(XGETTEXT) $(XGETTEXT_OPTS) -o $@.tmp $(SOURCES)
117         $(AM_V_at)  $(XGETTEXT) $(XGETTEXT_OPTS) --omit-header -Lc \
118                 -ajo $@.tmp src/errors.lst
119         $(AM_V_at)  mv -f $@.tmp $@
120
121 .po.mo:
122         $(AM_V_at)$(MKDIR_P) $(@D)
123         $(AM_V_GEN)$(MSGFMT) -c -o $@ $<
124
125 install-data-local: install-mo
126 install-mo: $(MOFILES)
127         for mo in $?; do \
128                 lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
129                 test x"$$lang" = x"" && exit 1; \
130                 inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
131                 (set -x; $(MKDIR_P) "$$inst") \
132                         || exit $$?; \
133                 (set -x; $(INSTALL_DATA) "$$mo" "$$inst/$(PACKAGE).mo") \
134                         || exit $$?; \
135         done
136
137 installdirs-local: installdirs-mo
138 installdirs-mo:
139         for mo in $(MOFILES); do \
140                 lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
141                 test x"$$lang" = x"" && exit 1; \
142                 inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
143                 (set -x; $(MKDIR_P) "$$inst") || exit $$?; \
144         done
145
146 uninstall-local: uninstall-mo
147 uninstall-mo:
148         for mo in $(ALL_MOFILES); do \
149                 lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
150                 test x"$$lang" = x"" && exit 1; \
151                 inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
152                 (set -x; cd "$$inst" && rm -f '$(PACKAGE).mo'); \
153         done
154
155 .PHONY: install-mo installdirs-mo uninstall-mo
156
157 # These are required to prevent the builtin lex/yacc rules from
158 # superseding ours...
159 src/scan.c src/scan.h: src/scan.stamp
160 src/parse.c src/parse.h: src/parse.stamp
161
162 # The flex/bison rules refrain from updating unchanged headers for the
163 # convenience of developers, but the headers must be distributed with
164 # up-to-date timestamps, otherwise make will try to update them in a fresh
165 # VPATH build.
166 dist-hook: update-headers
167 update-headers: unfuck-distdir
168         touch -c '$(distdir)/src/scan.h'
169         touch -c '$(distdir)/src/parse.h'
170 .PHONY: update-headers
171
172 # When running "make dist" in a VPATH build with a read-only srcdir, Automake
173 # will produce a distribution with all files read-only.  Moreover, the files
174 # are read-only in distdir when the dist hooks are run.  This hook will
175 # manually fix up the permissions.  All dist hooks that modify files in distdir
176 # should list unfuck-distdir as a prerequisite.
177 dist-hook: unfuck-distdir
178 unfuck-distdir:
179         find '$(distdir)' -type f -exec chmod u+w {} +
180 .PHONY: unfuck-distdir
181
182 # Supporting rules for bison/flex.
183
184 BISON_V   = $(BISON_V_$(V))
185 BISON_V_  = $(BISON_V_$(AM_DEFAULT_VERBOSITY))
186 BISON_V_0 = @echo "  BISON " $<;
187
188 FLEX_V   = $(FLEX_V_$(V))
189 FLEX_V_  = $(FLEX_V_$(AM_DEFAULT_VERBOSITY))
190 FLEX_V_0 = @echo "  FLEX  " $<;
191
192 .y.c: ;
193 .l.c: ;
194
195 .y.stamp:
196         $(AM_V_at) touch $@.tmp
197         $(BISON_V) $(BISON) -o $*.c --defines=$*.h.tmp $(BISONFLAGS) $<
198         $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
199                 rm -f $*.h.tmp; \
200         else \
201                 mv -f $*.h.tmp $*.h; \
202         fi
203         $(AM_V_at) mv -f $@.tmp $@
204
205 .l.stamp:
206         $(AM_V_at) touch $@.tmp
207         $(FLEX_V) $(FLEX) -o $*.c --header-file=$*.h.tmp $(FLEXFLAGS) $<
208         $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
209                 rm -f $*.h.tmp; \
210         else \
211                 mv -f $*.h.tmp $*.h; \
212         fi
213         $(AM_V_at) mv -f $@.tmp $@
214
215 .stamp.c:
216         @if test -f $@; then :; else \
217                 rm -f $<; \
218                 $(MAKE) $(AM_MAKEFLAGS) $<; \
219         fi
220
221 .stamp.h:
222         @if test -f $@; then :; else \
223                 rm -f $<; \
224                 $(MAKE) $(AM_MAKEFLAGS) $<; \
225         fi
226
227 include $(top_srcdir)/lib/gnulib.mk
228 include $(top_srcdir)/glconfig.mk