gh-114099: Refactor configure and Makefile to accomodate non-macOS frameworks (#115120)

Part of the PEP 730 work to add iOS support.

This change lays the groundwork for introducing iOS/tvOS/watchOS 
frameworks; it includes the structural refactoring needed so that iOS
branches can be added into in a subsequent PR.

Summary of changes:
* Updates config.sub to the 2024-01-01 release. This is the "as 
  released" version of config.sub.
* Adds a RESSRCDIR variable to allow sharing of macOS and iOS Makefile 
  steps.
* Adds an INSTALLTARGETS variable so platforms can customise which
  targets are actually installed. This will be used to exclude certain
  targets (e.g., binaries, manfiles) from iOS framework installs.
* Adds a PYTHONFRAMEWORKINSTALLNAMEPREFIX variable; this is used as
  the install name for the library. This is needed to allow for iOS
  frameworks to specify an @rpath-based install name.
* Evaluates MACHDEP earlier in the configure process so that
  ac_sys_system is available.
* Modifies _PYTHON_HOST_PLATFORM evaluation for cross-platform builds
  so that the CPU architecture is differentiated from the host
  identifier. This will be used to generate a _PYTHON_HOST_PLATFORM
  definition that includes ABI information, not just CPU architecture.
* Differentiates between SOABI_PLATFORM and PLATFORM_TRIPLET.
  SOABI_PLATFORM is used in binary module names, and includes the ABI,
  but not the OS or CPU architecture (e.g.,
  math.cpython-313-iphonesimulator.dylib). PLATFORM_TRIPLET is used
  as the sys._multiarch value, and on iOS will contains the ABI and
  architecture (e.g., iphoneos-arm64). This differentiation hasn't
  historically been needed because while macOS is a multiarch platform,
  it uses a bare darwin as PLATFORM_TRIPLE.
* Removes the use of the deprecated -Wl,-single_module flag when
  compiling macOS frameworks.
* Some whitespace normalisation where there was a mix of spaces and tabs 
  in a single block.
This commit is contained in:
Russell Keith-Magee 2024-02-13 07:10:24 +08:00 committed by GitHub
parent 10756b10ff
commit 2f0778675a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 604 additions and 436 deletions

393
configure generated vendored
View file

@ -972,7 +972,7 @@ HAS_XCRUN
EXPORT_MACOSX_DEPLOYMENT_TARGET
CONFIGURE_MACOSX_DEPLOYMENT_TARGET
_PYTHON_HOST_PLATFORM
MACHDEP
INSTALLTARGETS
FRAMEWORKINSTALLAPPSPREFIX
FRAMEWORKUNIXTOOLSPREFIX
FRAMEWORKPYTHONW
@ -980,6 +980,8 @@ FRAMEWORKALTINSTALLLAST
FRAMEWORKALTINSTALLFIRST
FRAMEWORKINSTALLLAST
FRAMEWORKINSTALLFIRST
RESSRCDIR
PYTHONFRAMEWORKINSTALLNAMEPREFIX
PYTHONFRAMEWORKINSTALLDIR
PYTHONFRAMEWORKPREFIX
PYTHONFRAMEWORKDIR
@ -989,6 +991,7 @@ LIPO_INTEL64_FLAGS
LIPO_32BIT_FLAGS
ARCH_RUN_32BIT
UNIVERSALSDK
MACHDEP
PKG_CONFIG_LIBDIR
PKG_CONFIG_PATH
PKG_CONFIG
@ -4004,6 +4007,77 @@ if test "$with_pkg_config" = yes -a -z "$PKG_CONFIG"; then
as_fn_error $? "pkg-config is required" "$LINENO" 5]
fi
# Set name for machine-dependent library files
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking MACHDEP" >&5
printf %s "checking MACHDEP... " >&6; }
if test -z "$MACHDEP"
then
# avoid using uname for cross builds
if test "$cross_compiling" = yes; then
# ac_sys_system and ac_sys_release are used for setting
# a lot of different things including 'define_xopen_source'
# in the case statement below.
case "$host" in
*-*-linux-android*)
ac_sys_system=Linux-android
;;
*-*-linux*)
ac_sys_system=Linux
;;
*-*-cygwin*)
ac_sys_system=Cygwin
;;
*-*-vxworks*)
ac_sys_system=VxWorks
;;
*-*-emscripten)
ac_sys_system=Emscripten
;;
*-*-wasi)
ac_sys_system=WASI
;;
*)
# for now, limit cross builds to known configurations
MACHDEP="unknown"
as_fn_error $? "cross build not supported for $host" "$LINENO" 5
esac
ac_sys_release=
else
ac_sys_system=`uname -s`
if test "$ac_sys_system" = "AIX" \
-o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
ac_sys_release=`uname -v`
else
ac_sys_release=`uname -r`
fi
fi
ac_md_system=`echo $ac_sys_system |
tr -d '/ ' | tr '[A-Z]' '[a-z]'`
ac_md_release=`echo $ac_sys_release |
tr -d '/ ' | sed 's/^[A-Z]\.//' | sed 's/\..*//'`
MACHDEP="$ac_md_system$ac_md_release"
case $MACHDEP in
aix*) MACHDEP="aix";;
linux*) MACHDEP="linux";;
cygwin*) MACHDEP="cygwin";;
darwin*) MACHDEP="darwin";;
'') MACHDEP="unknown";;
esac
if test "$ac_sys_system" = "SunOS"; then
# For Solaris, there isn't an OS version specific macro defined
# in most compilers, so we define one here.
SUNOS_VERSION=`echo $ac_sys_release | sed -e 's!\.\(0-9\)$!.0\1!g' | tr -d '.'`
printf "%s\n" "#define Py_SUNOS_VERSION $SUNOS_VERSION" >>confdefs.h
fi
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: \"$MACHDEP\"" >&5
printf "%s\n" "\"$MACHDEP\"" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --enable-universalsdk" >&5
printf %s "checking for --enable-universalsdk... " >&6; }
# Check whether --enable-universalsdk was given.
@ -4127,11 +4201,15 @@ then :
PYTHONFRAMEWORKDIR=no-framework
PYTHONFRAMEWORKPREFIX=
PYTHONFRAMEWORKINSTALLDIR=
PYTHONFRAMEWORKINSTALLNAMEPREFIX=
RESSRCDIR=
FRAMEWORKINSTALLFIRST=
FRAMEWORKINSTALLLAST=
FRAMEWORKALTINSTALLFIRST=
FRAMEWORKALTINSTALLLAST=
FRAMEWORKPYTHONW=
INSTALLTARGETS="commoninstall bininstall maninstall"
if test "x${prefix}" = "xNONE"; then
FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
else
@ -4144,77 +4222,91 @@ then :
PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure "
FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
FRAMEWORKPYTHONW="frameworkpythonw"
FRAMEWORKINSTALLAPPSPREFIX="/Applications"
if test "x${prefix}" = "xNONE" ; then
FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
case $ac_sys_system in #(
Darwin) :
FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
FRAMEWORKPYTHONW="frameworkpythonw"
FRAMEWORKINSTALLAPPSPREFIX="/Applications"
INSTALLTARGETS="commoninstall bininstall maninstall"
else
FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
fi
if test "x${prefix}" = "xNONE" ; then
FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
case "${enableval}" in
/System*)
FRAMEWORKINSTALLAPPSPREFIX="/Applications"
if test "${prefix}" = "NONE" ; then
# See below
FRAMEWORKUNIXTOOLSPREFIX="/usr"
fi
;;
else
FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
fi
/Library*)
FRAMEWORKINSTALLAPPSPREFIX="/Applications"
;;
case "${enableval}" in
/System*)
FRAMEWORKINSTALLAPPSPREFIX="/Applications"
if test "${prefix}" = "NONE" ; then
# See below
FRAMEWORKUNIXTOOLSPREFIX="/usr"
fi
;;
*/Library/Frameworks)
MDIR="`dirname "${enableval}"`"
MDIR="`dirname "${MDIR}"`"
FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
/Library*)
FRAMEWORKINSTALLAPPSPREFIX="/Applications"
;;
if test "${prefix}" = "NONE"; then
# User hasn't specified the
# --prefix option, but wants to install
# the framework in a non-default location,
# ensure that the compatibility links get
# installed relative to that prefix as well
# instead of in /usr/local.
FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
fi
;;
*/Library/Frameworks)
MDIR="`dirname "${enableval}"`"
MDIR="`dirname "${MDIR}"`"
FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
*)
FRAMEWORKINSTALLAPPSPREFIX="/Applications"
;;
if test "${prefix}" = "NONE"; then
# User hasn't specified the
# --prefix option, but wants to install
# the framework in a non-default location,
# ensure that the compatibility links get
# installed relative to that prefix as well
# instead of in /usr/local.
FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
fi
;;
*)
FRAMEWORKINSTALLAPPSPREFIX="/Applications"
;;
esac
prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
PYTHONFRAMEWORKINSTALLNAMEPREFIX=${prefix}
RESSRCDIR=Mac/Resources/framework
# Add files for Mac specific code to the list of output
# files:
ac_config_files="$ac_config_files Mac/Makefile"
ac_config_files="$ac_config_files Mac/PythonLauncher/Makefile"
ac_config_files="$ac_config_files Mac/Resources/framework/Info.plist"
ac_config_files="$ac_config_files Mac/Resources/app/Info.plist"
;;
*)
as_fn_error $? "Unknown platform for framework build" "$LINENO" 5
;;
esac
esac
prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
# Add files for Mac specific code to the list of output
# files:
ac_config_files="$ac_config_files Mac/Makefile"
ac_config_files="$ac_config_files Mac/PythonLauncher/Makefile"
ac_config_files="$ac_config_files Mac/Resources/framework/Info.plist"
ac_config_files="$ac_config_files Mac/Resources/app/Info.plist"
esac
else $as_nop
PYTHONFRAMEWORK=
PYTHONFRAMEWORKDIR=no-framework
PYTHONFRAMEWORKPREFIX=
PYTHONFRAMEWORKINSTALLDIR=
PYTHONFRAMEWORKINSTALLNAMEPREFIX=
RESSRCDIR=
FRAMEWORKINSTALLFIRST=
FRAMEWORKINSTALLLAST=
FRAMEWORKALTINSTALLFIRST=
FRAMEWORKALTINSTALLLAST=
FRAMEWORKPYTHONW=
INSTALLTARGETS="commoninstall bininstall maninstall"
if test "x${prefix}" = "xNONE" ; then
FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
else
@ -4239,107 +4331,39 @@ fi
printf "%s\n" "#define _PYTHONFRAMEWORK \"${PYTHONFRAMEWORK}\"" >>confdefs.h
# Set name for machine-dependent library files
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking MACHDEP" >&5
printf %s "checking MACHDEP... " >&6; }
if test -z "$MACHDEP"
then
# avoid using uname for cross builds
if test "$cross_compiling" = yes; then
# ac_sys_system and ac_sys_release are used for setting
# a lot of different things including 'define_xopen_source'
# in the case statement below.
case "$host" in
*-*-linux-android*)
ac_sys_system=Linux-android
;;
*-*-linux*)
ac_sys_system=Linux
;;
*-*-cygwin*)
ac_sys_system=Cygwin
;;
*-*-vxworks*)
ac_sys_system=VxWorks
;;
*-*-emscripten)
ac_sys_system=Emscripten
;;
*-*-wasi)
ac_sys_system=WASI
;;
*)
# for now, limit cross builds to known configurations
MACHDEP="unknown"
as_fn_error $? "cross build not supported for $host" "$LINENO" 5
esac
ac_sys_release=
else
ac_sys_system=`uname -s`
if test "$ac_sys_system" = "AIX" \
-o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
ac_sys_release=`uname -v`
else
ac_sys_release=`uname -r`
fi
fi
ac_md_system=`echo $ac_sys_system |
tr -d '/ ' | tr '[A-Z]' '[a-z]'`
ac_md_release=`echo $ac_sys_release |
tr -d '/ ' | sed 's/^[A-Z]\.//' | sed 's/\..*//'`
MACHDEP="$ac_md_system$ac_md_release"
case $MACHDEP in
aix*) MACHDEP="aix";;
linux*) MACHDEP="linux";;
cygwin*) MACHDEP="cygwin";;
darwin*) MACHDEP="darwin";;
'') MACHDEP="unknown";;
esac
if test "$ac_sys_system" = "SunOS"; then
# For Solaris, there isn't an OS version specific macro defined
# in most compilers, so we define one here.
SUNOS_VERSION=`echo $ac_sys_release | sed -e 's!\.\(0-9\)$!.0\1!g' | tr -d '.'`
printf "%s\n" "#define Py_SUNOS_VERSION $SUNOS_VERSION" >>confdefs.h
fi
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: \"$MACHDEP\"" >&5
printf "%s\n" "\"$MACHDEP\"" >&6; }
if test "$cross_compiling" = yes; then
case "$host" in
*-*-linux*)
case "$host_cpu" in
arm*)
_host_cpu=arm
_host_ident=arm
;;
*)
_host_cpu=$host_cpu
_host_ident=$host_cpu
esac
;;
*-*-cygwin*)
_host_cpu=
_host_ident=
;;
*-*-vxworks*)
_host_cpu=$host_cpu
_host_ident=$host_cpu
;;
wasm32-*-* | wasm64-*-*)
_host_cpu=$host_cpu
_host_ident=$host_cpu
;;
*)
# for now, limit cross builds to known configurations
MACHDEP="unknown"
as_fn_error $? "cross build not supported for $host" "$LINENO" 5
esac
_PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
_PYTHON_HOST_PLATFORM="$MACHDEP${_host_ident:+-$_host_ident}"
fi
# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
@ -6769,8 +6793,6 @@ case $ac_sys_system in #(
;;
esac
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MULTIARCH" >&5
printf "%s\n" "$MULTIARCH" >&6; }
if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then
if test x$PLATFORM_TRIPLET != x$MULTIARCH; then
@ -6780,6 +6802,14 @@ elif test x$PLATFORM_TRIPLET != x && test x$MULTIARCH = x; then
MULTIARCH=$PLATFORM_TRIPLET
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MULTIARCH" >&5
printf "%s\n" "$MULTIARCH" >&6; }
case $ac_sys_system in #(
*) :
SOABI_PLATFORM=$PLATFORM_TRIPLET
;;
esac
if test x$MULTIARCH != x; then
MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\""
@ -7271,7 +7301,7 @@ fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking LDLIBRARY" >&5
printf %s "checking LDLIBRARY... " >&6; }
# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
# Apple framework builds need more magic. LDLIBRARY is the dynamic
# library that we build, but we do not want to link against it (we
# will find it with a -framework option). For this reason there is an
# extra variable BLDLIBRARY against which Python and the extension
@ -7279,9 +7309,14 @@ printf %s "checking LDLIBRARY... " >&6; }
# LDLIBRARY, but empty for MacOSX framework builds.
if test "$enable_framework"
then
LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
case $ac_sys_system in
Darwin)
LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)';;
*)
as_fn_error $? "Unknown platform for framework build" "$LINENO" 5;;
esac
BLDLIBRARY=''
RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
else
BLDLIBRARY='$(LDLIBRARY)'
fi
@ -7294,64 +7329,64 @@ printf "%s\n" "#define Py_ENABLE_SHARED 1" >>confdefs.h
case $ac_sys_system in
CYGWIN*)
LDLIBRARY='libpython$(LDVERSION).dll.a'
DLLLIBRARY='libpython$(LDVERSION).dll'
;;
LDLIBRARY='libpython$(LDVERSION).dll.a'
DLLLIBRARY='libpython$(LDVERSION).dll'
;;
SunOS*)
LDLIBRARY='libpython$(LDVERSION).so'
BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)'
RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
INSTSONAME="$LDLIBRARY".$SOVERSION
if test "$with_pydebug" != yes
then
PY3LIBRARY=libpython3.so
fi
;;
LDLIBRARY='libpython$(LDVERSION).so'
BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)'
RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
INSTSONAME="$LDLIBRARY".$SOVERSION
if test "$with_pydebug" != yes
then
PY3LIBRARY=libpython3.so
fi
;;
Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*|VxWorks*)
LDLIBRARY='libpython$(LDVERSION).so'
BLDLIBRARY='-L. -lpython$(LDVERSION)'
RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
INSTSONAME="$LDLIBRARY".$SOVERSION
if test "$with_pydebug" != yes
then
PY3LIBRARY=libpython3.so
fi
;;
LDLIBRARY='libpython$(LDVERSION).so'
BLDLIBRARY='-L. -lpython$(LDVERSION)'
RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
INSTSONAME="$LDLIBRARY".$SOVERSION
if test "$with_pydebug" != yes
then
PY3LIBRARY=libpython3.so
fi
;;
hp*|HP*)
case `uname -m` in
ia64)
LDLIBRARY='libpython$(LDVERSION).so'
;;
*)
LDLIBRARY='libpython$(LDVERSION).sl'
;;
esac
BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
;;
case `uname -m` in
ia64)
LDLIBRARY='libpython$(LDVERSION).so'
;;
*)
LDLIBRARY='libpython$(LDVERSION).sl'
;;
esac
BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
;;
Darwin*)
LDLIBRARY='libpython$(LDVERSION).dylib'
BLDLIBRARY='-L. -lpython$(LDVERSION)'
RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
;;
LDLIBRARY='libpython$(LDVERSION).dylib'
BLDLIBRARY='-L. -lpython$(LDVERSION)'
RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
;;
AIX*)
LDLIBRARY='libpython$(LDVERSION).so'
RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
;;
LDLIBRARY='libpython$(LDVERSION).so'
RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
;;
esac
else # shared is disabled
PY_ENABLE_SHARED=0
case $ac_sys_system in
CYGWIN*)
BLDLIBRARY='$(LIBRARY)'
LDLIBRARY='libpython$(LDVERSION).dll.a'
;;
BLDLIBRARY='$(LIBRARY)'
LDLIBRARY='libpython$(LDVERSION).dll.a'
;;
esac
fi
if test "$cross_compiling" = yes; then
RUNSHARED=
RUNSHARED=
fi
@ -23898,7 +23933,7 @@ printf %s "checking ABIFLAGS... " >&6; }
printf "%s\n" "$ABIFLAGS" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking SOABI" >&5
printf %s "checking SOABI... " >&6; }
SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${SOABI_PLATFORM:+-$SOABI_PLATFORM}
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5
printf "%s\n" "$SOABI" >&6; }
@ -23907,7 +23942,7 @@ printf "%s\n" "$SOABI" >&6; }
if test "$Py_DEBUG" = 'true'; then
# Similar to SOABI but remove "d" flag from ABIFLAGS
ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${SOABI_PLATFORM:+-$SOABI_PLATFORM}
printf "%s\n" "#define ALT_SOABI \"${ALT_SOABI}\"" >>confdefs.h