]> git.draconx.ca Git - cdecl99.git/blobdiff - Makefile.am
Bundle scripts to help re-bootstrap the package.
[cdecl99.git] / Makefile.am
index 5781b234e1f8fac84e0e5efc623b218309510129..6a8f1efe617e3960f51e8b6c35dae4f5e99b4fea 100644 (file)
@@ -1,37 +1,43 @@
-# Copyright © 2011 Nick Bowler
+# Copyright © 2011-2013, 2019-2021 Nick Bowler
 #
 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 # This is free software: you are free to do what the fuck you want to.
 # There is NO WARRANTY, to the extent permitted by law.
 
-ACLOCAL_AMFLAGS = -I m4
-AUTOMAKE_OPTIONS = nostdinc
+ACLOCAL_AMFLAGS = -I m4 -I common/m4
 
 # For Gnulib
 MOSTLYCLEANFILES =
-noinst_LTLIBRARIES =
+EXTRA_LTLIBRARIES =
 
 AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
        -I$(top_builddir)/lib -I$(top_srcdir)/lib \
-       -I$(top_builddir) -I$(top_srcdir) \
+       -I$(top_builddir)/test \
        -DBISON_LOCALEDIR=\"$(BISON_LOCALEDIR)\" \
        -DLOCALEDIR=\"$(localedir)\"
 
+AM_CFLAGS = $(GSL_CFLAGS)
+
 MAINTAINERCLEANFILES = src/scan.c src/scan.h src/scan.stamp \
        src/parse.c src/parse.h src/parse.stamp
 
-CLEANFILES = src/validtypes.h src/errtab.h test/typegen.h
+DISTCLEANFILES =
+
+CLEANFILES = src/validtypes.h src/errtab.h src/namespecs.h src/ordspecs.h \
+             test/typegen.h $(EXTRA_LTLIBRARIES)
 
-EXTRA_DIST = m4/gnulib-cache.m4 src/types.lst src/validtypes.sed \
-       src/errors.lst src/strtab.sed \
-       src/parse.stamp src/scan.stamp \
-       COPYING.WTFPL2
+EXTRA_DIST = bootstrap common/scripts/fix-gnulib.pl m4/gnulib-cache.m4 \
+             src/types.lst src/validtypes.sed src/specs.lst src/namespecs.sed \
+             src/ordspecs.sed src/errors.lst src/strtab.sed test/typegen.sh \
+             src/parse.y src/parse.stamp src/scan.l src/scan.stamp \
+             COPYING.WTFPL2 README.md INSTALL
 
 dist_man_MANS = doc/man/cdecl99.1 doc/man/libcdecl.3
 
 include_HEADERS = src/cdecl.h
-noinst_HEADERS = src/typemap.h src/output.h src/scan.h src/parse.h src/i18n.h \
-       src/error.h
+noinst_HEADERS = conf_pre.h conf_post.h src/typemap.h src/output.h src/scan.h \
+       src/parse.h src/i18n.h src/normalize.h src/error.h src/history.h \
+       test/declgen.h test/test.h
 
 noinst_DATA = $(MOFILES)
 
@@ -45,22 +51,24 @@ libcdecl_la_LIBADD = libgnu.la $(LTLIBINTL) $(LTLIBTHREAD)
 $(libcdecl_la_OBJECTS): $(gnulib_headers)
 
 bin_PROGRAMS = cdecl99
+cdecl99_SOURCES = src/cdecl99.c
+cdecl99_LDADD = libcdecl.la libgnu.la \
+                $(LTLIBICONV) $(LTLIBINTL) $(LTLIBREADLINE)
+$(cdecl99_OBJECTS): $(gnulib_headers)
 
-check_PROGRAMS =
-EXTRA_LTLIBRARIES = libtest.la
-libtest_la_CFLAGS = $(AM_CFLAGS) $(GSL_CFLAGS)
+check_PROGRAMS = test/crossparse
+check_LTLIBRARIES = libtest.la
 libtest_la_LIBADD = $(GSL_LIBS)
 libtest_la_SOURCES = test/testlib.c
+$(libtest_la_OBJECTS): $(gnulib_headers)
 
 if HAVE_GSL
 libtest_la_SOURCES += test/declgen.c
 check_PROGRAMS += test/randomdecl
 endif
 
-cdecl99_SOURCES = src/cdecl99.c
-cdecl99_LDADD = libcdecl.la libgnu.la $(LTLIBINTL) $(LTLIBREADLINE)
-$(cdecl99_OBJECTS): $(gnulib_headers)
-
+test_crossparse_LDADD = libcdecl.la libtest.la libgnu.la
+$(test_crossparse_OBJECTS): $(gnulib_headers)
 test_randomdecl_LDADD = libcdecl.la libtest.la libgnu.la
 $(test_randomdecl_OBJECTS): $(gnulib_headers)
 
@@ -71,10 +79,7 @@ src/typemap.lo: src/validtypes.h
 src/error.lo: src/errtab.h
 src/normalize.lo: src/ordspecs.h
 src/output.lo: src/namespecs.h
-
-# This is gross.
-declgen_o = test/libtest_la-declgen.lo
-$(declgen_o): test/typegen.h
+test/declgen.lo: test/typegen.h
 
 src/validtypes.h: $(srcdir)/src/types.lst $(srcdir)/src/validtypes.sed
        $(AM_V_GEN)sed -f $(srcdir)/src/validtypes.sed \
@@ -102,9 +107,11 @@ test/typegen.h: $(srcdir)/src/types.lst $(srcdir)/test/typegen.sh
        $(AM_V_at)mv -f $@.tmp $@
 
 # Supporting rules for gettext.
-ALL_MOFILES = $(POFILES:.po=.mo)
-EXTRA_DIST += po/$(PACKAGE).pot po/LINGUAS $(POFILES) $(ALL_MOFILES)
-MAINTAINERCLEANFILES += po/$(PACKAGE).pot $(ALL_MOFILES)
+include $(top_srcdir)/common/snippet/gettext.mk
+
+EXTRA_DIST += po/$(PACKAGE).pot
+MAINTAINERCLEANFILES += po/$(PACKAGE).pot
+
 XGETTEXT_OPTS = -D $(builddir) -D $(srcdir) --from-code=utf-8 \
        --add-comments=TRANSLATORS: --foreign-user \
        --package-name=$(PACKAGE) --package-version=$(PACKAGE_VERSION) \
@@ -118,42 +125,6 @@ po/$(PACKAGE).pot: $(SOURCES) src/errors.lst
                -ajo $@.tmp src/errors.lst
        $(AM_V_at)  mv -f $@.tmp $@
 
-.po.mo:
-       $(AM_V_at)$(MKDIR_P) $(@D)
-       $(AM_V_GEN)$(MSGFMT) -c -o $@ $<
-
-install-data-local: install-mo
-install-mo: $(MOFILES)
-       for mo in $?; do \
-               lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
-               test x"$$lang" = x"" && exit 1; \
-               inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
-               (set -x; $(MKDIR_P) "$$inst") \
-                       || exit $$?; \
-               (set -x; $(INSTALL_DATA) "$$mo" "$$inst/$(PACKAGE).mo") \
-                       || exit $$?; \
-       done
-
-installdirs-local: installdirs-mo
-installdirs-mo:
-       for mo in $(MOFILES); do \
-               lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
-               test x"$$lang" = x"" && exit 1; \
-               inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
-               (set -x; $(MKDIR_P) "$$inst") || exit $$?; \
-       done
-
-uninstall-local: uninstall-mo
-uninstall-mo:
-       for mo in $(ALL_MOFILES); do \
-               lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
-               test x"$$lang" = x"" && exit 1; \
-               inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
-               (set -x; cd "$$inst" && rm -f '$(PACKAGE).mo'); \
-       done
-
-.PHONY: install-mo installdirs-mo uninstall-mo
-
 # These are required to prevent the builtin lex/yacc rules from
 # superseding ours...
 src/scan.c src/scan.h: src/scan.stamp
@@ -164,26 +135,70 @@ src/parse.c src/parse.h: src/parse.stamp
 # up-to-date timestamps, otherwise make will try to update them in a fresh
 # VPATH build.
 dist-hook: update-headers
-update-headers:
+update-headers: unfuck-distdir
        touch -c '$(distdir)/src/scan.h'
        touch -c '$(distdir)/src/parse.h'
+.PHONY: update-headers
+
+# When running "make dist" in a VPATH build with a read-only srcdir, Automake
+# will produce a distribution with all files read-only.  Moreover, the files
+# are read-only in distdir when the dist hooks are run.  This hook will
+# manually fix up the permissions.  All dist hooks that modify files in distdir
+# should list unfuck-distdir as a prerequisite.
+dist-hook: unfuck-distdir
+unfuck-distdir:
+       find '$(distdir)' -type f -exec chmod u+w {} +
+.PHONY: unfuck-distdir
+
+GITLOG_FLAGS = --format='%s%n%n%b%n'
+
+dist-hook: generate-changelog
+generate-changelog: unfuck-distdir
+       -: "$${GIT_DIR=$(top_srcdir)/.git}"; \
+         export GIT_DIR; test -d "$$GIT_DIR" || exit 0; \
+         $(top_srcdir)/gitlog-to-changelog $(GITLOG_FLAGS) \
+           >'$(distdir)/ChangeLog.gen' && \
+         mv -f '$(distdir)/ChangeLog.gen' '$(distdir)/ChangeLog'
+       rm -f '$(distdir)/ChangeLog.gen'
+.PHONY: generate-changelog
+
+GENERIC_V   = $(GENERIC_V_@AM_V@)
+GENERIC_V_  = $(GENERIC_V_@AM_DEFAULT_V@)
+GENERIC_V_0 = @printf '%2.0s%$(DX_ALIGN_V)s %s\n'
+
+TEST_DISTRIBUTION = false
+TEST_DISTRIBUTION_OR_ERROR = if $(TEST_DISTRIBUTION); \
+  then echo 'Proceeding anyway...'; \
+  else echo 'Run $(MAKE) TEST_DISTRIBUTION=true to ignore this failure.'; \
+       false; \
+  fi
+
+distcheck-hook:
+       $(GENERIC_V) : 'CHECK   ' ChangeLog; \
+         $(AWK) '/^Stub/ { print FILENAME ":" NR ":", $$0; exit 1 }' \
+           $(distdir)/ChangeLog || { \
+             echo 'ERROR: *** Packaged ChangeLog was not properly generated from git log.'; \
+             echo '       *** The source version was used instead, but this appears to'; \
+             echo '       *** be the stub from a git checkout.  The "git" and "perl"'; \
+             echo '       *** programs are required for ChangeLog generation to work.'; \
+             $(TEST_DISTRIBUTION_OR_ERROR); } >&2
 
 # Supporting rules for bison/flex.
 
-BISON_V   = $(BISON_V_$(V))
-BISON_V_  = $(BISON_V_$(AM_DEFAULT_VERBOSITY))
-BISON_V_0 = @echo "  BISON " $<;
+BISON_V   = $(BISON_V_@AM_V@)
+BISON_V_  = $(BISON_V_@AM_DEFAULT_V@)
+BISON_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'BISON   ' $<;
 
-FLEX_V   = $(FLEX_V_$(V))
-FLEX_V_  = $(FLEX_V_$(AM_DEFAULT_VERBOSITY))
-FLEX_V_0 = @echo "  FLEX  " $<;
+FLEX_V   = $(FLEX_V_@AM_V@)
+FLEX_V_  = $(FLEX_V_@AM_DEFAULT_V@)
+FLEX_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'FLEX    ' $<;
 
 .y.c: ;
 .l.c: ;
 
 .y.stamp:
        $(AM_V_at) touch $@.tmp
-       $(BISON_V) $(BISON) -o $*.c --defines=$*.h.tmp $(BISONFLAGS) $<
+       $(BISON_V) $(BISON) $(BISON_COMPAT) -o $*.c --defines=$*.h.tmp $(BISONFLAGS) $<
        $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \
                rm -f $*.h.tmp; \
        else \
@@ -213,5 +228,16 @@ FLEX_V_0 = @echo "  FLEX  " $<;
                $(MAKE) $(AM_MAKEFLAGS) $<; \
        fi
 
+atlocal: config.status
+       $(AM_V_GEN) :; { \
+         printf ': "$${%s=%s}"\n' \
+           EXEEXT '$(EXEEXT)' \
+           check_PROGRAMS '$(check_PROGRAMS)' \
+           ; } >$@.tmp
+       $(AM_V_at) mv -f $@.tmp $@
+check_DATA = atlocal
+CLEANFILES += atlocal
+
 include $(top_srcdir)/lib/gnulib.mk
-include $(top_srcdir)/glconfig.mk
+include $(top_srcdir)/common/snippet/glconfig.mk
+include $(top_srcdir)/common/snippet/autotest.mk