From e5b12a313fdbbf9b628e920e40feb6613a9d6905 Mon Sep 17 00:00:00 2001 From: Vladimir Mezentsev Date: Thu, 2 May 2024 18:29:28 -0700 Subject: [PATCH] Fix hard-coded bash path in gprofng When running 'make check', the default gprofng test suite creates a shell script for which it used a hardcoded shebang of '/usr/bin/bash' this script would not run if bash is in a different location, like /bin/bash This commit adds 'AC_PATH_PROG(BASH, bash)' to configure.ac so the installation path of bash is detected at configuration time. The configuration is propagated to the runtest command line where it is needed. --- gprofng/Makefile.am | 1 + gprofng/Makefile.in | 2 ++ gprofng/configure | 47 ++++++++++++++++++++++++++-- gprofng/configure.ac | 3 ++ gprofng/doc/Makefile.in | 1 + gprofng/gp-display-html/Makefile.in | 1 + gprofng/src/Makefile.in | 1 + gprofng/testsuite/config/default.exp | 2 +- 8 files changed, 55 insertions(+), 3 deletions(-) diff --git a/gprofng/Makefile.am b/gprofng/Makefile.am index 5d26441c304..a5ee9dd63f3 100644 --- a/gprofng/Makefile.am +++ b/gprofng/Makefile.am @@ -68,6 +68,7 @@ if TCL_TRY CLOCK_GETTIME_LINK="$(CLOCK_GETTIME_LINK)" \ CHECK_TARGET=$@ \ PREFIX="$(prefix)" \ + BASH="$(BASH)" \ GPROFNG_BROKEN_JAVAC="$(GPROFNG_BROKEN_JAVAC)" \ MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS) $(PTHREAD_CFLAGS)" \ LDFLAGS="$(LDFLAGS)" LIBS="$(PTHREAD_LIBS) $(LIBS)" \ diff --git a/gprofng/Makefile.in b/gprofng/Makefile.in index dbc868191b7..5ced0e012eb 100644 --- a/gprofng/Makefile.in +++ b/gprofng/Makefile.in @@ -238,6 +238,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BASH = @BASH@ BISON = @BISON@ BUILD_SUBDIRS = @BUILD_SUBDIRS@ CC = @CC@ @@ -932,6 +933,7 @@ check-small check-extra check-install: site.exp development.exp @TCL_TRY_TRUE@ CLOCK_GETTIME_LINK="$(CLOCK_GETTIME_LINK)" \ @TCL_TRY_TRUE@ CHECK_TARGET=$@ \ @TCL_TRY_TRUE@ PREFIX="$(prefix)" \ +@TCL_TRY_TRUE@ BASH="$(BASH)" \ @TCL_TRY_TRUE@ GPROFNG_BROKEN_JAVAC="$(GPROFNG_BROKEN_JAVAC)" \ @TCL_TRY_TRUE@ MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS) $(PTHREAD_CFLAGS)" \ @TCL_TRY_TRUE@ LDFLAGS="$(LDFLAGS)" LIBS="$(PTHREAD_LIBS) $(LIBS)" \ diff --git a/gprofng/configure b/gprofng/configure index 17d1c500830..980553561bf 100755 --- a/gprofng/configure +++ b/gprofng/configure @@ -639,6 +639,7 @@ GPROFNG_CPPFLAGS GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS GPROFNG_CFLAGS LD_NO_AS_NEEDED +BASH BUILD_DOC_FALSE BUILD_DOC_TRUE BUILD_MAN_FALSE @@ -12248,7 +12249,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12251 "configure" +#line 12252 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12354,7 +12355,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12357 "configure" +#line 12358 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16861,6 +16862,48 @@ else fi +# Extract the first word of "bash", so it can be a program name with args. +set dummy bash; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_BASH+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $BASH in + [\\/]* | ?:[\\/]*) + ac_cv_path_BASH="$BASH" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_BASH="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +BASH=$ac_cv_path_BASH +if test -n "$BASH"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BASH" >&5 +$as_echo "$BASH" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + LD_NO_AS_NEEDED=${no_as_needed} GPROFNG_CFLAGS=${gprofng_cflags} diff --git a/gprofng/configure.ac b/gprofng/configure.ac index a7221d9eaf0..794e95793fc 100644 --- a/gprofng/configure.ac +++ b/gprofng/configure.ac @@ -228,6 +228,9 @@ fi AM_CONDITIONAL([BUILD_MAN], [test x$build_man = xtrue]) AM_CONDITIONAL([BUILD_DOC], [test x$build_doc = xtrue]) +AC_PATH_PROG([BASH], [bash]) +AC_SUBST([BASH]) + AC_SUBST(LD_NO_AS_NEEDED, [${no_as_needed}]) AC_SUBST(GPROFNG_CFLAGS, [${gprofng_cflags}]) AC_SUBST(GPROFNG_NO_FORMAT_TRUNCATION_CFLAGS) diff --git a/gprofng/doc/Makefile.in b/gprofng/doc/Makefile.in index 27a073e86b6..5b57544d91a 100644 --- a/gprofng/doc/Makefile.in +++ b/gprofng/doc/Makefile.in @@ -222,6 +222,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BASH = @BASH@ BISON = @BISON@ BUILD_SUBDIRS = @BUILD_SUBDIRS@ CC = @CC@ diff --git a/gprofng/gp-display-html/Makefile.in b/gprofng/gp-display-html/Makefile.in index 61c00cd6e46..b667ae91617 100644 --- a/gprofng/gp-display-html/Makefile.in +++ b/gprofng/gp-display-html/Makefile.in @@ -182,6 +182,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BASH = @BASH@ BISON = @BISON@ BUILD_SUBDIRS = @BUILD_SUBDIRS@ CC = @CC@ diff --git a/gprofng/src/Makefile.in b/gprofng/src/Makefile.in index db763ef71b2..cef4b275305 100644 --- a/gprofng/src/Makefile.in +++ b/gprofng/src/Makefile.in @@ -306,6 +306,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BASH = @BASH@ BISON = @BISON@ BUILD_SUBDIRS = @BUILD_SUBDIRS@ CC = @CC@ diff --git a/gprofng/testsuite/config/default.exp b/gprofng/testsuite/config/default.exp index 6b51d578d9f..74d1dad1b48 100644 --- a/gprofng/testsuite/config/default.exp +++ b/gprofng/testsuite/config/default.exp @@ -54,7 +54,7 @@ if { "$CHECK_TARGET" == "check-install" } { } set f [open "gprofng_wraper" w+] - puts $f "#!/usr/bin/bash" + puts $f "#!$BASH" puts $f "LD_LIBRARY_PATH=$ld_library_path:$orig_ld_library_path" puts $f "GPROFNG_SYSCONFDIR=$env(srcroot)/src" puts $f "GPROFNG_PRELOAD_LIBDIRS=$BUILDDIR/libcollector/.libs"