Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / python / makefile.mk
blob1f41a96866a760a06ec27274dc443174cc7b588c
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 \
61 Python-2.6.1-svn-1.7.patch
63 CONFIGURE_DIR=
65 .IF "$(GUI)"=="UNX"
66 BUILD_DIR=
67 MYCWD=$(shell @pwd)/$(INPATH)/misc/build
69 .IF "$(SYSTEM_OPENSSL)" != "YES"
70 #we want to be sure we use our internal openssl if
71 #that's enabled
72 CC+:=-I$(SOLARINCDIR)$/external
73 python_LDFLAGS+=-L$(SOLARLIBDIR)
74 .ENDIF
76 # CLFLAGS get overwritten in Makefile.pre.in
77 .IF "$(SYSBASE)"!=""
78 CC+:=-I$(SYSBASE)$/usr$/include
79 python_LDFLAGS+=-L$(SYSBASE)/usr/lib
80 .IF "$(COMNAME)"=="sunpro5"
81 CC+:=$(C_RESTRICTIONFLAGS)
82 .ENDIF # "$(COMNAME)"=="sunpro5"
83 .ENDIF # "$(SYSBASE)"!=""
85 .IF "$(OS)$(CPU)"=="SOLARISU"
86 CC+:=$(ARCH_FLAGS)
87 python_LDFLAGS+=$(ARCH_FLAGS)
88 .ENDIF
90 .IF "$(OS)"=="AIX"
91 python_CFLAGS=-g0
92 .ENDIF
94 .IF "$(OS)" == "MACOSX"
95 my_prefix = @__________________________________________________$(EXTRPATH)
96 .ELSE
97 my_prefix = python-inst
98 .END
100 CONFIGURE_ACTION=$(AUGMENT_LIBRARY_PATH) ./configure --prefix=/$(my_prefix) --enable-shared CFLAGS="$(python_CFLAGS)" LDFLAGS="$(python_LDFLAGS)"
102 .IF "$(OS)$(CPUNAME)" == "SOLARISINTEL"
103 CONFIGURE_ACTION += --disable-ipv6
104 .ENDIF
106 .IF "$(OS)" == "MACOSX"
107 PATCH_FILES+=Python-2.6.1-py8067.patch
108 # don't build dual-arch version as OOo itself is not universal binary either
109 PATCH_FILES+=Python-2.6.1-arch_$(eq,$(CPU),I i386 ppc).patch
111 CONFIGURE_ACTION+=--enable-universalsdk=$(MACOSX_SDK_PATH) --with-universal-archs=32-bit --enable-framework=/$(my_prefix) --with-framework-name=OOoPython
112 ALLTAR: $(MISC)/OOoPython.framework.zip
114 .ENDIF
116 .IF "$(OS)"=="AIX"
117 CONFIGURE_ACTION += --disable-ipv6 --with-threads
118 .ENDIF
119 BUILD_ACTION=$(ENV_BUILD) $(GNUMAKE) -j$(EXTMAXPROCESS) && $(GNUMAKE) install DESTDIR=$(MYCWD) && chmod -R ug+w $(MYCWD)/$(my_prefix) && chmod g+w Include
120 .ELSE
121 # ----------------------------------
122 # WINDOWS
123 # ----------------------------------
124 .IF "$(COM)"=="GCC"
125 PATCH_FILES=Python-$(PYVERSION)-mingw.patch
126 BUILD_DIR=
127 MYCWD=$(shell cygpath -m $(shell @pwd))/$(INPATH)/misc/build
128 python_CFLAGS=-mno-cygwin -mthreads
129 python_LDFLAGS=-mno-cygwin -mthreads
130 .IF "$(MINGW_SHARED_GCCLIB)"=="YES"
131 python_LDFLAGS+=-shared-libgcc
132 .ENDIF
133 python_LDFLAGS+=-shared-libgcc -Wl,--enable-runtime-pseudo-reloc-v2
134 CONFIGURE_ACTION=./configure --prefix=$(MYCWD)/$(my_prefix) --enable-shared CC="$(CC:s/guw.exe //)" CXX="$(CXX:s/guw.exe //)" MACHDEP=MINGW32 LN="cp -p" CFLAGS="$(python_CFLAGS)" LDFLAGS="$(python_LDFLAGS)"
135 BUILD_ACTION=$(ENV_BUILD) make && make install
136 .ELSE
138 .IF "$(CCNUMVER)" >= "001600000000"
139 PATCH_FILES+=Python-$(PYVERSION)-vc10.patch
140 BUILD_DIR=PC/VS10.0
141 .ELIF "$(CCNUMVER)" >= "001500000000"
142 BUILD_DIR=PCbuild
143 .ELIF "$(CCNUMVER)" >= "001400000000"
144 BUILD_DIR=PC/VS8.0
145 .ELIF "$(CCNUMVER)" >= "001310000000"
146 BUILD_DIR=PC/VS7.1
147 .ELSE
148 BUILD_DIR=PC/VC6
149 .ENDIF
151 .IF "$(CPUNAME)" == "INTEL"
152 ARCH=Win32
153 .ELSE
154 ARCH=x64
155 .ENDIF
157 .IF "$(debug)"!=""
158 CONF=Debug
159 .ELSE
160 CONF=Release
161 .ENDIF
163 # Build python executable and then runs a minimal script. Running the minimal script
164 # ensures that certain *.pyc files are generated which would otherwise be created on
165 # solver during registration in insetoo_native
166 .IF "$(CCNUMVER)" >= "001600000000"
167 BUILD_ACTION=MSBuild.exe pcbuild.sln /t:Build /p:Configuration=$(CONF) /ToolsVersion:4.0
168 .ELSE
169 BUILD_ACTION=$(COMPATH)$/vcpackages$/vcbuild.exe pcbuild.sln "$(CONF)|$(ARCH)"
170 .ENDIF
171 .ENDIF
172 .ENDIF
174 PYVERSIONFILE=$(MISC)$/pyversion.mk
175 PYVERSIONGFILE=$(MISC)$/pyversion.Makefile
177 # --- Targets ------------------------------------------------------
180 .INCLUDE : set_ext.mk
181 .ENDIF # DISABLE_PYTHON != TRUE
182 .INCLUDE : target.mk
183 .IF "$(DISABLE_PYTHON)"!="TRUE"
184 .INCLUDE : tg_ext.mk
186 .IF "$(L10N_framework)"==""
187 .IF "$(GUI)" != "UNX"
188 .IF "$(COM)"!="GCC"
189 PYCONFIG:=$(MISC)$/build$/pyconfig.h
190 $(MISC)$/build$/$(TARFILE_NAME)$/PC$/pyconfig.h : $(PACKAGE_DIR)$/$(CONFIGURE_FLAG_FILE)
192 $(PACKAGE_DIR)$/$(BUILD_FLAG_FILE) : $(PYCONFIG)
194 $(PYCONFIG) : $(MISC)$/build$/$(TARFILE_NAME)$/PC$/pyconfig.h
195 -rm -f $@
196 cat $(MISC)$/build$/$(TARFILE_NAME)$/PC$/pyconfig.h > $@
197 # We know that the only thing guarded with #ifdef _DEBUG in PC/pyconfig.h is
198 # the line defining Py_DEBUG.
199 .IF "$(debug)"!=""
200 # If Python is built with debugging, then the modules we build need to be built with
201 # Py_DEBUG defined too because of the Py_InitModule4 redefining magic in modsupport.h
202 sed -e 's/^#ifdef _DEBUG$/#if 1/' <$@ >$@.new && mv $@.new $@
203 .ELSE
204 # Correspondingly, if Python is not built with debugging, it won't use the Py_InitModule4 redefining
205 # magic, so our Python modules should not be built to provide that either.
206 sed -e 's/^#ifdef _DEBUG$/#if 0/' <$@ >$@.new && mv $@.new $@
207 .ENDIF
208 .ENDIF
209 .ENDIF
211 ALLTAR : $(PYVERSIONFILE) $(PYVERSIONGFILE)
212 .ENDIF # "$(L10N_framework)"==""
214 # rule to allow relocating the whole framework, removing reference to buildinstallation directory
215 $(PACKAGE_DIR)/fixscripts: $(PACKAGE_DIR)$/$(PREDELIVER_FLAG_FILE)
216 @echo remove build installdir from scripts
217 $(COMMAND_ECHO)for file in \
218 $(MYCWD)/$(my_prefix)/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/bin/2to3 \
219 $(MYCWD)/$(my_prefix)/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/bin/idle$(PYMAJOR).$(PYMINOR) \
220 $(MYCWD)/$(my_prefix)/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/bin/pydoc$(PYMAJOR).$(PYMINOR) \
221 $(MYCWD)/$(my_prefix)/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/bin/python$(PYMAJOR).$(PYMINOR)-config \
222 $(MYCWD)/$(my_prefix)/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/bin/smtpd$(PYMAJOR).$(PYMINOR).py ; do \
223 {{ rm "$$file" && awk '\
224 BEGIN {{print "\
225 #!/bin/bash\n\
226 origpath=$$(pwd)\n\
227 bindir=$$(cd $$(dirname \"$$0\") ; pwd)\n\
228 cd \"$$origpath\"\n\
229 \"$$bindir/../Resources/Python.app/Contents/MacOS/OOoPython\" - $$@ <<EOF"}} \
230 FNR==1{{next}} \
231 {{print}} \
232 END {{print "EOF"}}' > "$$file" ; }} < "$$file" ; chmod +x "$$file" ; done
233 @touch $@
235 $(PACKAGE_DIR)/fixinstallnames: $(PACKAGE_DIR)$/$(PREDELIVER_FLAG_FILE)
236 @echo remove build installdir from OOoPython
237 $(COMMAND_ECHO)install_name_tool -change \
238 /$(my_prefix)/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/OOoPython \
239 @executable_path/../../../../OOoPython \
240 $(MYCWD)/$(my_prefix)/OOoPython.framework/Versions/$(PYMAJOR).$(PYMINOR)/Resources/Python.app/Contents/MacOS/OOoPython
241 @touch $@
243 $(MISC)/OOoPython.framework.zip: $(PACKAGE_DIR)/fixinstallnames $(PACKAGE_DIR)/fixscripts
244 @-rm -f $@
245 @echo creating $@
246 $(COMMAND_ECHO)cd $(MISC)/build/$(my_prefix) && find OOoPython.framework \
247 -not -type l -not -name Info.plist.in \
248 -not -name pythonw$(PYMAJOR).$(PYMINOR) \
249 -not -name python$(PYMAJOR).$(PYMINOR) -print0 | \
250 xargs -0 zip $(ZIP_VERBOSITY) ../../$(@:f)
252 $(PYVERSIONFILE) : pyversion.mk $(PACKAGE_DIR)$/$(PREDELIVER_FLAG_FILE)
253 @-rm -f $@
254 $(COMMAND_ECHO)$(COPY) pyversion.mk $@
256 $(PYVERSIONGFILE) : pyversion.Makefile $(PACKAGE_DIR)$/$(PREDELIVER_FLAG_FILE)
257 @-rm -f $@
258 $(COMMAND_ECHO)$(COPY) pyversion.Makefile $@
260 .ENDIF # DISABLE_PYTHON != TRUE