From 53e4e92e32721b1fa4490fbcd7ea6bb62f283839 Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 1 Nov 2017 22:55:49 +0000 Subject: [PATCH] Fix libssh2 detection. Fixes #1058. Closes #1059 --- configure | 51 +++++++++++++++++++++++++++++++++++++++++++-------- configure.ac | 8 ++++---- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/configure b/configure index 3c22b4bb1..8eb4c3d69 100755 --- a/configure +++ b/configure @@ -5552,8 +5552,8 @@ $as_echo "no" >&6; } if test -n "$PYTHON"; then # If the user set $PYTHON, use it and don't search something else. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version >= 2.4" >&5 -$as_echo_n "checking whether $PYTHON version >= 2.4... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version is >= 2.4" >&5 +$as_echo_n "checking whether $PYTHON version is >= 2.4... " >&6; } prog="import sys # split strings by '.' and convert to numeric. Append some zeros # because we need at least 4 digits for the hex conversion. @@ -5571,7 +5571,9 @@ sys.exit(sys.hexversion < minverhex)" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - as_fn_error $? "too old" "$LINENO" 5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "Python interpreter is too old" "$LINENO" 5 fi am_display_PYTHON=$PYTHON else @@ -5690,6 +5692,25 @@ $as_echo "$am_cv_python_platform" >&6; } PYTHON_PLATFORM=$am_cv_python_platform + # Just factor out some code duplication. + am_python_setup_sysconfig="\ +import sys +# Prefer sysconfig over distutils.sysconfig, for better compatibility +# with python 3.x. See automake bug#10227. +try: + import sysconfig +except ImportError: + can_use_sysconfig = 0 +else: + can_use_sysconfig = 1 +# Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs: +# +try: + from platform import python_implementation + if python_implementation() == 'CPython' and sys.version[:3] == '2.7': + can_use_sysconfig = 0 +except ImportError: + pass" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON script directory" >&5 @@ -5703,7 +5724,14 @@ else else am_py_prefix=$prefix fi - am_cv_python_pythondir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(0,0,prefix='$am_py_prefix'))" 2>/dev/null` + am_cv_python_pythondir=`$PYTHON -c " +$am_python_setup_sysconfig +if can_use_sysconfig: + sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'}) +else: + from distutils import sysconfig + sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix') +sys.stdout.write(sitedir)"` case $am_cv_python_pythondir in $am_py_prefix*) am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'` @@ -5740,7 +5768,14 @@ else else am_py_exec_prefix=$exec_prefix fi - am_cv_python_pyexecdir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(1,0,prefix='$am_py_exec_prefix'))" 2>/dev/null` + am_cv_python_pyexecdir=`$PYTHON -c " +$am_python_setup_sysconfig +if can_use_sysconfig: + sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'}) +else: + from distutils import sysconfig + sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix') +sys.stdout.write(sitedir)"` case $am_cv_python_pyexecdir in $am_py_exec_prefix*) am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'` @@ -6801,8 +6836,7 @@ if test "${with_libssh2+set}" = set; then : CPPFLAGS="-I$with_libssh2/include $CPPFLAGS" LDFLAGS="-L$with_libssh2/lib $LDFLAGS" - ac_fn_c_check_header_compile "$LINENO" "libssh2.h" "ac_cv_header_libssh2_h" "-lm -" + ac_fn_c_check_header_mongrel "$LINENO" "libssh2.h" "ac_cv_header_libssh2_h" "$ac_includes_default" if test "x$ac_cv_header_libssh2_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libssh2_version in -lssh2" >&5 @@ -6811,7 +6845,7 @@ if ${ac_cv_lib_ssh2_libssh2_version+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lssh2 $LIBS" +LIBS="-lssh2 -lm $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6847,6 +6881,7 @@ if test "x$ac_cv_lib_ssh2_libssh2_version" = xyes; then : LIBSSH2_LIB=$with_libssh2/lib fi + fi diff --git a/configure.ac b/configure.ac index 3d00e164e..9bea4c8ce 100644 --- a/configure.ac +++ b/configure.ac @@ -589,9 +589,8 @@ AC_HELP_STRING([--with-libz=included], [Always use version included with Nmap]), AC_CHECK_LIB(z, gzread, [have_libz=yes ZLIB_INC=$with_libz/include - ZLIB_LIB=$with_libz/lib]) - ],, - ) + ZLIB_LIB=$with_libz/lib],,) + ]) LDFLAGS=$_ldflags CPPFLAGS=$_cppflags @@ -674,7 +673,8 @@ AC_HELP_STRING([--without-libssh2], [Compile without libssh2]), AC_CHECK_LIB(ssh2, libssh2_version, [have_libssh2=yes LIBSSH2_INC=$with_libssh2/include - LIBSSH2_LIB=$with_libssh2/lib])],,[-lm]) + LIBSSH2_LIB=$with_libssh2/lib],,[-lm]) + ]) LDFLAGS=$_ldflags CPPFLAGS=$_cppflags