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 = bootstrap $(DX_BASEDIR)/scripts/fix-gnulib.pl m4/gnulib-cache.m4 \
30 src/types.lst src/validtypes.sed src/specs.lst src/namespecs.sed \
31 src/ordspecs.sed 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 README.md INSTALL
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 src/options.h
55 cdecl99_LDADD = libcdecl.la libgnu.la \
56 $(LTLIBICONV) $(LTLIBINTL) $(LTLIBREADLINE)
57 $(cdecl99_OBJECTS): $(gnulib_headers)
58 $(cdecl99_OBJECTS): src/options.h
60 check_PROGRAMS = test/crossparse
61 check_LTLIBRARIES = libtest.la
62 libtest_la_LIBADD = $(GSL_LIBS)
63 libtest_la_SOURCES = test/testlib.c
64 $(libtest_la_OBJECTS): $(gnulib_headers)
67 libtest_la_SOURCES += test/declgen.c
68 check_PROGRAMS += test/randomdecl
71 test_crossparse_LDADD = libcdecl.la libtest.la libgnu.la
72 $(test_crossparse_OBJECTS): $(gnulib_headers)
73 test_randomdecl_LDADD = libcdecl.la libtest.la libgnu.la
74 $(test_randomdecl_OBJECTS): $(gnulib_headers)
76 src/parse.lo: src/scan.h
77 src/scan.lo: src/parse.h
78 src/parse-decl.lo: src/scan.h src/parse.h
79 src/typemap.lo: src/validtypes.h
80 src/error.lo: src/errtab.h
81 src/normalize.lo: src/ordspecs.h
82 src/output.lo: src/namespecs.h
83 test/declgen.lo: test/typegen.h
85 src/validtypes.h: $(srcdir)/src/types.lst $(srcdir)/src/validtypes.sed
86 $(AM_V_GEN)sed -f $(srcdir)/src/validtypes.sed \
87 < $(srcdir)/src/types.lst > $@.tmp
88 $(AM_V_at)mv -f $@.tmp $@
90 src/namespecs.h: $(srcdir)/src/specs.lst $(srcdir)/src/namespecs.sed
91 $(AM_V_GEN) sed -f $(srcdir)/src/namespecs.sed \
92 < $(srcdir)/src/specs.lst > $@.tmp
93 $(AM_V_at) mv -f $@.tmp $@
95 src/ordspecs.h: $(srcdir)/src/specs.lst $(srcdir)/src/ordspecs.sed
96 $(AM_V_GEN) sed -f $(srcdir)/src/ordspecs.sed \
97 < $(srcdir)/src/specs.lst > $@.tmp
98 $(AM_V_at) mv -f $@.tmp $@
100 src/errtab.h: $(srcdir)/src/errors.lst $(srcdir)/src/strtab.sed
101 $(AM_V_GEN)sed -f $(srcdir)/src/strtab.sed \
102 < $(srcdir)/src/errors.lst > $@.tmp
103 $(AM_V_at)mv -f $@.tmp $@
105 test/typegen.h: $(srcdir)/src/types.lst $(srcdir)/test/typegen.sh
106 $(AM_V_GEN) $(SHELL) $(srcdir)/test/typegen.sh \
107 < $(srcdir)/src/types.lst > $@.tmp
108 $(AM_V_at)mv -f $@.tmp $@
110 # Supporting rules for gettext.
111 include $(top_srcdir)/common/snippet/gettext.mk
113 EXTRA_DIST += po/$(PACKAGE).pot
114 MAINTAINERCLEANFILES += po/$(PACKAGE).pot
116 XGETTEXT_OPTS = -D $(builddir) -D $(srcdir) --from-code=utf-8 \
117 --add-comments=TRANSLATORS: --foreign-user \
118 --package-name=$(PACKAGE) --package-version=$(PACKAGE_VERSION) \
119 --msgid-bugs-address=$(PACKAGE_BUGREPORT) \
120 --keyword=_ --keyword=N_ --keyword=PN_:1c,2
122 po/$(PACKAGE).pot: $(SOURCES) src/errors.lst
123 $(AM_V_at) $(MKDIR_P) $(@D)
124 $(AM_V_GEN) $(XGETTEXT) $(XGETTEXT_OPTS) -o $@.tmp $(SOURCES)
125 $(AM_V_at) $(XGETTEXT) $(XGETTEXT_OPTS) --omit-header -Lc \
126 -ajo $@.tmp src/errors.lst
127 $(AM_V_at) mv -f $@.tmp $@
129 # These are required to prevent the builtin lex/yacc rules from
130 # superseding ours...
131 src/scan.c src/scan.h: src/scan.stamp
132 src/parse.c src/parse.h: src/parse.stamp
134 # The flex/bison rules refrain from updating unchanged headers for the
135 # convenience of developers, but the headers must be distributed with
136 # up-to-date timestamps, otherwise make will try to update them in a fresh
138 dist-hook: update-headers
139 update-headers: unfuck-distdir
140 touch -c '$(distdir)/src/scan.h'
141 touch -c '$(distdir)/src/parse.h'
142 .PHONY: update-headers
144 # When running "make dist" in a VPATH build with a read-only srcdir, Automake
145 # will produce a distribution with all files read-only. Moreover, the files
146 # are read-only in distdir when the dist hooks are run. This hook will
147 # manually fix up the permissions. All dist hooks that modify files in distdir
148 # should list unfuck-distdir as a prerequisite.
149 dist-hook: unfuck-distdir
151 find '$(distdir)' -type f -exec chmod u+w {} +
152 .PHONY: unfuck-distdir
154 GITLOG_FLAGS = --format='%s%n%n%b%n'
156 dist-hook: generate-changelog
157 generate-changelog: unfuck-distdir
158 -: "$${GIT_DIR=$(top_srcdir)/.git}"; \
159 export GIT_DIR; test -d "$$GIT_DIR" || exit 0; \
160 $(top_srcdir)/gitlog-to-changelog $(GITLOG_FLAGS) \
161 >'$(distdir)/ChangeLog.gen' && \
162 mv -f '$(distdir)/ChangeLog.gen' '$(distdir)/ChangeLog'
163 rm -f '$(distdir)/ChangeLog.gen'
164 .PHONY: generate-changelog
166 GENERIC_V = $(GENERIC_V_@AM_V@)
167 GENERIC_V_ = $(GENERIC_V_@AM_DEFAULT_V@)
168 GENERIC_V_0 = @printf '%2.0s%$(DX_ALIGN_V)s %s\n'
170 TEST_DISTRIBUTION = false
171 TEST_DISTRIBUTION_OR_ERROR = if $(TEST_DISTRIBUTION); \
172 then echo 'Proceeding anyway...'; \
173 else echo 'Run $(MAKE) TEST_DISTRIBUTION=true to ignore this failure.'; \
178 $(GENERIC_V) : 'CHECK ' ChangeLog; \
179 $(AWK) '/^Stub/ { print FILENAME ":" NR ":", $$0; exit 1 }' \
180 $(distdir)/ChangeLog || { \
181 echo 'ERROR: *** Packaged ChangeLog was not properly generated from git log.'; \
182 echo ' *** The source version was used instead, but this appears to'; \
183 echo ' *** be the stub from a git checkout. The "git" and "perl"'; \
184 echo ' *** programs are required for ChangeLog generation to work.'; \
185 $(TEST_DISTRIBUTION_OR_ERROR); } >&2
187 OPTFILES = src/options.opt
189 $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-options.awk $< >$@.tmp
190 $(AM_V_at) mv -f $@.tmp $@
191 $(OPTFILES:.opt=.h): $(DX_BASEDIR)/scripts/gen-options.awk
192 MAINTAINERCLEANFILES += $(OPTFILES:.opt=.h)
193 EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-options.awk $(OPTFILES)
195 # Supporting rules for bison/flex.
197 BISON_V = $(BISON_V_@AM_V@)
198 BISON_V_ = $(BISON_V_@AM_DEFAULT_V@)
199 BISON_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'BISON ' $<;
201 FLEX_V = $(FLEX_V_@AM_V@)
202 FLEX_V_ = $(FLEX_V_@AM_DEFAULT_V@)
203 FLEX_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'FLEX ' $<;
206 echo "ERROR: *** $$tool is missing on your system."; \
207 echo " *** Because of this, I cannot compile $$toolsrc, but"; \
208 echo " *** (perhaps because you modified it) the sources appear out"; \
209 echo " *** of date. If $$tool is installed but was not detected by"; \
210 echo " *** configure, consired setting $$toolvar and re-running configure."; \
211 echo " *** See config.log for more details."; } >&2; false
216 $(BISON_V)tool=bison toolvar=BISON toolsrc=$<; $(DEV_TOOL_ERROR)
218 $(AM_V_at) touch $@.tmp
219 $(BISON_V) $(BISON) $(BISON_COMPAT) -o $*.c --defines=$*.h.tmp $(BISONFLAGS) $<
220 $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
223 mv -f $*.h.tmp $*.h; \
225 $(AM_V_at) mv -f $@.tmp $@
230 $(FLEX_V)tool=flex toolvar=FLEX toolsrc=$<; $(DEV_TOOL_ERROR)
232 $(AM_V_at) touch $@.tmp
233 $(FLEX_V) $(FLEX) -o $*.c --header-file=$*.h.tmp $(FLEXFLAGS) $<
234 $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
237 mv -f $*.h.tmp $*.h; \
239 $(AM_V_at) mv -f $@.tmp $@
242 @if test -f $@; then :; else \
244 $(MAKE) $(AM_MAKEFLAGS) $<; \
248 @if test -f $@; then :; else \
250 $(MAKE) $(AM_MAKEFLAGS) $<; \
253 atlocal: config.status
255 printf ': "$${%s=%s}"\n' \
257 check_PROGRAMS '$(check_PROGRAMS)' \
259 $(AM_V_at) mv -f $@.tmp $@
261 CLEANFILES += atlocal
263 include $(top_srcdir)/lib/gnulib.mk
264 include $(top_srcdir)/common/snippet/glconfig.mk
265 include $(top_srcdir)/common/snippet/autotest.mk