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 \
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 test/typegen.sh src/parse.y src/parse.stamp \
32 src/scan.l src/scan.stamp COPYING.WTFPL2 README.md INSTALL
34 dist_man_MANS = doc/man/cdecl99.1 doc/man/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 test/typegen.h: $(srcdir)/src/types.lst $(srcdir)/test/typegen.sh
110 $(AM_V_GEN) $(SHELL) $(srcdir)/test/typegen.sh \
111 < $(srcdir)/src/types.lst > $@.tmp
112 $(AM_V_at)mv -f $@.tmp $@
114 # Supporting rules for gettext.
115 include $(top_srcdir)/common/snippet/gettext.mk
117 EXTRA_DIST += po/$(PACKAGE).pot
118 MAINTAINERCLEANFILES += po/$(PACKAGE).pot
120 XGETTEXT_OPTS = -D $(builddir) -D $(srcdir) --from-code=utf-8 \
121 --add-comments=TRANSLATORS: --foreign-user \
122 --package-name=$(PACKAGE) --package-version=$(PACKAGE_VERSION) \
123 --msgid-bugs-address=$(PACKAGE_BUGREPORT) \
124 --keyword=_ --keyword=N_ --keyword=PN_:1c,2
126 po/$(PACKAGE).pot: $(SOURCES)
127 $(AM_V_at) $(MKDIR_P) $(@D)
128 $(AM_V_GEN) $(XGETTEXT) $(XGETTEXT_OPTS) -o $@.tmp $(SOURCES)
129 $(AM_V_at) mv -f $@.tmp $@
131 # These are required to prevent the builtin lex/yacc rules from
132 # superseding ours...
133 src/scan.c src/scan.h: src/scan.stamp
134 src/parse.c src/parse.h: src/parse.stamp
136 # The flex/bison rules refrain from updating unchanged headers for the
137 # convenience of developers, but the headers must be distributed with
138 # up-to-date timestamps, otherwise make will try to update them in a fresh
140 dist-hook: update-headers
141 update-headers: unfuck-distdir
142 touch -c '$(distdir)/src/scan.h'
143 touch -c '$(distdir)/src/parse.h'
144 .PHONY: update-headers
146 # When running "make dist" in a VPATH build with a read-only srcdir, Automake
147 # will produce a distribution with all files read-only. Moreover, the files
148 # are read-only in distdir when the dist hooks are run. This hook will
149 # manually fix up the permissions. All dist hooks that modify files in distdir
150 # should list unfuck-distdir as a prerequisite.
151 dist-hook: unfuck-distdir
153 find '$(distdir)' -type f -exec chmod u+w {} +
154 .PHONY: unfuck-distdir
156 GITLOG_FLAGS = --format='%s%n%n%b%n'
158 dist-hook: generate-changelog
159 generate-changelog: unfuck-distdir
160 -: "$${GIT_DIR=$(top_srcdir)/.git}"; \
161 export GIT_DIR; test -d "$$GIT_DIR" || exit 0; \
162 $(top_srcdir)/gitlog-to-changelog $(GITLOG_FLAGS) \
163 >'$(distdir)/ChangeLog.gen' && \
164 mv -f '$(distdir)/ChangeLog.gen' '$(distdir)/ChangeLog'
165 rm -f '$(distdir)/ChangeLog.gen'
166 .PHONY: generate-changelog
168 GENERIC_V = $(GENERIC_V_@AM_V@)
169 GENERIC_V_ = $(GENERIC_V_@AM_DEFAULT_V@)
170 GENERIC_V_0 = @printf '%2.0s%$(DX_ALIGN_V)s %s\n'
172 TEST_DISTRIBUTION = false
173 TEST_DISTRIBUTION_OR_ERROR = if $(TEST_DISTRIBUTION); \
174 then echo 'Proceeding anyway...'; \
175 else echo 'Run $(MAKE) TEST_DISTRIBUTION=true to ignore this failure.'; \
180 $(GENERIC_V) : 'CHECK ' ChangeLog; \
181 $(AWK) '/^Stub/ { print FILENAME ":" NR ":", $$0; exit 1 }' \
182 $(distdir)/ChangeLog || { \
183 echo 'ERROR: *** Packaged ChangeLog was not properly generated from git log.'; \
184 echo ' *** The source version was used instead, but this appears to'; \
185 echo ' *** be the stub from a git checkout. The "git" and "perl"'; \
186 echo ' *** programs are required for ChangeLog generation to work.'; \
187 $(TEST_DISTRIBUTION_OR_ERROR); } >&2
188 $(GENERIC_V) : 'CHECK ' NEWS; \
189 $(AWK) 'NR == 1 && $$NF != "$(PACKAGE_VERSION):" \
190 { print FILENAME ":" NR ":", $$0; exit 1}' \
191 $(distdir)/NEWS || { \
192 echo 'ERROR: *** First line of NEWS should match the package version'; \
193 echo ' *** $(PACKAGE_VERSION), but that does not appear to be the case.'; \
194 echo ' *** Remember to update NEWS before preparing a release.'; \
195 $(TEST_DISTRIBUTION_OR_ERROR); } >&2
197 OPTFILES = src/options.opt
199 $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-options.awk $< >$@.tmp
200 $(AM_V_at) mv -f $@.tmp $@
201 $(OPTFILES:.opt=.h): $(DX_BASEDIR)/scripts/gen-options.awk
202 MAINTAINERCLEANFILES += $(OPTFILES:.opt=.h)
203 EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-options.awk $(OPTFILES)
205 STRFILES = src/commands.str src/errtab.str
207 $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-strtab.awk $< >$@.tmp
208 $(AM_V_at) mv -f $@.tmp $@
209 $(STRFILES:.str=.h): $(DX_BASEDIR)/scripts/gen-strtab.awk
210 MAINTAINERCLEANFILES += $(STRFILES:.str=.h)
211 EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-strtab.awk $(STRFILES)
213 src/cmdlist.h: src/gen-cmdlist.awk src/execute.c
214 $(AM_V_GEN) if test -f '$(builddir)/src/execute.c'; \
215 then f='$(builddir)/src/execute.c'; \
216 else f='$(srcdir)/src/execute.c'; \
217 fi; $(AWK) -f $(srcdir)/src/gen-cmdlist.awk "$$f" >$@.tmp
218 $(AM_V_at) mv -f $@.tmp $@
219 DISTCLEANFILES += src/cmdlist.h
220 EXTRA_DIST += src/gen-cmdlist.awk
222 # Supporting rules for bison/flex.
224 BISON_V = $(BISON_V_@AM_V@)
225 BISON_V_ = $(BISON_V_@AM_DEFAULT_V@)
226 BISON_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'BISON ' $<;
228 FLEX_V = $(FLEX_V_@AM_V@)
229 FLEX_V_ = $(FLEX_V_@AM_DEFAULT_V@)
230 FLEX_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'FLEX ' $<;
233 echo "ERROR: *** $$tool is missing on your system."; \
234 echo " *** Because of this, I cannot compile $$toolsrc, but"; \
235 echo " *** (perhaps because you modified it) the sources appear out"; \
236 echo " *** of date. If $$tool is installed but was not detected by"; \
237 echo " *** configure, consired setting $$toolvar and re-running configure."; \
238 echo " *** See config.log for more details."; } >&2; false
243 $(BISON_V)tool=bison toolvar=BISON toolsrc=$<; $(DEV_TOOL_ERROR)
245 $(AM_V_at) touch $@.tmp
246 $(BISON_V) $(BISON) $(BISON_COMPAT) -o $*.c --defines=$*.h.tmp $(BISONFLAGS) $<
247 $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
250 mv -f $*.h.tmp $*.h; \
252 $(AM_V_at) mv -f $@.tmp $@
257 $(FLEX_V)tool=flex toolvar=FLEX toolsrc=$<; $(DEV_TOOL_ERROR)
259 $(AM_V_at) touch $@.tmp
260 $(FLEX_V) $(FLEX) -o $*.c --header-file=$*.h.tmp $(FLEXFLAGS) $<
261 $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
264 mv -f $*.h.tmp $*.h; \
266 $(AM_V_at) mv -f $@.tmp $@
269 @if test -f $@; then :; else \
271 $(MAKE) $(AM_MAKEFLAGS) $<; \
275 @if test -f $@; then :; else \
277 $(MAKE) $(AM_MAKEFLAGS) $<; \
280 GPERFFILES = src/execute.gperf
282 $(V_GPERF) $(GPERF) $< >$@.tmp
283 $(AM_V_at) mv $@.tmp $@
284 MAINTAINERCLEANFILES += $(GPERFFILES:.gperf=.c)
285 EXTRA_DIST += $(GPERFFILES)
287 atlocal: config.status
289 printf ': "$${%s=%s}"\n' \
291 check_PROGRAMS '$(check_PROGRAMS)' \
293 $(AM_V_at) mv -f $@.tmp $@
295 CLEANFILES += atlocal
297 include $(top_srcdir)/lib/gnulib.mk
298 include $(top_srcdir)/common/snippet/glconfig.mk
299 include $(top_srcdir)/common/snippet/autotest.mk