]> git.draconx.ca Git - gob-dx.git/blobdiff - Makefile.am
Replace gnulib patch with new common helper macro.
[gob-dx.git] / Makefile.am
index 0f6ad3da08ea1b68cabb8542f22422df9465f349..c7ca686336571964e5b662a9542082c02cba443e 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright © 2019-2020 Nick Bowler
+# Copyright © 2019-2022 Nick Bowler
 #
 # Based on original work Copyright © 1999-2013 Jiri (George) Lebl.
 #
 ACLOCAL_AMFLAGS = -I m4 -I common/m4
 
 AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
-              -I$(builddir) -I$(srcdir) -DPKGDATADIR=\"$(pkgdatadir)\"
+              -I$(top_builddir)/lib -I$(top_srcdir)/lib \
+              -I$(DX_BASEDIR)/src -DPKGDATADIR=\"$(pkgdatadir)\"
 AM_CFLAGS = $(LIBGLIB_CFLAGS)
 AM_YFLAGS = -d -t
 
 bin_PROGRAMS = gob2
 
-EXTRA_DIST = COPYING.generated-code examples/GNOME_Foo_SomeInterface.idl \
-             examples/README examples/foo-some-interface.gob \
-             examples/gtk-button-count.gob examples/my-glade-main.c \
-             examples/my-glade.glade examples/my-glade.gob gob2.spec \
-             src/treefuncs.c src/treefuncs.h src/treefuncs.stamp \
-             src/treefuncs.def src/generate_treefuncs.pl \
-             t/test.gob t/str.gob
+EXTRA_DIST = COPYING.GPL3 COPYING.generated-code common/scripts/fix-gnulib.pl \
+             examples/GNOME_Foo_SomeInterface.idl examples/README \
+             examples/foo-some-interface.gob examples/gtk-button-count.gob \
+             examples/my-glade-main.c examples/my-glade.glade \
+             examples/my-glade.gob gob2.spec src/generate_treefuncs.pl \
+             src/lexer.l src/lexer.stamp src/treefuncs.def \
+             src/treefuncs.stamp t/str.gob t/test-fooable.c t/test-fooable.h \
+             t/test.gob m4/gnulib-cache.m4 bootstrap
 
-CLEANFILES =
+CLEANFILES = $(EXTRA_LIBRARIES)
 DISTCLEANFILES =
-MAINTAINERCLEANFILES = src/treefuncs.c src/treefuncs.h src/treefuncs.stamp
+MOSTLYCLEANFILES =
+MAINTAINERCLEANFILES = src/lexer.c src/lexer.h src/lexer.stamp \
+                       src/treefuncs.c src/treefuncs.h src/treefuncs.stamp
+
+# For Gnulib
+EXTRA_LIBRARIES =
 
 EXTRA_PROGRAMS = parser-rdeps
-parser_rdeps_SOURCES = src/main.c src/lexer.l
+parser_rdeps_SOURCES = src/main.c src/lexer.c
 $(parser_rdeps_OBJECTS): src/parse.h
 
-noinst_HEADERS = src/main.h src/treefuncs.h src/out.h src/util.h src/checks.h
+noinst_HEADERS = src/main.h src/treefuncs.h src/out.h src/util.h src/checks.h \
+                 common/src/help.h
 
 gob2_SOURCES = src/main.c src/main.h src/treefuncs.c src/out.c src/util.c \
-               src/checks.c src/parse.y src/lexer.l
-gob2_LDADD = $(LIBGLIB_LIBS) @LEXLIB@
-$(gob2_OBJECTS): src/treefuncs.h
+               src/checks.c src/parse.y src/lexer.c src/lexer.h src/options.h \
+               common/src/help.c
+gob2_LDADD = $(LIBGLIB_LIBS) libgnu.a
+$(gob2_OBJECTS): $(gnulib_headers) src/treefuncs.h src/options.h
+
+if GOB_STRCASE
+gob2_SOURCES += src/gob-strcase.c
+endif
 
 man_MANS = doc/gob2.1
 EXTRA_DIST += doc/makehtml.pl
 
-PERL_ERROR = @:; { \
-         printf '%s: ERROR: perl was not available at configure time.\n' "$@"; \
-         printf '%s: If perl is installed but was not detected by configure,\n' "$@"; \
-         printf '%s: consider setting PERL and re-running configure.\n' "$@"; \
-       } 1>&2; false
+FLEX_V   = $(FLEX_V_@AM_V@)
+FLEX_V_  = $(FLEX_V_@AM_DEFAULT_V@)
+FLEX_V_0 = @printf '  %$(DX_ALIGN_V)s %s\n' 'FLEX    ' $<;
+
+TOOL_ERROR = { \
+  echo "ERROR: *** $$tool is missing on your system."; \
+  echo "       *** Because of this, I cannot compile $$toolsrc."; \
+  echo "       *** If $$tool is installed but was not detected by configure,";\
+  echo "       *** consider setting $$toolvar and re-running configure."; \
+  echo "       *** See config.log for more details."; } >&2; false
+
+DEV_TOOL_ERROR = { \
+  echo "ERROR: *** $$tool is missing on your system."; \
+  echo "       *** Because of this, I cannot compile $$toolsrc, but"; \
+  echo "       *** (perhaps because you modified it) the sources appear out"; \
+  echo "       *** of date.  If $$tool is installed but was not detected by"; \
+  echo "       *** configure, consired setting $$toolvar and re-running configure."; \
+  echo "       *** See config.log for more details."; } >&2; false
 
 src/treefuncs.stamp: src/generate_treefuncs.pl src/treefuncs.def
 if !HAVE_PERL
-       $(PERL_ERROR)
+       @tool=perl toolvar=PERL toolsrc=src/treefuncs.def; $(DEV_TOOL_ERROR)
 endif
-       $(AM_V_at) $(MKDIR_P) $(@D)
+       $(AM_V_at) $(MKDIR_P) $(@D) && touch $@.tmp
        $(AM_V_GEN) (cd $(@D) && \
          $(PERL) $(abs_srcdir)/src/generate_treefuncs.pl \
                  $(abs_srcdir)/src/treefuncs.def; )
-       $(AM_V_at) touch $@
+       $(AM_V_at) mv -f $@.tmp $@
+
+OPTFILES = src/options.opt
+.opt.h:
+       $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-options.awk $< >$@.tmp
+       $(AM_V_at) mv -f $@.tmp $@
+$(OPTFILES:.opt=.h): $(DX_BASEDIR)/scripts/gen-options.awk
+MAINTAINERCLEANFILES += $(OPTFILES:.opt=.h)
+EXTRA_DIST += $(DX_BASEDIR)/scripts/gen-options.awk $(OPTFILES)
+
+.l.c: ;
+.l.stamp:
+if !HAVE_FLEX
+       @tool=flex toolvar=FLEX toolsrc=$<; $(DEV_TOOL_ERROR)
+endif
+       $(AM_V_at) touch $@.tmp
+       $(AM_V_at) rm -f $*.h.tmp; mv -f $*.h $*.h.tmp 2>/dev/null; :
+       $(FLEX_V) $(FLEX) -o $*.c --header-file=$*.h $(FLEXFLAGS) $<
+       $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; \
+         then mv -f $*.h.tmp $*.h; \
+         else rm -f $*.h.tmp; fi
+       $(AM_V_at) mv -f $@.tmp $@
 
 .stamp.c:
        @test -f $@ || { rm -f $<; $(MAKE) $(AM_MAKEFLAGS) $<; }
 .stamp.h:
        @test -f $@ || { rm -f $<; $(MAKE) $(AM_MAKEFLAGS) $<; }
 
+# Required to prevent the builtin lex rule from superseding ours
+src/lexer.c src/lexer.h: src/lexer.stamp
+
 html-local: doc/gob2.html
 doc/gob2.html: doc/gob2.1
 if !HAVE_PERL
-       $(PERL_ERROR)
+       @tool=perl toolvar=PERL toolsrc=$@; $(TOOL_ERROR)
 endif
        $(AM_V_GEN) $(PERL) $(top_srcdir)/doc/makehtml.pl <doc/gob2.1 >$@.tmp
        $(AM_V_at) mv -f $@.tmp $@
@@ -86,11 +136,100 @@ uninstall-gob2-html:
 m4dir = $(datadir)/aclocal
 m4_DATA = gob2.m4
 
-gob2.m4: $(top_srcdir)/common/m4/gob2.m4
-       $(AM_V_GEN) $(SED) 's/DX_PROG_GOB2/GOB2_CHECK/g' \
-         $(top_srcdir)/common/m4/gob2.m4 >$@.tmp
+gob2.m4: $(DX_BASEDIR)/m4/gob2.m4 $(DX_BASEDIR)/m4/basename.m4
+       $(AM_V_GEN) :; { \
+         $(SED) -e 's/DX_PROG_GOB2/GOB2_CHECK/g' \
+                -e 's/DX_BASENAME/GOB2_BASENAME/g' \
+                $(DX_BASEDIR)/m4/gob2.m4 && echo && \
+         $(SED) -e 's/DX_/GOB2_/g' -e 's/dx_fn_/gob2_fn_/g' \
+                $(DX_BASEDIR)/m4/basename.m4; \
+       } >$@.tmp
        $(AM_V_at) mv -f $@.tmp $@
 DISTCLEANFILES += gob2.m4
-EXTRA_DIST += common/m4/gob2.m4
+EXTRA_DIST += $(DX_BASEDIR)/m4/gob2.m4 $(DX_BASEDIR)/m4/basename.m4
+
+git_changelog_start = 2cd951c678998b2b0230c8eb25717ecf0f1dd2db
+dist-hook: generate-changelog
+generate-changelog: unfuck-distdir
+       -: "$${GIT_DIR=$(top_srcdir)/.git}"; \
+         export GIT_DIR; test -d "$$GIT_DIR" || exit 0; { \
+           $(PERL) -x $(top_srcdir)/build-aux/gitlog-to-changelog -- \
+             $(git_changelog_start).. && \
+           echo && \
+           git show $(git_changelog_start):ChangeLog; \
+         } >$(distdir)/ChangeLog.gen && \
+         mv -f $(distdir)/ChangeLog.gen $(distdir)/ChangeLog
+       rm -f $(distdir)/ChangeLog.gen
+.PHONY: generate-changelog
+
+# Ensure that any generated headers, which may be left unchanged to improve
+# incremental build performance, are fully up-to-date in the distribution.
+dist-hook: update-headers
+update-headers: unfuck-distdir
+       touch -c $(distdir)/src/lexer.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 fix
+# up the permission.  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
+
+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
+       $(GENERIC_V) : 'CHECK   ' NEWS; \
+         $(AWK) -F: 'NR == 1 && $$1 != "$(PACKAGE_VERSION)" \
+           { print FILENAME ":" NR ":", $$0; exit 1}' \
+           $(distdir)/NEWS || { \
+             echo 'ERROR: *** First line of NEWS should match the package version'; \
+             echo '       *** $(PACKAGE_VERSION), but that does not appear to be the case.'; \
+             echo '       *** Remember to update NEWS before preparing a release.'; \
+             $(TEST_DISTRIBUTION_OR_ERROR); } >&2
+
+atlocal: config.status
+       $(AM_V_GEN) :; { \
+         printf ': "$${%s=%s}"\n' \
+           CC '$(CC)' \
+           CXX '$(CXX)' \
+           AWK '$(AWK)' \
+           CPPFLAGS '$(CPPFLAGS)' \
+           CFLAGS '$(CFLAGS)' \
+           CXXFLAGS '$(CXXFLAGS)' \
+           LDFLAGS '$(LDFLAGS)' \
+           GTK_CFLAGS '$(GTK_CFLAGS)' \
+           GTK_LIBS '$(GTK_LIBS)' \
+           LIBGOBJECT_CFLAGS '$(LIBGOBJECT_CFLAGS)' \
+           LIBGOBJECT_LIBS '$(LIBGOBJECT_LIBS)' \
+           HAVE_GOBJECT '$(HAVE_GOBJECT)' \
+           HAVE_GOBJECT_PRIVATES '$(HAVE_GOBJECT_PRIVATES)' \
+           HAVE_GTK2 '$(HAVE_GTK2)' \
+           pkgdatadir '$(pkgdatadir)' \
+           ; } >$@.tmp
+       $(AM_V_at) mv -f $@.tmp $@
+check_DATA = atlocal
+CLEANFILES += atlocal
 
+include $(top_srcdir)/lib/gnulib.mk
 include $(top_srcdir)/common/snippet/autotest.mk