From fd5de54fa1df41dbb46b8869901541987cbdc427 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 26 Nov 2009 10:11:43 -0800 Subject: Not all systems have a yacc alias for the yacc program. txr is known to work with two yacc implementations: GNU Bison and Berkeley yacc. Let's add some auto-detection for yacc. --- configure | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 7 deletions(-) (limited to 'configure') diff --git a/configure b/configure index a5e0d2b9..58a13760 100755 --- a/configure +++ b/configure @@ -109,7 +109,10 @@ intptr=${intptr-} tool_prefix=${tool_prefix-} lex=${lex-'$(cross)$(tool_prefix)flex'} lexlib=${lexlib--lfl} -yacc=${yacc-'$(cross)$(tool_prefix)yacc'} +yaccname_given=${yaccname+yes} +yaccname=${yaccname-} +yacc_given=${yacc+yes} +yacc=${yacc-'$(cross)$(tool_prefix)$(yaccname)'} nm=${nm-'$(cross)$(tool_prefix)nm'} opt_flags=${opt_flags--O2} lang_flags=${lang_flags--ansi -D_POSIX_C_SOURCE=2} @@ -249,6 +252,12 @@ lexlib [$lexlib] Specifies the linker flag to use for linking the lex library. +yaccname [$yaccname] + + Specifies just the name of the yacc program without the path. + The following variable, yacc, specifies the full name. + If blank, the choice yacc program will be auto-detected. + yacc [$yacc] Specifies the program to use for compiling yacc scanners to C. @@ -446,12 +455,9 @@ else printf "warning: its recommended to build in a separate directory\n" fi -# -# Finally, we generate config.make -# -printf "generating config.make ...\n" - -cat > config.make < config.make <> config.h fi +# +# Yacc tests +# + +printf "Checking for yacc program ... " + +if [ -z "$yacc_given" -a -z "$yaccname_given" ] ; then + for yaccname in "yacc" "byacc" "bison -y" "" ; do + yaccpath=$(make yaccname="$yaccname" conftest.yacc) + if command -v $yaccpath > /dev/null ; then + break; + fi + done + + if [ -z "$yaccname" ] ; then + printf "not found\n" + exit 1 + fi + + printf '"%s"\n' "$yaccpath" +else + yaccpath=$(make conftest.yacc) + case $yaccpath in + *bison ) + printf "error\n\n" + printf "GNU Bison needs -y to behave like yacc\n\n" + printf "This needs to be specified in the --yaccname or --yacc option\n\n" + exit 1 + ;; + * ) + printf "given\n" + ;; + esac +fi # # Clean up # + rm -f conftest conftest.[co] conftest.{err,syms} rm -f conftest2 conftest[12].[oc] +# +# Regenerate config.make +# + +printf "regenerating config.make ... " +gen_config_make +printf "\n" + # # Save configuration in config.log # -- cgit v1.2.3