Skip to content

Commit

Permalink
New version of python lookup in configure
Browse files Browse the repository at this point in the history
- Thru extra library
  • Loading branch information
ingwarsw committed Sep 6, 2014
1 parent 044937e commit ebb31f3
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 23 deletions.
178 changes: 166 additions & 12 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,10 @@ SYMLINK
LIBNAME
EXENAME
PCRE
PYTHON_INCLUDE
PYTHON_LIB
PYTHON_INCLUDE_DIR
PYTHON_BIN
RANLIB
STRIP
SET_MAKE
Expand Down Expand Up @@ -4685,24 +4689,174 @@ fi

# python patch
if test "$enable_python" = "yes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: /python enabled" >&5
$as_echo "$as_me: /python enabled" >&6;}
ac_fn_c_check_header_mongrel "$LINENO" "Python.h" "ac_cv_header_Python_h" "$ac_includes_default"
if test "x$ac_cv_header_Python_h" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for python build information" >&5
$as_echo_n "checking for python build information... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
$as_echo "" >&6; }
for python in python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python; do
for ac_prog in $python
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 :
$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.
else
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_prog_PYTHON_BIN="$ac_prog"
$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

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; }
else
break
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


test -n "$PYTHON_BIN" && break
done

ax_python_bin=$PYTHON_BIN
if test x$ax_python_bin != x; then
as_ac_Lib=`$as_echo "ac_cv_lib_$ax_python_bin''_main" | $as_tr_sh`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -l$ax_python_bin" >&5
$as_echo_n "checking for main in -l$ax_python_bin... " >&6; }
if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-l$ax_python_bin $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
eval "$as_ac_Lib=yes"
else
eval "$as_ac_Lib=no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
eval ac_res=\$$as_ac_Lib
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
ax_python_lib=$ax_python_bin
else
ax_python_lib=no
fi

if test x$ax_python_lib == xno; then
as_ac_Lib=`$as_echo "ac_cv_lib_${ax_python_bin}m''_main" | $as_tr_sh`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -l${ax_python_bin}m" >&5
$as_echo_n "checking for main in -l${ax_python_bin}m... " >&6; }
if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-l${ax_python_bin}m $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
CFLAGS="$CFLAGS -DTFPYTHON"
pyinc=`python -c "import distutils.sysconfig; print distutils.sysconfig.get_python_inc()"`
pyver=`python -c "import distutils.sysconfig; print distutils.sysconfig.get_python_version()"`
CPPFLAGS="$CPPFLAGS -I$pyinc"
LIBS="$LIBS -lpython${pyver}"
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
eval "$as_ac_Lib=yes"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: /python disabled" >&5
$as_echo "$as_me: /python disabled" >&6;}
eval "$as_ac_Lib=no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
eval ac_res=\$$as_ac_Lib
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
ax_python_lib=${ax_python_bin}m
else
ax_python_lib=no
fi

fi
if test x$ax_python_lib != xno; then
ax_python_header=`$ax_python_bin -c "from distutils.sysconfig import *; print(get_config_var('CONFINCLUDEPY'))"`
if test x$ax_python_header != x; then
break;
fi
fi
fi
done
if test x$ax_python_bin = x; then
ax_python_bin=no
fi
if test x$ax_python_header = x; then
ax_python_header=no
fi
if test x$ax_python_lib = x; then
ax_python_lib=no
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: results of the Python check:" >&5
$as_echo " results of the Python check:" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Binary: $ax_python_bin" >&5
$as_echo " Binary: $ax_python_bin" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Library: $ax_python_lib" >&5
$as_echo " Library: $ax_python_lib" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Include Dir: $ax_python_header" >&5
$as_echo " Include Dir: $ax_python_header" >&6; }

if test x$ax_python_header != xno; then
PYTHON_INCLUDE_DIR=$ax_python_header

fi
if test x$ax_python_lib != xno; then
PYTHON_LIB=$ax_python_lib

fi

CFLAGS="$CFLAGS -DTFPYTHON"
PYTHON_INCLUDE="-I$PYTHON_INCLUDE_DIR"
PYTHON_LIB="-l$PYTHON_LIB"


fi


Expand Down
15 changes: 6 additions & 9 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,12 @@ fi

# python patch
if test "$enable_python" = "yes"; then
AC_MSG_NOTICE([/python enabled])
AC_CHECK_HEADER( Python.h, , break )
CFLAGS="$CFLAGS -DTFPYTHON"
pyinc=`python -c "import distutils.sysconfig; print distutils.sysconfig.get_python_inc()"`
pyver=`python -c "import distutils.sysconfig; print distutils.sysconfig.get_python_version()"`
CPPFLAGS="$CPPFLAGS -I$pyinc"
LIBS="$LIBS -lpython${pyver}"
else
AC_MSG_NOTICE([/python disabled])
AX_PYTHON
CFLAGS="$CFLAGS -DTFPYTHON"
PYTHON_INCLUDE="-I$PYTHON_INCLUDE_DIR"
PYTHON_LIB="-l$PYTHON_LIB"
AC_SUBST(PYTHON_INCLUDE)
AC_SUBST(PYTHON_LIB)
fi

dnl ### test termcap.
Expand Down
98 changes: 98 additions & 0 deletions m4/ax_python.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_python.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PYTHON
#
# DESCRIPTION
#
# This macro does a complete Python development environment check.
#
# It recurses through several python versions (from 2.1 to 2.6 in this
# version), looking for an executable. When it finds an executable, it
# looks to find the header files and library.
#
# It sets PYTHON_BIN to the name of the python executable,
# PYTHON_INCLUDE_DIR to the directory holding the header files, and
# PYTHON_LIB to the name of the Python library.
#
# This macro calls AC_SUBST on PYTHON_BIN (via AC_CHECK_PROG),
# PYTHON_INCLUDE_DIR and PYTHON_LIB.
#
# LICENSE
#
# Copyright (c) 2008 Michael Tindal
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.

#serial 14

AC_DEFUN([AX_PYTHON],
[AC_MSG_CHECKING(for python build information)
AC_MSG_RESULT([])
for python in python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python; do
AC_CHECK_PROGS(PYTHON_BIN, [$python])
ax_python_bin=$PYTHON_BIN
if test x$ax_python_bin != x; then
AC_CHECK_LIB($ax_python_bin, main, ax_python_lib=$ax_python_bin, ax_python_lib=no)
if test x$ax_python_lib == xno; then
AC_CHECK_LIB(${ax_python_bin}m, main, ax_python_lib=${ax_python_bin}m, ax_python_lib=no)
fi
if test x$ax_python_lib != xno; then
ax_python_header=`$ax_python_bin -c "from distutils.sysconfig import *; print(get_config_var('CONFINCLUDEPY'))"`
if test x$ax_python_header != x; then
break;
fi
fi
fi
done
if test x$ax_python_bin = x; then
ax_python_bin=no
fi
if test x$ax_python_header = x; then
ax_python_header=no
fi
if test x$ax_python_lib = x; then
ax_python_lib=no
fi
AC_MSG_RESULT([ results of the Python check:])
AC_MSG_RESULT([ Binary: $ax_python_bin])
AC_MSG_RESULT([ Library: $ax_python_lib])
AC_MSG_RESULT([ Include Dir: $ax_python_header])
if test x$ax_python_header != xno; then
PYTHON_INCLUDE_DIR=$ax_python_header
AC_SUBST(PYTHON_INCLUDE_DIR)
fi
if test x$ax_python_lib != xno; then
PYTHON_LIB=$ax_python_lib
AC_SUBST(PYTHON_LIB)
fi
])dnl
4 changes: 2 additions & 2 deletions unix/vars.mak.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ SYMLINK = @SYMLINK@
# MANTYPE = @MANTYPE@
MODE = @MODE@
CC = @CC@
CFLAGS = @CFLAGS@ @CPPFLAGS@ @LUA_DEFINES@ @LUA_INCLUDE@
CFLAGS = @CFLAGS@ @CPPFLAGS@ @LUA_DEFINES@ @LUA_INCLUDE@ @PYTHON_INCLUDE@
LDFLAGS = @LDFLAGS@
STD_C = @STD_C@
STRIP = @STRIP@
RANLIB = @RANLIB@
LIBS = @LIBS@ @LUA_LIB@
LIBS = @LIBS@ @LUA_LIB@ @PYTHON_LIB@
OTHER_OBJS = @OTHER_OBJS@
PCRE = @PCRE@

Expand Down

0 comments on commit ebb31f3

Please sign in to comment.