]> git.draconx.ca Git - cdecl99.git/blob - Makefile.am
Update .gitignore.
[cdecl99.git] / Makefile.am
1 # Copyright © 2011-2013,2019 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 AUTOMAKE_OPTIONS = parallel-tests color-tests
8 ACLOCAL_AMFLAGS = -I m4 -I common/m4
9
10 # For Gnulib
11 MOSTLYCLEANFILES =
12 noinst_LTLIBRARIES =
13
14 AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
15         -I$(top_builddir)/lib -I$(top_srcdir)/lib \
16         -I$(top_builddir)/test \
17         -DBISON_LOCALEDIR=\"$(BISON_LOCALEDIR)\" \
18         -DLOCALEDIR=\"$(localedir)\"
19
20 AM_CFLAGS = $(GSL_CFLAGS)
21
22 MAINTAINERCLEANFILES = src/scan.c src/scan.h src/scan.stamp \
23         src/parse.c src/parse.h src/parse.stamp
24
25 DISTCLEANFILES =
26
27 CLEANFILES = src/validtypes.h src/errtab.h src/namespecs.h src/ordspecs.h \
28         test/typegen.h
29
30 EXTRA_DIST = m4/gnulib-cache.m4 src/types.lst src/validtypes.sed \
31         src/specs.lst src/namespecs.sed src/ordspecs.sed \
32         src/errors.lst src/strtab.sed test/typegen.sh \
33         src/parse.y src/parse.stamp src/scan.l src/scan.stamp \
34         COPYING.WTFPL2
35
36 dist_man_MANS = doc/man/cdecl99.1 doc/man/libcdecl.3
37
38 include_HEADERS = src/cdecl.h
39 noinst_HEADERS = conf_pre.h conf_post.h src/typemap.h src/output.h src/scan.h \
40         src/parse.h src/i18n.h src/normalize.h src/error.h src/history.h \
41         test/declgen.h test/test.h
42
43 noinst_DATA = $(MOFILES)
44
45 lib_LTLIBRARIES = libcdecl.la
46 libcdecl_la_LDFLAGS = -no-undefined \
47         -export-symbols-regex '^cdecl_[[:lower:]]'
48 libcdecl_la_SOURCES = src/scan.c src/parse.c src/parse-decl.c src/typemap.c \
49         src/output.c src/explain.c src/declare.c src/i18n.c src/error.c \
50         src/normalize.c
51 libcdecl_la_LIBADD = libgnu.la $(LTLIBINTL) $(LTLIBTHREAD)
52 $(libcdecl_la_OBJECTS): $(gnulib_headers)
53
54 bin_PROGRAMS = cdecl99
55 cdecl99_SOURCES = src/cdecl99.c
56 cdecl99_LDADD = libcdecl.la libgnu.la $(LTLIBINTL) $(LTLIBREADLINE)
57 $(cdecl99_OBJECTS): $(gnulib_headers)
58
59 check_PROGRAMS = test/crossparse
60 check_LTLIBRARIES = libtest.la
61 libtest_la_LIBADD = $(GSL_LIBS)
62 libtest_la_SOURCES = test/testlib.c
63 $(libtest_la_OBJECTS): $(gnulib_headers)
64
65 if HAVE_GSL
66 libtest_la_SOURCES += test/declgen.c
67 check_PROGRAMS += test/randomdecl
68 endif
69
70 test_crossparse_LDADD = libcdecl.la libtest.la libgnu.la
71 $(test_crossparse_OBJECTS): $(gnulib_headers)
72 test_randomdecl_LDADD = libcdecl.la libtest.la libgnu.la
73 $(test_randomdecl_OBJECTS): $(gnulib_headers)
74
75 TESTS_ENVIRONMENT = SHELL='$(SHELL)' LIBTOOL='$(LIBTOOL)' EXEEXT='$(EXEEXT)'
76 TEST_EXTENSIONS = .sh
77 SH_LOG_COMPILER = $(SHELL)
78
79 TESTS = tests/libcdecl-static-symbols.sh tests/randomdecl-sanity.sh \
80         tests/crossparse-c-random.sh tests/cdecl99-c-invalid.sh
81
82 dist_check_SCRIPTS = tests/randomdecl-sanity.sed $(TESTS)
83
84 src/parse.lo: src/scan.h
85 src/scan.lo: src/parse.h
86 src/parse-decl.lo: src/scan.h src/parse.h
87 src/typemap.lo: src/validtypes.h
88 src/error.lo: src/errtab.h
89 src/normalize.lo: src/ordspecs.h
90 src/output.lo: src/namespecs.h
91 test/declgen.lo: test/typegen.h
92
93 src/validtypes.h: $(srcdir)/src/types.lst $(srcdir)/src/validtypes.sed
94         $(AM_V_GEN)sed -f $(srcdir)/src/validtypes.sed \
95                 < $(srcdir)/src/types.lst > $@.tmp
96         $(AM_V_at)mv -f $@.tmp $@
97
98 src/namespecs.h: $(srcdir)/src/specs.lst $(srcdir)/src/namespecs.sed
99         $(AM_V_GEN) sed -f $(srcdir)/src/namespecs.sed \
100                 < $(srcdir)/src/specs.lst > $@.tmp
101         $(AM_V_at) mv -f $@.tmp $@
102
103 src/ordspecs.h: $(srcdir)/src/specs.lst $(srcdir)/src/ordspecs.sed
104         $(AM_V_GEN) sed -f $(srcdir)/src/ordspecs.sed \
105                 < $(srcdir)/src/specs.lst > $@.tmp
106         $(AM_V_at) mv -f $@.tmp $@
107
108 src/errtab.h: $(srcdir)/src/errors.lst $(srcdir)/src/strtab.sed
109         $(AM_V_GEN)sed -f $(srcdir)/src/strtab.sed \
110                 < $(srcdir)/src/errors.lst > $@.tmp
111         $(AM_V_at)mv -f $@.tmp $@
112
113 test/typegen.h: $(srcdir)/src/types.lst $(srcdir)/test/typegen.sh
114         $(AM_V_GEN) $(SHELL) $(srcdir)/test/typegen.sh \
115                 < $(srcdir)/src/types.lst > $@.tmp
116         $(AM_V_at)mv -f $@.tmp $@
117
118 # Supporting rules for gettext.
119 include $(top_srcdir)/common/snippet/gettext.mk
120
121 EXTRA_DIST += po/$(PACKAGE).pot
122 MAINTAINERCLEANFILES += po/$(PACKAGE).pot
123
124 XGETTEXT_OPTS = -D $(builddir) -D $(srcdir) --from-code=utf-8 \
125         --add-comments=TRANSLATORS: --foreign-user \
126         --package-name=$(PACKAGE) --package-version=$(PACKAGE_VERSION) \
127         --msgid-bugs-address=$(PACKAGE_BUGREPORT) \
128         --keyword=_ --keyword=N_ --keyword=PN_:1c,2
129
130 po/$(PACKAGE).pot: $(SOURCES) src/errors.lst
131         $(AM_V_at)  $(MKDIR_P) $(@D)
132         $(AM_V_GEN) $(XGETTEXT) $(XGETTEXT_OPTS) -o $@.tmp $(SOURCES)
133         $(AM_V_at)  $(XGETTEXT) $(XGETTEXT_OPTS) --omit-header -Lc \
134                 -ajo $@.tmp src/errors.lst
135         $(AM_V_at)  mv -f $@.tmp $@
136
137 # These are required to prevent the builtin lex/yacc rules from
138 # superseding ours...
139 src/scan.c src/scan.h: src/scan.stamp
140 src/parse.c src/parse.h: src/parse.stamp
141
142 # The flex/bison rules refrain from updating unchanged headers for the
143 # convenience of developers, but the headers must be distributed with
144 # up-to-date timestamps, otherwise make will try to update them in a fresh
145 # VPATH build.
146 dist-hook: update-headers
147 update-headers: unfuck-distdir
148         touch -c '$(distdir)/src/scan.h'
149         touch -c '$(distdir)/src/parse.h'
150 .PHONY: update-headers
151
152 # When running "make dist" in a VPATH build with a read-only srcdir, Automake
153 # will produce a distribution with all files read-only.  Moreover, the files
154 # are read-only in distdir when the dist hooks are run.  This hook will
155 # manually fix up the permissions.  All dist hooks that modify files in distdir
156 # should list unfuck-distdir as a prerequisite.
157 dist-hook: unfuck-distdir
158 unfuck-distdir:
159         find '$(distdir)' -type f -exec chmod u+w {} +
160 .PHONY: unfuck-distdir
161
162 # Supporting rules for bison/flex.
163
164 BISON_V   = $(BISON_V_@AM_V@)
165 BISON_V_  = $(BISON_V_@AM_DEFAULT_V@)
166 BISON_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'BISON   ' $<;
167
168 FLEX_V   = $(FLEX_V_@AM_V@)
169 FLEX_V_  = $(FLEX_V_@AM_DEFAULT_V@)
170 FLEX_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'FLEX    ' $<;
171
172 .y.c: ;
173 .l.c: ;
174
175 .y.stamp:
176         $(AM_V_at) touch $@.tmp
177         $(BISON_V) $(BISON) -o $*.c --defines=$*.h.tmp $(BISONFLAGS) $<
178         $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
179                 rm -f $*.h.tmp; \
180         else \
181                 mv -f $*.h.tmp $*.h; \
182         fi
183         $(AM_V_at) mv -f $@.tmp $@
184
185 .l.stamp:
186         $(AM_V_at) touch $@.tmp
187         $(FLEX_V) $(FLEX) -o $*.c --header-file=$*.h.tmp $(FLEXFLAGS) $<
188         $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
189                 rm -f $*.h.tmp; \
190         else \
191                 mv -f $*.h.tmp $*.h; \
192         fi
193         $(AM_V_at) mv -f $@.tmp $@
194
195 .stamp.c:
196         @if test -f $@; then :; else \
197                 rm -f $<; \
198                 $(MAKE) $(AM_MAKEFLAGS) $<; \
199         fi
200
201 .stamp.h:
202         @if test -f $@; then :; else \
203                 rm -f $<; \
204                 $(MAKE) $(AM_MAKEFLAGS) $<; \
205         fi
206
207 include $(top_srcdir)/lib/gnulib.mk
208 include $(top_srcdir)/common/snippet/glconfig.mk