]> git.draconx.ca Git - cdecl99.git/blob - Makefile.am
031c0a83ec9629ad74060a637bd2fea29f723abe
[cdecl99.git] / Makefile.am
1 # Copyright © 2011-2013, 2019-2023 Nick Bowler
2 #
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.
6
7 ACLOCAL_AMFLAGS = -I m4 -I common/m4
8
9 # For Gnulib
10 MOSTLYCLEANFILES =
11 EXTRA_LTLIBRARIES =
12
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)\"
18
19 MAINTAINERCLEANFILES = src/scan.c src/scan.h src/scan.stamp \
20                        src/parse.c src/parse.h src/parse.stamp
21
22 DISTCLEANFILES =
23
24 CLEANFILES = $(EXTRA_LTLIBRARIES) $(EXTRA_LIBRARIES)
25
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
29
30 dist_man_MANS = doc/cdecl99.1 doc/libcdecl.3
31
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
35
36 noinst_DATA = $(MOFILES)
37
38 shared_gl_objects = $(gnulib_symfiles:.glsym=.lo)
39 static_gl_objects = $(gnulib_extra_objects:.lo=.@OBJEXT@)
40
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)
50
51 EXTRA_LIBRARIES = libgnu.a
52 libgnu_a_SOURCES =
53 libgnu_a_SHORTNAME = s
54 libgnu_a_CFLAGS = $(AM_CFLAGS)
55 libgnu_a_LIBADD = $(static_gl_objects)
56 EXTRA_libgnu_a_SOURCES = $(libgnu_la_SOURCES) $(EXTRA_libgnu_la_SOURCES)
57
58 EXTRA_libgnu_a_DEPENDENCIES = $(static_gl_objects)
59 dummy $(static_gl_objects): $(gnulib_headers)
60
61 bin_PROGRAMS = cdecl99
62 cdecl99_SOURCES = common/src/help.c src/commands.c src/cdecl99.h
63 EXTRA_cdecl99_DEPENDENCIES = $(libmain_a_OBJECTS) $(libexec_a_OBJECTS)
64 cdecl99_LDADD = $(EXTRA_cdecl99_DEPENDENCIES) libcdecl.la libgnu.a \
65                 $(LTLIBINTL) $(LTLIBREADLINE)
66 $(cdecl99_OBJECTS): $(gnulib_headers)
67
68 if USE_NLS
69 cdecl99_SOURCES += common/src/copysym.c common/src/copysym.h
70 endif
71
72 EXTRA_LIBRARIES += libexec.a
73 libexec_a_SOURCES = src/execute.c src/commands.h
74 $(libexec_a_OBJECTS): $(gnulib_headers)
75 $(libexec_a_OBJECTS): src/commands.h src/cmdlist.h
76
77 EXTRA_LIBRARIES += libmain.a
78 libmain_a_SOURCES = src/cdecl99.c src/options.h
79 $(libmain_a_OBJECTS): $(gnulib_headers)
80 $(libmain_a_OBJECTS): src/options.h
81
82 check_PROGRAMS = t/crossparse t/normalize t/randomdecl t/rng-test
83 check_LIBRARIES = libtest.a
84 libtest_a_SOURCES = t/testlib.c t/rng.c common/src/help.c
85 $(libtest_a_OBJECTS): $(gnulib_headers)
86
87 TEST_LIBS = libtest.a libcdecl.la libgnu.a $(LDEXP_LIBM)
88
89 t_randomdecl_SOURCES = t/randomdecl.c t/declgen.c
90 t_randomdecl_LDADD = $(TEST_LIBS)
91 $(t_randomdecl_OBJECTS): $(gnulib_headers)
92
93 t_crossparse_LDADD = $(TEST_LIBS)
94 $(t_crossparse_OBJECTS): $(gnulib_headers)
95
96 t_normalize_LDADD = src/normalize.lo $(TEST_LIBS)
97 $(t_normalize_OBJECTS): $(gnulib_headers)
98
99 t_rng_test_LDADD = $(TEST_LIBS)
100 $(t_rng_test_OBJECTS): $(gnulib_headers)
101 EXTRA_DIST += t/xos256p.c
102
103 src/parse.lo: src/scan.h src/errmsg.h
104 src/scan.lo: src/parse.h src/errmsg.h
105 src/parse-decl.lo: src/scan.h src/parse.h src/typemap.h src/errmsg.h
106 src/output.lo: src/specstr.h
107 src/error.lo: src/errmsg.h
108 t/declgen.$(OBJEXT): t/typegen.h
109 t/cdeclerr.$(OBJEXT): src/errmsg.h
110
111 check_PROGRAMS += t/cdeclerr
112 t_cdeclerr_SOURCES = common/src/tap.c t/cdeclerr.c
113 EXTRA_t_cdeclerr_DEPENDENCIES = src/error.lo $(shared_gl_objects)
114 t_cdeclerr_LDADD = $(EXTRA_t_cdeclerr_DEPENDENCIES) $(LIBTHREAD)
115 $(t_cdeclerr_OBJECTS): $(gnulib_headers)
116
117 # Supporting rules for gettext.
118 include $(top_srcdir)/common/snippet/gettext.mk
119
120 EXTRA_DIST += po/$(PACKAGE).pot
121 MAINTAINERCLEANFILES += po/$(PACKAGE).pot
122
123 XGETTEXT_OPTS = -D $(builddir) -D $(srcdir) --from-code=utf-8 \
124         --add-comments=TRANSLATORS: --foreign-user \
125         --package-name=$(PACKAGE) --package-version=$(PACKAGE_VERSION) \
126         --msgid-bugs-address=$(PACKAGE_BUGREPORT) \
127         --keyword=_ --keyword=N_ --keyword=PN_:1c,2
128
129 po/$(PACKAGE).pot: $(SOURCES)
130         $(AM_V_at)  $(MKDIR_P) $(@D)
131         $(AM_V_GEN) $(XGETTEXT) $(XGETTEXT_OPTS) -o $@.tmp $(SOURCES)
132         $(AM_V_at)  mv -f $@.tmp $@
133
134 # These are required to prevent the builtin lex/yacc rules from
135 # superseding ours...
136 src/scan.c src/scan.h: src/scan.stamp
137 src/parse.c src/parse.h: src/parse.stamp
138
139 # The flex/bison rules refrain from updating unchanged headers for the
140 # convenience of developers, but the headers must be distributed with
141 # up-to-date timestamps, otherwise make will try to update them in a fresh
142 # VPATH build.
143 dist-hook: update-headers
144 update-headers: unfuck-distdir
145         touch -c '$(distdir)/src/scan.h'
146         touch -c '$(distdir)/src/parse.h'
147 .PHONY: update-headers
148
149 # When running "make dist" in a VPATH build with a read-only srcdir, Automake
150 # will produce a distribution with all files read-only.  Moreover, the files
151 # are read-only in distdir when the dist hooks are run.  This hook will
152 # manually fix up the permissions.  All dist hooks that modify files in distdir
153 # should list unfuck-distdir as a prerequisite.
154 dist-hook: unfuck-distdir
155 unfuck-distdir:
156         find '$(distdir)' -type f -exec chmod u+w {} +
157 .PHONY: unfuck-distdir
158
159 GITLOG_FLAGS = --format='%s%n%n%b%n'
160
161 dist-hook: generate-changelog
162 generate-changelog: unfuck-distdir
163         -: "$${GIT_DIR=$(top_srcdir)/.git}"; \
164           export GIT_DIR; test -d "$$GIT_DIR" || exit 0; \
165           $(top_srcdir)/gitlog-to-changelog $(GITLOG_FLAGS) \
166             >'$(distdir)/ChangeLog.gen' && \
167           mv -f '$(distdir)/ChangeLog.gen' '$(distdir)/ChangeLog'
168         rm -f '$(distdir)/ChangeLog.gen'
169 .PHONY: generate-changelog
170
171 GENERIC_V   = $(GENERIC_V_@AM_V@)
172 GENERIC_V_  = $(GENERIC_V_@AM_DEFAULT_V@)
173 GENERIC_V_0 = @printf '%2.0s%$(DX_ALIGN_V)s %s\n'
174
175 TEST_DISTRIBUTION = false
176 TEST_DISTRIBUTION_OR_ERROR = if $(TEST_DISTRIBUTION); \
177   then echo 'Proceeding anyway...'; \
178   else echo 'Run $(MAKE) TEST_DISTRIBUTION=true to ignore this failure.'; \
179        false; \
180   fi
181
182 distcheck-hook:
183         $(GENERIC_V) : 'CHECK   ' ChangeLog; \
184           $(AWK) '/^Stub/ { print FILENAME ":" NR ":", $$0; exit 1 }' \
185             $(distdir)/ChangeLog || { \
186               echo 'ERROR: *** Packaged ChangeLog was not properly generated from git log.'; \
187               echo '       *** The source version was used instead, but this appears to'; \
188               echo '       *** be the stub from a git checkout.  The "git" and "perl"'; \
189               echo '       *** programs are required for ChangeLog generation to work.'; \
190               $(TEST_DISTRIBUTION_OR_ERROR); } >&2
191         $(GENERIC_V) : 'CHECK   ' NEWS; \
192           $(AWK) 'NR == 1 && $$NF != "$(PACKAGE_VERSION):" \
193             { print FILENAME ":" NR ":", $$0; exit 1}' \
194             $(distdir)/NEWS || { \
195               echo 'ERROR: *** First line of NEWS should match the package version'; \
196               echo '       *** $(PACKAGE_VERSION), but that does not appear to be the case.'; \
197               echo '       *** Remember to update NEWS before preparing a release.'; \
198               $(TEST_DISTRIBUTION_OR_ERROR); } >&2
199
200 OPTFILES = src/options.opt
201 .opt.h:
202         $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-options.awk $< >$@.tmp
203         $(AM_V_at) mv -f $@.tmp $@
204 $(OPTFILES:.opt=.h): $(DX_BASEDIR)/scripts/gen-options.awk
205 MAINTAINERCLEANFILES += $(OPTFILES:.opt=.h)
206 EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-options.awk $(OPTFILES)
207
208 STRFILES = src/commands.str src/errmsg.str
209 .str.h:
210         $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-strtab.awk $< >$@.tmp
211         $(AM_V_at) mv -f $@.tmp $@
212 $(STRFILES:.str=.h): $(DX_BASEDIR)/scripts/gen-strtab.awk
213 MAINTAINERCLEANFILES += $(STRFILES:.str=.h)
214 EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-strtab.awk $(STRFILES)
215
216 src/cmdlist.h: src/gen-cmdlist.awk src/execute.c
217         $(AM_V_GEN) if test -f '$(builddir)/src/execute.c'; \
218           then f='$(builddir)/src/execute.c'; \
219           else f='$(srcdir)/src/execute.c'; \
220           fi; $(AWK) -f $(srcdir)/src/gen-cmdlist.awk "$$f" >$@.tmp
221         $(AM_V_at) mv -f $@.tmp $@
222 DISTCLEANFILES += src/cmdlist.h
223 EXTRA_DIST += src/gen-cmdlist.awk
224
225 src/specstr.h: src/gen-specstr.awk src/cdecl.h
226         $(AM_V_GEN) $(AWK) -f $(srcdir)/src/gen-specstr.awk \
227                               $(srcdir)/src/cdecl.h >$@.tmp
228         $(AM_V_at) mv -f $@.tmp $@
229 DISTCLEANFILES += src/specstr.h
230 EXTRA_DIST += src/gen-specstr.awk
231
232 src/typemap.h: src/gen-typemap.awk src/types.lst
233         $(AM_V_GEN) $(AWK) -f $(srcdir)/src/gen-typemap.awk \
234                               $(srcdir)/src/types.lst >$@.tmp
235         $(AM_V_at) mv -f $@.tmp $@
236 DISTCLEANFILES += src/typemap.h
237 EXTRA_DIST += src/gen-typemap.awk
238
239 t/typegen.h: t/gen-typegen.awk src/types.lst
240         $(AM_V_GEN) $(AWK) -f $(srcdir)/t/gen-typegen.awk \
241                               $(srcdir)/src/types.lst >$@.tmp
242         $(AM_V_at) mv -f $@.tmp $@
243 DISTCLEANFILES += t/typegen.h
244 EXTRA_DIST += t/gen-typegen.awk
245
246 # Supporting rules for bison/flex.
247
248 BISON_V   = $(BISON_V_@AM_V@)
249 BISON_V_  = $(BISON_V_@AM_DEFAULT_V@)
250 BISON_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'BISON   ' $<;
251
252 FLEX_V   = $(FLEX_V_@AM_V@)
253 FLEX_V_  = $(FLEX_V_@AM_DEFAULT_V@)
254 FLEX_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'FLEX    ' $<;
255
256 DEV_TOOL_ERROR = { \
257   echo "ERROR: *** $$tool is missing on your system."; \
258   echo "       *** Because of this, I cannot compile $$toolsrc, but"; \
259   echo "       *** (perhaps because you modified it) the sources appear out"; \
260   echo "       *** of date.  If $$tool is installed but was not detected by"; \
261   echo "       *** configure, consired setting $$toolvar and re-running configure."; \
262   echo "       *** See config.log for more details."; } >&2; false
263
264 .y.c: ;
265 .y.stamp:
266 if !HAVE_BISON
267         $(BISON_V)tool=bison toolvar=BISON toolsrc=$<; $(DEV_TOOL_ERROR)
268 endif
269         $(AM_V_at) touch $@.tmp
270         $(BISON_V) $(BISON) $(BISON_COMPAT) -o $*.c --defines=$*.h.tmp $(BISONFLAGS) $<
271         $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
272                 rm -f $*.h.tmp; \
273         else \
274                 mv -f $*.h.tmp $*.h; \
275         fi
276         $(AM_V_at) mv -f $@.tmp $@
277
278 .l.c: ;
279 .l.stamp:
280 if !HAVE_FLEX
281         $(FLEX_V)tool=flex toolvar=FLEX toolsrc=$<; $(DEV_TOOL_ERROR)
282 endif
283         $(AM_V_at) touch $@.tmp
284         $(FLEX_V) $(FLEX) -o $*.c --header-file=$*.h.tmp $(FLEXFLAGS) $<
285         $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
286                 rm -f $*.h.tmp; \
287         else \
288                 mv -f $*.h.tmp $*.h; \
289         fi
290         $(AM_V_at) mv -f $@.tmp $@
291
292 .stamp.c:
293         @if test -f $@; then :; else \
294                 rm -f $<; \
295                 $(MAKE) $(AM_MAKEFLAGS) $<; \
296         fi
297
298 .stamp.h:
299         @if test -f $@; then :; else \
300                 rm -f $<; \
301                 $(MAKE) $(AM_MAKEFLAGS) $<; \
302         fi
303
304 GPERF     = gperf
305 V_GPERF   = $(V_GPERF_@AM_V@)
306 V_GPERF_  = $(V_GPERF_@AM_DEFAULT_V@)
307 V_GPERF_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'GPERF   ' $@;
308
309 GPERFFILES = src/execute.gperf
310 .gperf.c:
311         $(V_GPERF) $(GPERF) $< >$@.tmp
312         $(AM_V_at) mv $@.tmp $@
313 MAINTAINERCLEANFILES += $(GPERFFILES:.gperf=.c)
314 EXTRA_DIST += $(GPERFFILES)
315
316 atlocal: config.status
317         $(AM_V_GEN) :; { \
318           printf ': "$${%s=%s}"\n' \
319             AWK '$(AWK)' \
320             EXEEXT '$(EXEEXT)' \
321             check_PROGRAMS '$(check_PROGRAMS)' \
322             ; } >$@.tmp
323         $(AM_V_at) mv -f $@.tmp $@
324 check_DATA = atlocal
325 CLEANFILES += atlocal
326
327 include $(top_srcdir)/lib/gnulib.mk
328 include $(top_srcdir)/common/snippet/glconfig.mk
329 include $(top_srcdir)/common/snippet/autotest.mk