Hi Bruno, > Le 3 mai 2020 à 01:14, Bruno Haible <[email protected]> a écrit : > > When a flex version < 2.6.4 is in $PATH, bison fails to build. > [...] > I don't know what the flex command is that the config.status attempts to > execute (because you chose to hide it).
Passing V=1 to 'make' restores the initial verbosity. > $ cd examples/c/reccalc/ > > $ grep -i flex Makefile local.mk > Makefile:FLEX = flex > Makefile: $(FLEX) $(FLEXFLAGS) -o$*.c --header-file=$*.h $< > local.mk:if FLEX_WORKS > local.mk:endif FLEX_WORKS > > Apparently the --header-file option is not supported. > > Indeed: https://github.com/westes/flex/blob/master/NEWS > shows that the option --header was introduced in version 2.5.6. > And > https://github.com/westes/flex/commit/56a530abf7e16ce35ea36748ff2e86f2f0022bc2 > shows that the option --header-file was introduced in version 2.6.4. Thank you very much for the thorough investigation, and precise diagnostic! I'll install this. Cheers! commit bc0511aa5f3dae16614c94b6ac9ed04c0202639d Author: Akim Demaille <[email protected]> Date: Sun May 3 09:51:18 2020 +0200 examples: beware of the portability of flex --header-file The option --header was introduced in version 2.5.6. The option --header-file was introduced in version 2.6.4. Reported by Bruno Haible. https://lists.gnu.org/r/bug-bison/2020-05/msg00013.html So use --header, and do bother with versions that don't support it. * m4/flex.m4: Check whether flex supports --header. * configure.ac (FLEX_WORKS, FLEX_CXX_WORKS): Set to false if it doesn't. * * examples/c/reccalc/local.mk, examples/c/reccalc/Makefile: Use --header rather than --header-file. diff --git a/configure.ac b/configure.ac index 68c54a12..c1b0c182 100644 --- a/configure.ac +++ b/configure.ac @@ -261,9 +261,8 @@ if ! "$LEX_IS_FLEX" || test "X$LEX" = X:; then AC_MSG_WARN([bypassing lex because flex is required]) LEX=: fi -AM_CONDITIONAL([FLEX_WORKS], [$LEX_IS_FLEX]) -AM_CONDITIONAL([FLEX_CXX_WORKS], - [$LEX_IS_FLEX && test $bison_cv_cxx_works = yes]) +AM_CONDITIONAL([FLEX_WORKS], [$LEX_IS_FLEX && $FLEX_SUPPORTS_HEADER_OPT]) +AM_CONDITIONAL([FLEX_CXX_WORKS], [$LEX_WORKS && test $bison_cv_cxx_works = yes]) AC_PROG_YACC AC_PROG_RANLIB AC_PROG_GNU_M4 diff --git a/examples/c/reccalc/Makefile b/examples/c/reccalc/Makefile index 84fbd3ee..a64ceedb 100644 --- a/examples/c/reccalc/Makefile +++ b/examples/c/reccalc/Makefile @@ -12,7 +12,7 @@ all: $(BASE) $(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $< %.c %.h: %.l - $(FLEX) $(FLEXFLAGS) -o$*.c --header-file=$*.h $< + $(FLEX) $(FLEXFLAGS) -o$*.c --header=$*.h $< scan.o: parse.h parse.o: scan.h diff --git a/examples/c/reccalc/local.mk b/examples/c/reccalc/local.mk index de889789..0538f120 100644 --- a/examples/c/reccalc/local.mk +++ b/examples/c/reccalc/local.mk @@ -69,7 +69,9 @@ DASH = - $(AM_V_LEX)rm -f $@ [email protected] $(AM_V_at)$(MKDIR_P) %D% $(AM_V_at)touch [email protected] - $(AM_V_at)$(LEX) $(AM_LFLAGS) $(LFLAGS) -o%D%/scan.c --header-file=%D%/scan.h $(srcdir)/%D%/scan.l +## --header introduced in 2.5.6, renamed as --header-file in 2.6.4. +## Backward compatibility ensured since --header is an unambiguous prefix. + $(AM_V_at)$(LEX) $(AM_LFLAGS) $(LFLAGS) -o%D%/scan.c --header=%D%/scan.h $(srcdir)/%D%/scan.l $(AM_V_at)mv [email protected] $@ diff --git a/m4/flex.m4 b/m4/flex.m4 index f17e7152..911a689e 100644 --- a/m4/flex.m4 +++ b/m4/flex.m4 @@ -41,6 +41,22 @@ else fi ]) + +AC_CACHE_CHECK([whether flex supports --header=FILE], + [ac_cv_prog_lex_supports_header_opt], +[if _AC_DO_VAR([LEX --header=conftest.h conftest.l]); then + ac_cv_prog_lex_supports_header_opt=yes +else + ac_cv_prog_lex_supports_header_opt=no +fi +]) +if test "$ac_cv_prog_lex_supports_header_opt" = yes; then + FLEX_SUPPORTS_HEADER_OPT=true +else + FLEX_SUPPORTS_HEADER_OPT=false +fi + + cat >conftest.l <<_ACEOF[ %% a { ECHO; }
