diff options
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | Makefile | 6 | ||||
-rwxr-xr-x | configure | 75 |
3 files changed, 89 insertions, 8 deletions
@@ -1,3 +1,19 @@ +2009-11-26 Kaz Kylheku <kkylheku@gmail.com> + + 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. + + * Makefile: use "include" rather than "-include" for + including config.make, so that make fails if the file does + not exist. + (conftest.yacc): New target. Just outputs the value of the + variable expansion of $(YACC). + + * configure (yaccname): New variable. + (gen_config_make): New function. + Steps added to test for existence of various yaccs. + 2009-11-25 Kaz Kylheku <kkylheku@gmail.com> * gc.c (mark_mem_region): Bugfix: do not mess with the valgrind @@ -26,7 +26,7 @@ # Test data in the tests/ directory is in the public domain, # unless it contains notices to the contrary. --include config.make +include config.make CFLAGS := -I. -I$(top_srcdir) $(LANG_FLAGS) $(DIAG_FLAGS) \ $(OPT_FLAGS) $(DBG_FLAGS) $(PLATFORM_FLAGS) @@ -115,3 +115,7 @@ conftest2: conftest1.c conftest2.c conftest.syms: conftest.o $(NM) -t o -P $^ > $@ + +.PHONY: conftest.yacc +conftest.yacc: + @echo $(YACC) @@ -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 <<! +gen_config_make() +{ + cat > config.make <<! # absolute path to source code directory top_srcdir := $top_srcdir @@ -480,6 +486,9 @@ cross := $cross # compiler name ccname = $ccname +# name of yacc program +yaccname = $yaccname + # prefix for compiler command compiler_prefix := $compiler_prefix @@ -501,6 +510,15 @@ REMOVE_FLAGS := $remove_flags LEX_DBG_FLAGS := $lex_dbg_flags TXR_DBG_OPTS := $txr_dbg_opts ! +} + +# +# Before doing some other tests, we need a config.make +# + +printf "generating config.make ... " +gen_config_make +printf "\n" # # Start config.h header @@ -682,14 +700,57 @@ $inline int func(void) printf "#define HAVE_VALGRIND\n" >> 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 # cat > config.log <<! |