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