a9e0067
To: vim_dev@googlegroups.com
a9e0067
Subject: Patch 7.3.062
a9e0067
Fcc: outbox
a9e0067
From: Bram Moolenaar <Bram@moolenaar.net>
a9e0067
Mime-Version: 1.0
a9e0067
Content-Type: text/plain; charset=UTF-8
a9e0067
Content-Transfer-Encoding: 8bit
a9e0067
------------
a9e0067
a9e0067
Patch 7.3.062
a9e0067
Problem:    Python doesn't work properly when installed in another directory
a9e0067
	    than expected.
a9e0067
Solution:   Figure out home directory in configure and use Py_SetPythonHome()
a9e0067
	    at runtime. (Roland Puntaier)
a9e0067
Files:	    src/configure.in, src/auto/configure, src/if_python.c,
a9e0067
	    src/if_python3.c
a9e0067
a9e0067
a9e0067
*** ../vim-7.3.061/src/configure.in	2010-11-03 22:32:18.000000000 +0100
a9e0067
--- src/configure.in	2010-11-16 17:47:36.000000000 +0100
a9e0067
***************
a9e0067
*** 891,899 ****
a9e0067
  
a9e0067
  	PYTHON_LIBS="${vi_cv_path_python_plibs}"
a9e0067
  	if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
a9e0067
! 	  PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
a9e0067
  	else
a9e0067
! 	  PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version}"
a9e0067
  	fi
a9e0067
  	PYTHON_SRC="if_python.c"
a9e0067
  	dnl For Mac OSX 10.2 config.o is included in the Python library.
a9e0067
--- 891,899 ----
a9e0067
  
a9e0067
  	PYTHON_LIBS="${vi_cv_path_python_plibs}"
a9e0067
  	if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
a9e0067
! 	  PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
a9e0067
  	else
a9e0067
! 	  PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
a9e0067
  	fi
a9e0067
  	PYTHON_SRC="if_python.c"
a9e0067
  	dnl For Mac OSX 10.2 config.o is included in the Python library.
a9e0067
***************
a9e0067
*** 905,911 ****
a9e0067
  	if test "${vi_cv_var_python_version}" = "1.4"; then
a9e0067
  	   PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
a9e0067
  	fi
a9e0067
! 	PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
a9e0067
  
a9e0067
  	dnl On FreeBSD linking with "-pthread" is required to use threads.
a9e0067
  	dnl _THREAD_SAFE must be used for compiling then.
a9e0067
--- 905,911 ----
a9e0067
  	if test "${vi_cv_var_python_version}" = "1.4"; then
a9e0067
  	   PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
a9e0067
  	fi
a9e0067
!     PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
a9e0067
  
a9e0067
  	dnl On FreeBSD linking with "-pthread" is required to use threads.
a9e0067
  	dnl _THREAD_SAFE must be used for compiling then.
a9e0067
***************
a9e0067
*** 1063,1071 ****
a9e0067
  
a9e0067
        PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
a9e0067
        if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
a9e0067
!         PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}"
a9e0067
        else
a9e0067
!         PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}"
a9e0067
        fi
a9e0067
        PYTHON3_SRC="if_python3.c"
a9e0067
        dnl For Mac OSX 10.2 config.o is included in the Python library.
a9e0067
--- 1063,1071 ----
a9e0067
  
a9e0067
        PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
a9e0067
        if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
a9e0067
!         PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
a9e0067
        else
a9e0067
!         PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
a9e0067
        fi
a9e0067
        PYTHON3_SRC="if_python3.c"
a9e0067
        dnl For Mac OSX 10.2 config.o is included in the Python library.
a9e0067
***************
a9e0067
*** 1143,1151 ****
a9e0067
  if test "$python_ok" = yes && test "$python3_ok" = yes; then
a9e0067
    AC_DEFINE(DYNAMIC_PYTHON)
a9e0067
    AC_DEFINE(DYNAMIC_PYTHON3)
a9e0067
!   AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL)
a9e0067
    cflags_save=$CFLAGS
a9e0067
!   CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
a9e0067
    ldflags_save=$LDFLAGS
a9e0067
    LDFLAGS="$LDFLAGS -ldl"
a9e0067
    AC_RUN_IFELSE([
a9e0067
--- 1143,1151 ----
a9e0067
  if test "$python_ok" = yes && test "$python3_ok" = yes; then
a9e0067
    AC_DEFINE(DYNAMIC_PYTHON)
a9e0067
    AC_DEFINE(DYNAMIC_PYTHON3)
a9e0067
!   AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
a9e0067
    cflags_save=$CFLAGS
a9e0067
!   CFLAGS="$CFLAGS $PYTHON_CFLAGS"
a9e0067
    ldflags_save=$LDFLAGS
a9e0067
    LDFLAGS="$LDFLAGS -ldl"
a9e0067
    AC_RUN_IFELSE([
a9e0067
***************
a9e0067
*** 1156,1170 ****
a9e0067
       * Only the first pyhton version used will be switched on.
a9e0067
       */
a9e0067
  
a9e0067
!     int no_rtl_global_needed_for(char *python_instsoname)
a9e0067
      {
a9e0067
        int needed = 0;
a9e0067
        void* pylib = dlopen(python_instsoname, RTLD_LAZY);
a9e0067
        if (pylib != 0)
a9e0067
        {
a9e0067
            void (*init)(void) = dlsym(pylib, "Py_Initialize");
a9e0067
            int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
a9e0067
            void (*final)(void) = dlsym(pylib, "Py_Finalize");
a9e0067
            (*init)();
a9e0067
            needed = (*simple)("import termios") == -1;
a9e0067
            (*final)();
a9e0067
--- 1156,1172 ----
a9e0067
       * Only the first pyhton version used will be switched on.
a9e0067
       */
a9e0067
  
a9e0067
!     int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
a9e0067
      {
a9e0067
        int needed = 0;
a9e0067
        void* pylib = dlopen(python_instsoname, RTLD_LAZY);
a9e0067
        if (pylib != 0)
a9e0067
        {
a9e0067
+           void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
a9e0067
            void (*init)(void) = dlsym(pylib, "Py_Initialize");
a9e0067
            int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
a9e0067
            void (*final)(void) = dlsym(pylib, "Py_Finalize");
a9e0067
+           (*pfx)(prefix);
a9e0067
            (*init)();
a9e0067
            needed = (*simple)("import termios") == -1;
a9e0067
            (*final)();
a9e0067
***************
a9e0067
*** 1176,1188 ****
a9e0067
      int main(int argc, char** argv)
a9e0067
      {
a9e0067
        int not_needed = 0;
a9e0067
!       if (no_rtl_global_needed_for("libpython2.7.so.1.0") && no_rtl_global_needed_for("libpython3.1.so.1.0"))
a9e0067
              not_needed = 1;
a9e0067
        return !not_needed;
a9e0067
      }],
a9e0067
      [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
a9e0067
    CFLAGS=$cflags_save
a9e0067
    LDFLAGS=$ldflags_save
a9e0067
    PYTHON_SRC="if_python.c"
a9e0067
    PYTHON_OBJ="objects/if_python.o"
a9e0067
    PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
a9e0067
--- 1178,1237 ----
a9e0067
      int main(int argc, char** argv)
a9e0067
      {
a9e0067
        int not_needed = 0;
a9e0067
!       if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}"))
a9e0067
              not_needed = 1;
a9e0067
        return !not_needed;
a9e0067
      }],
a9e0067
      [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
a9e0067
+ 
a9e0067
    CFLAGS=$cflags_save
a9e0067
    LDFLAGS=$ldflags_save
a9e0067
+ 
a9e0067
+   AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
a9e0067
+   cflags_save=$CFLAGS
a9e0067
+   CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
a9e0067
+   ldflags_save=$LDFLAGS
a9e0067
+   LDFLAGS="$LDFLAGS -ldl"
a9e0067
+   AC_RUN_IFELSE([
a9e0067
+     #include <dlfcn.h>
a9e0067
+     #include <wchar.h>
a9e0067
+     /* If this program fails, then RTLD_GLOBAL is needed.
a9e0067
+      * RTLD_GLOBAL will be used and then it is not possible to
a9e0067
+      * have both python versions enabled in the same vim instance.
a9e0067
+      * Only the first pyhton version used will be switched on.
a9e0067
+      */
a9e0067
+ 
a9e0067
+     int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
a9e0067
+     {
a9e0067
+       int needed = 0;
a9e0067
+       void* pylib = dlopen(python_instsoname, RTLD_LAZY);
a9e0067
+       if (pylib != 0)
a9e0067
+       {
a9e0067
+           void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
a9e0067
+           void (*init)(void) = dlsym(pylib, "Py_Initialize");
a9e0067
+           int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
a9e0067
+           void (*final)(void) = dlsym(pylib, "Py_Finalize");
a9e0067
+           (*pfx)(prefix);
a9e0067
+           (*init)();
a9e0067
+           needed = (*simple)("import termios") == -1;
a9e0067
+           (*final)();
a9e0067
+           dlclose(pylib);
a9e0067
+       }
a9e0067
+       return !needed;
a9e0067
+     }
a9e0067
+ 
a9e0067
+     int main(int argc, char** argv)
a9e0067
+     {
a9e0067
+       int not_needed = 0;
a9e0067
+       if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}"))
a9e0067
+             not_needed = 1;
a9e0067
+       return !not_needed;
a9e0067
+     }],
a9e0067
+     [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
a9e0067
+ 
a9e0067
+   CFLAGS=$cflags_save
a9e0067
+   LDFLAGS=$ldflags_save
a9e0067
+ 
a9e0067
    PYTHON_SRC="if_python.c"
a9e0067
    PYTHON_OBJ="objects/if_python.o"
a9e0067
    PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
a9e0067
*** ../vim-7.3.061/src/auto/configure	2010-11-03 22:32:18.000000000 +0100
a9e0067
--- src/auto/configure	2010-11-16 17:47:42.000000000 +0100
a9e0067
***************
a9e0067
*** 5326,5334 ****
a9e0067
  
a9e0067
  	PYTHON_LIBS="${vi_cv_path_python_plibs}"
a9e0067
  	if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
a9e0067
! 	  PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}"
a9e0067
  	else
a9e0067
! 	  PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version}"
a9e0067
  	fi
a9e0067
  	PYTHON_SRC="if_python.c"
a9e0067
  		if test "x$MACOSX" = "xyes"; then
a9e0067
--- 5326,5334 ----
a9e0067
  
a9e0067
  	PYTHON_LIBS="${vi_cv_path_python_plibs}"
a9e0067
  	if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
a9e0067
! 	  PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
a9e0067
  	else
a9e0067
! 	  PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
a9e0067
  	fi
a9e0067
  	PYTHON_SRC="if_python.c"
a9e0067
  		if test "x$MACOSX" = "xyes"; then
a9e0067
***************
a9e0067
*** 5339,5345 ****
a9e0067
  	if test "${vi_cv_var_python_version}" = "1.4"; then
a9e0067
  	   PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
a9e0067
  	fi
a9e0067
! 	PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
a9e0067
  
a9e0067
  								{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if -pthread should be used" >&5
a9e0067
  $as_echo_n "checking if -pthread should be used... " >&6; }
a9e0067
--- 5339,5345 ----
a9e0067
  	if test "${vi_cv_var_python_version}" = "1.4"; then
a9e0067
  	   PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
a9e0067
  	fi
a9e0067
!     PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
a9e0067
  
a9e0067
  								{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if -pthread should be used" >&5
a9e0067
  $as_echo_n "checking if -pthread should be used... " >&6; }
a9e0067
***************
a9e0067
*** 5601,5609 ****
a9e0067
  
a9e0067
        PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
a9e0067
        if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
a9e0067
!         PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}"
a9e0067
        else
a9e0067
!         PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}"
a9e0067
        fi
a9e0067
        PYTHON3_SRC="if_python3.c"
a9e0067
              if test "x$MACOSX" = "xyes"; then
a9e0067
--- 5601,5609 ----
a9e0067
  
a9e0067
        PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
a9e0067
        if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
a9e0067
!         PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
a9e0067
        else
a9e0067
!         PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
a9e0067
        fi
a9e0067
        PYTHON3_SRC="if_python3.c"
a9e0067
              if test "x$MACOSX" = "xyes"; then
a9e0067
***************
a9e0067
*** 5708,5717 ****
a9e0067
  
a9e0067
    $as_echo "#define DYNAMIC_PYTHON3 1" >>confdefs.h
a9e0067
  
a9e0067
!   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can do without RTLD_GLOBAL" >&5
a9e0067
! $as_echo_n "checking whether we can do without RTLD_GLOBAL... " >&6; }
a9e0067
    cflags_save=$CFLAGS
a9e0067
!   CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
a9e0067
    ldflags_save=$LDFLAGS
a9e0067
    LDFLAGS="$LDFLAGS -ldl"
a9e0067
    if test "$cross_compiling" = yes; then :
a9e0067
--- 5708,5717 ----
a9e0067
  
a9e0067
    $as_echo "#define DYNAMIC_PYTHON3 1" >>confdefs.h
a9e0067
  
a9e0067
!   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can do without RTLD_GLOBAL for Python" >&5
a9e0067
! $as_echo_n "checking whether we can do without RTLD_GLOBAL for Python... " >&6; }
a9e0067
    cflags_save=$CFLAGS
a9e0067
!   CFLAGS="$CFLAGS $PYTHON_CFLAGS"
a9e0067
    ldflags_save=$LDFLAGS
a9e0067
    LDFLAGS="$LDFLAGS -ldl"
a9e0067
    if test "$cross_compiling" = yes; then :
a9e0067
***************
a9e0067
*** 5730,5744 ****
a9e0067
       * Only the first pyhton version used will be switched on.
a9e0067
       */
a9e0067
  
a9e0067
!     int no_rtl_global_needed_for(char *python_instsoname)
a9e0067
      {
a9e0067
        int needed = 0;
a9e0067
        void* pylib = dlopen(python_instsoname, RTLD_LAZY);
a9e0067
        if (pylib != 0)
a9e0067
        {
a9e0067
            void (*init)(void) = dlsym(pylib, "Py_Initialize");
a9e0067
            int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
a9e0067
            void (*final)(void) = dlsym(pylib, "Py_Finalize");
a9e0067
            (*init)();
a9e0067
            needed = (*simple)("import termios") == -1;
a9e0067
            (*final)();
a9e0067
--- 5730,5746 ----
a9e0067
       * Only the first pyhton version used will be switched on.
a9e0067
       */
a9e0067
  
a9e0067
!     int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
a9e0067
      {
a9e0067
        int needed = 0;
a9e0067
        void* pylib = dlopen(python_instsoname, RTLD_LAZY);
a9e0067
        if (pylib != 0)
a9e0067
        {
a9e0067
+           void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
a9e0067
            void (*init)(void) = dlsym(pylib, "Py_Initialize");
a9e0067
            int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
a9e0067
            void (*final)(void) = dlsym(pylib, "Py_Finalize");
a9e0067
+           (*pfx)(prefix);
a9e0067
            (*init)();
a9e0067
            needed = (*simple)("import termios") == -1;
a9e0067
            (*final)();
a9e0067
***************
a9e0067
*** 5750,5756 ****
a9e0067
      int main(int argc, char** argv)
a9e0067
      {
a9e0067
        int not_needed = 0;
a9e0067
!       if (no_rtl_global_needed_for("libpython2.7.so.1.0") && no_rtl_global_needed_for("libpython3.1.so.1.0"))
a9e0067
              not_needed = 1;
a9e0067
        return !not_needed;
a9e0067
      }
a9e0067
--- 5752,5758 ----
a9e0067
      int main(int argc, char** argv)
a9e0067
      {
a9e0067
        int not_needed = 0;
a9e0067
!       if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}"))
a9e0067
              not_needed = 1;
a9e0067
        return !not_needed;
a9e0067
      }
a9e0067
***************
a9e0067
*** 5767,5774 ****
a9e0067
--- 5769,5844 ----
a9e0067
    conftest.$ac_objext conftest.beam conftest.$ac_ext
a9e0067
  fi
a9e0067
  
a9e0067
+ 
a9e0067
    CFLAGS=$cflags_save
a9e0067
    LDFLAGS=$ldflags_save
a9e0067
+ 
a9e0067
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can do without RTLD_GLOBAL for Python3" >&5
a9e0067
+ $as_echo_n "checking whether we can do without RTLD_GLOBAL for Python3... " >&6; }
a9e0067
+   cflags_save=$CFLAGS
a9e0067
+   CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
a9e0067
+   ldflags_save=$LDFLAGS
a9e0067
+   LDFLAGS="$LDFLAGS -ldl"
a9e0067
+   if test "$cross_compiling" = yes; then :
a9e0067
+   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
a9e0067
+ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
a9e0067
+ as_fn_error "cannot run test program while cross compiling
a9e0067
+ See \`config.log' for more details." "$LINENO" 5; }
a9e0067
+ else
a9e0067
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
a9e0067
+ /* end confdefs.h.  */
a9e0067
+ 
a9e0067
+     #include <dlfcn.h>
a9e0067
+     #include <wchar.h>
a9e0067
+     /* If this program fails, then RTLD_GLOBAL is needed.
a9e0067
+      * RTLD_GLOBAL will be used and then it is not possible to
a9e0067
+      * have both python versions enabled in the same vim instance.
a9e0067
+      * Only the first pyhton version used will be switched on.
a9e0067
+      */
a9e0067
+ 
a9e0067
+     int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
a9e0067
+     {
a9e0067
+       int needed = 0;
a9e0067
+       void* pylib = dlopen(python_instsoname, RTLD_LAZY);
a9e0067
+       if (pylib != 0)
a9e0067
+       {
a9e0067
+           void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
a9e0067
+           void (*init)(void) = dlsym(pylib, "Py_Initialize");
a9e0067
+           int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
a9e0067
+           void (*final)(void) = dlsym(pylib, "Py_Finalize");
a9e0067
+           (*pfx)(prefix);
a9e0067
+           (*init)();
a9e0067
+           needed = (*simple)("import termios") == -1;
a9e0067
+           (*final)();
a9e0067
+           dlclose(pylib);
a9e0067
+       }
a9e0067
+       return !needed;
a9e0067
+     }
a9e0067
+ 
a9e0067
+     int main(int argc, char** argv)
a9e0067
+     {
a9e0067
+       int not_needed = 0;
a9e0067
+       if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}"))
a9e0067
+             not_needed = 1;
a9e0067
+       return !not_needed;
a9e0067
+     }
a9e0067
+ _ACEOF
a9e0067
+ if ac_fn_c_try_run "$LINENO"; then :
a9e0067
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
a9e0067
+ $as_echo "yes" >&6; };$as_echo "#define PY3_NO_RTLD_GLOBAL 1" >>confdefs.h
a9e0067
+ 
a9e0067
+ else
a9e0067
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
a9e0067
+ $as_echo "no" >&6; }
a9e0067
+ fi
a9e0067
+ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
a9e0067
+   conftest.$ac_objext conftest.beam conftest.$ac_ext
a9e0067
+ fi
a9e0067
+ 
a9e0067
+ 
a9e0067
+   CFLAGS=$cflags_save
a9e0067
+   LDFLAGS=$ldflags_save
a9e0067
+ 
a9e0067
    PYTHON_SRC="if_python.c"
a9e0067
    PYTHON_OBJ="objects/if_python.o"
a9e0067
    PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
a9e0067
*** ../vim-7.3.061/src/if_python.c	2010-10-23 14:02:48.000000000 +0200
a9e0067
--- src/if_python.c	2010-11-16 17:07:00.000000000 +0100
a9e0067
***************
a9e0067
*** 102,108 ****
a9e0067
  #  include <dlfcn.h>
a9e0067
  #  define FARPROC void*
a9e0067
  #  define HINSTANCE void*
a9e0067
! #  ifdef PY_NO_RTLD_GLOBAL
a9e0067
  #   define load_dll(n) dlopen((n), RTLD_LAZY)
a9e0067
  #  else
a9e0067
  #   define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
a9e0067
--- 102,108 ----
a9e0067
  #  include <dlfcn.h>
a9e0067
  #  define FARPROC void*
a9e0067
  #  define HINSTANCE void*
a9e0067
! #  if defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)
a9e0067
  #   define load_dll(n) dlopen((n), RTLD_LAZY)
a9e0067
  #  else
a9e0067
  #   define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
a9e0067
***************
a9e0067
*** 168,173 ****
a9e0067
--- 168,174 ----
a9e0067
  # define Py_BuildValue dll_Py_BuildValue
a9e0067
  # define Py_FindMethod dll_Py_FindMethod
a9e0067
  # define Py_InitModule4 dll_Py_InitModule4
a9e0067
+ # define Py_SetPythonHome dll_Py_SetPythonHome
a9e0067
  # define Py_Initialize dll_Py_Initialize
a9e0067
  # define Py_Finalize dll_Py_Finalize
a9e0067
  # define Py_IsInitialized dll_Py_IsInitialized
a9e0067
***************
a9e0067
*** 226,231 ****
a9e0067
--- 227,233 ----
a9e0067
  static PyObject*(*dll_Py_BuildValue)(char *, ...);
a9e0067
  static PyObject*(*dll_Py_FindMethod)(struct PyMethodDef[], PyObject *, char *);
a9e0067
  static PyObject*(*dll_Py_InitModule4)(char *, struct PyMethodDef *, char *, PyObject *, int);
a9e0067
+ static void(*dll_Py_SetPythonHome)(char *home);
a9e0067
  static void(*dll_Py_Initialize)(void);
a9e0067
  static void(*dll_Py_Finalize)(void);
a9e0067
  static int(*dll_Py_IsInitialized)(void);
a9e0067
***************
a9e0067
*** 310,315 ****
a9e0067
--- 312,318 ----
a9e0067
  # else
a9e0067
      {"Py_InitModule4", (PYTHON_PROC*)&dll_Py_InitModule4},
a9e0067
  # endif
a9e0067
+     {"Py_SetPythonHome", (PYTHON_PROC*)&dll_Py_SetPythonHome},
a9e0067
      {"Py_Initialize", (PYTHON_PROC*)&dll_Py_Initialize},
a9e0067
      {"Py_Finalize", (PYTHON_PROC*)&dll_Py_Finalize},
a9e0067
      {"Py_IsInitialized", (PYTHON_PROC*)&dll_Py_IsInitialized},
a9e0067
***************
a9e0067
*** 349,355 ****
a9e0067
  {
a9e0067
      int i;
a9e0067
  
a9e0067
! #if !defined(PY_NO_RTLD_GLOBAL) && defined(UNIX) && defined(FEAT_PYTHON3)
a9e0067
      /* Can't have Python and Python3 loaded at the same time.
a9e0067
       * It cause a crash, because RTLD_GLOBAL is needed for
a9e0067
       * standard C extension libraries of one or both python versions. */
a9e0067
--- 352,358 ----
a9e0067
  {
a9e0067
      int i;
a9e0067
  
a9e0067
! #if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON3)
a9e0067
      /* Can't have Python and Python3 loaded at the same time.
a9e0067
       * It cause a crash, because RTLD_GLOBAL is needed for
a9e0067
       * standard C extension libraries of one or both python versions. */
a9e0067
***************
a9e0067
*** 543,548 ****
a9e0067
--- 546,555 ----
a9e0067
  	}
a9e0067
  #endif
a9e0067
  
a9e0067
+ #ifdef PYTHON_HOME
a9e0067
+ 	Py_SetPythonHome(PYTHON_HOME);
a9e0067
+ #endif
a9e0067
+ 
a9e0067
  	init_structs();
a9e0067
  
a9e0067
  #if !defined(MACOS) || defined(MACOS_X_UNIX)
a9e0067
*** ../vim-7.3.061/src/if_python3.c	2010-10-23 14:02:48.000000000 +0200
a9e0067
--- src/if_python3.c	2010-11-16 17:07:26.000000000 +0100
a9e0067
***************
a9e0067
*** 80,86 ****
a9e0067
  #  include <dlfcn.h>
a9e0067
  #  define FARPROC void*
a9e0067
  #  define HINSTANCE void*
a9e0067
! #  ifdef PY_NO_RTLD_GLOBAL
a9e0067
  #   define load_dll(n) dlopen((n), RTLD_LAZY)
a9e0067
  #  else
a9e0067
  #   define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
a9e0067
--- 80,86 ----
a9e0067
  #  include <dlfcn.h>
a9e0067
  #  define FARPROC void*
a9e0067
  #  define HINSTANCE void*
a9e0067
! #  if defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)
a9e0067
  #   define load_dll(n) dlopen((n), RTLD_LAZY)
a9e0067
  #  else
a9e0067
  #   define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
a9e0067
***************
a9e0067
*** 132,137 ****
a9e0067
--- 132,138 ----
a9e0067
  # define PyType_Ready py3_PyType_Ready
a9e0067
  #undef Py_BuildValue
a9e0067
  # define Py_BuildValue py3_Py_BuildValue
a9e0067
+ # define Py_SetPythonHome py3_Py_SetPythonHome
a9e0067
  # define Py_Initialize py3_Py_Initialize
a9e0067
  # define Py_Finalize py3_Py_Finalize
a9e0067
  # define Py_IsInitialized py3_Py_IsInitialized
a9e0067
***************
a9e0067
*** 170,175 ****
a9e0067
--- 171,177 ----
a9e0067
   * Pointers for dynamic link
a9e0067
   */
a9e0067
  static int (*py3_PySys_SetArgv)(int, wchar_t **);
a9e0067
+ static void (*py3_Py_SetPythonHome)(wchar_t *home);
a9e0067
  static void (*py3_Py_Initialize)(void);
a9e0067
  static PyObject* (*py3_PyList_New)(Py_ssize_t size);
a9e0067
  static PyGILState_STATE (*py3_PyGILState_Ensure)(void);
a9e0067
***************
a9e0067
*** 254,259 ****
a9e0067
--- 256,262 ----
a9e0067
  } py3_funcname_table[] =
a9e0067
  {
a9e0067
      {"PySys_SetArgv", (PYTHON_PROC*)&py3_PySys_SetArgv},
a9e0067
+     {"Py_SetPythonHome", (PYTHON_PROC*)&py3_Py_SetPythonHome},
a9e0067
      {"Py_Initialize", (PYTHON_PROC*)&py3_Py_Initialize},
a9e0067
      {"PyArg_ParseTuple", (PYTHON_PROC*)&py3_PyArg_ParseTuple},
a9e0067
      {"PyList_New", (PYTHON_PROC*)&py3_PyList_New},
a9e0067
***************
a9e0067
*** 336,342 ****
a9e0067
      int i;
a9e0067
      void *ucs_from_string, *ucs_from_string_and_size;
a9e0067
  
a9e0067
! # if !defined(PY_NO_RTLD_GLOBAL) && defined(UNIX) && defined(FEAT_PYTHON)
a9e0067
      /* Can't have Python and Python3 loaded at the same time.
a9e0067
       * It cause a crash, because RTLD_GLOBAL is needed for
a9e0067
       * standard C extension libraries of one or both python versions. */
a9e0067
--- 339,345 ----
a9e0067
      int i;
a9e0067
      void *ucs_from_string, *ucs_from_string_and_size;
a9e0067
  
a9e0067
! # if !(defined(PY_NO_RTLD_GLOBAL) && defined(PY3_NO_RTLD_GLOBAL)) && defined(UNIX) && defined(FEAT_PYTHON)
a9e0067
      /* Can't have Python and Python3 loaded at the same time.
a9e0067
       * It cause a crash, because RTLD_GLOBAL is needed for
a9e0067
       * standard C extension libraries of one or both python versions. */
a9e0067
***************
a9e0067
*** 539,544 ****
a9e0067
--- 542,552 ----
a9e0067
  
a9e0067
  	init_structs();
a9e0067
  
a9e0067
+ 
a9e0067
+ #ifdef PYTHON3_HOME
a9e0067
+ 	Py_SetPythonHome(PYTHON3_HOME);
a9e0067
+ #endif
a9e0067
+ 
a9e0067
  	/* initialise threads */
a9e0067
  	PyEval_InitThreads();
a9e0067
  
a9e0067
*** ../vim-7.3.061/src/version.c	2010-11-16 16:25:46.000000000 +0100
a9e0067
--- src/version.c	2010-11-16 17:12:40.000000000 +0100
a9e0067
***************
a9e0067
*** 716,717 ****
a9e0067
--- 716,719 ----
a9e0067
  {   /* Add new patch number below this line */
a9e0067
+ /**/
a9e0067
+     62,
a9e0067
  /**/
a9e0067
a9e0067
-- 
a9e0067
ARTHUR: CHARGE!
a9e0067
   [The mighty ARMY charges.  Thundering noise of feet.  Clatter of coconuts.
a9e0067
   Shouts etc.   Suddenly there is a wail of a siren and a couple of police
a9e0067
   cars roar round in front of the charging ARMY and the POLICE leap out and
a9e0067
   stop them.  TWO POLICEMAN and the HISTORIAN'S WIFE.  Black Marias skid up
a9e0067
   behind them.]
a9e0067
HISTORIAN'S WIFE: They're the ones, I'm sure.
a9e0067
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
a9e0067
a9e0067
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
a9e0067
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
a9e0067
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
a9e0067
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///