2012-11-17 00:39:31 +01:00
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
2013-05-06 23:46:30 +02:00
$( eval $ ( call gb_ExternalProject_ExternalProject ,python 3) )
2012-11-17 00:39:31 +01:00
2012-12-28 11:19:06 -05:00
$( eval $ ( call gb_ExternalProject_use_externals ,python 3,\
expat \
openssl \
2013-05-08 14:23:35 +02:00
zlib \
2012-12-28 11:19:06 -05:00
) )
2012-11-17 00:39:31 +01:00
$( eval $ ( call gb_ExternalProject_register_targets ,python 3,\
build \
2013-05-04 14:50:51 +02:00
$( if $( filter MACOSX,$( OS) ) ,\
fixscripts \
fixinstallnames \
executables \
) \
2012-11-17 00:39:31 +01:00
) )
i f e q ( $( OS ) $( COM ) , W N T M S C )
# TODO: using Debug configuration and related mangling of pyconfig.h
# at least for MSVC 2008 it is necessary to clear MAKEFLAGS because
# nmake is invoked
$(call gb_ExternalProject_get_state_target,python3,build) :
2013-02-21 08:15:39 -06:00
$( call gb_ExternalProject_run,build,\
adapt all externals to build against MSVC debug runtime
Add patches and/or tweaks to the following modules:
curl, cppunit, icu, lcms2, libxml2, libxslt, libxmlsec,
lpsolve, nss, openssl, python3
lcms2 has an inconsistency where the .lib and the .dll don't agree on
the .dll name.
openssl gets a honorable mention because apparently it's undocumented
custom build system can build with /MDd if one picks the right
configuration but i couldn't figure out how to do that in an hour of
trying, and just patched the release config instead.
Change-Id: I7854a0fc85247e398d561b4f513d09fe2d1ebb3c
2013-04-14 13:52:56 +02:00
MAKEFLAGS = MSBuild.exe pcbuild.sln /t:Build \
/p:Configuration= $( if $( MSVC_USE_DEBUG_RUNTIME) ,Debug,Release) \
/p:Platform= $( if $( filter INTEL,$( CPUNAME) ) ,Win32,x64) \
2014-07-08 23:46:25 +02:00
$( if $( filter 120,$( VCVER) ) ,/p:PlatformToolset= v120 \
2014-08-09 16:06:09 +02:00
/p:VisualStudioVersion= 12.0 /ToolsVersion:12.0) \
2013-02-21 08:15:39 -06:00
,PCBuild)
2012-11-17 00:39:31 +01:00
e l s e
# this was added in 2004, hopefully is obsolete now (and why only intel anyway)? $(if $(filter SOLARIS-INTEL,$(OS)$(CPUNAME)),--disable-ipv6)
# --with-system-expat: this should find the one in the solver (or system)
# create a symlink "LO_lib" because the .so are in a directory with platform
# specific name like build/lib.linux-x86_64-3.3
2014-02-22 18:27:30 +01:00
python3_cflags = $( ZLIB_CFLAGS)
2013-10-10 09:55:31 +03:00
i f n e q ( , $( ENABLE_VALGRIND ) )
2012-11-27 15:35:02 +01:00
python3_cflags += $( VALGRIND_CFLAGS)
e n d i f
2012-11-17 00:39:31 +01:00
$(call gb_ExternalProject_get_state_target,python3,build) :
2013-02-21 08:15:39 -06:00
$( call gb_ExternalProject_run,build,\
./configure \
2014-02-27 16:19:43 +01:00
$( if $( CROSS_COMPILING) ,--build= $( BUILD_PLATFORM) --host= $( HOST_PLATFORM) ) \
2013-10-10 09:55:31 +03:00
$( if $( ENABLE_VALGRIND) ,--with-valgrind) \
2012-11-26 20:58:16 +01:00
--prefix= /python-inst \
2013-04-20 17:41:34 -05:00
$( if $( filter MACOSX,$( OS) ) ,,--with-system-expat) \
2013-08-28 10:04:08 +02:00
$( if $( filter AIX,$( OS) ) , \
--disable-ipv6 --with-threads OPT = "-g0 -fwrapv -O3 -Wall" , \
$( if $( gb_Module_CURRENTMODULE_DEBUG_ENABLED) , \
OPT = " $( gb_COMPILERNOOPTFLAGS) $( gb_DEBUG_CFLAGS) " ) ) \
2012-11-17 00:39:31 +01:00
$( if $( filter WNT-GCC,$( OS) -$( COM) ) ,--with-threads ac_cv_printf_zd_format = no) \
2012-11-17 14:34:52 +02:00
$( if $( filter MACOSX,$( OS) ) , \
2014-07-12 11:33:57 +02:00
$( if $( filter INTEL,$( CPUNAME) ) ,--enable-universalsdk= $( MACOSX_SDK_PATH) \
2014-10-16 10:38:48 +03:00
--with-universal-archs= intel \
) \
2014-07-07 14:18:12 -04:00
--enable-framework= /@__________________________________________________OOO --with-framework-name= LibreOfficePython, \
2012-11-17 14:34:52 +02:00
--enable-shared \
) \
2012-11-17 00:39:31 +01:00
CC = " $( strip $( CC) \
2014-02-11 15:57:18 +01:00
$( if $( SYSTEM_OPENSSL) ,,-I$( call gb_UnpackedTarball_get_dir,openssl) /include \
2013-08-31 18:55:53 -05:00
$( if $( DISABLE_OPENSSL) ,,-I$( call gb_UnpackedTarball_get_dir,openssl) /include) ) \
2014-02-11 16:33:18 +01:00
$( if $( SYSTEM_EXPAT) ,,-I$( call gb_UnpackedTarball_get_dir,expat) /lib) \
2012-11-17 00:39:31 +01:00
$( if $( SYSBASE) , -I$( SYSBASE) /usr/include) \
) " \
2012-11-27 15:35:02 +01:00
$( if $( python3_cflags) ,CFLAGS= '$(python3_cflags)' ) \
2015-02-23 18:06:32 +01:00
$( if $( filter -fsanitize= %,$( CC) ) ,LINKCC= " $( CXX) " ) \
2012-11-17 00:39:31 +01:00
LDFLAGS = " $( strip $( LDFLAGS) \
2014-02-11 15:57:18 +01:00
$( if $( SYSTEM_OPENSSL) ,,-L$( call gb_UnpackedTarball_get_dir,openssl) ) \
2014-02-11 16:33:18 +01:00
$( if $( SYSTEM_EXPAT) ,,-L$( gb_StaticLibrary_WORKDIR) ) \
2012-11-17 00:39:31 +01:00
$( if $( SYSBASE) , -L$( SYSBASE) /usr/lib) \
$( if $( filter WNT-GCC,$( OS) -$( COM) ) , -shared-libgcc \
2014-03-10 23:22:15 +01:00
$( if $( MINGW_SHARED_GCCLIB) ,-Wl$( COMMA) --enable-runtime-pseudo-reloc-v2 -Wl$( COMMA) --export-all-symbols) ) \
2014-02-21 19:30:45 +01:00
$( gb_LTOFLAGS) \
2012-11-17 00:39:31 +01:00
) " \
2013-04-18 22:00:55 +02:00
&& MAKEFLAGS = $( MAKE) \
$( if $( filter MACOSX,$( OS) ) ,DESTDIR= $( EXTERNAL_WORKDIR) /python-inst install) \
2013-02-21 08:15:39 -06:00
&& ln -s build/lib.* LO_lib \
)
2012-11-17 00:39:31 +01:00
e n d i f
2013-05-04 14:50:51 +02:00
i f e q ( $( OS ) , M A C O S X )
python3_fw_prefix = $( call gb_UnpackedTarball_get_dir,python3) /python-inst/@__________________________________________________OOO/LibreOfficePython.framework
# rule to allow relocating the whole framework, removing reference to buildinstallation directory
$(call gb_ExternalProject_get_state_target,python3,fixscripts) : $( call gb_ExternalProject_get_state_target ,python 3,build )
$( call gb_Output_announce,python3 - remove reference to installroot from scripts,build,CUS,5)
$( COMMAND_ECHO) for file in \
$( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /bin/2to3 \
$( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /bin/2to3-$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) \
$( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /bin/idle$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) \
$( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /bin/pydoc$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) \
$( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /bin/python$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) -config \
$( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /bin/python$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) m-config \
$( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /bin/pyvenv-$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) ; do \
2014-05-22 16:58:22 +02:00
{ rm " $$ file " && $( gb_AWK) ' \
2013-05-04 14:50:51 +02:00
BEGIN { print " #!/bin/bash\n\
origpath = $$ ( pwd ) \n \
bindir = $$ ( cd $$ ( dirname \" $$ 0\" ) ; pwd ) \n \
c d \ " $$ o r i g p a t h \ " \ n \
\ "$$bindir/../Resources/Python.app/Contents/MacOS/LibreOfficePython\" - $$@ <<EOF" } \
FNR = = 1{ next} \
{ print} \
END { print "EOF" } ' > " $$ file " ; } < " $$ file " ; chmod +x " $$ file " ; done
touch $@
$(call gb_ExternalProject_get_state_target,python3,fixinstallnames) : $( call gb_ExternalProject_get_state_target ,python 3,build )
2013-09-13 22:01:26 +02:00
$( INSTALL_NAME_TOOL) -change \
2013-05-04 14:50:51 +02:00
$( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /LibreOfficePython \
@executable_path/../../../../LibreOfficePython \
$( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /Resources/Python.app/Contents/MacOS/LibreOfficePython
2014-11-02 16:42:47 +01:00
for file in $( shell find $( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /lib/python$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /lib-dynload -name "*.so" ) ; do \
$( INSTALL_NAME_TOOL) -change \
$( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /LibreOfficePython \
@loader_path/../../../LibreOfficePython $$ file ; done
2013-05-04 14:50:51 +02:00
touch $@
# also delete binaries that are symlinked in scp2
$(call gb_ExternalProject_get_state_target,python3,executables) : $( call gb_ExternalProject_get_state_target ,python 3,build )
cd $( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /bin ; \
for file in python$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) \
2015-07-26 21:38:38 +02:00
python$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) m ; do \
2013-09-13 22:01:26 +02:00
$( INSTALL_NAME_TOOL) -change \
2013-05-04 14:50:51 +02:00
$( python3_fw_prefix) /Versions/$( PYTHON_VERSION_MAJOR) .$( PYTHON_VERSION_MINOR) /LibreOfficePython \
@executable_path/../LibreOfficePython $$ file ; done
touch $@
e n d i f
2012-11-17 00:39:31 +01:00
# vim: set noet sw=4 ts=4: