From 2e08ecd5bee74febfb2db98815df62072d105285 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Wed, 24 Feb 2021 00:08:16 -0500 Subject: [PATCH] Give better errors when flex/bison are unavailable. --- Makefile.am | 17 +++++++++++++++-- configure.ac | 8 ++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 6a8f1ef..620b37b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -193,10 +193,19 @@ 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: ; +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 +.y.c: ; .y.stamp: +if !HAVE_BISON + $(BISON_V)tool=bison toolvar=BISON toolsrc=$<; $(DEV_TOOL_ERROR) +endif $(AM_V_at) touch $@.tmp $(BISON_V) $(BISON) $(BISON_COMPAT) -o $*.c --defines=$*.h.tmp $(BISONFLAGS) $< $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \ @@ -206,7 +215,11 @@ FLEX_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'FLEX ' $<; fi $(AM_V_at) mv -f $@.tmp $@ +.l.c: ; .l.stamp: +if !HAVE_FLEX + $(FLEX_V)tool=flex toolvar=FLEX toolsrc=$<; $(DEV_TOOL_ERROR) +endif $(AM_V_at) touch $@.tmp $(FLEX_V) $(FLEX) -o $*.c --header-file=$*.h.tmp $(FLEXFLAGS) $< $(AM_V_at) if cmp $*.h.tmp $*.h >/dev/null 2>&1; then \ diff --git a/configure.ac b/configure.ac index e0a67aa..b30597a 100644 --- a/configure.ac +++ b/configure.ac @@ -48,8 +48,12 @@ m4_traceoff([AM_GNU_GETTEXT]) AM_GNU_GETTEXT([external]) DX_LINGUAS -DX_PROG_FLEX([], [], [FLEX=false]) -DX_PROG_BISON([], [], [BISON=false]) +DX_PROG_FLEX([], [have_flex=yes], [have_flex=no]) +AM_CONDITIONAL([HAVE_FLEX], [test x"$have_flex" = x"yes"]) + +DX_PROG_BISON([], [have_bison=yes], [have_bison=no]) +AM_CONDITIONAL([HAVE_BISON], [test x"$have_bison" = x"yes"]) + DX_BISON_COMPAT BISON_I18N -- 2.43.0