comparison src/configure.in @ 2641:b803b2776880 v7.3.062

updated for version 7.3.062 Problem: Python doesn't work properly when installed in another directory than expected. Solution: Figure out home directory in configure and use Py_SetPythonHome() at runtime. (Roland Puntaier)
author Bram Moolenaar <bram@vim.org>
date Tue, 16 Nov 2010 19:26:02 +0100
parents 1ccc1ace9e5b
children 7c46737918cb
comparison
equal deleted inserted replaced
2640:266f9d9f5109 2641:b803b2776880
889 fi 889 fi
890 ]) 890 ])
891 891
892 PYTHON_LIBS="${vi_cv_path_python_plibs}" 892 PYTHON_LIBS="${vi_cv_path_python_plibs}"
893 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then 893 if test "${vi_cv_path_python_pfx}" = "${vi_cv_path_python_epfx}"; then
894 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version}" 894 PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
895 else 895 else
896 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}" 896 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}\\\""
897 fi 897 fi
898 PYTHON_SRC="if_python.c" 898 PYTHON_SRC="if_python.c"
899 dnl For Mac OSX 10.2 config.o is included in the Python library. 899 dnl For Mac OSX 10.2 config.o is included in the Python library.
900 if test "x$MACOSX" = "xyes"; then 900 if test "x$MACOSX" = "xyes"; then
901 PYTHON_OBJ="objects/if_python.o" 901 PYTHON_OBJ="objects/if_python.o"
903 PYTHON_OBJ="objects/if_python.o objects/py_config.o" 903 PYTHON_OBJ="objects/if_python.o objects/py_config.o"
904 fi 904 fi
905 if test "${vi_cv_var_python_version}" = "1.4"; then 905 if test "${vi_cv_var_python_version}" = "1.4"; then
906 PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o" 906 PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
907 fi 907 fi
908 PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'" 908 PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
909 909
910 dnl On FreeBSD linking with "-pthread" is required to use threads. 910 dnl On FreeBSD linking with "-pthread" is required to use threads.
911 dnl _THREAD_SAFE must be used for compiling then. 911 dnl _THREAD_SAFE must be used for compiling then.
912 dnl The "-pthread" is added to $LIBS, so that the following check for 912 dnl The "-pthread" is added to $LIBS, so that the following check for
913 dnl sigaltstack() will look in libc_r (it's there in libc!). 913 dnl sigaltstack() will look in libc_r (it's there in libc!).
1061 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//` 1061 vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
1062 ]) 1062 ])
1063 1063
1064 PYTHON3_LIBS="${vi_cv_path_python3_plibs}" 1064 PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
1065 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then 1065 if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
1066 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}" 1066 PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
1067 else 1067 else
1068 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}" 1068 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}\\\""
1069 fi 1069 fi
1070 PYTHON3_SRC="if_python3.c" 1070 PYTHON3_SRC="if_python3.c"
1071 dnl For Mac OSX 10.2 config.o is included in the Python library. 1071 dnl For Mac OSX 10.2 config.o is included in the Python library.
1072 if test "x$MACOSX" = "xyes"; then 1072 if test "x$MACOSX" = "xyes"; then
1073 PYTHON3_OBJ="objects/if_python3.o" 1073 PYTHON3_OBJ="objects/if_python3.o"
1141 dnl if python2.x and python3.x are enabled one can only link in code 1141 dnl if python2.x and python3.x are enabled one can only link in code
1142 dnl with dlopen(), dlsym(), dlclose() 1142 dnl with dlopen(), dlsym(), dlclose()
1143 if test "$python_ok" = yes && test "$python3_ok" = yes; then 1143 if test "$python_ok" = yes && test "$python3_ok" = yes; then
1144 AC_DEFINE(DYNAMIC_PYTHON) 1144 AC_DEFINE(DYNAMIC_PYTHON)
1145 AC_DEFINE(DYNAMIC_PYTHON3) 1145 AC_DEFINE(DYNAMIC_PYTHON3)
1146 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL) 1146 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python)
1147 cflags_save=$CFLAGS 1147 cflags_save=$CFLAGS
1148 CFLAGS="$CFLAGS $PYTHON3_CFLAGS" 1148 CFLAGS="$CFLAGS $PYTHON_CFLAGS"
1149 ldflags_save=$LDFLAGS 1149 ldflags_save=$LDFLAGS
1150 LDFLAGS="$LDFLAGS -ldl" 1150 LDFLAGS="$LDFLAGS -ldl"
1151 AC_RUN_IFELSE([ 1151 AC_RUN_IFELSE([
1152 #include <dlfcn.h> 1152 #include <dlfcn.h>
1153 /* If this program fails, then RTLD_GLOBAL is needed. 1153 /* If this program fails, then RTLD_GLOBAL is needed.
1154 * RTLD_GLOBAL will be used and then it is not possible to 1154 * RTLD_GLOBAL will be used and then it is not possible to
1155 * have both python versions enabled in the same vim instance. 1155 * have both python versions enabled in the same vim instance.
1156 * Only the first pyhton version used will be switched on. 1156 * Only the first pyhton version used will be switched on.
1157 */ 1157 */
1158 1158
1159 int no_rtl_global_needed_for(char *python_instsoname) 1159 int no_rtl_global_needed_for(char *python_instsoname, char *prefix)
1160 { 1160 {
1161 int needed = 0; 1161 int needed = 0;
1162 void* pylib = dlopen(python_instsoname, RTLD_LAZY); 1162 void* pylib = dlopen(python_instsoname, RTLD_LAZY);
1163 if (pylib != 0) 1163 if (pylib != 0)
1164 { 1164 {
1165 void (*pfx)(char *home) = dlsym(pylib, "Py_SetPythonHome");
1165 void (*init)(void) = dlsym(pylib, "Py_Initialize"); 1166 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1166 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString"); 1167 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1167 void (*final)(void) = dlsym(pylib, "Py_Finalize"); 1168 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1169 (*pfx)(prefix);
1168 (*init)(); 1170 (*init)();
1169 needed = (*simple)("import termios") == -1; 1171 needed = (*simple)("import termios") == -1;
1170 (*final)(); 1172 (*final)();
1171 dlclose(pylib); 1173 dlclose(pylib);
1172 } 1174 }
1174 } 1176 }
1175 1177
1176 int main(int argc, char** argv) 1178 int main(int argc, char** argv)
1177 { 1179 {
1178 int not_needed = 0; 1180 int not_needed = 0;
1179 if (no_rtl_global_needed_for("libpython2.7.so.1.0") && no_rtl_global_needed_for("libpython3.1.so.1.0")) 1181 if (no_rtl_global_needed_for("${python_INSTSONAME}", "${vi_cv_path_python_pfx}"))
1180 not_needed = 1; 1182 not_needed = 1;
1181 return !not_needed; 1183 return !not_needed;
1182 }], 1184 }],
1183 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)]) 1185 [AC_MSG_RESULT(yes);AC_DEFINE(PY_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1186
1184 CFLAGS=$cflags_save 1187 CFLAGS=$cflags_save
1185 LDFLAGS=$ldflags_save 1188 LDFLAGS=$ldflags_save
1189
1190 AC_MSG_CHECKING(whether we can do without RTLD_GLOBAL for Python3)
1191 cflags_save=$CFLAGS
1192 CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
1193 ldflags_save=$LDFLAGS
1194 LDFLAGS="$LDFLAGS -ldl"
1195 AC_RUN_IFELSE([
1196 #include <dlfcn.h>
1197 #include <wchar.h>
1198 /* If this program fails, then RTLD_GLOBAL is needed.
1199 * RTLD_GLOBAL will be used and then it is not possible to
1200 * have both python versions enabled in the same vim instance.
1201 * Only the first pyhton version used will be switched on.
1202 */
1203
1204 int no_rtl_global_needed_for(char *python_instsoname, wchar_t *prefix)
1205 {
1206 int needed = 0;
1207 void* pylib = dlopen(python_instsoname, RTLD_LAZY);
1208 if (pylib != 0)
1209 {
1210 void (*pfx)(wchar_t *home) = dlsym(pylib, "Py_SetPythonHome");
1211 void (*init)(void) = dlsym(pylib, "Py_Initialize");
1212 int (*simple)(char*) = dlsym(pylib, "PyRun_SimpleString");
1213 void (*final)(void) = dlsym(pylib, "Py_Finalize");
1214 (*pfx)(prefix);
1215 (*init)();
1216 needed = (*simple)("import termios") == -1;
1217 (*final)();
1218 dlclose(pylib);
1219 }
1220 return !needed;
1221 }
1222
1223 int main(int argc, char** argv)
1224 {
1225 int not_needed = 0;
1226 if (no_rtl_global_needed_for("${python3_INSTSONAME}", L"${vi_cv_path_python3_pfx}"))
1227 not_needed = 1;
1228 return !not_needed;
1229 }],
1230 [AC_MSG_RESULT(yes);AC_DEFINE(PY3_NO_RTLD_GLOBAL)], [AC_MSG_RESULT(no)])
1231
1232 CFLAGS=$cflags_save
1233 LDFLAGS=$ldflags_save
1234
1186 PYTHON_SRC="if_python.c" 1235 PYTHON_SRC="if_python.c"
1187 PYTHON_OBJ="objects/if_python.o" 1236 PYTHON_OBJ="objects/if_python.o"
1188 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\"" 1237 PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"${python_INSTSONAME}\\\""
1189 PYTHON_LIBS= 1238 PYTHON_LIBS=
1190 PYTHON3_SRC="if_python3.c" 1239 PYTHON3_SRC="if_python3.c"