From abaa5855cb562f6899ed1a0dd456e9824adffdf2 Mon Sep 17 00:00:00 2001 From: Scott Fennell Date: Thu, 19 Nov 2020 17:20:26 -0600 Subject: [PATCH] 1076 why path dumb (#1080) Remove closes #1076 --- autoconf/configure.ac | 62 +++++++++++++--- configure | 164 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 206 insertions(+), 20 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 1a22a090..749c1e76 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -135,10 +135,15 @@ AC_DEFUN([AX_GTEST_HOME],[ AC_DEFUN([AX_SWIG_BIN],[ AC_ARG_WITH([swig], - AS_HELP_STRING([--with-swig@<:@=DIR@:>@], [path of directory containing the SWIG executable.]), - PATH="$withval:${PATH}" + [AS_HELP_STRING([--with-swig@<:@=DIR@:>@], [path of directory containing the SWIG executable.])], + [ + TEMP_PATH="${PATH}" + PATH="$withval:${PATH}" + AX_PKG_SWIG($1, [], [AC_MSG_ERROR([Trick requires SWIG version >= 2.0])]) + PATH="${TEMP_PATH}" + ], + [AX_PKG_SWIG($1, [], [AC_MSG_ERROR([Trick requires SWIG version >= 2.0])])] ) - AC_SUBST([SWIG_BIN]) ]) AC_DEFUN([AX_UDUNITS_HOME],[ @@ -150,6 +155,48 @@ AC_DEFUN([AX_UDUNITS_HOME],[ AC_SUBST([UDUNITS_HOME]) ]) +dnl SOURCE: https://stackoverflow.com/a/59191148 + +dnl NA_HELP_STRINGS(list1, help1[, list2, help2[, ... listN, helpN]]) +dnl ************************************************************************** +dnl +dnl Similar to `AS_HELP_STRING()`, but with support for multiple strings, each +dnl one associated with one or more options +dnl +dnl From: https://github.com/madmurphy/not-autotools +dnl +dnl ************************************************************************** +m4_define([NA_HELP_STRINGS], + [m4_if(m4_count($1), [1], + [m4_if([$#], [0], [], [$#], [1], + [m4_text_wrap($1, [ ])], + [AS_HELP_STRING(m4_normalize($1), [$2])m4_if([$#], [2], [], [m4_newline()NA_HELP_STRINGS(m4_shift2($@))])])], + [m4_text_wrap(m4_argn(1, $1)[,], [ ])m4_newline()NA_HELP_STRINGS(m4_dquote(m4_shift($1))m4_if([$#], [1], [], [, m4_shift($@)]))])]) + + + +dnl test if want to prepend /usr/local/bin to PATH +dnl AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given]) +AC_DEFUN( + [AX_PREPEND_PATH], + [AC_ARG_WITH( + [prepend-path], + [NA_HELP_STRINGS( +[--without-prepend-path], [do not prepend to path (this is default)], [--with-prepend-path@<:@=DIR@:>@], [specify a directory to prepend to PATH (default is /usr/local/bin)])], + [AS_IF( + [test "x${with_prepend_path}" = xyes], + [PATH="/usr/local/bin:${PATH}"], + [AS_IF( + [test "x${with_prepend_path}" != xno], + [PATH="${withval}:${PATH}"], + [] + )] + )], + [] + )] +) + + dnl test if we want to use java, default to yes AC_DEFUN([AX_JAVA],[ AC_ARG_ENABLE([java], @@ -230,9 +277,6 @@ case "${host_os}" in esac -dnl add extra paths to find programs -PATH="/usr/local/bin:${PATH}" - dnl add extra paths to find xml headers and X headers on the mac. AS_IF([test "$ON_MAC" = "yes"], [ @@ -416,11 +460,10 @@ PYTHON_LIBS=`${PYTHON_LIBS_COMMAND}` AC_SUBST([PYTHON_CPPFLAGS]) AC_SUBST([PYTHON_LIBS]) AC_SUBST([PYTHON_EXTRA_LIBS]) - +AX_PREPEND_PATH AC_PATH_PROG(GNUPLOT, gnuplot, nognuplot) AS_IF([test "$ac_cv_path_GNUPLOT" = "nognuplot"],AC_MSG_NOTICE([could not find gnuplot]),[]) -AX_SWIG_BIN([]) -AX_PKG_SWIG(2.0, [], [AC_MSG_ERROR([Trick requires SWIG version >= 2.0])]) +AX_SWIG_BIN([2.0]) AX_JAVA AX_PTHREAD() @@ -533,4 +576,3 @@ AX_ER7_UTILS([]) AC_OUTPUT([share/trick/makefiles/config_user.mk]) printf "\033@<:@32mconfigure script successfully completed\033@<:@0m\n" - diff --git a/configure b/configure index 171d4e3f..99964c27 100755 --- a/configure +++ b/configure @@ -650,7 +650,6 @@ JAVA_CC USE_JAVA SWIG_LIB SWIG -SWIG_BIN GNUPLOT PYTHON_EXTRA_LIBS PYTHON_LIBS @@ -745,6 +744,7 @@ enable_32bit enable_offline enable_mongoose with_python +with_prepend_path with_swig enable_java with_llvm @@ -1404,6 +1404,10 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-x use the X Window System --with-python[=DIR] python root directory + --without-prepend-path do not prepend to path (this is default) + --with-prepend-path[=DIR] + specify a directory to prepend to PATH (default is + /usr/local/bin) --with-swig[=DIR] path of directory containing the SWIG executable. --with-llvm[=DIR] LLVM root directory --with-zlib=DIR root directory path of zlib installation [defaults to @@ -2408,6 +2412,14 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + + + + + + + @@ -2500,8 +2512,6 @@ case "${host_os}" in esac -PATH="/usr/local/bin:${PATH}" - if test "$ON_MAC" = "yes"; then : # Extract the first word of "xcrun", so it can be a program name with args. @@ -5606,6 +5616,19 @@ PYTHON_LIBS=`${PYTHON_LIBS_COMMAND}` +# Check whether --with-prepend-path was given. +if test "${with_prepend_path+set}" = set; then : + withval=$with_prepend_path; if test "x${with_prepend_path}" = xyes; then : + PATH="/usr/local/bin:${PATH}" +else + if test "x${with_prepend_path}" != xno; then : + PATH="${withval}:${PATH}" +fi + +fi +fi + + # Extract the first word of "gnuplot", so it can be a program name with args. set dummy gnuplot; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -5655,12 +5678,9 @@ fi # Check whether --with-swig was given. if test "${with_swig+set}" = set; then : - withval=$with_swig; PATH="$withval:${PATH}" - -fi - - - + withval=$with_swig; + TEMP_PATH="${PATH}" + PATH="$withval:${PATH}" # Find path to the "swig" executable. for ac_prog in swig swig3.0 swig2.0 @@ -5779,6 +5799,131 @@ $as_echo "$as_me: WARNING: cannot determine SWIG version" >&2;} fi + PATH="${TEMP_PATH}" + +else + + # Find path to the "swig" executable. + for ac_prog in swig swig3.0 swig2.0 +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; 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_SWIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $SWIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_SWIG="$SWIG" # 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_SWIG="$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 +SWIG=$ac_cv_path_SWIG +if test -n "$SWIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SWIG" >&5 +$as_echo "$SWIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$SWIG" && break +done + + if test -z "$SWIG" ; then + as_fn_error $? "Trick requires SWIG version >= 2.0" "$LINENO" 5 + elif test -n "2.0" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking SWIG version" >&5 +$as_echo_n "checking SWIG version... " >&6; } + swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $swig_version" >&5 +$as_echo "$swig_version" >&6; } + if test -n "$swig_version" ; then + # Calculate the required version number components + required=2.0 + required_major=`echo $required | sed 's/[^0-9].*//'` + if test -z "$required_major" ; then + required_major=0 + fi + required=`echo $required | sed 's/[0-9]*[^0-9]//'` + required_minor=`echo $required | sed 's/[^0-9].*//'` + if test -z "$required_minor" ; then + required_minor=0 + fi + required=`echo $required | sed 's/[0-9]*[^0-9]//'` + required_patch=`echo $required | sed 's/[^0-9].*//'` + if test -z "$required_patch" ; then + required_patch=0 + fi + # Calculate the available version number components + available=$swig_version + available_major=`echo $available | sed 's/[^0-9].*//'` + if test -z "$available_major" ; then + available_major=0 + fi + available=`echo $available | sed 's/[0-9]*[^0-9]//'` + available_minor=`echo $available | sed 's/[^0-9].*//'` + if test -z "$available_minor" ; then + available_minor=0 + fi + available=`echo $available | sed 's/[0-9]*[^0-9]//'` + available_patch=`echo $available | sed 's/[^0-9].*//'` + if test -z "$available_patch" ; then + available_patch=0 + fi + # Convert the version tuple into a single number for easier comparison. + # Using base 100 should be safe since SWIG internally uses BCD values + # to encode its version number. + required_swig_vernum=`expr $required_major \* 10000 \ + \+ $required_minor \* 100 \+ $required_patch` + available_swig_vernum=`expr $available_major \* 10000 \ + \+ $available_minor \* 100 \+ $available_patch` + + if test $available_swig_vernum -lt $required_swig_vernum; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: SWIG version >= 2.0 is required. You have $swig_version." >&5 +$as_echo "$as_me: WARNING: SWIG version >= 2.0 is required. You have $swig_version." >&2;} + SWIG='' + as_fn_error $? "Trick requires SWIG version >= 2.0" "$LINENO" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SWIG library" >&5 +$as_echo_n "checking for SWIG library... " >&6; } + SWIG_LIB=`$SWIG -swiglib` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SWIG_LIB" >&5 +$as_echo "$SWIG_LIB" >&6; } + + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot determine SWIG version" >&5 +$as_echo "$as_me: WARNING: cannot determine SWIG version" >&2;} + SWIG='' + as_fn_error $? "Trick requires SWIG version >= 2.0" "$LINENO" 5 + fi + fi + + + +fi + + # Check whether --enable-java was given. if test "${enable_java+set}" = set; then : @@ -9182,4 +9327,3 @@ fi printf "\033[32mconfigure script successfully completed\033[0m\n" -