]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Just use python-config to configure the python module
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 10 Sep 2019 19:04:41 +0000 (14:04 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 10 Sep 2019 19:04:41 +0000 (14:04 -0500)
src/modules/rlm_python/configure
src/modules/rlm_python/configure.ac

index 759f59f92c1dbff84ada5083f8057ba182a15db3..b495cedb59b17994d4fe4301804f9edad494bf34 100755 (executable)
@@ -588,7 +588,7 @@ LIBOBJS
 targetname
 mod_cflags
 mod_ldflags
-PYTHON_BIN
+PYTHON_CONFIG_BIN
 CPP
 OBJEXT
 EXEEXT
@@ -638,9 +638,7 @@ SHELL'
 ac_subst_files=''
 ac_user_opts='
 enable_option_checking
-with_rlm_python_bin
-with_rlm_python_lib_dir
-with_rlm_python_include_dir
+with_rlm_python_config_bin
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1258,8 +1256,6 @@ Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-rlm-python-bin=PATH   Path to python binary
-  --with-rlm-python-lib-dir=DIR       Directory for Python library files
-  --with-rlm-python-include-dir=DIR   Directory for Python include files
 
 Some influential environment variables:
   CC          C compiler command
@@ -1425,52 +1421,6 @@ fi
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_cpp
-
-# ac_fn_c_try_link LINENO
-# -----------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_link ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-        test -z "$ac_c_werror_flag" ||
-        test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-        test "$cross_compiling" = yes ||
-        test -x conftest$ac_exeext
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-       ac_retval=1
-fi
-  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
-  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
-  # interfere with the next link command; also delete a directory that is
-  # left behind by Apple's compiler.  We do this before executing the actions.
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_link
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -2757,34 +2707,34 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
                PYHTON_BIN=
 
-# Check whether --with-rlm-python-bin was given.
-if test "${with_rlm_python_bin+set}" = set; then :
-  withval=$with_rlm_python_bin;  case "$withval" in
+# Check whether --with-rlm-python-config-bin was given.
+if test "${with_rlm_python_config_bin+set}" = set; then :
+  withval=$with_rlm_python_config_bin;  case "$withval" in
            no)
-               as_fn_error $? "Need rlm-python-bin" "$LINENO" 5
+               as_fn_error $? "Need rlm-python-config-bin" "$LINENO" 5
                ;;
            yes)
                ;;
            *)
-               PYTHON_BIN="$withval"
+               PYTHON_CONFIG_BIN="$withval"
                ;;
          esac
 
 fi
 
 
-       if test "x$PYTHON_BIN" = x; then
-               for ac_prog in  python2.7 python2.6 python
+       if test "x$PYTHON_CONFIG_BIN" = x; then
+               for ac_prog in  python2.7-config python-config
 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_prog_PYTHON_BIN+:} false; then :
+if ${ac_cv_prog_PYTHON_CONFIG_BIN+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$PYTHON_BIN"; then
-  ac_cv_prog_PYTHON_BIN="$PYTHON_BIN" # Let the user override the test.
+  if test -n "$PYTHON_CONFIG_BIN"; then
+  ac_cv_prog_PYTHON_CONFIG_BIN="$PYTHON_CONFIG_BIN" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 as_dummy="${PATH}:/usr/bin:/usr/local/bin"
@@ -2794,7 +2744,7 @@ do
   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_prog_PYTHON_BIN="$ac_prog"
+    ac_cv_prog_PYTHON_CONFIG_BIN="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -2804,702 +2754,50 @@ IFS=$as_save_IFS
 
 fi
 fi
-PYTHON_BIN=$ac_cv_prog_PYTHON_BIN
-if test -n "$PYTHON_BIN"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_BIN" >&5
-$as_echo "$PYTHON_BIN" >&6; }
+PYTHON_CONFIG_BIN=$ac_cv_prog_PYTHON_CONFIG_BIN
+if test -n "$PYTHON_CONFIG_BIN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_CONFIG_BIN" >&5
+$as_echo "$PYTHON_CONFIG_BIN" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-  test -n "$PYTHON_BIN" && break
+  test -n "$PYTHON_CONFIG_BIN" && break
 done
-test -n "$PYTHON_BIN" || PYTHON_BIN="not-found"
+test -n "$PYTHON_CONFIG_BIN" || PYTHON_CONFIG_BIN="not-found"
 
        fi
 
-       if test "x$PYTHON_BIN" = "xnot-found"; then
-               fail="python-binary"
+       if test "x$PYTHON_CONFIG_BIN" = "xnot-found"; then
+               fail="python-config"
        fi
 
-               PY_LIB_DIR=
-
-# Check whether --with-rlm-python-lib-dir was given.
-if test "${with_rlm_python_lib_dir+set}" = set; then :
-  withval=$with_rlm_python_lib_dir;  case "$withval" in
-           no)
-               as_fn_error $? "Need rlm-python-lib-dir" "$LINENO" 5
-               ;;
-           yes)
-               ;;
-           *)
-               PY_LIB_DIR="$withval"
-               ;;
-         esac
-
-fi
-
-
-               PY_INC_DIR=
-
-# Check whether --with-rlm-python-include-dir was given.
-if test "${with_rlm_python_include_dir+set}" = set; then :
-  withval=$with_rlm_python_include_dir;  case "$withval" in
-           no)
-               as_fn_error $? "Need rlm-python-include-dir" "$LINENO" 5
-               ;;
-           yes)
-               ;;
-           *)
-               PY_INC_DIR="$withval"
-               ;;
-         esac
-
-fi
-
-
-       if test x$fail = x; then
-               PY_PREFIX=`${PYTHON_BIN} -c 'import sys ; print(sys.prefix)'`
-               { $as_echo "$as_me:${as_lineno-$LINENO}: Python sys.prefix \"${PY_PREFIX}\"" >&5
-$as_echo "$as_me: Python sys.prefix \"${PY_PREFIX}\"" >&6;}
-
-               PY_EXEC_PREFIX=`${PYTHON_BIN} -c 'import sys ; print(sys.exec_prefix)'`
-               { $as_echo "$as_me:${as_lineno-$LINENO}: Python sys.exec_prefix \"${PY_EXEC_PREFIX}\"" >&5
-$as_echo "$as_me: Python sys.exec_prefix \"${PY_EXEC_PREFIX}\"" >&6;}
-
-               PY_SYS_VERSION=`${PYTHON_BIN} -c 'import sys ; print(sys.version[0:3])'`
-               { $as_echo "$as_me:${as_lineno-$LINENO}: Python sys.version \"${PY_SYS_VERSION}\"" >&5
-$as_echo "$as_me: Python sys.version \"${PY_SYS_VERSION}\"" >&6;}
-
-               PY_LIB_DIR="$PY_EXEC_PREFIX/lib/python${PY_SYS_VERSION}/config"
-               PY_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python${PY_SYS_VERSION}/config"
-
-               PY_MAKEFILE="$PY_EXEC_PREFIX/lib/python${PY_SYS_VERSION}/config/Makefile"
-               if test -f ${PY_MAKEFILE}; then
-                       PY_LOCAL_MOD_LIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE | sed -e 's/[[:blank:]]/ /g;s/^ *//;s/ *$//'`
-                       { $as_echo "$as_me:${as_lineno-$LINENO}: Python local_mod_libs \"${PY_LOCAL_MOD_LIBS}\"" >&5
-$as_echo "$as_me: Python local_mod_libs \"${PY_LOCAL_MOD_LIBS}\"" >&6;}
-
-                       PY_BASE_MOD_LIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE | sed -e 's/[[:blank:]]/ /g;s/^ *//;s/ *$//'`
-                       { $as_echo "$as_me:${as_lineno-$LINENO}: Python base_mod_libs \"${PY_BASE_MOD_LIBS}\"" >&5
-$as_echo "$as_me: Python base_mod_libs \"${PY_BASE_MOD_LIBS}\"" >&6;}
-
-                       PY_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PY_MAKEFILE | sed -e 's/[[:blank:]]/ /g;s/  / /g;s/^ *//;s/ *$//'`
-                       PY_OTHER_LDFLAGS=`sed -n -e 's/^LINKFORSHARED=\(.*\)/\1/p' $PY_MAKEFILE | sed -e 's/[[:blank:]]/ /g;s/  / /g;s/^ *//;s/ *$//'`
-                       { $as_echo "$as_me:${as_lineno-$LINENO}: Python other_libs \"${PY_OTHER_LDFLAGS} ${PY_OTHER_LIBS}\"" >&5
-$as_echo "$as_me: Python other_libs \"${PY_OTHER_LDFLAGS} ${PY_OTHER_LIBS}\"" >&6;}
-               fi
-               PY_EXTRA_LIBS="$PY_LOCALMODLIBS $PY_BASE_MOD_LIBS $PY_OTHER_LIBS"
-
-               old_CFLAGS=$CFLAGS
-               CFLAGS="$CFLAGS $PY_CFLAGS"
-               smart_try_dir="$PY_PREFIX/include/python$PY_SYS_VERSION"
-
-
-
-ac_safe=`echo "Python.h" | sed 'y%./+-%__pm%'`
-old_CPPFLAGS="$CPPFLAGS"
-smart_include=
-smart_include_dir="/usr/local/include /opt/include"
-
-_smart_try_dir=
-_smart_include_dir=
-
-for _prefix in $smart_prefix ""; do
-for _dir in $smart_try_dir; do
-  _smart_try_dir="${_smart_try_dir} ${_dir}/${_prefix}"
-done
-
-for _dir in $smart_include_dir; do
-  _smart_include_dir="${_smart_include_dir} ${_dir}/${_prefix}"
-done
-done
-
-if test "x$_smart_try_dir" != "x"; then
-for try in $_smart_try_dir; do
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python.h in $try" >&5
-$as_echo_n "checking for Python.h in $try... " >&6; }
-  CPPFLAGS="-isystem $try $old_CPPFLAGS"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-                   #include <Python.h>
-int
-main ()
-{
-int a = 1;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-                    smart_include="-isystem $try"
-                    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-                    break
-
-else
-
-                    smart_include=
-                    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-CPPFLAGS="$old_CPPFLAGS"
-fi
-
-if test "x$smart_include" = "x"; then
-for _prefix in $smart_prefix; do
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${_prefix}/Python.h" >&5
-$as_echo_n "checking for ${_prefix}/Python.h... " >&6; }
-
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-                   #include <Python.h>
-int
-main ()
-{
-int a = 1;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-                    smart_include="-isystem ${_prefix}/"
-                    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-                    break
-
-else
-
-                    smart_include=
-                    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-fi
-
-if test "x$smart_include" = "x"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python.h" >&5
-$as_echo_n "checking for Python.h... " >&6; }
-
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-                   #include <Python.h>
-int
-main ()
-{
-int a = 1;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-                    smart_include=" "
-                    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-                    break
-
-else
-
-                    smart_include=
-                    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-if test "x$smart_include" = "x"; then
-
-for prefix in $smart_prefix; do
-
-
-if test "x$LOCATE" != "x"; then
-DIRS=
-file="${_prefix}/${1}"
-
-for x in `${LOCATE} $file 2>/dev/null`; do
-                    base=`echo $x | sed "s%/${file}%%"`
-  if test "x$x" = "x$base"; then
-    continue;
-  fi
-
-  dir=`${DIRNAME} $x 2>/dev/null`
-        exclude=`echo ${dir} | ${GREP} /home`
-  if test "x$exclude" != "x"; then
-    continue
-  fi
-
-          already=`echo \$_smart_include_dir ${DIRS} | ${GREP} ${dir}`
-  if test "x$already" = "x"; then
-    DIRS="$DIRS $dir"
-  fi
-done
-fi
-
-eval "_smart_include_dir=\"\$_smart_include_dir $DIRS\""
-
-done
-
-
-if test "x$LOCATE" != "x"; then
-DIRS=
-file=Python.h
-
-for x in `${LOCATE} $file 2>/dev/null`; do
-                    base=`echo $x | sed "s%/${file}%%"`
-  if test "x$x" = "x$base"; then
-    continue;
-  fi
-
-  dir=`${DIRNAME} $x 2>/dev/null`
-        exclude=`echo ${dir} | ${GREP} /home`
-  if test "x$exclude" != "x"; then
-    continue
-  fi
-
-          already=`echo \$_smart_include_dir ${DIRS} | ${GREP} ${dir}`
-  if test "x$already" = "x"; then
-    DIRS="$DIRS $dir"
-  fi
-done
-fi
-
-eval "_smart_include_dir=\"\$_smart_include_dir $DIRS\""
-
-
-for try in $_smart_include_dir; do
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python.h in $try" >&5
-$as_echo_n "checking for Python.h in $try... " >&6; }
-  CPPFLAGS="-isystem $try $old_CPPFLAGS"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-                   #include <Python.h>
-int
-main ()
-{
-int a = 1;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-                    smart_include="-isystem $try"
-                    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-                    break
-
-else
-
-                    smart_include=
-                    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-CPPFLAGS="$old_CPPFLAGS"
-fi
-
-if test "x$smart_include" != "x"; then
-eval "ac_cv_header_$ac_safe=yes"
-CPPFLAGS="$smart_include $old_CPPFLAGS"
-SMART_CPPFLAGS="$smart_include $SMART_CPPFLAGS"
-fi
-
-smart_prefix=
-
-               CFLAGS=$old_CFLAGS
-
-               if test "x$ac_cv_header_Python_h" = "xyes"; then
-                       mod_cflags="$SMART_CPPFLAGS"
-               else
-                       fail="$fail Python.h"
-                       targetname=
-               fi
-
-               old_LIBS=$LIBS
-               LIBS="$LIBS $PY_LIB_LOC $PY_EXTRA_LIBS -lm"
-               smart_try_dir=$PY_LIB_DIR
-
-
-sm_lib_safe=`echo "python${PY_SYS_VERSION}" | sed 'y%./+-%__p_%'`
-sm_func_safe=`echo "Py_Initialize" | sed 'y%./+-%__p_%'`
-
-old_LIBS="$LIBS"
-old_CPPFLAGS="$CPPFLAGS"
-smart_lib=
-smart_ldflags=
-smart_lib_dir=
-
-if test "x$smart_try_dir" != "x"; then
-for try in $smart_try_dir; do
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Py_Initialize in -lpython${PY_SYS_VERSION} in $try" >&5
-$as_echo_n "checking for Py_Initialize in -lpython${PY_SYS_VERSION} in $try... " >&6; }
-  LIBS="-lpython${PY_SYS_VERSION} $old_LIBS"
-  CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-extern char Py_Initialize();
-int
-main ()
-{
-Py_Initialize()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-                smart_lib="-lpython${PY_SYS_VERSION}"
-                smart_ldflags="-L$try -Wl,-rpath,$try"
-                { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-                break
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-done
-LIBS="$old_LIBS"
-CPPFLAGS="$old_CPPFLAGS"
-fi
-
-if test "x$smart_lib" = "x"; then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Py_Initialize in -lpython${PY_SYS_VERSION}" >&5
-$as_echo_n "checking for Py_Initialize in -lpython${PY_SYS_VERSION}... " >&6; }
-LIBS="-lpython${PY_SYS_VERSION} $old_LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-extern char Py_Initialize();
-int
-main ()
-{
-Py_Initialize()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-               smart_lib="-lpython${PY_SYS_VERSION}"
-               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS="$old_LIBS"
-fi
-
-if test "x$smart_lib" = "x"; then
-
-
-if test "x$LOCATE" != "x"; then
-DIRS=
-file=libpython${PY_SYS_VERSION}${libltdl_cv_shlibext}
-
-for x in `${LOCATE} $file 2>/dev/null`; do
-                    base=`echo $x | sed "s%/${file}%%"`
-  if test "x$x" = "x$base"; then
-    continue;
-  fi
-
-  dir=`${DIRNAME} $x 2>/dev/null`
-        exclude=`echo ${dir} | ${GREP} /home`
-  if test "x$exclude" != "x"; then
-    continue
-  fi
-
-          already=`echo \$smart_lib_dir ${DIRS} | ${GREP} ${dir}`
-  if test "x$already" = "x"; then
-    DIRS="$DIRS $dir"
-  fi
-done
-fi
-
-eval "smart_lib_dir=\"\$smart_lib_dir $DIRS\""
-
-
-
-if test "x$LOCATE" != "x"; then
-DIRS=
-file=libpython${PY_SYS_VERSION}.a
-
-for x in `${LOCATE} $file 2>/dev/null`; do
-                    base=`echo $x | sed "s%/${file}%%"`
-  if test "x$x" = "x$base"; then
-    continue;
-  fi
-
-  dir=`${DIRNAME} $x 2>/dev/null`
-        exclude=`echo ${dir} | ${GREP} /home`
-  if test "x$exclude" != "x"; then
-    continue
-  fi
-
-          already=`echo \$smart_lib_dir ${DIRS} | ${GREP} ${dir}`
-  if test "x$already" = "x"; then
-    DIRS="$DIRS $dir"
-  fi
-done
-fi
-
-eval "smart_lib_dir=\"\$smart_lib_dir $DIRS\""
-
-
-for try in $smart_lib_dir /usr/local/lib /opt/lib; do
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Py_Initialize in -lpython${PY_SYS_VERSION} in $try" >&5
-$as_echo_n "checking for Py_Initialize in -lpython${PY_SYS_VERSION} in $try... " >&6; }
-  LIBS="-lpython${PY_SYS_VERSION} $old_LIBS"
-  CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-extern char Py_Initialize();
-int
-main ()
-{
-Py_Initialize()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-                 smart_lib="-lpython${PY_SYS_VERSION}"
-                 smart_ldflags="-L$try -Wl,-rpath,$try"
-                 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-                 break
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-done
-LIBS="$old_LIBS"
-CPPFLAGS="$old_CPPFLAGS"
-fi
-
-if test "x$smart_lib" != "x"; then
-eval "ac_cv_lib_${sm_lib_safe}_${sm_func_safe}=yes"
-LIBS="$smart_ldflags $smart_lib $old_LIBS"
-SMART_LIBS="$smart_ldflags $smart_lib $SMART_LIBS"
-fi
-
-               LIBS=$old_LIBS
-
-               eval t=\${ac_cv_lib_${sm_lib_safe}_${sm_func_safe}}
-               if test "x$t" = "xyes"; then
-                       mod_ldflags="$PY_LIB_LOC $PY_EXTRA_LIBS $SMART_LIBS -lm"
-                       targetname=rlm_python
-               else
-
-
-sm_lib_safe=`echo "python${PY_SYS_VERSION}m" | sed 'y%./+-%__p_%'`
-sm_func_safe=`echo "Py_Initialize" | sed 'y%./+-%__p_%'`
-
-old_LIBS="$LIBS"
-old_CPPFLAGS="$CPPFLAGS"
-smart_lib=
-smart_ldflags=
-smart_lib_dir=
-
-if test "x$smart_try_dir" != "x"; then
-for try in $smart_try_dir; do
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Py_Initialize in -lpython${PY_SYS_VERSION}m in $try" >&5
-$as_echo_n "checking for Py_Initialize in -lpython${PY_SYS_VERSION}m in $try... " >&6; }
-  LIBS="-lpython${PY_SYS_VERSION}m $old_LIBS"
-  CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-extern char Py_Initialize();
-int
-main ()
-{
-Py_Initialize()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-                smart_lib="-lpython${PY_SYS_VERSION}m"
-                smart_ldflags="-L$try -Wl,-rpath,$try"
-                { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-                break
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-done
-LIBS="$old_LIBS"
-CPPFLAGS="$old_CPPFLAGS"
-fi
-
-if test "x$smart_lib" = "x"; then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Py_Initialize in -lpython${PY_SYS_VERSION}m" >&5
-$as_echo_n "checking for Py_Initialize in -lpython${PY_SYS_VERSION}m... " >&6; }
-LIBS="-lpython${PY_SYS_VERSION}m $old_LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-extern char Py_Initialize();
-int
-main ()
-{
-Py_Initialize()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-               smart_lib="-lpython${PY_SYS_VERSION}m"
-               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS="$old_LIBS"
-fi
-
-if test "x$smart_lib" = "x"; then
-
-
-if test "x$LOCATE" != "x"; then
-DIRS=
-file=libpython${PY_SYS_VERSION}m${libltdl_cv_shlibext}
-
-for x in `${LOCATE} $file 2>/dev/null`; do
-                    base=`echo $x | sed "s%/${file}%%"`
-  if test "x$x" = "x$base"; then
-    continue;
-  fi
-
-  dir=`${DIRNAME} $x 2>/dev/null`
-        exclude=`echo ${dir} | ${GREP} /home`
-  if test "x$exclude" != "x"; then
-    continue
-  fi
-
-          already=`echo \$smart_lib_dir ${DIRS} | ${GREP} ${dir}`
-  if test "x$already" = "x"; then
-    DIRS="$DIRS $dir"
-  fi
-done
-fi
-
-eval "smart_lib_dir=\"\$smart_lib_dir $DIRS\""
-
-
-
-if test "x$LOCATE" != "x"; then
-DIRS=
-file=libpython${PY_SYS_VERSION}m.a
-
-for x in `${LOCATE} $file 2>/dev/null`; do
-                    base=`echo $x | sed "s%/${file}%%"`
-  if test "x$x" = "x$base"; then
-    continue;
-  fi
+       python_cflags=`${PYTHON_CONFIG_BIN} --cflags`
+       { $as_echo "$as_me:${as_lineno-$LINENO}: ${PYTHON_CONFIG_BIN}'s cflags were \"${python_cflags}\"" >&5
+$as_echo "$as_me: ${PYTHON_CONFIG_BIN}'s cflags were \"${python_cflags}\"" >&6;}
 
-  dir=`${DIRNAME} $x 2>/dev/null`
-        exclude=`echo ${dir} | ${GREP} /home`
-  if test "x$exclude" != "x"; then
-    continue
-  fi
 
-          already=`echo \$smart_lib_dir ${DIRS} | ${GREP} ${dir}`
-  if test "x$already" = "x"; then
-    DIRS="$DIRS $dir"
-  fi
-done
-fi
+               mod_cflags=`echo $python_cflags | sed -e '\
+               s/-I/-isystem/g;\
+               s/-isysroot[ =]\{0,1\}[^-]*//g;\
+               s/-O[[:digit:]][[:blank:]]*//g;\
+               s/-g[[:digit:]]*[[:blank:]]*//g;\
+               s/-Werror[[:blank:]]*//g;\
+               s/-DNDEBUG[[:blank:]]*//g'`
+       { $as_echo "$as_me:${as_lineno-$LINENO}: Sanitized cflags were \"${mod_cflags}\"" >&5
+$as_echo "$as_me: Sanitized cflags were \"${mod_cflags}\"" >&6;}
 
-eval "smart_lib_dir=\"\$smart_lib_dir $DIRS\""
+       python_ldflags=`${PYTHON_CONFIG_BIN} --ldflags`
+       { $as_echo "$as_me:${as_lineno-$LINENO}: ${PYTHON_CONFIG_BIN}'s ldflags were \"$python_ldflags}\"" >&5
+$as_echo "$as_me: ${PYTHON_CONFIG_BIN}'s ldflags were \"$python_ldflags}\"" >&6;}
 
+       mod_ldflags=$python_ldflags
+       { $as_echo "$as_me:${as_lineno-$LINENO}: Sanitized ldflags were \"${mod_ldflags}\"" >&5
+$as_echo "$as_me: Sanitized ldflags were \"${mod_ldflags}\"" >&6;}
 
-for try in $smart_lib_dir /usr/local/lib /opt/lib; do
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Py_Initialize in -lpython${PY_SYS_VERSION}m in $try" >&5
-$as_echo_n "checking for Py_Initialize in -lpython${PY_SYS_VERSION}m in $try... " >&6; }
-  LIBS="-lpython${PY_SYS_VERSION}m $old_LIBS"
-  CPPFLAGS="-L$try -Wl,-rpath,$try $old_CPPFLAGS"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-extern char Py_Initialize();
-int
-main ()
-{
-Py_Initialize()
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-
-                 smart_lib="-lpython${PY_SYS_VERSION}m"
-                 smart_ldflags="-L$try -Wl,-rpath,$try"
-                 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-                 break
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-done
-LIBS="$old_LIBS"
-CPPFLAGS="$old_CPPFLAGS"
-fi
-
-if test "x$smart_lib" != "x"; then
-eval "ac_cv_lib_${sm_lib_safe}_${sm_func_safe}=yes"
-LIBS="$smart_ldflags $smart_lib $old_LIBS"
-SMART_LIBS="$smart_ldflags $smart_lib $SMART_LIBS"
-fi
-
-                       eval t=\${ac_cv_lib_${sm_lib_safe}_${sm_func_safe}}
-                       if test "x$t" = "xyes"; then
-                               mod_ldflags="$PY_LIB_LOC $PY_EXTRA_LIBS $SMART_LIBS -lm"
-                               targetname=rlm_python
-                       else
-                               targetname=
-                               fail="$fail libpython$PY_SYS_VERSION"
-                       fi
-               fi
-       fi
+       targetname="rlm_python"
 else
        targetname=
        echo \*\*\* module rlm_python is disabled.
@@ -3521,6 +2819,8 @@ fi
 
 
 
+
+
 unset ac_cv_env_LIBS_set
 unset ac_cv_env_LIBS_value
 
index 831a33aad029a8b4851da9c4818177e18641ade0..ac34cbbaf69136385d28555acf5541c5d4f89d38 100644 (file)
@@ -8,124 +8,56 @@ if test x$with_[]modname != xno; then
        AC_PROG_CC
        AC_PROG_CPP
 
-       dnl extra argument: --with-rlm-python-bin
+       dnl extra argument: --with-rlm-python-config-bin
        PYHTON_BIN=
-       AC_ARG_WITH(rlm-python-bin,
+       AC_ARG_WITH(rlm-python-config-bin,
        [  --with-rlm-python-bin=PATH   Path to python binary []],
        [ case "$withval" in
            no)
-               AC_MSG_ERROR(Need rlm-python-bin)
+               AC_MSG_ERROR(Need rlm-python-config-bin)
                ;;
            yes)
                ;;
            *)
-               PYTHON_BIN="$withval"
+               PYTHON_CONFIG_BIN="$withval"
                ;;
          esac ]
        )
 
-       if test "x$PYTHON_BIN" = x; then
-               AC_CHECK_PROGS(PYTHON_BIN, [ python2.7 python2.6 python ], not-found, [${PATH}:/usr/bin:/usr/local/bin])
+       if test "x$PYTHON_CONFIG_BIN" = x; then
+               AC_CHECK_PROGS(PYTHON_CONFIG_BIN, [ python2.7-config python-config ], not-found, [${PATH}:/usr/bin:/usr/local/bin])
        fi
 
-       if test "x$PYTHON_BIN" = "xnot-found"; then
-               fail="python-binary"
+       if test "x$PYTHON_CONFIG_BIN" = "xnot-found"; then
+               fail="python-config"
        fi
 
-       dnl extra argument: --with-rlm-python-lib-dir
-       PY_LIB_DIR=
-       AC_ARG_WITH(rlm-python-lib-dir,
-       [  --with-rlm-python-lib-dir=DIR       Directory for Python library files []],
-       [ case "$withval" in
-           no)
-               AC_MSG_ERROR(Need rlm-python-lib-dir)
-               ;;
-           yes)
-               ;;
-           *)
-               PY_LIB_DIR="$withval"
-               ;;
-         esac ]
-       )
-
-       dnl extra argument: --with-rlm-python-include-dir
-       PY_INC_DIR=
-       AC_ARG_WITH(rlm-python-include-dir,
-       [  --with-rlm-python-include-dir=DIR   Directory for Python include files []],
-       [ case "$withval" in
-           no)
-               AC_MSG_ERROR(Need rlm-python-include-dir)
-               ;;
-           yes)
-               ;;
-           *)
-               PY_INC_DIR="$withval"
-               ;;
-         esac ]
-       )
-
-       if test x$fail = x; then
-               PY_PREFIX=`${PYTHON_BIN} -c 'import sys ; print(sys.prefix)'`
-               AC_MSG_NOTICE([Python sys.prefix \"${PY_PREFIX}\"])
-
-               PY_EXEC_PREFIX=`${PYTHON_BIN} -c 'import sys ; print(sys.exec_prefix)'`
-               AC_MSG_NOTICE([Python sys.exec_prefix \"${PY_EXEC_PREFIX}\"])
+       python_cflags=`${PYTHON_CONFIG_BIN} --cflags`
+       AC_MSG_NOTICE([${PYTHON_CONFIG_BIN}'s cflags were \"${python_cflags}\"])
 
-               PY_SYS_VERSION=`${PYTHON_BIN} -c 'import sys ; print(sys.version[[0:3]])'`
-               AC_MSG_NOTICE([Python sys.version \"${PY_SYS_VERSION}\"])
+       dnl # Convert -I to -isystem to get rid of warnings about issues in Python headers
+       dnl # Strip -systemroot
+       dnl # Strip optimisation flags (-O[0-9]?)
+       dnl # Strip debug symbol flags (-g[0-9]?)
+       dnl # Strip -Werror
 
-               PY_LIB_DIR="$PY_EXEC_PREFIX/lib/python${PY_SYS_VERSION}/config"
-               PY_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python${PY_SYS_VERSION}/config"
+       dnl # Strip -DNDEBUG
+       mod_cflags=`echo $python_cflags | sed -e '\
+               s/-I/-isystem/g;\
+               s/-isysroot[[ =]]\{0,1\}[[^-]]*//g;\
+               s/-O[[[:digit:]]][[[:blank:]]]*//g;\
+               s/-g[[[:digit:]]]*[[[:blank:]]]*//g;\
+               s/-Werror[[[:blank:]]]*//g;\
+               s/-DNDEBUG[[[:blank:]]]*//g'`
+       AC_MSG_NOTICE([Sanitized cflags were \"${mod_cflags}\"])
 
-               PY_MAKEFILE="$PY_EXEC_PREFIX/lib/python${PY_SYS_VERSION}/config/Makefile"
-               if test -f ${PY_MAKEFILE}; then
-                       PY_LOCAL_MOD_LIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE | sed -e 's/[[[:blank:]]]/ /g;s/^ *//;s/ *$//'`
-                       AC_MSG_NOTICE([Python local_mod_libs \"${PY_LOCAL_MOD_LIBS}\"])
+       python_ldflags=`${PYTHON_CONFIG_BIN} --ldflags`
+       AC_MSG_NOTICE([${PYTHON_CONFIG_BIN}'s ldflags were \"$python_ldflags}\"])
 
-                       PY_BASE_MOD_LIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE | sed -e 's/[[[:blank:]]]/ /g;s/^ *//;s/ *$//'`
-                       AC_MSG_NOTICE([Python base_mod_libs \"${PY_BASE_MOD_LIBS}\"])
+       mod_ldflags=$python_ldflags
+       AC_MSG_NOTICE([Sanitized ldflags were \"${mod_ldflags}\"])
 
-                       PY_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PY_MAKEFILE | sed -e 's/[[[:blank:]]]/ /g;s/  / /g;s/^ *//;s/ *$//'`
-                       PY_OTHER_LDFLAGS=`sed -n -e 's/^LINKFORSHARED=\(.*\)/\1/p' $PY_MAKEFILE | sed -e 's/[[[:blank:]]]/ /g;s/  / /g;s/^ *//;s/ *$//'`
-                       AC_MSG_NOTICE([Python other_libs \"${PY_OTHER_LDFLAGS} ${PY_OTHER_LIBS}\"])
-               fi
-               PY_EXTRA_LIBS="$PY_LOCALMODLIBS $PY_BASE_MOD_LIBS $PY_OTHER_LIBS"
-
-               old_CFLAGS=$CFLAGS
-               CFLAGS="$CFLAGS $PY_CFLAGS"
-               smart_try_dir="$PY_PREFIX/include/python$PY_SYS_VERSION"
-               FR_SMART_CHECK_INCLUDE(Python.h)
-               CFLAGS=$old_CFLAGS
-
-               if test "x$ac_cv_header_Python_h" = "xyes"; then
-                       mod_cflags="$SMART_CPPFLAGS"
-               else
-                       fail="$fail Python.h"
-                       targetname=
-               fi
-
-               old_LIBS=$LIBS
-               LIBS="$LIBS $PY_LIB_LOC $PY_EXTRA_LIBS -lm"
-               smart_try_dir=$PY_LIB_DIR
-               FR_SMART_CHECK_LIB(python${PY_SYS_VERSION}, Py_Initialize)
-               LIBS=$old_LIBS
-
-               eval t=\${ac_cv_lib_${sm_lib_safe}_${sm_func_safe}}
-               if test "x$t" = "xyes"; then
-                       mod_ldflags="$PY_LIB_LOC $PY_EXTRA_LIBS $SMART_LIBS -lm"
-                       targetname=modname
-               else
-                       FR_SMART_CHECK_LIB(python${PY_SYS_VERSION}m, Py_Initialize)
-                       eval t=\${ac_cv_lib_${sm_lib_safe}_${sm_func_safe}}
-                       if test "x$t" = "xyes"; then
-                               mod_ldflags="$PY_LIB_LOC $PY_EXTRA_LIBS $SMART_LIBS -lm"
-                               targetname=modname
-                       else
-                               targetname=
-                               fail="$fail libpython$PY_SYS_VERSION"
-                       fi
-               fi
-       fi
+       targetname="rlm_python"
 else
        targetname=
        echo \*\*\* module modname is disabled.
@@ -141,6 +73,8 @@ if test x"$fail" != x""; then
        fi
 fi
 
+
+
 AC_SUBST(mod_ldflags)
 AC_SUBST(mod_cflags)
 AC_SUBST(targetname)