Bump version to 4.3-4
[LibreOffice.git] / external / python3 / ExternalProject_python3.mk
blob42c3dffdd9173908809611bc74a1da12987c685f
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 ) \
27 ifeq ($(OS)$(COM),WNTMSC)
29 # TODO: using Debug configuration and related mangling of pyconfig.h
31 # at least for MSVC 2008 it is necessary to clear MAKEFLAGS because
32 # nmake is invoked
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 100,$(VCVER)), \
39 /ToolsVersion:4.0, \
40 /p:PlatformToolset=$(if $(filter 80,$(WINDOWS_SDK_VERSION)),v110,v110_xp) \
41 /p:VisualStudioVersion=11.0) \
42 && cd $(EXTERNAL_WORKDIR) \
43 && ln -s PCbuild LO_lib \
44 ,PCBuild)
46 else
48 # this was added in 2004, hopefully is obsolete now (and why only intel anyway)? $(if $(filter SOLARIS-INTEL,$(OS)$(CPUNAME)),--disable-ipv6)
50 # --with-system-expat: this should find the one in the solver (or system)
52 # create a symlink "LO_lib" because the .so are in a directory with platform
53 # specific name like build/lib.linux-x86_64-3.3
55 python3_cflags = $(ZLIB_CFLAGS)
56 ifneq (,$(ENABLE_VALGRIND))
57 python3_cflags += $(VALGRIND_CFLAGS)
58 endif
60 $(call gb_ExternalProject_get_state_target,python3,build) :
61 $(call gb_ExternalProject_run,build,\
62 ./configure \
63 $(if $(CROSS_COMPILING),--build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM)) \
64 $(if $(ENABLE_VALGRIND),--with-valgrind) \
65 --prefix=/python-inst \
66 $(if $(filter MACOSX,$(OS)),,--with-system-expat) \
67 $(if $(filter AIX,$(OS)), \
68 --disable-ipv6 --with-threads OPT="-g0 -fwrapv -O3 -Wall", \
69 $(if $(gb_Module_CURRENTMODULE_DEBUG_ENABLED), \
70 OPT="$(gb_COMPILERNOOPTFLAGS) $(gb_DEBUG_CFLAGS)")) \
71 $(if $(filter WNT-GCC,$(OS)-$(COM)),--with-threads ac_cv_printf_zd_format=no) \
72 $(if $(filter MACOSX,$(OS)), \
73 $(if $(filter INTEL POWERPC,$(CPUNAME)),--enable-universalsdk=$(MACOSX_SDK_PATH) --with-universal-archs=32-bit) --enable-framework=/@__________________________________________________OOO --with-framework-name=LibreOfficePython, \
74 --enable-shared \
75 ) \
76 CC="$(strip $(CC) \
77 $(if $(SYSTEM_OPENSSL),,-I$(call gb_UnpackedTarball_get_dir,openssl)/include \
78 $(if $(DISABLE_OPENSSL),,-I$(call gb_UnpackedTarball_get_dir,openssl)/include)) \
79 $(if $(SYSTEM_EXPAT),,-I$(call gb_UnpackedTarball_get_dir,expat)/lib) \
80 $(if $(SYSBASE), -I$(SYSBASE)/usr/include) \
81 )" \
82 $(if $(python3_cflags),CFLAGS='$(python3_cflags)') \
83 LDFLAGS="$(strip $(LDFLAGS) \
84 $(if $(SYSTEM_OPENSSL),,-L$(call gb_UnpackedTarball_get_dir,openssl)) \
85 $(if $(SYSTEM_EXPAT),,-L$(gb_StaticLibrary_WORKDIR)) \
86 $(if $(SYSBASE), -L$(SYSBASE)/usr/lib) \
87 $(if $(filter WNT-GCC,$(OS)-$(COM)), -shared-libgcc \
88 $(if $(MINGW_SHARED_GCCLIB),-Wl$(COMMA)--enable-runtime-pseudo-reloc-v2 -Wl$(COMMA)--export-all-symbols)) \
89 $(gb_LTOFLAGS) \
90 )" \
91 && MAKEFLAGS= $(MAKE) \
92 $(if $(filter MACOSX,$(OS)),DESTDIR=$(EXTERNAL_WORKDIR)/python-inst install) \
93 && ln -s build/lib.* LO_lib \
96 endif
98 ifeq ($(OS),MACOSX)
100 python3_fw_prefix=$(call gb_UnpackedTarball_get_dir,python3)/python-inst/@__________________________________________________OOO/LibreOfficePython.framework
102 # rule to allow relocating the whole framework, removing reference to buildinstallation directory
103 $(call gb_ExternalProject_get_state_target,python3,fixscripts) : $(call gb_ExternalProject_get_state_target,python3,build)
104 $(call gb_Output_announce,python3 - remove reference to installroot from scripts,build,CUS,5)
105 $(COMMAND_ECHO)for file in \
106 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/2to3 \
107 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/2to3-$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR) \
108 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/idle$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR) \
109 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/pydoc$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR) \
110 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)-config \
111 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)m-config \
112 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin/pyvenv-$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR) ; do \
113 { rm "$$file" && $(gb_AWK) '\
114 BEGIN {print "#!/bin/bash\n\
115 origpath=$$(pwd)\n\
116 bindir=$$(cd $$(dirname \"$$0\") ; pwd)\n\
117 cd \"$$origpath\"\n\
118 \"$$bindir/../Resources/Python.app/Contents/MacOS/LibreOfficePython\" - $$@ <<EOF"} \
119 FNR==1{next} \
120 {print} \
121 END {print "EOF"}' > "$$file" ; } < "$$file" ; chmod +x "$$file" ; done
122 touch $@
124 $(call gb_ExternalProject_get_state_target,python3,fixinstallnames) : $(call gb_ExternalProject_get_state_target,python3,build)
125 $(INSTALL_NAME_TOOL) -change \
126 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/LibreOfficePython \
127 @executable_path/../../../../LibreOfficePython \
128 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/Resources/Python.app/Contents/MacOS/LibreOfficePython
129 touch $@
131 # also delete binaries that are symlinked in scp2
132 $(call gb_ExternalProject_get_state_target,python3,executables) : $(call gb_ExternalProject_get_state_target,python3,build)
133 cd $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/bin ; \
134 for file in python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR) \
135 python$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)m \
136 pythonw$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR) ; do \
137 $(INSTALL_NAME_TOOL) -change \
138 $(python3_fw_prefix)/Versions/$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)/LibreOfficePython \
139 @executable_path/../LibreOfficePython $$file ; done
140 touch $@
142 endif
144 # vim: set noet sw=4 ts=4: