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