1 # Copyright © 2011-2013, 2019-2021 Nick Bowler
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.
7 ACLOCAL_AMFLAGS = -I m4 -I common/m4
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)\"
19 AM_CFLAGS = $(GSL_CFLAGS)
21 MAINTAINERCLEANFILES = src/scan.c src/scan.h src/scan.stamp \
22 src/parse.c src/parse.h src/parse.stamp
26 CLEANFILES = src/validtypes.h src/errtab.h src/namespecs.h src/ordspecs.h \
27 test/typegen.h $(EXTRA_LTLIBRARIES)
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 \
35 dist_man_MANS = doc/man/cdecl99.1 doc/man/libcdecl.3
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
42 noinst_DATA = $(MOFILES)
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 \
50 libcdecl_la_LIBADD = libgnu.la $(LTLIBINTL) $(LTLIBTHREAD)
51 $(libcdecl_la_OBJECTS): $(gnulib_headers)
53 bin_PROGRAMS = cdecl99
54 cdecl99_SOURCES = src/cdecl99.c
55 cdecl99_LDADD = libcdecl.la libgnu.la $(LTLIBINTL) $(LTLIBREADLINE)
56 $(cdecl99_OBJECTS): $(gnulib_headers)
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)
65 libtest_la_SOURCES += test/declgen.c
66 check_PROGRAMS += test/randomdecl
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)
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
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 $@
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 $@
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 $@
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 $@
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 $@
108 # Supporting rules for gettext.
109 include $(top_srcdir)/common/snippet/gettext.mk
111 EXTRA_DIST += po/$(PACKAGE).pot
112 MAINTAINERCLEANFILES += po/$(PACKAGE).pot
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
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 $@
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
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
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
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
149 find '$(distdir)' -type f -exec chmod u+w {} +
150 .PHONY: unfuck-distdir
152 # Supporting rules for bison/flex.
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 ' $<;
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 ' $<;
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 \
171 mv -f $*.h.tmp $*.h; \
173 $(AM_V_at) mv -f $@.tmp $@
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 \
181 mv -f $*.h.tmp $*.h; \
183 $(AM_V_at) mv -f $@.tmp $@
186 @if test -f $@; then :; else \
188 $(MAKE) $(AM_MAKEFLAGS) $<; \
192 @if test -f $@; then :; else \
194 $(MAKE) $(AM_MAKEFLAGS) $<; \
197 atlocal: config.status
199 printf ': "$${%s=%s}"\n' \
201 check_PROGRAMS '$(check_PROGRAMS)' \
203 $(AM_V_at) mv -f $@.tmp $@
205 CLEANFILES += atlocal
207 include $(top_srcdir)/lib/gnulib.mk
208 include $(top_srcdir)/common/snippet/glconfig.mk
209 include $(top_srcdir)/common/snippet/autotest.mk