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/namespecs.h src/ordspecs.h \
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/parse.y src/parse.stamp src/scan.l \
32 src/scan.stamp COPYING.WTFPL2 README.md INSTALL
34 dist_man_MANS = doc/cdecl99.1 doc/libcdecl.3
36 include_HEADERS = src/cdecl.h
37 noinst_HEADERS = conf_pre.h conf_post.h src/scan.h src/parse.h \
38 test/declgen.h test/test.h
40 noinst_DATA = $(MOFILES)
42 lib_LTLIBRARIES = libcdecl.la
43 libcdecl_la_LDFLAGS = -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 \
47 src/error.c src/normalize.c src/cdecl-internal.h \
49 libcdecl_la_LIBADD = libgnu.la $(LTLIBINTL) $(LTLIBTHREAD)
50 $(libcdecl_la_OBJECTS): $(gnulib_headers)
52 bin_PROGRAMS = cdecl99
53 cdecl99_SOURCES = src/commands.c src/cdecl99.h
54 cdecl99_LDADD = $(libmain_a_OBJECTS) $(libexec_a_OBJECTS) libcdecl.la \
55 libgnu.la $(LTLIBICONV) $(LTLIBINTL) $(LTLIBREADLINE)
56 $(cdecl99_OBJECTS): $(gnulib_headers)
57 $(cdecl99_OBJECTS): src/options.h
59 EXTRA_LIBRARIES = libexec.a
60 libexec_a_SOURCES = src/execute.c src/commands.h
61 $(libexec_a_OBJECTS): $(gnulib_headers)
62 $(libexec_a_OBJECTS): src/commands.h src/cmdlist.h
64 EXTRA_LIBRARIES += libmain.a
65 libmain_a_SOURCES = src/cdecl99.c src/options.h
66 $(libmain_a_OBJECTS): $(gnulib_headers)
67 $(libmain_a_OBJECTS): src/options.h
69 check_PROGRAMS = test/crossparse
70 check_LTLIBRARIES = libtest.la
71 libtest_la_LIBADD = $(GSL_LIBS)
72 libtest_la_SOURCES = test/testlib.c
73 $(libtest_la_OBJECTS): $(gnulib_headers)
76 libtest_la_SOURCES += test/declgen.c
77 check_PROGRAMS += test/randomdecl
80 test_crossparse_LDADD = libtest.la libcdecl.la libgnu.la
81 $(test_crossparse_OBJECTS): $(gnulib_headers)
82 test_randomdecl_LDADD = libtest.la libcdecl.la libgnu.la
83 $(test_randomdecl_OBJECTS): $(gnulib_headers)
85 src/parse.lo: src/scan.h
86 src/scan.lo: src/parse.h
87 src/parse-decl.lo: src/scan.h src/parse.h
88 src/typemap.lo: src/validtypes.h
89 src/error.lo: src/errtab.h
90 src/normalize.lo: src/ordspecs.h
91 src/output.lo: src/namespecs.h
92 test/declgen.lo: test/typegen.h
94 src/validtypes.h: $(srcdir)/src/types.lst $(srcdir)/src/validtypes.sed
95 $(AM_V_GEN)sed -f $(srcdir)/src/validtypes.sed \
96 < $(srcdir)/src/types.lst > $@.tmp
97 $(AM_V_at)mv -f $@.tmp $@
99 src/namespecs.h: $(srcdir)/src/specs.lst $(srcdir)/src/namespecs.sed
100 $(AM_V_GEN) sed -f $(srcdir)/src/namespecs.sed \
101 < $(srcdir)/src/specs.lst > $@.tmp
102 $(AM_V_at) mv -f $@.tmp $@
104 src/ordspecs.h: $(srcdir)/src/specs.lst $(srcdir)/src/ordspecs.sed
105 $(AM_V_GEN) sed -f $(srcdir)/src/ordspecs.sed \
106 < $(srcdir)/src/specs.lst > $@.tmp
107 $(AM_V_at) mv -f $@.tmp $@
109 # Supporting rules for gettext.
110 include $(top_srcdir)/common/snippet/gettext.mk
112 EXTRA_DIST += po/$(PACKAGE).pot
113 MAINTAINERCLEANFILES += po/$(PACKAGE).pot
115 XGETTEXT_OPTS = -D $(builddir) -D $(srcdir) --from-code=utf-8 \
116 --add-comments=TRANSLATORS: --foreign-user \
117 --package-name=$(PACKAGE) --package-version=$(PACKAGE_VERSION) \
118 --msgid-bugs-address=$(PACKAGE_BUGREPORT) \
119 --keyword=_ --keyword=N_ --keyword=PN_:1c,2
121 po/$(PACKAGE).pot: $(SOURCES)
122 $(AM_V_at) $(MKDIR_P) $(@D)
123 $(AM_V_GEN) $(XGETTEXT) $(XGETTEXT_OPTS) -o $@.tmp $(SOURCES)
124 $(AM_V_at) mv -f $@.tmp $@
126 # These are required to prevent the builtin lex/yacc rules from
127 # superseding ours...
128 src/scan.c src/scan.h: src/scan.stamp
129 src/parse.c src/parse.h: src/parse.stamp
131 # The flex/bison rules refrain from updating unchanged headers for the
132 # convenience of developers, but the headers must be distributed with
133 # up-to-date timestamps, otherwise make will try to update them in a fresh
135 dist-hook: update-headers
136 update-headers: unfuck-distdir
137 touch -c '$(distdir)/src/scan.h'
138 touch -c '$(distdir)/src/parse.h'
139 .PHONY: update-headers
141 # When running "make dist" in a VPATH build with a read-only srcdir, Automake
142 # will produce a distribution with all files read-only. Moreover, the files
143 # are read-only in distdir when the dist hooks are run. This hook will
144 # manually fix up the permissions. All dist hooks that modify files in distdir
145 # should list unfuck-distdir as a prerequisite.
146 dist-hook: unfuck-distdir
148 find '$(distdir)' -type f -exec chmod u+w {} +
149 .PHONY: unfuck-distdir
151 GITLOG_FLAGS = --format='%s%n%n%b%n'
153 dist-hook: generate-changelog
154 generate-changelog: unfuck-distdir
155 -: "$${GIT_DIR=$(top_srcdir)/.git}"; \
156 export GIT_DIR; test -d "$$GIT_DIR" || exit 0; \
157 $(top_srcdir)/gitlog-to-changelog $(GITLOG_FLAGS) \
158 >'$(distdir)/ChangeLog.gen' && \
159 mv -f '$(distdir)/ChangeLog.gen' '$(distdir)/ChangeLog'
160 rm -f '$(distdir)/ChangeLog.gen'
161 .PHONY: generate-changelog
163 GENERIC_V = $(GENERIC_V_@AM_V@)
164 GENERIC_V_ = $(GENERIC_V_@AM_DEFAULT_V@)
165 GENERIC_V_0 = @printf '%2.0s%$(DX_ALIGN_V)s %s\n'
167 TEST_DISTRIBUTION = false
168 TEST_DISTRIBUTION_OR_ERROR = if $(TEST_DISTRIBUTION); \
169 then echo 'Proceeding anyway...'; \
170 else echo 'Run $(MAKE) TEST_DISTRIBUTION=true to ignore this failure.'; \
175 $(GENERIC_V) : 'CHECK ' ChangeLog; \
176 $(AWK) '/^Stub/ { print FILENAME ":" NR ":", $$0; exit 1 }' \
177 $(distdir)/ChangeLog || { \
178 echo 'ERROR: *** Packaged ChangeLog was not properly generated from git log.'; \
179 echo ' *** The source version was used instead, but this appears to'; \
180 echo ' *** be the stub from a git checkout. The "git" and "perl"'; \
181 echo ' *** programs are required for ChangeLog generation to work.'; \
182 $(TEST_DISTRIBUTION_OR_ERROR); } >&2
183 $(GENERIC_V) : 'CHECK ' NEWS; \
184 $(AWK) 'NR == 1 && $$NF != "$(PACKAGE_VERSION):" \
185 { print FILENAME ":" NR ":", $$0; exit 1}' \
186 $(distdir)/NEWS || { \
187 echo 'ERROR: *** First line of NEWS should match the package version'; \
188 echo ' *** $(PACKAGE_VERSION), but that does not appear to be the case.'; \
189 echo ' *** Remember to update NEWS before preparing a release.'; \
190 $(TEST_DISTRIBUTION_OR_ERROR); } >&2
192 OPTFILES = src/options.opt
194 $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-options.awk $< >$@.tmp
195 $(AM_V_at) mv -f $@.tmp $@
196 $(OPTFILES:.opt=.h): $(DX_BASEDIR)/scripts/gen-options.awk
197 MAINTAINERCLEANFILES += $(OPTFILES:.opt=.h)
198 EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-options.awk $(OPTFILES)
200 STRFILES = src/commands.str src/errtab.str
202 $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-strtab.awk $< >$@.tmp
203 $(AM_V_at) mv -f $@.tmp $@
204 $(STRFILES:.str=.h): $(DX_BASEDIR)/scripts/gen-strtab.awk
205 MAINTAINERCLEANFILES += $(STRFILES:.str=.h)
206 EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-strtab.awk $(STRFILES)
208 src/cmdlist.h: src/gen-cmdlist.awk src/execute.c
209 $(AM_V_GEN) if test -f '$(builddir)/src/execute.c'; \
210 then f='$(builddir)/src/execute.c'; \
211 else f='$(srcdir)/src/execute.c'; \
212 fi; $(AWK) -f $(srcdir)/src/gen-cmdlist.awk "$$f" >$@.tmp
213 $(AM_V_at) mv -f $@.tmp $@
214 DISTCLEANFILES += src/cmdlist.h
215 EXTRA_DIST += src/gen-cmdlist.awk
217 test/typegen.h: test/gen-typegen.awk src/types.lst
218 $(AM_V_GEN) $(AWK) -f $(srcdir)/test/gen-typegen.awk \
219 $(srcdir)/src/types.lst >$@.tmp
220 $(AM_V_at) mv -f $@.tmp $@
221 DISTCLEANFILES += test/typegen.h
222 EXTRA_DIST += test/gen-typegen.awk
224 # Supporting rules for bison/flex.
226 BISON_V = $(BISON_V_@AM_V@)
227 BISON_V_ = $(BISON_V_@AM_DEFAULT_V@)
228 BISON_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'BISON ' $<;
230 FLEX_V = $(FLEX_V_@AM_V@)
231 FLEX_V_ = $(FLEX_V_@AM_DEFAULT_V@)
232 FLEX_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'FLEX ' $<;
235 echo "ERROR: *** $$tool is missing on your system."; \
236 echo " *** Because of this, I cannot compile $$toolsrc, but"; \
237 echo " *** (perhaps because you modified it) the sources appear out"; \
238 echo " *** of date. If $$tool is installed but was not detected by"; \
239 echo " *** configure, consired setting $$toolvar and re-running configure."; \
240 echo " *** See config.log for more details."; } >&2; false
245 $(BISON_V)tool=bison toolvar=BISON toolsrc=$<; $(DEV_TOOL_ERROR)
247 $(AM_V_at) touch $@.tmp
248 $(BISON_V) $(BISON) $(BISON_COMPAT) -o $*.c --defines=$*.h.tmp $(BISONFLAGS) $<
249 $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
252 mv -f $*.h.tmp $*.h; \
254 $(AM_V_at) mv -f $@.tmp $@
259 $(FLEX_V)tool=flex toolvar=FLEX toolsrc=$<; $(DEV_TOOL_ERROR)
261 $(AM_V_at) touch $@.tmp
262 $(FLEX_V) $(FLEX) -o $*.c --header-file=$*.h.tmp $(FLEXFLAGS) $<
263 $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
266 mv -f $*.h.tmp $*.h; \
268 $(AM_V_at) mv -f $@.tmp $@
271 @if test -f $@; then :; else \
273 $(MAKE) $(AM_MAKEFLAGS) $<; \
277 @if test -f $@; then :; else \
279 $(MAKE) $(AM_MAKEFLAGS) $<; \
282 GPERFFILES = src/execute.gperf
284 $(V_GPERF) $(GPERF) $< >$@.tmp
285 $(AM_V_at) mv $@.tmp $@
286 MAINTAINERCLEANFILES += $(GPERFFILES:.gperf=.c)
287 EXTRA_DIST += $(GPERFFILES)
289 atlocal: config.status
291 printf ': "$${%s=%s}"\n' \
293 check_PROGRAMS '$(check_PROGRAMS)' \
295 $(AM_V_at) mv -f $@.tmp $@
297 CLEANFILES += atlocal
299 include $(top_srcdir)/lib/gnulib.mk
300 include $(top_srcdir)/common/snippet/glconfig.mk
301 include $(top_srcdir)/common/snippet/autotest.mk