Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / external / python3 / ExternalProject_python3.mk
blobdafeb1ca5ae818113800c27ad6a85fce8d7182d1
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 $(eval $(call gb_ExternalProject_ExternalProject,python3))
12 $(eval $(call gb_ExternalProject_use_externals,python3,\
13 expat \
14 openssl \
15 zlib \
18 $(eval $(call gb_ExternalProject_register_targets,python3,\
19 build \
20 $(if $(filter MACOSX,$(OS)),\
21 fixscripts \
22 fixinstallnames \
23 executables \
24 removeunnecessarystuff \
25 ) \
28 ifeq ($(OS),WNT)
30 # TODO: using Debug configuration and related mangling of pyconfig.h
32 # at least for MSVC 2008 it is necessary to clear MAKEFLAGS because
33 # nmake is invoked
34 $(call gb_ExternalProject_get_state_target,python3,build) :
35 $(call gb_ExternalProject_run,build,\
36 MAKEFLAGS= MSBuild.exe pcbuild.sln /t:Build \
37 /p:Configuration=$(if $(MSVC_USE_DEBUG_RUNTIME),Debug,Release) \
38 /p:Platform=$(if $(filter INTEL,$(CPUNAME)),Win32,x64) \
39 /maxcpucount \
40 $(if $(filter 150,$(VCVER)),/p:PlatformToolset=v141 /p:VisualStudioVersion=15.0 /ToolsVersion:15.0) \
41 $(if $(filter 160,$(VCVER)),/p:PlatformToolset=v142 /p:VisualStudioVersion=16.0 /ToolsVersion:Current) \
42 $(if $(filter 10,$(WINDOWS_SDK_VERSION)),/p:WindowsTargetPlatformVersion=$(UCRTVERSION)) \
43 ,PCBuild)
45 else
47 # this was added in 2004, hopefully is obsolete now (and why only intel anyway)? $(if $(filter SOLARIS-INTEL,$(OS)$(CPUNAME)),--disable-ipv6)
49 # --with-system-expat: this should find the one in the solver (or system)
51 # create a symlink "LO_lib" because the .so are in a directory with platform
52 # specific name like build/lib.linux-x86_64-3.3
54 python3_cflags = $(ZLIB_CFLAGS)
55 ifneq (,$(ENABLE_VALGRIND))
56 python3_cflags += $(VALGRIND_CFLAGS)
57 endif
59 $(call gb_ExternalProject_get_state_target,python3,build) :
60 $(call gb_ExternalProject_run,build,\
61 $(if $(filter MACOSX,$(OS)), \
62 $(if $(filter 10.8 10.9 10.10 10.11,$(MACOSX_DEPLOYMENT_TARGET)), \
63 ac_cv_func_getentropy=no \
64 ac_cv_func_clock_gettime=no \
65 ) \
66 ) \
67 ./configure \
68 $(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \
69 $(if $(ENABLE_VALGRIND),--with-valgrind) \
70 --prefix=/python-inst \
71 $(if $(filter MACOSX,$(OS)),,--with-system-expat) \
72 $(if $(filter AIX,$(OS)), \
73 --disable-ipv6 --with-threads OPT="-g0 -fwrapv -O3 -Wall", \
74 $(if $(gb_Module_CURRENTMODULE_DEBUG_ENABLED), \
75 OPT="$(gb_COMPILERNOOPTFLAGS) $(gb_DEBUGINFO_FLAGS)")) \
76 $(if $(filter MACOSX,$(OS)), \
77 $(if $(filter INTEL,$(CPUNAME)),--enable-universalsdk=$(MACOSX_SDK_PATH) \
78 --with-universal-archs=intel \
79 ) \
80 --enable-framework=/@__________________________________________________OOO --with-framework-name=LibreOfficePython, \
81 --enable-shared \
82 ) \
83 CC="$(strip $(CC) \
84 $(if $(SYSTEM_OPENSSL),,-I$(call gb_UnpackedTarball_get_dir,openssl)/include \
85 $(if $(DISABLE_OPENSSL),,-I$(call gb_UnpackedTarball_get_dir,openssl)/include)) \
86 $(if $(SYSTEM_EXPAT),,-I$(call gb_UnpackedTarball_get_dir,expat)/lib) \
87 $(if $(SYSBASE), -I$(SYSBASE)/usr/include) \
88 )" \
89 $(if $(python3_cflags),CFLAGS='$(python3_cflags)') \
90 $(if $(filter -fsanitize=%,$(CC)),LINKCC="$(CXX) -pthread") \
91 LDFLAGS="$(strip $(LDFLAGS) \
92 $(if $(SYSTEM_OPENSSL),,-L$(call gb_UnpackedTarball_get_dir,openssl)) \
93 $(if $(SYSTEM_EXPAT),,-L$(gb_StaticLibrary_WORKDIR)) \
94 $(if $(SYSTEM_ZLIB),,-L$(gb_StaticLibrary_WORKDIR)) \
95 $(if $(SYSBASE), -L$(SYSBASE)/usr/lib) \
96 $(gb_LTOFLAGS) \
97 )" \
98 && MAKEFLAGS= $(MAKE) \
99 $(if $(filter MACOSX,$(OS)),DESTDIR=$(EXTERNAL_WORKDIR)/python-inst install) \
100 $(if $(SYSTEM_ZLIB),,ZLIB_INCDIR=$(WORKDIR)/UnpackedTarball/zlib) \
101 && ln -s build/lib.* LO_lib \
104 endif
106 ifeq ($(OS),MACOSX)
108 python3_fw_prefix=$(call gb_UnpackedTarball_get_dir,python3)/python-inst/@__________________________________________________OOO/LibreOfficePython.framework
110 # rule to allow relocating the whole framework, removing reference to buildinstallation directory
111 $(call gb_ExternalProject_get_state_target,python3,fixscripts) : $(call gb_ExternalProject_get_state_target,python3,build)
112 $(call gb_Output_announce,python3 - remove reference to installroot from scripts,build,CUS,5)
113 $(COMMAND_ECHO)for file in \
114 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/2to3 \
115 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/2to3-$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR) \
116 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/idle$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR) \
117 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/pydoc$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR) \
118 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)-config \
119 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)m-config \
120 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/pyvenv-$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR) ; do \
121 { rm "$$file" && $(gb_AWK) '\
122 BEGIN {print "#!/bin/bash\n\
123 origpath=$$(pwd)\n\
124 bindir=$$(cd $$(dirname \"$$0\") ; pwd)\n\
125 cd \"$$origpath\"\n\
126 \"$$bindir/../Resources/Python.app/Contents/MacOS/LibreOfficePython\" - $$@ <<EOF"} \
127 FNR==1{next} \
128 {print} \
129 END {print "EOF"}' > "$$file" ; } < "$$file" ; chmod +x "$$file" ; done
130 touch $@
132 $(call gb_ExternalProject_get_state_target,python3,fixinstallnames) : $(call gb_ExternalProject_get_state_target,python3,build)
133 $(INSTALL_NAME_TOOL) -change \
134 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/LibreOfficePython \
135 @executable_path/../../../../LibreOfficePython \
136 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/Resources/Python.app/Contents/MacOS/LibreOfficePython
137 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 \
138 $(INSTALL_NAME_TOOL) -change \
139 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/LibreOfficePython \
140 @loader_path/../../../LibreOfficePython $$file ; done
141 touch $@
143 # also delete binaries that are symlinked in scp2
144 $(call gb_ExternalProject_get_state_target,python3,executables) : $(call gb_ExternalProject_get_state_target,python3,build)
145 cd $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin ; \
146 for file in python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR) \
147 python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)m ; do \
148 $(INSTALL_NAME_TOOL) -change \
149 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/LibreOfficePython \
150 @executable_path/../LibreOfficePython $$file ; done
151 touch $@
153 $(call gb_ExternalProject_get_state_target,python3,removeunnecessarystuff) : $(call gb_ExternalProject_get_state_target,python3,build)
154 $(call gb_Output_announce,python3 - remove the stuff we don't need to ship,build,CUS,5)
155 rm -rf $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/lib/python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/test
157 endif
159 # vim: set noet sw=4 ts=4: