From 226139d4a1177505fcc7db4f50395e732ba6f6d9 Mon Sep 17 00:00:00 2001 From: MrIron Date: Fri, 17 Oct 2025 22:10:28 +0200 Subject: [PATCH] Fix check for yacc/bison in configure script. --- configure | 91 +++++++++++++++++++++++++++++++++++++++++++++++----- configure.ac | 35 ++++++++++++++------ 2 files changed, 109 insertions(+), 17 deletions(-) diff --git a/configure b/configure index a1c24222..51a5c673 100755 --- a/configure +++ b/configure @@ -651,6 +651,7 @@ INSTALL_RULE ENGINE_C YFLAGS YACC +BISON SHPROG RMPROG LN_S @@ -6536,7 +6537,59 @@ done test -n "$SHPROG" || SHPROG="/bin/sh" -for ac_prog in 'bison -y' byacc +for ac_prog in bison +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_BISON+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) if test -n "$BISON"; then + ac_cv_prog_BISON="$BISON" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_BISON="$ac_prog" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi ;; +esac +fi +BISON=$ac_cv_prog_BISON +if test -n "$BISON"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $BISON" >&5 +printf "%s\n" "$BISON" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + + test -n "$BISON" && break +done + + +if test -n "$BISON"; then + YACC="$BISON -y" +else + for ac_prog in 'bison -y' byacc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -6585,13 +6638,35 @@ fi done test -n "$YACC" || YACC="yacc" -if test "$YACC" = ":" ; then - as_fn_error $? "Cannot find yacc." "$LINENO" 5 -elif echo "" | $YACC -V -v --version > /dev/null 2>&1 ; then - : -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $YACC may not work as yacc." >&5 -printf "%s\n" "$as_me: WARNING: $YACC may not work as yacc." >&2;} +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $YACC can parse a minimal grammar" >&5 +printf %s "checking whether $YACC can parse a minimal grammar... " >&6; } +if test ${ac_cv_yacc_works+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + cat > conftest.y <<'EOF' +%token T +%% +start: /* empty */ ; +%% +EOF + if $YACC -d conftest.y >/dev/null 2>&1; then + ac_cv_yacc_works=yes + else + ac_cv_yacc_works=no + fi + rm -f conftest.y conftest.tab.c conftest.tab.h conftest.output + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_yacc_works" >&5 +printf "%s\n" "$ac_cv_yacc_works" >&6; } + +if test "$ac_cv_yacc_works" = "no"; then + as_fn_error $? "No working yacc/bison found. Please install bison or a compatible yacc (e.g. byacc)." "$LINENO" 5 fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for posix non-blocking" >&5 diff --git a/configure.ac b/configure.ac index a33b70ec..eff3ecc4 100644 --- a/configure.ac +++ b/configure.ac @@ -125,16 +125,33 @@ AC_PATH_PROGS(RMPROG, rm, /bin/rm) AC_PATH_PROGS(SHPROG, sh, /bin/sh) dnl YACC - ditto -AC_PROG_YACC -dnl The autoconf docs say $YACC defaults to 'yacc'. This seems to be true, -dnl but judging from AC_PROG_LEX, it may not stay true. -if test "$YACC" = ":" ; then - AC_MSG_ERROR([Cannot find yacc.]) -elif echo "" | $YACC -V -v --version > /dev/null 2>&1 ; then - : +dnl Prefer bison if present +AC_CHECK_PROGS([BISON], [bison]) + +if test -n "$BISON"; then + YACC="$BISON -y" else -dnl byacc does not seem to have any way to test for workingness, so only warn. - AC_MSG_WARN([$YACC may not work as yacc.]) + AC_PROG_YACC +fi + +dnl Test whether the selected $YACC actually works +AC_CACHE_CHECK([whether $YACC can parse a minimal grammar], [ac_cv_yacc_works], [ + cat > conftest.y <<'EOF' +%token T +%% +start: /* empty */ ; +%% +EOF + if $YACC -d conftest.y >/dev/null 2>&1; then + ac_cv_yacc_works=yes + else + ac_cv_yacc_works=no + fi + rm -f conftest.y conftest.tab.c conftest.tab.h conftest.output +]) + +if test "$ac_cv_yacc_works" = "no"; then + AC_MSG_ERROR([No working yacc/bison found. Please install bison or a compatible yacc (e.g. byacc).]) fi unet_NONBLOCKING