use system python for building if possible

Also simplifies configure, hopefully without any mistake;)

Change-Id: I5c6c53fbee06cd1ecccf878a5c080274bfd950c1
Reviewed-on: https://gerrit.libreoffice.org/2563
Reviewed-by: David Ostrovsky <David.Ostrovsky@gmx.de>
Tested-by: David Ostrovsky <David.Ostrovsky@gmx.de>
This commit is contained in:
Matúš Kukan 2013-03-05 22:03:38 +01:00 committed by David Ostrovsky
parent 5a2cfa6773
commit e482672b58
5 changed files with 81 additions and 136 deletions

View File

@ -2754,32 +2754,8 @@ endef
endif # SYSTEM_UCPP endif # SYSTEM_UCPP
# TODO what do do with gb_PYTHON_PRECOMMAND? Move here? ifeq (,$(PYTHON_FOR_BUILD))
ifeq ($(SYSTEM_PYTHON),YES)
define gb_ExternalExecutable__register_python
$(call gb_ExternalExecutable_set_external,python,$(PYTHON))
endef
else ifeq ($(OS),MACOSX)
#fixme: remove this MACOSX ifeq branch by filling in gb_PYTHON_PRECOMMAND in
#gbuild/platform/macosx.mk correctly for mac, e.g. PYTHONPATH and PYTHONHOME
#dirs for in-tree internal python
define gb_ExternalExecutable__register_python
$(call gb_ExternalExecutable_set_external,python,$(PYTHON))
endef
else ifeq ($(DISABLE_PYTHON),TRUE)
# Build-time python
gb_ExternalExecutable__register_python :=
else # ! SYSTEM_PYTHON
# internal python
define gb_ExternalExecutable__register_python define gb_ExternalExecutable__register_python
$(call gb_ExternalExecutable_set_internal,python) $(call gb_ExternalExecutable_set_internal,python)
$(call gb_ExternalExecutable_set_precommand,python,$(gb_PYTHON_PRECOMMAND)) $(call gb_ExternalExecutable_set_precommand,python,$(gb_PYTHON_PRECOMMAND))
@ -2792,7 +2768,14 @@ $(call gb_ExternalExecutable_add_dependencies,python,\
endef endef
endif # SYSTEM_PYTHON else
define gb_ExternalExecutable__register_python
$(call gb_ExternalExecutable_set_external,python,$(PYTHON_FOR_BUILD))
endef
endif # PYTHON_FOR_BUILD
ifneq ($(SYSTEM_GENBRK),) ifneq ($(SYSTEM_GENBRK),)

View File

@ -465,7 +465,6 @@ export PROGRESSTEXTCOLOR=@PROGRESSTEXTCOLOR@
export PSPRINT=TRUE export PSPRINT=TRUE
export PTHREAD_CFLAGS=@PTHREAD_CFLAGS@ export PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
export PTHREAD_LIBS=@PTHREAD_LIBS@ export PTHREAD_LIBS=@PTHREAD_LIBS@
export PYTHON=@PYTHON@
export PYTHON_CFLAGS=$(gb_SPACE)@PYTHON_CFLAGS@ export PYTHON_CFLAGS=$(gb_SPACE)@PYTHON_CFLAGS@
export PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@ export PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
export PYTHON_LIBS=$(gb_SPACE)@PYTHON_LIBS@ export PYTHON_LIBS=$(gb_SPACE)@PYTHON_LIBS@

View File

@ -4019,7 +4019,6 @@ if test "$cross_compiling" = "yes"; then
( (
unset COM GUI GUIBASE OS CPU CPUNAME unset COM GUI GUIBASE OS CPU CPUNAME
unset CC CXX SYSBASE CFLAGS unset CC CXX SYSBASE CFLAGS
unset PYTHON_CFLAGS PYTHON_LIBS
unset AR NM OBJDUMP PKG_CONFIG RANLIB STRIP unset AR NM OBJDUMP PKG_CONFIG RANLIB STRIP
unset CPPUNIT_CFLAGS CPPUNIT_LIBS unset CPPUNIT_CFLAGS CPPUNIT_LIBS
unset LIBXML_CFLAGS LIBXML_LIBS LIBXSLT_CFLAGS LIBXSLT_LIBS XSLTPROC unset LIBXML_CFLAGS LIBXML_LIBS LIBXSLT_CFLAGS LIBXSLT_LIBS XSLTPROC
@ -4066,10 +4065,10 @@ if test "$cross_compiling" = "yes"; then
cp config.log ../config.Build.log cp config.log ../config.Build.log
mkdir -p ../config_build mkdir -p ../config_build
cp config_host/*.h ../config_build cp config_host/*.h ../config_build
. ./bin/get_config_variables COM GUI OS PATH CPU CPUNAME CC CXX DISABLE_PYTHON MACOSX_DEPLOYMENT_TARGET INPATH OUTPATH PYTHON SYSTEM_LIBXSLT OUTDIR WORKDIR . ./bin/get_config_variables COM GUI OS PATH CPU CPUNAME CC CXX MACOSX_DEPLOYMENT_TARGET INPATH OUTPATH SYSTEM_LIBXSLT OUTDIR WORKDIR
for V in COM GUI OS CPU CPUNAME CC CXX DISABLE_PYTHON MACOSX_DEPLOYMENT_TARGET INPATH OUTPATH \ for V in COM GUI OS CPU CPUNAME CC CXX MACOSX_DEPLOYMENT_TARGET INPATH OUTPATH \
PYTHON SYSTEM_LIBXSLT; do SYSTEM_LIBXSLT; do
VV='$'$V VV='$'$V
VV=`eval "echo $VV"` VV=`eval "echo $VV"`
if test -n "$VV"; then if test -n "$VV"; then
@ -4106,14 +4105,12 @@ else
CPUNAME_FOR_BUILD="$CPUNAME" CPUNAME_FOR_BUILD="$CPUNAME"
CPU_FOR_BUILD="$CPU" CPU_FOR_BUILD="$CPU"
CXX_FOR_BUILD="$CXX" CXX_FOR_BUILD="$CXX"
DISABLE_PYTHON_FOR_BUILD="$DISABLE_PYTHON"
GUI_FOR_BUILD="$GUI" GUI_FOR_BUILD="$GUI"
INPATH_FOR_BUILD="$INPATH" INPATH_FOR_BUILD="$INPATH"
MACOSX_DEPLOYMENT_TARGET_FOR_BUILD="$MACOSX_DEPLOYMENT_TARGET" MACOSX_DEPLOYMENT_TARGET_FOR_BUILD="$MACOSX_DEPLOYMENT_TARGET"
OS_FOR_BUILD="$OS" OS_FOR_BUILD="$OS"
OUTDIR_FOR_BUILD="$OUTDIR" OUTDIR_FOR_BUILD="$OUTDIR"
OUTPATH_FOR_BUILD="$OUTPATH" OUTPATH_FOR_BUILD="$OUTPATH"
PYTHON_FOR_BUILD="$PYTHON"
WORKDIR_FOR_BUILD="$WORKDIR" WORKDIR_FOR_BUILD="$WORKDIR"
fi fi
AC_SUBST(COM_FOR_BUILD) AC_SUBST(COM_FOR_BUILD)
@ -4126,7 +4123,6 @@ AC_SUBST(CXX_FOR_BUILD)
AC_SUBST(INPATH_FOR_BUILD) AC_SUBST(INPATH_FOR_BUILD)
AC_SUBST(OUTPATH_FOR_BUILD) AC_SUBST(OUTPATH_FOR_BUILD)
AC_SUBST(MACOSX_DEPLOYMENT_TARGET_FOR_BUILD) AC_SUBST(MACOSX_DEPLOYMENT_TARGET_FOR_BUILD)
AC_SUBST([PYTHON_FOR_BUILD])
AC_SUBST(OUTDIR_FOR_BUILD) AC_SUBST(OUTDIR_FOR_BUILD)
AC_SUBST(WORKDIR_FOR_BUILD) AC_SUBST(WORKDIR_FOR_BUILD)
@ -7262,29 +7258,42 @@ AC_SUBST(LIBXML_LIBS)
AC_SUBST(XMLLINT) AC_SUBST(XMLLINT)
AC_SUBST([MINGW_LIBXML_DLL]) AC_SUBST([MINGW_LIBXML_DLL])
AC_SUBST([MINGW_ZLIB_DLL]) AC_SUBST([MINGW_ZLIB_DLL])
dnl ===================================================================
dnl Checks for Python
dnl ===================================================================
AC_MSG_CHECKING([which Python to use]) # =====================================================================
# Checking for a Python interpreter with version >= 2.6 needed to build LO.
# Optionally user can pass an option to configure, i. e.
# ./configure PYTHON=/usr/bin/python
# =====================================================================
# This allows a lack of system python with no error, we use internal one in that case.
AM_PATH_PYTHON([2.6],, [:])
if test "$PYTHON" != ":"; then
PYTHON_FOR_BUILD=$PYTHON
fi
AC_SUBST(PYTHON_FOR_BUILD)
# Checks for Python to use for Pyuno
AC_MSG_CHECKING([which Python to use for Pyuno])
case "$enable_python" in case "$enable_python" in
no|disable) no|disable)
if test $build_os = cygwin; then if test -z $PYTHON_FOR_BUILD; then
# Python is required to build nss. In theory we could separate the build-time Python # Python is required to build LibreOffice. In theory we could separate the build-time Python
# requirement from the choice whether to include Python stuff in the installer, but why # requirement from the choice whether to include Python stuff in the installer, but why
# bother? # bother?
AC_MSG_ERROR([Python is required at build time when building on Windows]) AC_MSG_ERROR([Python is required at build time.])
fi fi
enable_python=no enable_python=no
AC_MSG_RESULT([none]) AC_MSG_RESULT([none])
DISABLE_PYTHON=TRUE
;; ;;
""|yes|auto) ""|yes|auto)
if test "$DISABLE_SCRIPTING" = TRUE -a $build_os != cygwin; then if test "$DISABLE_SCRIPTING" = TRUE -a -n $PYTHON_FOR_BUILD; then
AC_MSG_RESULT([no, overridden by --disable-scripting]) AC_MSG_RESULT([no, overridden by --disable-scripting])
enable_python=no enable_python=no
DISABLE_PYTHON=TRUE elif test $_os = Darwin -a \( "$with_macosx_version_min_required" = 10.4 -o "$with_macosx_version_min_required" = 10.5 \) \
-a \( "$with_macosx_sdk" = 10.4 -o "$with_macosx_sdk" = 10.5 \); then
# When building against a more recent SDK the ionternal Python can't be compiled, I can't be bothered to fix that for now,
# building against a recent SDK is only for developer's own builds anyway.
AC_MSG_RESULT([internal, the Python in Mac OS X $with_macosx_version_min_required is incompatible with Python3-ified pyuno])
enable_python=internal
elif test $build_os = cygwin; then elif test $build_os = cygwin; then
dnl When building on Windows we don't attempt to use any installed dnl When building on Windows we don't attempt to use any installed
dnl "system" Python. dnl "system" Python.
@ -7294,22 +7303,28 @@ no|disable)
dnl MinGW cross-compilation setups.) dnl MinGW cross-compilation setups.)
AC_MSG_RESULT([internal]) AC_MSG_RESULT([internal])
enable_python=internal enable_python=internal
elif test $_os = Darwin -a \( "$with_macosx_version_min_required" = 10.4 -o "$with_macosx_version_min_required" = 10.5 \) \ elif test "$cross_compiling" = yes; then
-a \( "$with_macosx_sdk" = 10.4 -o "$with_macosx_sdk" = 10.5 \); then AC_MSG_RESULT([system])
# When building against a more recent SDK the ionternal Python can't be compiled, I can't be bothered to fix that for now, enable_python=system
# building against a recent SDK is only for developer's own builds anyway.
AC_MSG_RESULT([internal, the Python in Mac OS X $with_macosx_version_min_required is incompatible with Python3-ified pyuno])
enable_python=internal
else else
AC_MSG_RESULT([checking below]) # Unset variables set by the above AM_PATH_PYTHON so that
enable_python=auto # we actually do check anew.
unset PYTHON am_cv_pathless_PYTHON ac_cv_path_PYTHON
AM_PATH_PYTHON([3.3],, [:])
if test "$PYTHON" = :; then
AC_MSG_RESULT([internal])
enable_python=internal
else
AC_MSG_RESULT([system])
enable_python=system
fi
fi fi
;; ;;
internal) internal)
AC_MSG_RESULT([internal]) AC_MSG_RESULT([internal])
;; ;;
system) system)
if test $_os = Darwin -a -z "$PYTHON" -a \( "$with_macosx_version_min_required" = 10.4 -o "$with_macosx_version_min_required" = 10.5 \); then if test $_os = Darwin -a -z "$PYTHON_CFLAGS" -a \( "$with_macosx_version_min_required" = 10.4 -o "$with_macosx_version_min_required" = 10.5 \); then
AC_MSG_ERROR([Cannot use "system" Python, the Python in Mac OS X $with_macosx_version_min_required is incompatible with Python3-ified pyuno]) AC_MSG_ERROR([Cannot use "system" Python, the Python in Mac OS X $with_macosx_version_min_required is incompatible with Python3-ified pyuno])
fi fi
AC_MSG_RESULT([system]) AC_MSG_RESULT([system])
@ -7319,86 +7334,40 @@ system)
;; ;;
esac esac
AC_SUBST(DISABLE_PYTHON)
if test $_os = WINNT -a "$WITH_MINGW" != yes -a $enable_python = system; then
AC_MSG_ERROR([Must use internal Python when building with MSVC])
fi
if test $enable_python != no; then if test $enable_python != no; then
BUILD_TYPE="$BUILD_TYPE PYUNO" BUILD_TYPE="$BUILD_TYPE PYUNO"
fi fi
if test "$cross_compiling" = yes; then
if test $enable_python = auto; then
enable_python=system
fi
else
if test $enable_python = system -a -z "$PYTHON"; then
if test $_os = Darwin; then
# We already have logic above to make sure the system Python
# is used only when building against SDK 10.6 or newer.
# Make sure we use the 2.6 Python when building against the
# 10.6 SDK.
case $with_macosx_sdk in
10.6)
python_version=2.6;;
10.7|10.8)
python_version=2.7;;
*)
# ???
python_version=2.7;;
esac
PYTHON=python$python_version
PYTHON_CFLAGS="-I/Developer/SDKs/MacOSX${with_macosx_sdk}.sdk/System/Library/Frameworks/Python.framework/Versions/${python_version}/include/python${python_version}"
PYTHON_LIBS="-framework Python"
else
# This causes an error if no python command is found
AM_PATH_PYTHON([3.3])
fi
elif test $enable_python = auto; then
# We should not come here in a MSVC build, I think?
if test $build_os = cygwin; then
AC_MSG_ERROR([Assertion failed - should not be here in a MSVC build])
fi
# This allows a lack of system Python 3.3 with no error, we check below for a system Python of
# earlier version.
AM_PATH_PYTHON([3.3],, [:])
if test "$PYTHON" = :; then
enable_python=internal
if test $_os = Darwin; then
# See the fixme in gbuild.mk
# There must be a system Python, 2.6 should be fine (?), to run build-time Python scripts
# like filter/source/svg/js2hxx.py. (Is that the only build-time Python script?) If we
# don't do this, PYTHON will stay with the value ":" which of course makes runing
# build-time Python scripts rather ineffective.
# Unset variables set by the above AM_PATH_PYTHON so that we acutally do check anew
# Finding an (old) system Python should not confuse our already decided intent to build an
# internal Python 3.3, that is directed by enable_python = internal.
unset PYTHON am_cv_pathless_PYTHON ac_cv_path_PYTHON
AM_PATH_PYTHON([2.6])
else
# For Linux it works to use the internally built Python, see gbuild.mk
:
fi
else
enable_python=system
fi
fi
fi
if test $enable_python = system; then if test $enable_python = system; then
if test -z "$PYTHON_CFLAGS" -a $_os = Darwin; then
# We already have logic above to make sure the system Python
# is used only when building against SDK 10.6 or newer.
# Make sure we use the 2.6 Python when building against the
# 10.6 SDK.
case $with_macosx_sdk in
10.6)
python_version=2.6;;
10.7|10.8)
python_version=2.7;;
*)
# ???
python_version=2.7;;
esac
PYTHON=python$python_version
PYTHON_CFLAGS="-I/Developer/SDKs/MacOSX${with_macosx_sdk}.sdk/System/Library/Frameworks/Python.framework/Versions/${python_version}/include/python${python_version}"
PYTHON_LIBS="-framework Python"
fi
if test -n "$PYTHON_CFLAGS" -a -n "$PYTHON_LIBS"; then if test -n "$PYTHON_CFLAGS" -a -n "$PYTHON_LIBS"; then
# Fallback: Accept these in the environment, or as set above # Fallback: Accept these in the environment, or as set above
# for MacOSX. # for MacOSX.
: :
elif test "$cross_compiling" != yes; then elif test "$cross_compiling" != yes; then
# Unset variables set by the above AM_PATH_PYTHON so that
# we actually do check anew.
unset PYTHON am_cv_pathless_PYTHON ac_cv_path_PYTHON
# This causes an error if no python command is found
AM_PATH_PYTHON([3.3])
python_include=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('INCLUDEPY'));"` python_include=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('INCLUDEPY'));"`
python_version=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'));"` python_version=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'));"`
python_libs=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBS'));"` python_libs=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBS'));"`
@ -7500,6 +7469,7 @@ internal)
fi fi
;; ;;
no) no)
DISABLE_PYTHON=TRUE
SYSTEM_PYTHON=NO SYSTEM_PYTHON=NO
;; ;;
*) *)
@ -7507,14 +7477,7 @@ no)
;; ;;
esac esac
dnl Cross-build of python requires python that is runnable on the build AC_SUBST(DISABLE_PYTHON)
dnl platform, because it is used in the build process
if test "$cross_compiling" = yes; then
if test "$DISABLE_PYTHON" = no -a "$SYSTEM_PYTHON" = no -a "$DISABLE_PYTHON_FOR_BUILD" = yes; then
AC_MSG_ERROR([Cross-build of python requires python that is runnable on the build platform. You must not use --disable-python for the 'build' config.])
fi
fi
AC_SUBST(SYSTEM_PYTHON) AC_SUBST(SYSTEM_PYTHON)
AC_SUBST(PYTHON_CFLAGS) AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_LIBS) AC_SUBST(PYTHON_LIBS)

View File

@ -50,7 +50,7 @@ $(call gb_ExternalProject_get_state_target,nss,build): $(call gb_ExternalProject
else else
$(call gb_ExternalProject_get_state_target,nss,build): $(call gb_ExternalProject_get_state_target,nss,configure) $(call gb_ExternalProject_get_state_target,nss,build): $(call gb_ExternalProject_get_state_target,nss,configure) $(call gb_ExternalExecutable_get_dependencies,python)
$(call gb_ExternalProject_run,build,\ $(call gb_ExternalProject_run,build,\
CC="$(CC) $(if $(filter YES,$(MINGW_SHARED_GCCLIB)),-shared-libgcc)" \ CC="$(CC) $(if $(filter YES,$(MINGW_SHARED_GCCLIB)),-shared-libgcc)" \
CXX="$(CXX) $(if $(filter YES,$(MINGW_SHARED_GCCLIB)),-shared-libgcc)" \ CXX="$(CXX) $(if $(filter YES,$(MINGW_SHARED_GCCLIB)),-shared-libgcc)" \
@ -58,13 +58,13 @@ $(call gb_ExternalProject_get_state_target,nss,build): $(call gb_ExternalProject
OS_TARGET=WINNT RC="$(WINDRES)" OS_RELEASE="5.0" \ OS_TARGET=WINNT RC="$(WINDRES)" OS_RELEASE="5.0" \
IMPORT_LIB_SUFFIX=dll.a \ IMPORT_LIB_SUFFIX=dll.a \
NSPR_CONFIGURE_OPTS="--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM) --enable-shared --disable-static" \ NSPR_CONFIGURE_OPTS="--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM) --enable-shared --disable-static" \
NSINSTALL="$(PYTHON_FOR_BUILD) $(SRCDIR)/nss/nsinstall.py" \ NSINSTALL="$(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/nss/nsinstall.py" \
$(MAKE) -j1 nss_build_all \ $(MAKE) -j1 nss_build_all \
,mozilla/security/nss) ,mozilla/security/nss)
endif endif
else # OS!=WNT else # OS!=WNT
$(call gb_ExternalProject_get_state_target,nss,build): $(call gb_ExternalProject_get_state_target,nss,configure) $(call gb_ExternalProject_get_state_target,nss,build): $(call gb_ExternalProject_get_state_target,nss,configure) $(call gb_ExternalExecutable_get_dependencies,python)
$(call gb_ExternalProject_run,build,\ $(call gb_ExternalProject_run,build,\
$(if $(filter FREEBSD LINUX MACOSX,$(OS)),$(if $(filter X,$(CPU)),USE_64=1)) \ $(if $(filter FREEBSD LINUX MACOSX,$(OS)),$(if $(filter X,$(CPU)),USE_64=1)) \
$(if $(filter MACOSX,$(OS)),MACOS_SDK_DIR=$(MACOSX_SDK_PATH) \ $(if $(filter MACOSX,$(OS)),MACOS_SDK_DIR=$(MACOSX_SDK_PATH) \
@ -72,7 +72,7 @@ $(call gb_ExternalProject_get_state_target,nss,build): $(call gb_ExternalProject
$(if $(filter SOLARIS,$(OS)),NS_USE_GCC=1) \ $(if $(filter SOLARIS,$(OS)),NS_USE_GCC=1) \
$(if $(filter YES,$(CROSS_COMPILING)),\ $(if $(filter YES,$(CROSS_COMPILING)),\
$(if $(filter MACOSXP,$(OS)$(CPU)),CPU_ARCH=ppc) \ $(if $(filter MACOSXP,$(OS)$(CPU)),CPU_ARCH=ppc) \
NSINSTALL="$(PYTHON_FOR_BUILD) $(SRCDIR)/nss/nsinstall.py") \ NSINSTALL="$(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/nss/nsinstall.py") \
NSDISTMODE=copy \ NSDISTMODE=copy \
$(MAKE) -j1 nss_build_all \ $(MAKE) -j1 nss_build_all \
,mozilla/security/nss) ,mozilla/security/nss)

View File

@ -101,7 +101,7 @@ endef
# #
# Optionally set a specific executable call to use. # Optionally set a specific executable call to use.
# Example: # Example:
# $(call gb_ExternalExecutable_set_external,python,$(PYTHON)) # $(call gb_ExternalExecutable_set_external,genbrk,$(SYSTEM_GENBRK))
# #
# gb_ExternalExecutable_set_external executable call? # gb_ExternalExecutable_set_external executable call?
define gb_ExternalExecutable_set_external define gb_ExternalExecutable_set_external