@@ -44,9 +44,11 @@ TRIPLE_OS-macOS=macos
4444VERSION_MIN-macOS =11.0
4545
4646# iOS targets
47- TARGETS-iOS =iphonesimulator.x86_64 iphonesimulator.arm64 iphoneos.arm64
47+ TARGETS-iOS =iphonesimulator.x86_64 iphonesimulator.arm64 iphoneos.arm64 macabi.x86_64 macabi.arm64
4848TRIPLE_OS-iOS =ios
4949VERSION_MIN-iOS =13.0
50+ VERSION_MIN_OVERRIDE-macabi =14.2
51+ CONFIGFLAGS-macabi=--with-catalyst-macos-version =11.2
5052
5153# tvOS targets
5254TARGETS-tvOS =appletvsimulator.x86_64 appletvsimulator.arm64 appletvos.arm64
@@ -132,15 +134,34 @@ os=$2
132134OS_LOWER-$(target ) =$(shell echo $(os ) | tr '[:upper:]' '[:lower:]')
133135
134136# $(target) can be broken up into is composed of $(SDK).$(ARCH)
135- SDK-$(target ) =$$(basename $(target ) )
137+ BASE-$(target ) =$$(basename $(target ) )
138+ SDK-$(target ) =$$(subst macabi,macosx,$$(BASE-$(target ) ) )
136139ARCH-$(target ) =$$(subst .,,$$(suffix $(target ) ) )
137140
141+ # Compute version minimum for the target
142+ VERSION_MIN-$(target ) =$$(VERSION_MIN-$(os ) )
143+ ifdef VERSION_MIN_OVERRIDE-$$(BASE-$(target))
144+ VERSION_MIN-$(target) =$$(VERSION_MIN_OVERRIDE-$$(BASE-$(target ) ) )
145+ endif
146+
147+ # Inherit the basename for the configure flags.
148+ ifdef CONFIGFLAGS-$$(BASE-$(target))
149+ CONFIGFLAGS-$(target) =$$(CONFIGFLAGS-$$(BASE-$(target ) )
150+ else
151+ CONFIGFLAGS-$(target ) =
152+ endif
153+
138154ifneq ($(os ) ,macOS )
139- ifeq ($$(findstring simulator,$$(SDK-$(target))),)
140- TARGET_TRIPLE-$(target) =$$(ARCH-$(target ) ) -apple-$$(TRIPLE_OS-$(os ) )$$(VERSION_MIN-$(os ) )
155+ ifeq ($$(findstring simulator,$$(BASE-$(target))),)
156+ ifeq ($$(findstring macabi,$$(BASE-$(target))),)
157+ TARGET_TRIPLE-$(target) =$$(ARCH-$(target ) ) -apple-$$(TRIPLE_OS-$(os ) )$$(VERSION_MIN-$(target ) )
141158IS_SIMULATOR-$(target) =False
159+ else
160+ TARGET_TRIPLE-$(target) =$$(ARCH-$(target ) ) -apple-$$(TRIPLE_OS-$(os ) )$$(VERSION_MIN-$(target ) ) -macabi
161+ IS_SIMULATOR-$(target) =False
162+ endif
142163 else
143- TARGET_TRIPLE-$(target) =$$(ARCH-$(target ) ) -apple-$$(TRIPLE_OS-$(os ) )$$(VERSION_MIN-$(os ) ) -simulator
164+ TARGET_TRIPLE-$(target) =$$(ARCH-$(target ) ) -apple-$$(TRIPLE_OS-$(os ) )$$(VERSION_MIN-$(target ) ) -simulator
144165IS_SIMULATOR-$(target) =True
145166 endif
146167endif
@@ -274,6 +295,13 @@ PYTHON_PLATFORM_CONFIG-$(target)=$$(PYTHON_INSTALL-$(target))/platform-config/$$
274295PYTHON_PLATFORM_SITECUSTOMIZE-$(target) =$$(PYTHON_PLATFORM_CONFIG-$(target ) ) /sitecustomize.py
275296
276297
298+
299+ ifneq ($$(BASE-$(target ) ) ,macabi)
300+ RESCDIR-$(target) =$(PROJECT_DIR ) /$$(PYTHON_SRCDIR-$(target ) ) /$(os ) /Resources
301+ else
302+ RESCDIR-$(target) =$(PROJECT_DIR ) /$$(PYTHON_SRCDIR-$(target ) ) /MacCatalyst/Resources
303+ endif
304+
277305$$(PYTHON_SRCDIR-$(target ) ) /configure : \
278306 downloads/Python-$(PYTHON_VERSION ) .tar.gz \
279307 $$(BZIP2_LIB-$(target ) ) \
@@ -287,15 +315,15 @@ $$(PYTHON_SRCDIR-$(target))/configure: \
287315 # Apply target Python patches
288316 cd $$(PYTHON_SRCDIR-$(target ) ) && patch -p1 < $(PROJECT_DIR ) /patch/Python/Python.patch
289317 # Make sure the binary scripts are executable
290- chmod 755 $$(PYTHON_SRCDIR -$(target ) ) / $( os ) /Resources /bin/*
318+ chmod 755 $$(RESCDIR -$(target ) ) /bin/*
291319 # Touch the configure script to ensure that Make identifies it as up to date.
292320 touch $$(PYTHON_SRCDIR-$(target ) ) /configure
293321
294322$$(PYTHON_SRCDIR-$(target ) ) /Makefile : \
295323 $$(PYTHON_SRCDIR-$(target ) ) /configure
296324 # Configure target Python
297325 cd $$(PYTHON_SRCDIR-$(target ) ) && \
298- PATH=" $( PROJECT_DIR ) / $$ (PYTHON_SRCDIR -$( target) )/ $( os ) /Resources /bin:$( PATH) " \
326+ PATH=" $$ (RESCDIR -$( target) )/bin:$( PATH) " \
299327 ./configure \
300328 LIBLZMA_CFLAGS=" -I$$ (XZ_INSTALL-$( target) )/include" \
301329 LIBLZMA_LIBS=" -L$$ (XZ_INSTALL-$( target) )/lib -llzma" \
@@ -312,19 +340,21 @@ $$(PYTHON_SRCDIR-$(target))/Makefile: \
312340 --with-openssl=" $$ (OPENSSL_INSTALL-$( target) )" \
313341 --enable-framework=" $$ (PYTHON_INSTALL-$( target) )" \
314342 --with-system-libmpdec \
343+ $$(CONFIGFLAGS-$(target ) ) \
315344 2>&1 | tee -a ../python-$(PYTHON_VERSION ) .config.log
316345
317346$$(PYTHON_SRCDIR-$(target ) ) /python.exe : $$(PYTHON_SRCDIR-$(target ) ) /Makefile
318347 @echo " >>> Build Python for $( target) "
348+
319349 cd $$(PYTHON_SRCDIR-$(target ) ) && \
320- PATH=" $( PROJECT_DIR ) / $$ (PYTHON_SRCDIR -$( target) )/ $( os ) /Resources /bin:$( PATH) " \
350+ PATH=" $$ (RESCDIR -$( target) )/bin:$( PATH) " \
321351 make -j8 all \
322352 2>&1 | tee -a ../python-$(PYTHON_VERSION ) .build.log
323353
324354$$(PYTHON_LIB-$(target ) ) : $$(PYTHON_SRCDIR-$(target ) ) /python.exe
325355 @echo " >>> Install Python for $( target) "
326356 cd $$(PYTHON_SRCDIR-$(target ) ) && \
327- PATH=" $( PROJECT_DIR ) / $$ (PYTHON_SRCDIR -$( target) )/ $( os ) /Resources /bin:$( PATH) " \
357+ PATH=" $$ (RESCDIR -$( target) )/bin:$( PATH) " \
328358 make install \
329359 2>&1 | tee -a ../python-$(PYTHON_VERSION ) .install.log
330360
@@ -349,7 +379,7 @@ $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target)):
349379 | sed -e " s/{{platform}}/$$ (OS_LOWER-$( target) )/g" \
350380 | sed -e " s/{{arch}}/$$ (ARCH-$( target) )/g" \
351381 | sed -e " s/{{sdk}}/$$ (SDK-$( target) )/g" \
352- | sed -e " s/{{version_min}}/$$ (VERSION_MIN-$( os ) )/g" \
382+ | sed -e " s/{{version_min}}/$$ (VERSION_MIN-$( target ) )/g" \
353383 | sed -e " s/{{is_simulator}}/$$ (IS_SIMULATOR-$( target) )/g" \
354384 > $$(PYTHON_PLATFORM_CONFIG-$(target ) ) /_cross_$$(ARCH-$(target ) ) _$$(SDK-$(target ) ) .py
355385 cat $(PROJECT_DIR ) /patch/Python/sitecustomize.py.tmpl \
495525 $$(foreach target,$$(SDK_TARGETS-$(sdk)),cp $$(PYTHON_INCLUDE-$$(target))/pyconfig.h $$(PYTHON_INCLUDE-$(sdk))/pyconfig-$$(ARCH-$$(target)).h; )
496526
497527 # Copy the cross-target header from the source folder of the first target in the $(sdk) SDK
498- cp $$(PYTHON_SRCDIR -$$(firstword $$(SDK_TARGETS-$(sdk))))/$(os)/Resources /pyconfig.h $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h
528+ cp $$(RESCDIR -$$(firstword $$(SDK_TARGETS-$(sdk))))/pyconfig.h $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h
499529endif
500530
501531
0 commit comments