Fix linking on Windows
[LibreOffice.git] / python / makefile.mk
blob4f50ed3bcccf1ac9be263ada761df48c86965531
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2000, 2010 Oracle and/or its affiliates.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # This file is part of OpenOffice.org.
11 # OpenOffice.org is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU Lesser General Public License version 3
13 # only, as published by the Free Software Foundation.
15 # OpenOffice.org is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU Lesser General Public License version 3 for more details
19 # (a copy is included in the LICENSE file that accompanied this code).
21 # You should have received a copy of the GNU Lesser General Public License
22 # version 3 along with OpenOffice.org. If not, see
23 # <http://www.openoffice.org/license.html>
24 # for a copy of the LGPLv3 License.
26 #*************************************************************************
28 PRJ=.
30 PRJNAME=so_python
31 TARGET=so_python
33 # --- Settings -----------------------------------------------------
35 .INCLUDE : settings.mk
37 .IF "$(DISABLE_PYTHON)"!="TRUE"
39 .INCLUDE : pyversion.mk
41 .IF "$(SYSTEM_PYTHON)" == "YES"
42 all:
43 @echo "An already available installation of python should exist on your system."
44 @echo "Therefore the version provided here does not need to be built in addition."
45 .ENDIF
47 # --- Files --------------------------------------------------------
49 TARFILE_NAME=Python-$(PYVERSION)
50 TARFILE_MD5=e81c2f0953aa60f8062c05a4673f2be0
51 PATCH_FILES=\
52 Python-$(PYVERSION).patch \
53 Python-parallel-make.patch \
54 Python-ssl.patch \
55 Python-aix.patch \
56 Python-2.6.1-urllib.patch \
57 Python-2.6.1-sysbase.patch \
58 Python-2.6.1-nohardlink.patch \
59 Python-2.6.1-py2422.patch \
60 Python-2.6.1-py4768.patch
62 CONFIGURE_DIR=
64 .IF "$(GUI)"=="UNX"
65 BUILD_DIR=
66 MYCWD=$(shell @pwd)/$(INPATH)/misc/build
68 # CLFLAGS get overwritten in Makefile.pre.in
69 .IF "$(SYSBASE)"!=""
70 CC+:=-I$(SYSBASE)$/usr$/include
71 python_LDFLAGS+=-L$(SYSBASE)/usr/lib
72 .IF "$(COMNAME)"=="sunpro5"
73 CC+:=$(C_RESTRICTIONFLAGS)
74 .ENDIF # "$(COMNAME)"=="sunpro5"
75 .ENDIF # "$(SYSBASE)"!=""
77 .IF "$(OS)$(CPU)"=="SOLARISU"
78 CC+:=$(ARCH_FLAGS)
79 python_LDFLAGS+=$(ARCH_FLAGS)
80 .ENDIF
82 .IF "$(OS)"=="AIX"
83 python_CFLAGS=-g0
84 .ENDIF
86 CONFIGURE_ACTION=$(AUGMENT_LIBRARY_PATH) ./configure --prefix=/python-inst --enable-shared CFLAGS="$(python_CFLAGS)" LDFLAGS="$(python_LDFLAGS)"
88 .IF "$(OS)$(CPU)" == "SOLARISI"
89 CONFIGURE_ACTION += --disable-ipv6
90 .ENDIF
92 .IF "$(OS)" == "MACOSX"
93 PATCH_FILES+=Python-2.6.1-py8067.patch Python-2.6.1-dylib_dynload.patch
94 # don't build dual-arch version as OOo itself is not universal binary either
95 PATCH_FILES+=Python-2.6.1-arch_$(eq,$(CPU),I i386 ppc).patch
97 CONFIGURE_ACTION+=--enable-universalsdk=$(MACOSX_SDK_PATH) --with-universal-archs=32-bit --enable-framework=/python-inst --with-framework-name=OOoPython
98 ALLTAR: $(MISC)/OOoPython.framework.zip
100 .ENDIF
102 .IF "$(OS)"=="AIX"
103 CONFIGURE_ACTION += --disable-ipv6 --with-threads
104 .ENDIF
105 BUILD_ACTION=$(ENV_BUILD) $(GNUMAKE) -j$(EXTMAXPROCESS) && $(GNUMAKE) install DESTDIR=$(MYCWD) && chmod -R ug+w $(MYCWD)/python-inst && chmod g+w Include
106 .ELSE
107 # ----------------------------------
108 # WINDOWS
109 # ----------------------------------
110 .IF "$(COM)"=="GCC"
111 PATCH_FILES=Python-$(PYVERSION)-mingw.patch
112 BUILD_DIR=
113 MYCWD=$(shell cygpath -m $(shell @pwd))/$(INPATH)/misc/build
114 python_CFLAGS=-mno-cygwin -mthreads
115 python_LDFLAGS=-mno-cygwin -mthreads
116 .IF "$(MINGW_SHARED_GCCLIB)"=="YES"
117 python_LDFLAGS+=-shared-libgcc
118 .ENDIF
119 python_LDFLAGS+=-shared-libgcc -Wl,--enable-runtime-pseudo-reloc-v2
120 CONFIGURE_ACTION=./configure --prefix=$(MYCWD)/python-inst --enable-shared CC="$(CC:s/guw.exe //)" CXX="$(CXX:s/guw.exe //)" MACHDEP=MINGW32 LN="cp -p" CFLAGS="$(python_CFLAGS)" LDFLAGS="$(python_LDFLAGS)"
121 BUILD_ACTION=$(ENV_BUILD) make && make install
122 .ELSE
124 .IF "$(CCNUMVER)" >= "001600000000"
125 PATCH_FILES+=Python-$(PYVERSION)-vc10.patch
126 BUILD_DIR=PC/VS10.0
127 .ELIF "$(CCNUMVER)" >= "001500000000"
128 BUILD_DIR=PCbuild
129 .ELIF "$(CCNUMVER)" >= "001400000000"
130 BUILD_DIR=PC/VS8.0
131 .ELIF "$(CCNUMVER)" >= "001310000000"
132 BUILD_DIR=PC/VS7.1
133 .ELSE
134 BUILD_DIR=PC/VC6
135 .ENDIF
137 .IF "$(CPU)" == "I"
138 ARCH=Win32
139 .ELSE
140 ARCH=x64
141 .ENDIF
143 .IF "$(debug)"!=""
144 CONF=Debug
145 .ELSE
146 CONF=Release
147 .ENDIF
149 # Build python executable and then runs a minimal script. Running the minimal script
150 # ensures that certain *.pyc files are generated which would otherwise be created on
151 # solver during registration in insetoo_native
152 .IF "$(CCNUMVER)" >= "001600000000"
153 BUILD_ACTION=MSBuild.exe pcbuild.sln /t:Build /p:Configuration=$(CONF) /ToolsVersion:4.0
154 .ELSE
155 BUILD_ACTION=$(COMPATH)$/vcpackages$/vcbuild.exe pcbuild.sln "$(CONF)|$(ARCH)"
156 .ENDIF
157 .ENDIF
158 .ENDIF
160 PYVERSIONFILE=$(MISC)$/pyversion.mk
162 # --- Targets ------------------------------------------------------
165 .INCLUDE : set_ext.mk
166 .ENDIF # DISABLE_PYTHON != TRUE
167 .INCLUDE : target.mk
168 .IF "$(DISABLE_PYTHON)"!="TRUE"
169 .INCLUDE : tg_ext.mk
171 .IF "$(L10N_framework)"==""
172 .IF "$(GUI)" != "UNX"
173 .IF "$(COM)"!="GCC"
174 PYCONFIG:=$(MISC)$/build$/pyconfig.h
175 $(MISC)$/build$/$(TARFILE_NAME)$/PC$/pyconfig.h : $(PACKAGE_DIR)$/$(CONFIGURE_FLAG_FILE)
177 $(PACKAGE_DIR)$/$(BUILD_FLAG_FILE) : $(PYCONFIG)
179 $(PYCONFIG) : $(MISC)$/build$/$(TARFILE_NAME)$/PC$/pyconfig.h
180 -rm -f $@
181 cat $(MISC)$/build$/$(TARFILE_NAME)$/PC$/pyconfig.h > $@
182 # We know that the only thing guarded with #ifdef _DEBUG in PC/pyconfig.h is
183 # the line defining Py_DEBUG.
184 .IF "$(debug)"!=""
185 # If Python is built with debugging, then the modules we build need to be built with
186 # Py_DEBUG defined too because of the Py_InitModule4 redefining magic in modsupport.h
187 sed -e 's/^#ifdef _DEBUG$/#if 1/' <$@ >$@.new && mv $@.new $@
188 .ELSE
189 # Correspondingly, if Python is not built with debugging, it won't use the Py_InitModule4 redefining
190 # magic, so our Python modules should not be built to provide that either.
191 sed -e 's/^#ifdef _DEBUG$/#if 0/' <$@ >$@.new && mv $@.new $@
192 .ENDIF
193 .ENDIF
194 .ENDIF
196 ALLTAR : $(PYVERSIONFILE)
197 .ENDIF # "$(L10N_framework)"==""
199 # rule to allow relocating the whole framework, removing reference to buildinstallation directory
200 $(PACKAGE_DIR)/fixscripts: $(PACKAGE_DIR)$/$(PREDELIVER_FLAG_FILE)
201 @echo remove build installdir from scripts
202 $(COMMAND_ECHO)for file in \
203 $(MYCWD)/python-inst/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/bin/2to3 \
204 $(MYCWD)/python-inst/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/bin/idle$(PYMAJOR).$(PYMINOR) \
205 $(MYCWD)/python-inst/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/bin/pydoc$(PYMAJOR).$(PYMINOR) \
206 $(MYCWD)/python-inst/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/bin/python$(PYMAJOR).$(PYMINOR)-config \
207 $(MYCWD)/python-inst/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/bin/smtpd$(PYMAJOR).$(PYMINOR).py ; do \
208 {{ rm "$$file" && awk '\
209 BEGIN {{print "\
210 #!/bin/bash\n\
211 origpath=$$(pwd)\n\
212 bindir=$$(cd $$(dirname \"$$0\") ; pwd)\n\
213 cd \"$$origpath\"\n\
214 \"$$bindir/../Resources/Python.app/Contents/MacOS/OOoPython\" - $$@ <<EOF"}} \
215 FNR==1{{next}} \
216 {{print}} \
217 END {{print "EOF"}}' > "$$file" ; }} < "$$file" ; chmod +x "$$file" ; done
218 @touch $@
220 $(PACKAGE_DIR)/fixinstallnames: $(PACKAGE_DIR)$/$(PREDELIVER_FLAG_FILE)
221 @echo remove build installdir from OOoPython
222 $(COMMAND_ECHO)install_name_tool -change \
223 /python-inst/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/OOoPython \
224 @executable_path/../../../../OOoPython \
225 $(MYCWD)/python-inst/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/Resources/Python.app/Contents/MacOS/OOoPython
226 @touch $@
228 $(MISC)/OOoPython.framework.zip: $(PACKAGE_DIR)/fixinstallnames $(PACKAGE_DIR)/fixscripts
229 @-rm -f $@
230 @echo creating $@
231 $(COMMAND_ECHO)cd $(MISC)/build/python-inst && find OOoPython.framework \
232 -not -type l -not -name Info.plist.in \
233 -not -name pythonw$(PYMAJOR).$(PYMINOR) \
234 -not -name python$(PYMAJOR).$(PYMINOR) -print0 | \
235 xargs -0 zip $(ZIP_VERBOSITY) ../../$(@:f)
237 $(PYVERSIONFILE) : pyversion.mk $(PACKAGE_DIR)$/$(PREDELIVER_FLAG_FILE)
238 @-rm -f $@
239 $(COMMAND_ECHO)$(COPY) pyversion.mk $@
241 .ENDIF # DISABLE_PYTHON != TRUE