1 # Copyright © 2011 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 AUTOMAKE_OPTIONS = parallel-tests color-tests
8 ACLOCAL_AMFLAGS = -I m4
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)\"
20 AM_CFLAGS = $(GSL_CFLAGS)
22 MAINTAINERCLEANFILES = src/scan.c src/scan.h src/scan.stamp \
23 src/parse.c src/parse.h src/parse.stamp
25 CLEANFILES = src/validtypes.h src/errtab.h src/namespecs.h src/ordspecs.h \
28 EXTRA_DIST = m4/gnulib-cache.m4 src/types.lst src/validtypes.sed \
29 src/specs.lst src/namespecs.sed src/ordspecs.sed \
30 src/errors.lst src/strtab.sed test/typegen.sh \
31 src/parse.y src/parse.stamp src/scan.l src/scan.stamp \
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/typemap.h src/output.h src/scan.h \
38 src/parse.h src/i18n.h src/normalize.h src/error.h test/declgen.h \
41 noinst_DATA = $(MOFILES)
43 lib_LTLIBRARIES = libcdecl.la
44 libcdecl_la_LDFLAGS = -no-undefined \
45 -export-symbols-regex '^cdecl_[[:lower:]]'
46 libcdecl_la_SOURCES = src/scan.c src/parse.c src/parse-decl.c src/typemap.c \
47 src/output.c src/explain.c src/declare.c src/i18n.c src/error.c \
49 libcdecl_la_LIBADD = libgnu.la $(LTLIBINTL) $(LTLIBTHREAD)
50 $(libcdecl_la_OBJECTS): $(gnulib_headers)
52 bin_PROGRAMS = cdecl99
53 cdecl99_SOURCES = src/cdecl99.c
54 cdecl99_LDADD = libcdecl.la libgnu.la $(LTLIBINTL) $(LTLIBREADLINE)
55 $(cdecl99_OBJECTS): $(gnulib_headers)
57 check_PROGRAMS = test/crossparse
58 check_LTLIBRARIES = libtest.la
59 libtest_la_LIBADD = $(GSL_LIBS)
60 libtest_la_SOURCES = test/testlib.c
61 $(libtest_la_OBJECTS): $(gnulib_headers)
64 libtest_la_SOURCES += test/declgen.c
65 check_PROGRAMS += test/randomdecl
68 test_crossparse_LDADD = libcdecl.la libtest.la libgnu.la
69 $(test_crossparse_OBJECTS): $(gnulib_headers)
70 test_randomdecl_LDADD = libcdecl.la libtest.la libgnu.la
71 $(test_randomdecl_OBJECTS): $(gnulib_headers)
73 TESTS_ENVIRONMENT = SHELL='$(SHELL)' LIBTOOL='$(LIBTOOL)' EXEEXT='$(EXEEXT)'
75 SH_LOG_COMPILER = $(SHELL)
77 TESTS = tests/libcdecl-static-symbols.sh tests/crossparse-c-random.sh
78 EXTRA_DIST += $(TESTS)
80 src/parse.lo: src/scan.h
81 src/scan.lo: src/parse.h
82 src/parse-decl.lo: src/scan.h src/parse.h
83 src/typemap.lo: src/validtypes.h
84 src/error.lo: src/errtab.h
85 src/normalize.lo: src/ordspecs.h
86 src/output.lo: src/namespecs.h
87 test/declgen.lo: test/typegen.h
89 src/validtypes.h: $(srcdir)/src/types.lst $(srcdir)/src/validtypes.sed
90 $(AM_V_GEN)sed -f $(srcdir)/src/validtypes.sed \
91 < $(srcdir)/src/types.lst > $@.tmp
92 $(AM_V_at)mv -f $@.tmp $@
94 src/namespecs.h: $(srcdir)/src/specs.lst $(srcdir)/src/namespecs.sed
95 $(AM_V_GEN) sed -f $(srcdir)/src/namespecs.sed \
96 < $(srcdir)/src/specs.lst > $@.tmp
97 $(AM_V_at) mv -f $@.tmp $@
99 src/ordspecs.h: $(srcdir)/src/specs.lst $(srcdir)/src/ordspecs.sed
100 $(AM_V_GEN) sed -f $(srcdir)/src/ordspecs.sed \
101 < $(srcdir)/src/specs.lst > $@.tmp
102 $(AM_V_at) mv -f $@.tmp $@
104 src/errtab.h: $(srcdir)/src/errors.lst $(srcdir)/src/strtab.sed
105 $(AM_V_GEN)sed -f $(srcdir)/src/strtab.sed \
106 < $(srcdir)/src/errors.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 ALL_MOFILES = $(POFILES:.po=.mo)
116 EXTRA_DIST += po/$(PACKAGE).pot po/LINGUAS $(POFILES) $(ALL_MOFILES)
117 MAINTAINERCLEANFILES += po/$(PACKAGE).pot $(ALL_MOFILES)
118 XGETTEXT_OPTS = -D $(builddir) -D $(srcdir) --from-code=utf-8 \
119 --add-comments=TRANSLATORS: --foreign-user \
120 --package-name=$(PACKAGE) --package-version=$(PACKAGE_VERSION) \
121 --msgid-bugs-address=$(PACKAGE_BUGREPORT) \
122 --keyword=_ --keyword=N_ --keyword=PN_:1c,2
124 po/$(PACKAGE).pot: $(SOURCES) src/errors.lst
125 $(AM_V_at) $(MKDIR_P) $(@D)
126 $(AM_V_GEN) $(XGETTEXT) $(XGETTEXT_OPTS) -o $@.tmp $(SOURCES)
127 $(AM_V_at) $(XGETTEXT) $(XGETTEXT_OPTS) --omit-header -Lc \
128 -ajo $@.tmp src/errors.lst
129 $(AM_V_at) mv -f $@.tmp $@
132 $(AM_V_at)$(MKDIR_P) $(@D)
133 $(AM_V_GEN)$(MSGFMT) -c -o $@ $<
135 install-data-local: install-mo
136 install-mo: $(MOFILES)
138 lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
139 test x"$$lang" = x"" && exit 1; \
140 inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
141 (set -x; $(MKDIR_P) "$$inst") \
143 (set -x; $(INSTALL_DATA) "$$mo" "$$inst/$(PACKAGE).mo") \
147 installdirs-local: installdirs-mo
149 for mo in $(MOFILES); do \
150 lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
151 test x"$$lang" = x"" && exit 1; \
152 inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
153 (set -x; $(MKDIR_P) "$$inst") || exit $$?; \
156 uninstall-local: uninstall-mo
158 for mo in $(ALL_MOFILES); do \
159 lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
160 test x"$$lang" = x"" && exit 1; \
161 inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
162 (set -x; cd "$$inst" && rm -f '$(PACKAGE).mo'); \
165 .PHONY: install-mo installdirs-mo uninstall-mo
167 # These are required to prevent the builtin lex/yacc rules from
168 # superseding ours...
169 src/scan.c src/scan.h: src/scan.stamp
170 src/parse.c src/parse.h: src/parse.stamp
172 # The flex/bison rules refrain from updating unchanged headers for the
173 # convenience of developers, but the headers must be distributed with
174 # up-to-date timestamps, otherwise make will try to update them in a fresh
176 dist-hook: update-headers
177 update-headers: unfuck-distdir
178 touch -c '$(distdir)/src/scan.h'
179 touch -c '$(distdir)/src/parse.h'
180 .PHONY: update-headers
182 # When running "make dist" in a VPATH build with a read-only srcdir, Automake
183 # will produce a distribution with all files read-only. Moreover, the files
184 # are read-only in distdir when the dist hooks are run. This hook will
185 # manually fix up the permissions. All dist hooks that modify files in distdir
186 # should list unfuck-distdir as a prerequisite.
187 dist-hook: unfuck-distdir
189 find '$(distdir)' -type f -exec chmod u+w {} +
190 .PHONY: unfuck-distdir
192 # Supporting rules for bison/flex.
194 BISON_V = $(BISON_V_$(V))
195 BISON_V_ = $(BISON_V_$(AM_DEFAULT_VERBOSITY))
196 BISON_V_0 = @echo " BISON " $<;
198 FLEX_V = $(FLEX_V_$(V))
199 FLEX_V_ = $(FLEX_V_$(AM_DEFAULT_VERBOSITY))
200 FLEX_V_0 = @echo " FLEX " $<;
206 $(AM_V_at) touch $@.tmp
207 $(BISON_V) $(BISON) -o $*.c --defines=$*.h.tmp $(BISONFLAGS) $<
208 $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
211 mv -f $*.h.tmp $*.h; \
213 $(AM_V_at) mv -f $@.tmp $@
216 $(AM_V_at) touch $@.tmp
217 $(FLEX_V) $(FLEX) -o $*.c --header-file=$*.h.tmp $(FLEXFLAGS) $<
218 $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
221 mv -f $*.h.tmp $*.h; \
223 $(AM_V_at) mv -f $@.tmp $@
226 @if test -f $@; then :; else \
228 $(MAKE) $(AM_MAKEFLAGS) $<; \
232 @if test -f $@; then :; else \
234 $(MAKE) $(AM_MAKEFLAGS) $<; \
237 include $(top_srcdir)/lib/gnulib.mk
238 include $(top_srcdir)/glconfig.mk