]> git.draconx.ca Git - cdecl99.git/blob - Makefile.am
Make fix-gnulib only need a single output file.
[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 AUTOMAKE_OPTIONS = parallel-tests color-tests
8 ACLOCAL_AMFLAGS = -I m4
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)/test \
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 test/typegen.sh \
31         src/parse.y src/parse.stamp src/scan.l 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_pre.h 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 test/declgen.h \
39         test/test.h
40
41 noinst_DATA = $(MOFILES)
42
43 lib_LTLIBRARIES = libcdecl.la
44 libcdecl_la_LDFLAGS = -no-undefined \
45         -export-symbols-regex '^cdecl_[[:lower:]]'
46 libcdecl_la_SOURCES = src/scan.c src/parse.c src/parse-decl.c src/typemap.c \
47         src/output.c src/explain.c src/declare.c src/i18n.c src/error.c \
48         src/normalize.c
49 libcdecl_la_LIBADD = libgnu.la $(LTLIBINTL) $(LTLIBTHREAD)
50 $(libcdecl_la_OBJECTS): $(gnulib_headers)
51
52 bin_PROGRAMS = cdecl99
53 cdecl99_SOURCES = src/cdecl99.c
54 cdecl99_LDADD = libcdecl.la libgnu.la $(LTLIBINTL) $(LTLIBREADLINE)
55 $(cdecl99_OBJECTS): $(gnulib_headers)
56
57 check_PROGRAMS = test/crossparse
58 check_LTLIBRARIES = libtest.la
59 libtest_la_LIBADD = $(GSL_LIBS)
60 libtest_la_SOURCES = test/testlib.c
61 $(libtest_la_OBJECTS): $(gnulib_headers)
62
63 if HAVE_GSL
64 libtest_la_SOURCES += test/declgen.c
65 check_PROGRAMS += test/randomdecl
66 endif
67
68 test_crossparse_LDADD = libcdecl.la libtest.la libgnu.la
69 $(test_crossparse_OBJECTS): $(gnulib_headers)
70 test_randomdecl_LDADD = libcdecl.la libtest.la libgnu.la
71 $(test_randomdecl_OBJECTS): $(gnulib_headers)
72
73 TESTS_ENVIRONMENT = SHELL='$(SHELL)' LIBTOOL='$(LIBTOOL)' EXEEXT='$(EXEEXT)'
74 TEST_EXTENSIONS = .sh
75 SH_LOG_COMPILER = $(SHELL)
76
77 TESTS = tests/libcdecl-static-symbols.sh tests/randomdecl-sanity.sh \
78         tests/crossparse-c-random.sh tests/cdecl99-c-invalid.sh
79
80 EXTRA_DIST += $(TESTS)
81
82 src/parse.lo: src/scan.h
83 src/scan.lo: src/parse.h
84 src/parse-decl.lo: src/scan.h src/parse.h
85 src/typemap.lo: src/validtypes.h
86 src/error.lo: src/errtab.h
87 src/normalize.lo: src/ordspecs.h
88 src/output.lo: src/namespecs.h
89 test/declgen.lo: test/typegen.h
90
91 src/validtypes.h: $(srcdir)/src/types.lst $(srcdir)/src/validtypes.sed
92         $(AM_V_GEN)sed -f $(srcdir)/src/validtypes.sed \
93                 < $(srcdir)/src/types.lst > $@.tmp
94         $(AM_V_at)mv -f $@.tmp $@
95
96 src/namespecs.h: $(srcdir)/src/specs.lst $(srcdir)/src/namespecs.sed
97         $(AM_V_GEN) sed -f $(srcdir)/src/namespecs.sed \
98                 < $(srcdir)/src/specs.lst > $@.tmp
99         $(AM_V_at) mv -f $@.tmp $@
100
101 src/ordspecs.h: $(srcdir)/src/specs.lst $(srcdir)/src/ordspecs.sed
102         $(AM_V_GEN) sed -f $(srcdir)/src/ordspecs.sed \
103                 < $(srcdir)/src/specs.lst > $@.tmp
104         $(AM_V_at) mv -f $@.tmp $@
105
106 src/errtab.h: $(srcdir)/src/errors.lst $(srcdir)/src/strtab.sed
107         $(AM_V_GEN)sed -f $(srcdir)/src/strtab.sed \
108                 < $(srcdir)/src/errors.lst > $@.tmp
109         $(AM_V_at)mv -f $@.tmp $@
110
111 test/typegen.h: $(srcdir)/src/types.lst $(srcdir)/test/typegen.sh
112         $(AM_V_GEN) $(SHELL) $(srcdir)/test/typegen.sh \
113                 < $(srcdir)/src/types.lst > $@.tmp
114         $(AM_V_at)mv -f $@.tmp $@
115
116 # Supporting rules for gettext.
117 ALL_MOFILES = $(POFILES:.po=.mo)
118 EXTRA_DIST += po/$(PACKAGE).pot po/LINGUAS $(POFILES) $(ALL_MOFILES)
119 MAINTAINERCLEANFILES += po/$(PACKAGE).pot $(ALL_MOFILES)
120 XGETTEXT_OPTS = -D $(builddir) -D $(srcdir) --from-code=utf-8 \
121         --add-comments=TRANSLATORS: --foreign-user \
122         --package-name=$(PACKAGE) --package-version=$(PACKAGE_VERSION) \
123         --msgid-bugs-address=$(PACKAGE_BUGREPORT) \
124         --keyword=_ --keyword=N_ --keyword=PN_:1c,2
125
126 po/$(PACKAGE).pot: $(SOURCES) src/errors.lst
127         $(AM_V_at)  $(MKDIR_P) $(@D)
128         $(AM_V_GEN) $(XGETTEXT) $(XGETTEXT_OPTS) -o $@.tmp $(SOURCES)
129         $(AM_V_at)  $(XGETTEXT) $(XGETTEXT_OPTS) --omit-header -Lc \
130                 -ajo $@.tmp src/errors.lst
131         $(AM_V_at)  mv -f $@.tmp $@
132
133 .po.mo:
134         $(AM_V_at)$(MKDIR_P) $(@D)
135         $(AM_V_GEN)$(MSGFMT) -c -o $@ $<
136
137 install-data-local: install-mo
138 install-mo: $(MOFILES)
139         for mo in $?; 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") \
144                         || exit $$?; \
145                 (set -x; $(INSTALL_DATA) "$$mo" "$$inst/$(PACKAGE).mo") \
146                         || exit $$?; \
147         done
148
149 installdirs-local: installdirs-mo
150 installdirs-mo:
151         for mo in $(MOFILES); do \
152                 lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
153                 test x"$$lang" = x"" && exit 1; \
154                 inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
155                 (set -x; $(MKDIR_P) "$$inst") || exit $$?; \
156         done
157
158 uninstall-local: uninstall-mo
159 uninstall-mo:
160         for mo in $(ALL_MOFILES); do \
161                 lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
162                 test x"$$lang" = x"" && exit 1; \
163                 inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
164                 (set -x; cd "$$inst" && rm -f '$(PACKAGE).mo'); \
165         done
166
167 .PHONY: install-mo installdirs-mo uninstall-mo
168
169 # These are required to prevent the builtin lex/yacc rules from
170 # superseding ours...
171 src/scan.c src/scan.h: src/scan.stamp
172 src/parse.c src/parse.h: src/parse.stamp
173
174 # The flex/bison rules refrain from updating unchanged headers for the
175 # convenience of developers, but the headers must be distributed with
176 # up-to-date timestamps, otherwise make will try to update them in a fresh
177 # VPATH build.
178 dist-hook: update-headers
179 update-headers: unfuck-distdir
180         touch -c '$(distdir)/src/scan.h'
181         touch -c '$(distdir)/src/parse.h'
182 .PHONY: update-headers
183
184 # When running "make dist" in a VPATH build with a read-only srcdir, Automake
185 # will produce a distribution with all files read-only.  Moreover, the files
186 # are read-only in distdir when the dist hooks are run.  This hook will
187 # manually fix up the permissions.  All dist hooks that modify files in distdir
188 # should list unfuck-distdir as a prerequisite.
189 dist-hook: unfuck-distdir
190 unfuck-distdir:
191         find '$(distdir)' -type f -exec chmod u+w {} +
192 .PHONY: unfuck-distdir
193
194 # Supporting rules for bison/flex.
195
196 BISON_V   = $(BISON_V_$(V))
197 BISON_V_  = $(BISON_V_$(AM_DEFAULT_VERBOSITY))
198 BISON_V_0 = @echo "  BISON " $<;
199
200 FLEX_V   = $(FLEX_V_$(V))
201 FLEX_V_  = $(FLEX_V_$(AM_DEFAULT_VERBOSITY))
202 FLEX_V_0 = @echo "  FLEX  " $<;
203
204 .y.c: ;
205 .l.c: ;
206
207 .y.stamp:
208         $(AM_V_at) touch $@.tmp
209         $(BISON_V) $(BISON) -o $*.c --defines=$*.h.tmp $(BISONFLAGS) $<
210         $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
211                 rm -f $*.h.tmp; \
212         else \
213                 mv -f $*.h.tmp $*.h; \
214         fi
215         $(AM_V_at) mv -f $@.tmp $@
216
217 .l.stamp:
218         $(AM_V_at) touch $@.tmp
219         $(FLEX_V) $(FLEX) -o $*.c --header-file=$*.h.tmp $(FLEXFLAGS) $<
220         $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
221                 rm -f $*.h.tmp; \
222         else \
223                 mv -f $*.h.tmp $*.h; \
224         fi
225         $(AM_V_at) mv -f $@.tmp $@
226
227 .stamp.c:
228         @if test -f $@; then :; else \
229                 rm -f $<; \
230                 $(MAKE) $(AM_MAKEFLAGS) $<; \
231         fi
232
233 .stamp.h:
234         @if test -f $@; then :; else \
235                 rm -f $<; \
236                 $(MAKE) $(AM_MAKEFLAGS) $<; \
237         fi
238
239 include $(top_srcdir)/lib/gnulib.mk
240 include $(top_srcdir)/glconfig.mk