xref: /trunk/main/python/makefile.mk (revision 00a90ea2c35aa0d62b41963f97bc10041530f5d1)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22
23
24PRJ=.
25
26PRJNAME=so_python
27TARGET=so_python
28
29# --- Settings -----------------------------------------------------
30
31.INCLUDE :  settings.mk
32.INCLUDE :      pyversion_dmake.mk
33
34.IF "$(SYSTEM_PYTHON)" == "YES"
35all:
36    @echo "An already available installation of python should exist on your system."
37    @echo "Therefore the version provided here does not need to be built in addition."
38.ENDIF
39
40
41# --- Files --------------------------------------------------------
42
43
44TARFILE_NAME=Python-$(PYVERSION)
45TARFILE_MD5=57f84cbd92d478ceff55217d88a07ded
46PATCH_FILES=\
47    python-md5.patch \
48    python-solver-before-std.patch \
49    python-$(PYVERSION)-sysbase.patch \
50    python-$(PYVERSION)-nohardlink.patch
51# python-freebsd.patch: all hunks obsolete in Python 3.11 (upstream fixes).
52# python-ssl.patch: dropped. Python 3.11's setup.py finds the bundled OpenSSL
53#   through the compiler include/lib search paths instead of the old hard-coded
54#   source edit; see python_CFLAGS/python_LDFLAGS in the UNX branch below.
55
56# Windows build deferred — Python 3 requires modern MSVC (VS2008/msvs9 not supported).
57# The msvs9 patch files below are retained for reference but are NOT applied until
58# the Windows toolchain is modernised. See python3 migration notes.
59#.IF "$(GUI)"=="WNT"
60#.IF "$(CPUNAME)"=="INTEL"
61#PATCH_FILES += python-$(PYVERSION)-msvs9.patch
62#.ELIF "$(CPUNAME)"=="X86_64"
63#PATCH_FILES += \
64#   python-$(PYVERSION)-msvs9-win64.patch \
65#   python-$(PYVERSION)-msvs9-win64-target.patch \
66#   python-$(PYVERSION)-msvs9-subsystem.patch \
67#   python-$(PYVERSION)-msvs9-dir.patch \
68#   python-$(PYVERSION)-msvs9-no-host-python.patch \
69#   python-$(PYVERSION)-msvs9-python-path.patch
70#.ENDIF
71#.ENDIF
72
73CONFIGURE_DIR=
74
75.IF "$(GUI)"=="UNX"
76BUILD_DIR=
77MYCWD=$(shell @pwd)/$(INPATH)/misc/build
78
79# Point Python's setup.py at the bundled OpenSSL delivered to the solver.
80# (Replaces the old python-ssl.patch: Python 3.11 discovers _ssl/_hashlib via
81# the C compiler include/lib search paths, so feeding the solver's external
82# include dir and lib dir through CFLAGS/LDFLAGS is sufficient. Headers live
83# in $(SOLARINCDIR)/external/openssl/, so the search dir is .../external so
84# that setup.py's "openssl/ssl.h" probe resolves.)
85python_CFLAGS+=-I$(SOLARINCDIR)$/external
86python_LDFLAGS+=-L$(SOLARLIBDIR)
87
88# CLFLAGS get overwritten in Makefile.pre.in
89.IF "$(SYSBASE)"!=""
90CC+:=-I$(SYSBASE)$/usr$/include
91python_LDFLAGS+=-L$(SYSBASE)/usr/lib
92.IF "$(COMNAME)"=="sunpro5"
93CC+:=$(C_RESTRICTIONFLAGS)
94.ENDIF          # "$(COMNAME)"=="sunpro5"
95.ENDIF          # "$(SYSBASE)"!=""
96
97.IF "$(OS)$(CPU)"=="SOLARISU"
98CC+:=$(ARCH_FLAGS)
99python_LDFLAGS+=$(ARCH_FLAGS)
100.ENDIF
101
102CONFIGURE_ACTION=$(AUGMENT_LIBRARY_PATH) ./configure --prefix=$(MYCWD)/python-inst --enable-shared CFLAGS="$(python_CFLAGS)" LDFLAGS="$(python_LDFLAGS)"
103.IF "$(OS)$(CPU)" == "SOLARISI"
104CONFIGURE_ACTION += --disable-ipv6
105.ENDIF
106BUILD_ACTION=$(ENV_BUILD) $(GNUMAKE) -j$(EXTMAXPROCESS) && $(GNUMAKE) install && chmod -R ug+w $(MYCWD)/python-inst && chmod g+w Include
107.ELSE
108# ----------------------------------
109# WINDOWS
110# ----------------------------------
111.IF "$(COM)"=="GCC"
112#PATCH_FILES=python-$(PYVERSION)-mingw.patch
113BUILD_DIR=
114MYCWD=$(shell cygpath -m $(shell @pwd))/$(INPATH)/misc/build
115python_CFLAGS=-mno-cygwin -mthreads
116python_LDFLAGS=-mno-cygwin -mthreads
117.IF "$(MINGW_SHARED_GCCLIB)"=="YES"
118python_LDFLAGS+=-shared-libgcc
119.ENDIF
120python_LDFLAGS+=-shared-libgcc -Wl,--enable-runtime-pseudo-reloc-v2
121CONFIGURE_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)"
122BUILD_ACTION=$(ENV_BUILD) make && make install
123.ELSE
124#PYTHONPATH:=..$/Lib
125#.EXPORT : PYTHONPATH
126
127#.IF "$(CCNUMVER)" <= "001400000000"
128#EXFLAGS="/GX /YX"
129#.ELSE
130#.IF "$(WINDOWS_VISTA_PSDK)"!=""
131#EXFLAGS="/EHa /Zc:wchar_t- /D "_CRT_SECURE_NO_DEPRECATE""
132#ADDITIONALLIBS=ws2_32.lib
133#.ELSE  #"$(WINDOWS_VISTA_PSDK)"!=""
134#EXFLAGS="/EHa /Zc:wchar_t- /D "_CRT_SECURE_NO_DEPRECATE""
135#.ENDIF #"$(WINDOWS_VISTA_PSDK)"!=""
136#.ENDIF
137
138# Windows build deferred — Python 3 requires modern MSVC (PCbuild); VS9.0/vcbuild
139# no longer supported. Retained for reference. See python3 migration notes.
140#BUILD_DIR=PC/VS9.0
141#.IF "$(CPUNAME)"=="INTEL"
142#BUILD_ACTION=$(COMPATH)$/vcpackages$/vcbuild.exe -useenv pcbuild.sln "Release|Win32"
143#.ELIF "$(CPUNAME)"=="X86_64"
144#BUILD_ACTION=$(COMPATH)$/vcpackages$/vcbuild.exe -useenv pcbuild.sln "Release|x64"
145#.ENDIF
146.ENDIF
147.ENDIF
148
149PYVERSIONFILE_DMAKE=$(MISC)$/pyversion_dmake.mk
150PYVERSIONFILE=$(MISC)$/pyversion.mk
151
152# --- Targets ------------------------------------------------------
153
154
155.INCLUDE : set_ext.mk
156.INCLUDE : target.mk
157.INCLUDE : tg_ext.mk
158
159.IF "$(L10N_framework)"==""
160.IF "$(GUI)" != "UNX"
161.IF "$(COM)"!="GCC"
162PYCONFIG:=$(MISC)$/build$/pyconfig.h
163$(MISC)$/build$/$(TARFILE_NAME)$/PC$/pyconfig.h : $(PACKAGE_DIR)$/$(CONFIGURE_FLAG_FILE)
164
165$(PACKAGE_DIR)$/$(BUILD_FLAG_FILE) : $(PYCONFIG)
166
167$(PYCONFIG) : $(MISC)$/build$/$(TARFILE_NAME)$/PC$/pyconfig.h
168    -rm -f $@
169    cat $(MISC)$/build$/$(TARFILE_NAME)$/PC$/pyconfig.h > $@
170.ENDIF
171.ENDIF
172
173ALLTAR : $(PYVERSIONFILE_DMAKE) $(PYVERSIONFILE)
174.ENDIF          # "$(L10N_framework)"==""
175
176
177$(PYVERSIONFILE_DMAKE) : pyversion_dmake.mk $(PACKAGE_DIR)$/$(PREDELIVER_FLAG_FILE)
178    -rm -f $@
179    cat $? > $@
180
181$(PYVERSIONFILE) : pyversion.mk $(PACKAGE_DIR)$/$(PREDELIVER_FLAG_FILE)
182    -rm -f $@
183    cat $? > $@
184