diff options
Diffstat (limited to 'src/configure.in')
-rw-r--r-- | src/configure.in | 180 |
1 files changed, 179 insertions, 1 deletions
diff --git a/src/configure.in b/src/configure.in index 5896189e9d..a6fbc8540a 100644 --- a/src/configure.in +++ b/src/configure.in @@ -878,7 +878,7 @@ eof AC_MSG_RESULT(no) fi - dnl check that compiling a simple program still works with the flags + dnl Check that compiling a simple program still works with the flags dnl added for Python. AC_MSG_CHECKING([if compile and link flags for Python are sane]) cflags_save=$CFLAGS @@ -906,6 +906,7 @@ eof fi fi fi + AC_SUBST(PYTHON_CONFDIR) AC_SUBST(PYTHON_LIBS) AC_SUBST(PYTHON_GETPATH_CFLAGS) @@ -913,6 +914,183 @@ AC_SUBST(PYTHON_CFLAGS) AC_SUBST(PYTHON_SRC) AC_SUBST(PYTHON_OBJ) + +AC_MSG_CHECKING(--enable-python3interp argument) +AC_ARG_ENABLE(python3interp, + [ --enable-python3interp Include Python3 interpreter.], , + [enable_python3interp="no"]) +AC_MSG_RESULT($enable_python3interp) +if test "$enable_python3interp" = "yes"; then + dnl -- find the python3 executable + AC_PATH_PROG(vi_cv_path_python3, python3) + if test "X$vi_cv_path_python3" != "X"; then + + dnl -- get its version number + AC_CACHE_CHECK(Python version,vi_cv_var_python3_version, + [[vi_cv_var_python3_version=` + ${vi_cv_path_python3} -c 'import sys; print(sys.version[1:3])'` + ]]) + + dnl -- find where python3 thinks it was installed + AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx, + [ vi_cv_path_python3_pfx=` + ${vi_cv_path_python3} -c \ + "import sys; print(sys.prefix)"` ]) + + dnl -- and where it thinks it runs + AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx, + [ vi_cv_path_python3_epfx=` + ${vi_cv_path_python3} -c \ + "import sys; print(sys.exec_prefix)"` ]) + + dnl -- python3's internal library path + + AC_CACHE_VAL(vi_cv_path_python3path, + [ vi_cv_path_python3path=` + unset PYTHONPATH; + ${vi_cv_path_python3} -c \ + "import sys, string; print(':'.join(sys.path))"` ]) + + dnl -- where the Python implementation library archives are + + AC_ARG_WITH(python3-config-dir, + [ --with-python3-config-dir=PATH Python's config directory], + [ vi_cv_path_python3_conf="${withval}" ] ) + + AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf, + [ + vi_cv_path_python3_conf= + for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do + for subdir in lib share; do + d="${path}/${subdir}/python3${vi_cv_var_python3_version}/config" + if test -d "$d" && test -f "$d/config.c"; then + vi_cv_path_python3_conf="$d" + fi + done + done + ]) + + PYTHON3_CONFDIR="${vi_cv_path_python3_conf}" + + if test "X$PYTHON3_CONFDIR" = "X"; then + AC_MSG_RESULT([can't find it!]) + else + + dnl -- we need to examine Python's config/Makefile too + dnl see what the interpreter is built from + AC_CACHE_VAL(vi_cv_path_python3_plibs, + [ + pwd=`pwd` + tmp_mkf="$pwd/config-PyMake$$" + cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}" +__: + @echo "python3_MODLIBS='$(MODLIBS)'" + @echo "python3_LIBS='$(LIBS)'" + @echo "python3_SYSLIBS='$(SYSLIBS)'" + @echo "python3_LINKFORSHARED='$(LINKFORSHARED)'" +eof + dnl -- delete the lines from make about Entering/Leaving directory + eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`" + rm -f -- "${tmp_mkf}" + vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython3${vi_cv_var_python3_version}" + vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_MODLIBS} ${python3_LIBS} ${python3_SYSLIBS} ${python3_LINKFORSHARED}" + dnl remove -ltermcap, it can conflict with an earlier -lncurses + vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//` + vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//` + ]) + + PYTHON3_LIBS="${vi_cv_path_python3_plibs}" + if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python3${vi_cv_var_python3_version}" + else + PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python3${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python3${vi_cv_var_python3_version}" + fi + PYTHON3_SRC="if_python3.c" + dnl For Mac OSX 10.2 config.o is included in the Python library. + if test "x$MACOSX" = "xyes"; then + PYTHON3_OBJ="objects/if_python3.o" + else + PYTHON3_OBJ="objects/if_python3.o objects/py3_config.o" + fi + + dnl On FreeBSD linking with "-pthread" is required to use threads. + dnl _THREAD_SAFE must be used for compiling then. + dnl The "-pthread" is added to $LIBS, so that the following check for + dnl sigaltstack() will look in libc_r (it's there in libc!). + dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC + dnl will then define target-specific defines, e.g., -D_REENTRANT. + dnl Don't do this for Mac OSX, -pthread will generate a warning. + AC_MSG_CHECKING([if -pthread should be used]) + threadsafe_flag= + thread_lib= + dnl if test "x$MACOSX" != "xyes"; then + if test "`(uname) 2>/dev/null`" != Darwin; then + test "$GCC" = yes && threadsafe_flag="-pthread" + if test "`(uname) 2>/dev/null`" = FreeBSD; then + threadsafe_flag="-D_THREAD_SAFE" + thread_lib="-pthread" + fi + fi + libs_save_old=$LIBS + if test -n "$threadsafe_flag"; then + cflags_save=$CFLAGS + CFLAGS="$CFLAGS $threadsafe_flag" + LIBS="$LIBS $thread_lib" + AC_TRY_LINK(,[ ], + AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag", + AC_MSG_RESULT(no); LIBS=$libs_save_old + ) + CFLAGS=$cflags_save + else + AC_MSG_RESULT(no) + fi + + dnl check that compiling a simple program still works with the flags + dnl added for Python. + AC_MSG_CHECKING([if compile and link flags for Python are sane]) + cflags_save=$CFLAGS + libs_save=$LIBS + CFLAGS="$CFLAGS $PYTHON3_CFLAGS" + LIBS="$LIBS $PYTHON3_LIBS" + AC_TRY_LINK(,[ ], + AC_MSG_RESULT(yes); python3_ok=yes, + AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no) + CFLAGS=$cflags_save + LIBS=$libs_save + if test "$python3_ok" = yes; then + AC_DEFINE(FEAT_PYTHON3) + else + LIBS=$libs_save_old + PYTHON3_SRC= + PYTHON3_OBJ= + PYTHON3_LIBS= + PYTHON3_CFLAGS= + fi + fi + fi +fi + +AC_SUBST(PYTHON3_CONFDIR) +AC_SUBST(PYTHON3_LIBS) +AC_SUBST(PYTHON3_CFLAGS) +AC_SUBST(PYTHON3_SRC) +AC_SUBST(PYTHON3_OBJ) + +dnl if python2.x and python3.x are enabled one can only link in code +dnl with dlopen(), dlsym(), dlclose() +if test "$python_ok" = yes && test "$python3_ok" = yes; then + AC_DEFINE(DYNAMIC_PYTHON) + AC_DEFINE(DYNAMIC_PYTHON3) + PYTHON_SRC="if_python.c" + PYTHON_OBJ="objects/if_python.o" + PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"libpython${vi_cv_var_python_version}.so\\\"" + PYTHON_LIBS= + PYTHON3_SRC="if_python3.c" + PYTHON3_OBJ="objects/if_python3.o" + PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"libpython3${vi_cv_var_python3_version}.so\\\"" + PYTHON3_LIBS= +fi + AC_MSG_CHECKING(--enable-tclinterp argument) AC_ARG_ENABLE(tclinterp, [ --enable-tclinterp Include Tcl interpreter.], , |