]> git.draconx.ca Git - gob-dx.git/commitdiff
Require flex to build the scanner.
authorNick Bowler <nbowler@draconx.ca>
Fri, 7 Feb 2020 03:26:38 +0000 (22:26 -0500)
committerNick Bowler <nbowler@draconx.ca>
Fri, 7 Feb 2020 03:31:33 +0000 (22:31 -0500)
There is not much point in compatibility with various lex incarnations,
since the generated files are distributed and the user does not need
any lex tool to simply build from a tarball.

This additionally avoids a problem with AC_PROG_LEX which can hard-fail
the configure run when the selected lex command is not working, even
if the tool is not needed for the build.  Now, a fatal error will only
be generated if the tool is required at make time.

Makefile.am
common
configure.ac
src/.gitignore

index 7f099572f602a7f1dbd2d2992bc675ced8d33ea8..e8afbc60007d0c14f730aa7d753853f9c952a875 100644 (file)
@@ -20,48 +20,72 @@ EXTRA_DIST = COPYING.GPL3 COPYING.generated-code \
              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/treefuncs.def src/treefuncs.stamp t/str.gob t/test-fooable.c \
-             t/test-fooable.h t/test.gob
+             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
 
 CLEANFILES =
 DISTCLEANFILES =
-MAINTAINERCLEANFILES = src/treefuncs.c src/treefuncs.h src/treefuncs.stamp
+MAINTAINERCLEANFILES = src/lexer.c src/lexer.h src/lexer.stamp \
+                       src/treefuncs.c src/treefuncs.h src/treefuncs.stamp
 
 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
 
 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@
+               src/checks.c src/parse.y src/lexer.c src/lexer.h
+gob2_LDADD = $(LIBGLIB_LIBS)
 $(gob2_OBJECTS): src/treefuncs.h
 
 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, 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; $(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 $@
+
+.l.c: ;
+.l.stamp:
+if !HAVE_FLEX
+       @tool=flex toolvar=FLEX toolsrc=$<; $(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
@@ -95,7 +119,7 @@ EXTRA_DIST += common/m4/gob2.m4
 
 git_changelog_start = 2cd951c678998b2b0230c8eb25717ecf0f1dd2db
 dist-hook: generate-changelog
-generate-changelog:
+generate-changelog: unfuck-distdir
        -: "$${GIT_DIR=$(top_srcdir)/.git}"; \
          test -d "$$GIT_DIR" || exit 0; { \
            $(PERL) -x $(top_srcdir)/build-aux/gitlog-to-changelog -- \
@@ -107,6 +131,23 @@ generate-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'
diff --git a/common b/common
index 4705ffd69e7b7551bab4650f9e49756667be783b..803e498e869f88d9daceadf143e3360c17cb7410 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 4705ffd69e7b7551bab4650f9e49756667be783b
+Subproject commit 803e498e869f88d9daceadf143e3360c17cb7410
index f3e4b913b4925b9326cc375f8ec88c1afdba4ff1..b43fc7c047c0fc3fc89353573fd070b845f93a72 100644 (file)
@@ -16,7 +16,6 @@ DX_AUTOMAKE_COMPAT
 
 AC_PROG_CC
 AC_PROG_CXX
-AC_PROG_LEX
 AC_PROG_YACC
 
 AC_ARG_VAR([PERL], [command to execute perl programs])
@@ -25,6 +24,9 @@ AM_CONDITIONAL([HAVE_PERL], [$PERL -e 'my $x = 42; exit $x'; test $? = 42])
 
 LT_INIT
 
+DX_PROG_FLEX([], [have_flex=yes], [have_flex=no])
+AM_CONDITIONAL([HAVE_FLEX], [test x"$have_flex" = x"yes"])
+
 DX_LIB_GLIB2
 
 dnl Dependencies for test suite
index 27aec0858a1bd65a699b0ba2bc5b52d5fbfd820a..89b3329377c16a2420b8f1d2ead869f337ba6141 100644 (file)
@@ -1,4 +1,5 @@
-/lexer.c
+/lexer.[ch]
+/lexer.stamp
 /parse.[ch]
-/treefuncs.stamp
 /treefuncs.[ch]
+/treefuncs.stamp