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