1 # Copyright © 2011-2013, 2019-2023 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$(DX_BASEDIR)/src -I$(top_builddir)/t \
16 -DBISON_LOCALEDIR=\"$(BISON_LOCALEDIR)\" \
17 -DLOCALEDIR=\"$(localedir)\"
19 MAINTAINERCLEANFILES = src/scan.c src/scan.h src/scan.stamp \
20 src/parse.c src/parse.h src/parse.stamp
24 CLEANFILES = $(EXTRA_LTLIBRARIES) $(EXTRA_LIBRARIES)
26 EXTRA_DIST = bootstrap $(DX_BASEDIR)/scripts/fix-gnulib.pl m4/gnulib-cache.m4 \
27 src/types.lst src/parse.y src/parse.stamp src/scan.l \
28 src/scan.stamp COPYING.WTFPL2 README.md INSTALL
30 dist_man_MANS = doc/cdecl99.1 doc/libcdecl.3
32 include_HEADERS = src/cdecl.h
33 noinst_HEADERS = conf_pre.h conf_post.h common/src/help.h common/src/tap.h \
34 common/src/xtra.h src/scan.h src/parse.h t/declgen.h t/test.h
36 noinst_DATA = $(MOFILES)
38 shared_gl_objects = $(gnulib_symfiles:.glsym=.lo)
39 static_gl_objects = $(gnulib_extra_objects:.lo=.@OBJEXT@)
41 lib_LTLIBRARIES = libcdecl.la
42 libcdecl_la_LDFLAGS = -export-symbols-regex '^cdecl_([[:lower:]]|_gl_)' \
43 -no-undefined -version-info 1:0:0
44 libcdecl_la_SOURCES = src/scan.c src/parse.c src/parse-decl.c src/output.c \
45 src/explain.c src/declare.c src/error.c src/normalize.c \
46 src/cdecl-internal.h src/errmsg.h
47 libcdecl_la_LIBADD = $(shared_gl_objects) $(LTLIBINTL) $(LIBTHREAD)
48 EXTRA_libcdecl_la_DEPENDENCIES = $(shared_gl_objects)
49 $(libcdecl_la_OBJECTS): $(gnulib_headers)
52 libcdecl_la_SOURCES += src/i18n.c
55 EXTRA_LIBRARIES = libgnu.a
57 libgnu_a_SHORTNAME = s
58 libgnu_a_CFLAGS = $(AM_CFLAGS)
59 libgnu_a_LIBADD = $(static_gl_objects)
60 EXTRA_libgnu_a_SOURCES = $(libgnu_la_SOURCES) $(EXTRA_libgnu_la_SOURCES)
62 EXTRA_libgnu_a_DEPENDENCIES = $(static_gl_objects)
63 dummy $(static_gl_objects): $(gnulib_headers)
65 bin_PROGRAMS = cdecl99
66 cdecl99_SOURCES = common/src/help.c src/commands.c src/cdecl99.h
67 EXTRA_cdecl99_DEPENDENCIES = $(libmain_a_OBJECTS) $(libexec_a_OBJECTS)
68 cdecl99_LDADD = $(EXTRA_cdecl99_DEPENDENCIES) libcdecl.la libgnu.a \
69 $(LTLIBINTL) $(LTLIBREADLINE)
70 $(cdecl99_OBJECTS): $(gnulib_headers)
73 cdecl99_SOURCES += common/src/copysym.c common/src/copysym.h
76 EXTRA_LIBRARIES += libexec.a
77 libexec_a_SOURCES = src/execute.c src/commands.h
78 $(libexec_a_OBJECTS): $(gnulib_headers)
79 $(libexec_a_OBJECTS): src/commands.h src/cmdlist.h
81 EXTRA_LIBRARIES += libmain.a
82 libmain_a_SOURCES = src/cdecl99.c src/options.h
83 $(libmain_a_OBJECTS): $(gnulib_headers)
84 $(libmain_a_OBJECTS): src/options.h
86 check_PROGRAMS = t/crossparse t/normalize t/randomdecl t/rng-test
87 check_LIBRARIES = libtest.a
88 libtest_a_SOURCES = t/testlib.c t/rng.c common/src/help.c
89 $(libtest_a_OBJECTS): $(gnulib_headers)
91 TEST_LIBS = libtest.a libcdecl.la libgnu.a $(LDEXP_LIBM)
93 t_randomdecl_SOURCES = t/randomdecl.c t/declgen.c
94 t_randomdecl_LDADD = $(TEST_LIBS)
95 $(t_randomdecl_OBJECTS): $(gnulib_headers)
97 t_crossparse_LDADD = $(TEST_LIBS)
98 $(t_crossparse_OBJECTS): $(gnulib_headers)
100 t_normalize_LDADD = src/output.lo src/normalize.lo $(TEST_LIBS)
101 $(t_normalize_OBJECTS): $(gnulib_headers)
103 t_rng_test_LDADD = $(TEST_LIBS)
104 $(t_rng_test_OBJECTS): $(gnulib_headers)
105 EXTRA_DIST += t/xos256p.c
107 src/parse.lo: src/scan.h src/errmsg.h
108 src/scan.lo: src/parse.h src/errmsg.h
109 src/parse-decl.lo: src/scan.h src/parse.h src/typemap.h src/errmsg.h
110 src/output.lo: src/specstr.h
111 src/error.lo: src/errmsg.h
112 t/declgen.$(OBJEXT): t/typegen.h
113 t/cdeclerr.$(OBJEXT): src/errmsg.h
115 check_PROGRAMS += t/cdeclerr
116 t_cdeclerr_SOURCES = common/src/tap.c t/cdeclerr.c
117 EXTRA_t_cdeclerr_DEPENDENCIES = src/error.lo $(shared_gl_objects)
118 t_cdeclerr_LDADD = $(EXTRA_t_cdeclerr_DEPENDENCIES) $(LIBTHREAD)
119 $(t_cdeclerr_OBJECTS): $(gnulib_headers)
121 # Supporting rules for gettext.
122 include $(top_srcdir)/common/snippet/gettext.mk
124 EXTRA_DIST += po/$(PACKAGE).pot
125 MAINTAINERCLEANFILES += po/$(PACKAGE).pot
127 XGETTEXT_OPTS = -D $(builddir) -D $(srcdir) --from-code=utf-8 \
128 --add-comments=TRANSLATORS: --foreign-user \
129 --package-name=$(PACKAGE) --package-version=$(PACKAGE_VERSION) \
130 --msgid-bugs-address=$(PACKAGE_BUGREPORT) \
131 --keyword=_ --keyword=N_ --keyword=PN_:1c,2
133 po/$(PACKAGE).pot: $(SOURCES)
134 $(AM_V_at) $(MKDIR_P) $(@D)
135 $(AM_V_GEN) $(XGETTEXT) $(XGETTEXT_OPTS) -o $@.tmp $(SOURCES)
136 $(AM_V_at) mv -f $@.tmp $@
138 # These are required to prevent the builtin lex/yacc rules from
139 # superseding ours...
140 src/scan.c src/scan.h: src/scan.stamp
141 src/parse.c src/parse.h: src/parse.stamp
143 # The flex/bison rules refrain from updating unchanged headers for the
144 # convenience of developers, but the headers must be distributed with
145 # up-to-date timestamps, otherwise make will try to update them in a fresh
147 dist-hook: update-headers
148 update-headers: unfuck-distdir
149 touch -c '$(distdir)/src/scan.h'
150 touch -c '$(distdir)/src/parse.h'
151 .PHONY: update-headers
153 # When running "make dist" in a VPATH build with a read-only srcdir, Automake
154 # will produce a distribution with all files read-only. Moreover, the files
155 # are read-only in distdir when the dist hooks are run. This hook will
156 # manually fix up the permissions. All dist hooks that modify files in distdir
157 # should list unfuck-distdir as a prerequisite.
158 dist-hook: unfuck-distdir
160 find '$(distdir)' -type f -exec chmod u+w {} +
161 .PHONY: unfuck-distdir
163 GITLOG_FLAGS = --format='%s%n%n%b%n'
165 dist-hook: generate-changelog
166 generate-changelog: unfuck-distdir
167 -: "$${GIT_DIR=$(top_srcdir)/.git}"; \
168 export GIT_DIR; test -d "$$GIT_DIR" || exit 0; \
169 $(top_srcdir)/gitlog-to-changelog $(GITLOG_FLAGS) \
170 >'$(distdir)/ChangeLog.gen' && \
171 mv -f '$(distdir)/ChangeLog.gen' '$(distdir)/ChangeLog'
172 rm -f '$(distdir)/ChangeLog.gen'
173 .PHONY: generate-changelog
175 GENERIC_V = $(GENERIC_V_@AM_V@)
176 GENERIC_V_ = $(GENERIC_V_@AM_DEFAULT_V@)
177 GENERIC_V_0 = @printf '%2.0s%$(DX_ALIGN_V)s %s\n'
179 TEST_DISTRIBUTION = false
180 TEST_DISTRIBUTION_OR_ERROR = if $(TEST_DISTRIBUTION); \
181 then echo 'Proceeding anyway...'; \
182 else echo 'Run $(MAKE) TEST_DISTRIBUTION=true to ignore this failure.'; \
187 $(GENERIC_V) : 'CHECK ' ChangeLog; \
188 $(AWK) '/^Stub/ { print FILENAME ":" NR ":", $$0; exit 1 }' \
189 $(distdir)/ChangeLog || { \
190 echo 'ERROR: *** Packaged ChangeLog was not properly generated from git log.'; \
191 echo ' *** The source version was used instead, but this appears to'; \
192 echo ' *** be the stub from a git checkout. The "git" and "perl"'; \
193 echo ' *** programs are required for ChangeLog generation to work.'; \
194 $(TEST_DISTRIBUTION_OR_ERROR); } >&2
195 $(GENERIC_V) : 'CHECK ' NEWS; \
196 $(AWK) 'NR == 1 && $$NF != "$(PACKAGE_VERSION):" \
197 { print FILENAME ":" NR ":", $$0; exit 1}' \
198 $(distdir)/NEWS || { \
199 echo 'ERROR: *** First line of NEWS should match the package version'; \
200 echo ' *** $(PACKAGE_VERSION), but that does not appear to be the case.'; \
201 echo ' *** Remember to update NEWS before preparing a release.'; \
202 $(TEST_DISTRIBUTION_OR_ERROR); } >&2
204 OPTFILES = src/options.opt
206 $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-options.awk $< >$@.tmp
207 $(AM_V_at) mv -f $@.tmp $@
208 $(OPTFILES:.opt=.h): $(DX_BASEDIR)/scripts/gen-options.awk
209 MAINTAINERCLEANFILES += $(OPTFILES:.opt=.h)
210 EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-options.awk $(OPTFILES)
212 STRFILES = src/commands.str src/errmsg.str
214 $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-strtab.awk $< >$@.tmp
215 $(AM_V_at) mv -f $@.tmp $@
216 $(STRFILES:.str=.h): $(DX_BASEDIR)/scripts/gen-strtab.awk
217 MAINTAINERCLEANFILES += $(STRFILES:.str=.h)
218 EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-strtab.awk $(STRFILES)
220 src/cmdlist.h: src/gen-cmdlist.awk src/execute.c
221 $(AM_V_GEN) if test -f '$(builddir)/src/execute.c'; \
222 then f='$(builddir)/src/execute.c'; \
223 else f='$(srcdir)/src/execute.c'; \
224 fi; $(AWK) -f $(srcdir)/src/gen-cmdlist.awk "$$f" >$@.tmp
225 $(AM_V_at) mv -f $@.tmp $@
226 DISTCLEANFILES += src/cmdlist.h
227 EXTRA_DIST += src/gen-cmdlist.awk
229 src/specstr.h: src/gen-specstr.awk src/cdecl.h
230 $(AM_V_GEN) $(AWK) -f $(srcdir)/src/gen-specstr.awk \
231 $(srcdir)/src/cdecl.h >$@.tmp
232 $(AM_V_at) mv -f $@.tmp $@
233 DISTCLEANFILES += src/specstr.h
234 EXTRA_DIST += src/gen-specstr.awk
236 src/typemap.h: src/gen-typemap.awk src/types.lst
237 $(AM_V_GEN) $(AWK) -f $(srcdir)/src/gen-typemap.awk \
238 $(srcdir)/src/types.lst >$@.tmp
239 $(AM_V_at) mv -f $@.tmp $@
240 DISTCLEANFILES += src/typemap.h
241 EXTRA_DIST += src/gen-typemap.awk
243 t/typegen.h: t/gen-typegen.awk src/types.lst
244 $(AM_V_GEN) $(AWK) -f $(srcdir)/t/gen-typegen.awk \
245 $(srcdir)/src/types.lst >$@.tmp
246 $(AM_V_at) mv -f $@.tmp $@
247 DISTCLEANFILES += t/typegen.h
248 EXTRA_DIST += t/gen-typegen.awk
250 # Supporting rules for bison/flex.
252 BISON_V = $(BISON_V_@AM_V@)
253 BISON_V_ = $(BISON_V_@AM_DEFAULT_V@)
254 BISON_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'BISON ' $<;
256 FLEX_V = $(FLEX_V_@AM_V@)
257 FLEX_V_ = $(FLEX_V_@AM_DEFAULT_V@)
258 FLEX_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'FLEX ' $<;
261 echo "ERROR: *** $$tool is missing on your system."; \
262 echo " *** Because of this, I cannot compile $$toolsrc, but"; \
263 echo " *** (perhaps because you modified it) the sources appear out"; \
264 echo " *** of date. If $$tool is installed but was not detected by"; \
265 echo " *** configure, consired setting $$toolvar and re-running configure."; \
266 echo " *** See config.log for more details."; } >&2; false
271 $(BISON_V)tool=bison toolvar=BISON toolsrc=$<; $(DEV_TOOL_ERROR)
273 $(AM_V_at) touch $@.tmp
274 $(BISON_V) $(BISON) $(BISON_COMPAT) -o $*.c --defines=$*.h.tmp $(BISONFLAGS) $<
275 $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
278 mv -f $*.h.tmp $*.h; \
280 $(AM_V_at) mv -f $@.tmp $@
285 $(FLEX_V)tool=flex toolvar=FLEX toolsrc=$<; $(DEV_TOOL_ERROR)
287 $(AM_V_at) touch $@.tmp
288 $(FLEX_V) $(FLEX) -o $*.c --header-file=$*.h.tmp $(FLEXFLAGS) $<
289 $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
292 mv -f $*.h.tmp $*.h; \
294 $(AM_V_at) mv -f $@.tmp $@
297 @if test -f $@; then :; else \
299 $(MAKE) $(AM_MAKEFLAGS) $<; \
303 @if test -f $@; then :; else \
305 $(MAKE) $(AM_MAKEFLAGS) $<; \
309 V_GPERF = $(V_GPERF_@AM_V@)
310 V_GPERF_ = $(V_GPERF_@AM_DEFAULT_V@)
311 V_GPERF_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'GPERF ' $@;
313 GPERFFILES = src/execute.gperf
315 $(V_GPERF) $(GPERF) $< >$@.tmp
316 $(AM_V_at) mv $@.tmp $@
317 MAINTAINERCLEANFILES += $(GPERFFILES:.gperf=.c)
318 EXTRA_DIST += $(GPERFFILES)
320 atlocal: config.status
322 printf ': "$${%s=%s}"\n' \
325 check_PROGRAMS '$(check_PROGRAMS)' \
327 $(AM_V_at) mv -f $@.tmp $@
329 CLEANFILES += atlocal
331 include $(top_srcdir)/lib/gnulib.mk
332 include $(top_srcdir)/common/snippet/glconfig.mk
333 include $(top_srcdir)/common/snippet/autotest.mk