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
,\
18 $(eval
$(call gb_ExternalProject_register_targets
,python3
,\
20 $(if
$(filter MACOSX
,$(OS
)),\
29 # TODO: using Debug configuration and related mangling of pyconfig.h
31 # at least for MSVC 2008 it is necessary to clear MAKEFLAGS because
33 $(call gb_ExternalProject_get_state_target
,python3
,build
) :
34 $(call gb_ExternalProject_run
,build
,\
35 MAKEFLAGS
= MSBuild.exe pcbuild.sln
/t
:Build \
36 /p
:Configuration
=$(if
$(MSVC_USE_DEBUG_RUNTIME
),Debug
,Release
) \
37 /p
:Platform
=$(if
$(filter INTEL
,$(CPUNAME
)),Win32
,x64
) \
38 $(if
$(filter 120,$(VCVER
)),/p
:PlatformToolset
=v120
/p
:VisualStudioVersion
=12.0 /ToolsVersion
:12.0) \
39 $(if
$(filter 140,$(VCVER
)),/p
:PlatformToolset
=v140
/p
:VisualStudioVersion
=14.0 /ToolsVersion
:14.0) \
40 $(if
$(filter 150,$(VCVER
)),/p
:PlatformToolset
=v141
/p
:VisualStudioVersion
=15.0 /ToolsVersion
:15.0) \
41 $(if
$(filter 150-10,$(VCVER
)-$(WINDOWS_SDK_VERSION
)),/p
:WindowsTargetPlatformVersion
=$(UCRTVERSION
)) \
46 # this was added in 2004, hopefully is obsolete now (and why only intel anyway)? $(if $(filter SOLARIS-INTEL,$(OS)$(CPUNAME)),--disable-ipv6)
48 # --with-system-expat: this should find the one in the solver (or system)
50 # create a symlink "LO_lib" because the .so are in a directory with platform
51 # specific name like build/lib.linux-x86_64-3.3
53 python3_cflags
= $(ZLIB_CFLAGS
)
54 ifneq (,$(ENABLE_VALGRIND
))
55 python3_cflags
+= $(VALGRIND_CFLAGS
)
58 $(call gb_ExternalProject_get_state_target
,python3
,build
) :
59 $(call gb_ExternalProject_run
,build
,\
60 $(if
$(filter MACOSX
,$(OS
)), \
61 $(if
$(filter 10.8 10.9 10.10 10.11,$(MACOSX_DEPLOYMENT_TARGET
)), \
62 ac_cv_func_getentropy
=no \
63 ac_cv_func_clock_gettime
=no \
67 $(if
$(CROSS_COMPILING
),--build
=$(BUILD_PLATFORM
) --host
=$(HOST_PLATFORM
)) \
68 $(if
$(ENABLE_VALGRIND
),--with-valgrind
) \
69 --prefix=/python-inst \
70 $(if
$(filter MACOSX
,$(OS
)),,--with-system-expat
) \
71 $(if
$(filter AIX
,$(OS
)), \
72 --disable-ipv6
--with-threads OPT
="-g0 -fwrapv -O3 -Wall", \
73 $(if
$(gb_Module_CURRENTMODULE_DEBUG_ENABLED
), \
74 OPT
="$(gb_COMPILERNOOPTFLAGS) $(gb_DEBUGINFO_FLAGS) $(gb_DEBUG_CFLAGS)")) \
75 $(if
$(filter MACOSX
,$(OS
)), \
76 $(if
$(filter INTEL
,$(CPUNAME
)),--enable-universalsdk
=$(MACOSX_SDK_PATH
) \
77 --with-universal-archs
=intel \
79 --enable-framework
=/@__________________________________________________OOO
--with-framework-name
=LibreOfficePython
, \
83 $(if $(SYSTEM_OPENSSL),,-I$(call gb_UnpackedTarball_get_dir,openssl)/include \
84 $(if $(DISABLE_OPENSSL),,-I$(call gb_UnpackedTarball_get_dir,openssl)/include)) \
85 $(if $(SYSTEM_EXPAT),,-I$(call gb_UnpackedTarball_get_dir,expat)/lib) \
86 $(if $(SYSBASE), -I$(SYSBASE)/usr/include) \
88 $(if
$(python3_cflags
),CFLAGS
='$(python3_cflags)') \
89 $(if
$(filter -fsanitize
=%,$(CC
)),LINKCC
="$(CXX) -pthread") \
90 LDFLAGS
="$(strip $(LDFLAGS) \
91 $(if $(SYSTEM_OPENSSL),,-L$(call gb_UnpackedTarball_get_dir,openssl)) \
92 $(if $(SYSTEM_EXPAT),,-L$(gb_StaticLibrary_WORKDIR)) \
93 $(if $(SYSTEM_ZLIB),,-L$(gb_StaticLibrary_WORKDIR)) \
94 $(if $(SYSBASE), -L$(SYSBASE)/usr/lib) \
97 && MAKEFLAGS
= $(MAKE
) \
98 $(if
$(filter MACOSX
,$(OS
)),DESTDIR
=$(EXTERNAL_WORKDIR
)/python-inst
install) \
99 $(if
$(SYSTEM_ZLIB
),,ZLIB_INCDIR
=$(WORKDIR
)/UnpackedTarball
/zlib
) \
100 && ln
-s build
/lib.
* LO_lib \
107 python3_fw_prefix
=$(call gb_UnpackedTarball_get_dir
,python3
)/python-inst
/@__________________________________________________OOO
/LibreOfficePython.framework
109 # rule to allow relocating the whole framework, removing reference to buildinstallation directory
110 $(call gb_ExternalProject_get_state_target
,python3
,fixscripts
) : $(call gb_ExternalProject_get_state_target
,python3
,build
)
111 $(call gb_Output_announce
,python3
- remove reference to installroot from scripts
,build
,CUS
,5)
112 $(COMMAND_ECHO
)for file in \
113 $(python3_fw_prefix
)/Versions
/$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)/bin
/2to3 \
114 $(python3_fw_prefix
)/Versions
/$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)/bin
/2to3-
$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
) \
115 $(python3_fw_prefix
)/Versions
/$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)/bin
/idle
$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
) \
116 $(python3_fw_prefix
)/Versions
/$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)/bin
/pydoc
$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
) \
117 $(python3_fw_prefix
)/Versions
/$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)/bin
/python
$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)-config \
118 $(python3_fw_prefix
)/Versions
/$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)/bin
/python
$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)m-config \
119 $(python3_fw_prefix
)/Versions
/$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)/bin
/pyvenv-
$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
) ; do \
120 { rm "$$file" && $(gb_AWK
) '\
121 BEGIN {print "#!/bin/bash\n\
123 bindir=$$(cd $$(dirname \"$$0\") ; pwd)\n\
125 \"$$bindir/../Resources/Python.app/Contents/MacOS/LibreOfficePython\" - $$@ <<EOF"} \
128 END {print "EOF"}' > "$$file" ; } < "$$file" ; chmod
+x
"$$file" ; done
131 $(call gb_ExternalProject_get_state_target
,python3
,fixinstallnames
) : $(call gb_ExternalProject_get_state_target
,python3
,build
)
132 $(INSTALL_NAME_TOOL
) -change \
133 $(python3_fw_prefix
)/Versions
/$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)/LibreOfficePython \
134 @executable_path
/..
/..
/..
/..
/LibreOfficePython \
135 $(python3_fw_prefix
)/Versions
/$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)/Resources
/Python.app
/Contents
/MacOS
/LibreOfficePython
136 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 \
137 $(INSTALL_NAME_TOOL
) -change \
138 $(python3_fw_prefix
)/Versions
/$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)/LibreOfficePython \
139 @loader_path
/..
/..
/..
/LibreOfficePython
$$file ; done
142 # also delete binaries that are symlinked in scp2
143 $(call gb_ExternalProject_get_state_target
,python3
,executables
) : $(call gb_ExternalProject_get_state_target
,python3
,build
)
144 cd
$(python3_fw_prefix
)/Versions
/$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)/bin
; \
145 for file in python
$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
) \
146 python
$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)m
; do \
147 $(INSTALL_NAME_TOOL
) -change \
148 $(python3_fw_prefix
)/Versions
/$(PYTHON_VERSION_MAJOR
).
$(PYTHON_VERSION_MINOR
)/LibreOfficePython \
149 @executable_path
/..
/LibreOfficePython
$$file ; done
154 # vim: set noet sw=4 ts=4: