(svn r17703) -Change: [OSX] Rework the configure OSX SDK detection to actually try different SDK versions and use the best SDK for each universal target.

-Change: [OSX] Improve the configure checks for QuickDraw and QuickTime.
pull/155/head
michi_cc 15 years ago
parent e583861798
commit 6db8927ecc

@ -590,6 +590,55 @@ check_params() {
sleep 5 sleep 5
fi fi
if [ "$os" != "OSX" ] && [ "$with_osx_sysroot" != "0" ]; then
if [ "$with_osx_sysroot" = "1" ]; then
with_osx_sysroot="0"
log 1 "checking OSX sysroot... not OSX, skipping"
else
log 1 "configure: error: --with-osx-sysroot only works if OSX is the target"
exit 1
fi
fi
if [ "$with_osx_sysroot" != "0" ]; then
if [ "$enable_universal" = "0" ] && [ "$with_osx_sysroot" != "1" ] && [ "$with_osx_sysroot" != "2" ]; then
# Sysroot manually specified? Check for usability
log 1 "checking OSX sysroot... $with_osx_sysroot"
if ! check_osx_sdk "$with_osx_sysroot"; then
log 1 "Passed sysroot not found/not functional"
exit 1
fi
else
# If autodetect and no universal, use system default
if [ "$with_osx_sysroot" = "1" ] && [ "$enable_universal" = "0" ]; then
log 1 "checking OSX sysroot... no (use system default)"
else
log 1 "checking OSX sysroot... automatically"
detect_osx_sdk
fi
fi
if [ -n "$osx_sdk_path" ]; then
if [ "$enable_universal" != "0" ]; then
if [ -z "$osx_sdk_104_path" ]; then
log 1 "WARNING: Could not find a usable 10.4u SDK, the resulting"
log 1 "WARNING: binary will only run on OSX 10.5 or later"
osx_sdk_104_path="$osx_sdk_path"
fi
OSX_SYSROOT="-isysroot $osx_sdk_104_path"
OSX_LD_SYSROOT="-Wl,-syslibroot,$osx_sdk_104_path"
else
OSX_SYSROOT="-isysroot $osx_sdk_path"
OSX_LD_SYSROOT="-Wl,-syslibroot,$osx_sdk_path"
fi
fi
else
if [ "$os" = "OSX" ]; then
log 1 "checking OSX sysroot... no (use system default)"
fi
fi
detect_allegro detect_allegro
detect_sdl detect_sdl
detect_cocoa detect_cocoa
@ -792,36 +841,6 @@ check_params() {
with_threads="0" with_threads="0"
fi fi
if [ "$os" != "OSX" ] && [ "$with_osx_sysroot" != "0" ]; then
if [ "$with_osx_sysroot" = "1" ]; then
with_osx_sysroot="0"
log 1 "checking OSX sysroot... not OSX, skipping"
else
log 1 "configure: error: --with-osx-sysroot only works if OSX is the target"
exit 1
fi
fi
if [ "$with_osx_sysroot" != "0" ]; then
if [ "$enable_universal" = "0" ] && [ "$with_osx_sysroot" != "1" ] && [ "$with_osx_sysroot" != "2" ]; then
log 1 "checking OSX sysroot... $with_osx_sysroot"
else
# If autodetect and no universal, use system default
if [ "$with_osx_sysroot" = "1" ] && [ "$enable_universal" = "0" ]; then
log 1 "checking OSX sysroot... no (use system default)"
with_osx_sysroot="0"
else
log 1 "checking OSX sysroot... automatically"
with_osx_sysroot="3"
fi
fi
else
if [ "$os" = "OSX" ]; then
log 1 "checking OSX sysroot... no (use system default)"
fi
fi
if [ "$os" != "OSX" ] && [ "$with_application_bundle" != "0" ]; then if [ "$os" != "OSX" ] && [ "$with_application_bundle" != "0" ]; then
if [ "$with_application_bundle" = "1" ]; then if [ "$with_application_bundle" = "1" ]; then
with_application_bundle="0" with_application_bundle="0"
@ -840,7 +859,6 @@ check_params() {
fi fi
if [ "$os" = "OSX" ]; then if [ "$os" = "OSX" ]; then
check_osx_sdk
# Test on G5 # Test on G5
if [ "$enable_osx_g5" != "0" ]; then if [ "$enable_osx_g5" != "0" ]; then
@ -987,8 +1005,6 @@ check_params() {
menu_dir="`echo $menu_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`" menu_dir="`echo $menu_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
fi fi
# "set_universal_binary_flags" needs to be before "detect_iconv"
set_universal_binary_flags
detect_iconv detect_iconv
if [ -n "$personal_dir" ] if [ -n "$personal_dir" ]
@ -1234,12 +1250,18 @@ make_cflags_and_ldflags() {
if [ "$os" = "OSX" ]; then if [ "$os" = "OSX" ]; then
LDFLAGS="$LDFLAGS -framework Cocoa" LDFLAGS="$LDFLAGS -framework Cocoa"
if [ "$enable_dedicated" = "0" ] && [ "$cpu_type" = "32" ]; then if [ "$enable_dedicated" = "0" ] && ([ "$cpu_type" = "32" ] || [ "$enable_universal" != "0" ]); then
LIBS="$LIBS -framework QuickTime" LIBS="$LIBS -framework QuickTime"
else else
CFLAGS="$CFLAGS -DNO_QUICKTIME" CFLAGS="$CFLAGS -DNO_QUICKTIME"
fi fi
if [ "$enable_universal" = "0" ]; then
# Universal builds set this elsewhere
CFLAGS="$OSX_SYSROOT $CFLAGS"
LDFLAGS="$OSX_LD_SYSROOT $LDFLAGS"
fi
if [ "$enable_universal" = "0" ] && [ $cc_version -ge 40 ]; then if [ "$enable_universal" = "0" ] && [ $cc_version -ge 40 ]; then
# Only set the min version when not doing an universal build. # Only set the min version when not doing an universal build.
# Universal builds set the version elsewhere. # Universal builds set the version elsewhere.
@ -1319,7 +1341,7 @@ make_cflags_and_ldflags() {
fi fi
# 64bit machines need -D_SQ64 # 64bit machines need -D_SQ64
if [ "$cpu_type" = "64" ]; then if [ "$cpu_type" = "64" ] && [ "$enable_universal" = "0" ]; then
CFLAGS="$CFLAGS -D_SQ64" CFLAGS="$CFLAGS -D_SQ64"
fi fi
CFLAGS="$CFLAGS -I$SCRIPT_SRC_DIR" CFLAGS="$CFLAGS -I$SCRIPT_SRC_DIR"
@ -1688,27 +1710,24 @@ check_lipo() {
fi fi
} }
set_universal_binary_flags() { check_osx_sdk() {
if [ -z "$osx_target_version" ]; then local sysroot=""
# if we don't speficy a target version then we presume 10.4 if [ -n "$1" ]; then
osx_target_version=10.4 if echo "$1" | grep -q / ; then
fi # Seems to be a file system path
osx_sdk_path="$1"
if [ "$osx_target_version" = "10.4" ]; then else
# Apple added u to 10.4 to show that it's universal osx_sdk_path="/Developer/SDKs/MacOSX$1.sdk"
# There is a version without the u, but it's only in Xcode 2.0 and people should use the free update to 2.5 fi
osx_sysroot_version=10.4u if [ ! -d "$osx_sdk_path" ]; then
else # No directory, not present or garbage
osx_sysroot_version="$osx_target_version" return 1
fi fi
if [ "$with_osx_sysroot" = "3" ]; then # Set minimum version to 10.4 as that's when kCGBitmapByteOrder32Host was introduced
CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX$osx_sysroot_version.sdk" sysroot="-isysroot $osx_sdk_path -Wl,-syslibroot,$osx_sdk_path -mmacosx-version-min=10.4"
LDFLAGS="$LDFLAGS -Wl,-syslibroot,/Developer/SDKs/MacOSX$osx_sysroot_version.sdk"
fi fi
}
check_osx_sdk() {
cat > tmp.osx.mm << EOF cat > tmp.osx.mm << EOF
#include <Cocoa/Cocoa.h> #include <Cocoa/Cocoa.h>
int main() { int main() {
@ -1716,18 +1735,13 @@ int main() {
return 0; return 0;
} }
EOF EOF
execute="$cxx_host $CFLAGS tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1" execute="$cxx_host $sysroot $CFLAGS tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1"
eval $execute > /dev/null eval $execute > /dev/null
ret=$? ret=$?
log 2 "executing $execute" log 2 "executing $execute"
log 2 " exit code $ret" log 2 " exit code $ret"
rm -f tmp.osx.mm tmp.osx rm -f tmp.osx.mm tmp.osx
if [ "$ret" != "0" ]; then return $ret
log 1 "Your system SDK is probably too old"
log 1 "Please install/upgrade your Xcode to >= 2.5"
exit 1
fi
} }
check_direct_music() { check_direct_music() {
@ -2034,6 +2048,39 @@ detect_sdl() {
log 1 "checking SDL... found" log 1 "checking SDL... found"
} }
detect_osx_sdk() {
# Try to find the best SDK available. For a normal build this
# is currently the 10.5 SDK as this is needed to compile all
# optional code. Because such an executable won't run on 10.4
# or lower, also check for the 10.4u SDK when doing an universal
# build.
# Check for the 10.5 SDK, but try 10.6 if that fails
check_osx_sdk "10.5" || check_osx_sdk "10.6" || osx_sdk_path=""
if [ -z "$osx_sdk_path" ] || [ "$enable_universal" != "0" ]; then
# No better SDK or universal build enabled? Check 10.4u SDK as well
local old_sdk="$osx_sdk_path"
if check_osx_sdk "10.4u"; then
osx_sdk_104_path="$osx_sdk_path"
else
osx_sdk_104_path=""
fi
if [ -z "$old_sdk" ]; then
osx_sdk_path="$osx_sdk_104_path"
else
osx_sdk_path="$old_sdk"
fi
fi
if [ -z "$osx_sdk_path" ]; then
log 1 "Your system SDK is probably too old"
log 1 "Please install/upgrade your Xcode to >= 2.5"
exit 1
fi
}
detect_cocoa() { detect_cocoa() {
# 0 means no, 1 is auto-detect, 2 is force # 0 means no, 1 is auto-detect, 2 is force
if [ "$with_cocoa" = "0" ]; then if [ "$with_cocoa" = "0" ]; then
@ -2084,6 +2131,16 @@ detect_cocoa() {
detect_quickdraw() { detect_quickdraw() {
# 0 means no, 1 is auto-detect, 2 is force # 0 means no, 1 is auto-detect, 2 is force
if [ "$enable_cocoa_quickdraw" = "0" ]; then
log 1 "checking Quickdraw window subdriver... disabled"
return 0
fi
# Assume QuickDraw is available when doing an universal build
if [ "$enable_universal" != "0" ]; then
log 1 "checking Quickdraw window subdriver... found"
return 0
fi
# 64 bits doesn't have quickdraw # 64 bits doesn't have quickdraw
if [ "$cpu_type" = "64" ]; then if [ "$cpu_type" = "64" ]; then
@ -2092,20 +2149,12 @@ detect_quickdraw() {
return 0 return 0
fi fi
if [ "$enable_cocoa_quickdraw" = "0" ]; then
log 1 "checking Quickdraw window subdriver... disabled"
return 0
fi
cat > tmp.osx.mm << EOF cat > tmp.osx.mm << EOF
#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_3
#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_3
#include <AvailabilityMacros.h> #include <AvailabilityMacros.h>
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
int main(int argc, char *argv[]) { return 0; } int main(int argc, char *argv[]) { SetEmptyRgn(NULL); return 0; }
EOF EOF
execute="$cxx_host $CFLAGS tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1" execute="$cxx_host $OSX_SYSROOT $OSX_LD_SYSROOT $CFLAGS -mmacosx-version-min=10.3 tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1"
eval $execute > /dev/null eval $execute > /dev/null
ret=$? ret=$?
log 2 "executing $execute" log 2 "executing $execute"
@ -2565,7 +2614,7 @@ int main() {
return iconv(convd, &inbuf, &inlen, &outbuf, &outlen); return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
} }
EOF EOF
execute="$cxx_host $CFLAGS -c tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1" execute="$cxx_host $OSX_SYSROOT $CFLAGS -c tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
eval $execute > /dev/null eval $execute > /dev/null
ret=$? ret=$?
log 2 "executing $execute" log 2 "executing $execute"
@ -2586,7 +2635,7 @@ int main() {
return iconv(convd, &inbuf, &inlen, &outbuf, &outlen); return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
} }
EOF EOF
execute="$cxx_host $CFLAGS tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1" execute="$cxx_host $OSX_SYSROOT $OSX_LD_SYSROOT $CFLAGS tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
eval $execute > /dev/null eval $execute > /dev/null
ret=$? ret=$?
log 2 "executing $execute" log 2 "executing $execute"
@ -2853,6 +2902,14 @@ generate_src_normal() {
generate_src_osx() { generate_src_osx() {
cc_host_orig="$cc_host" cc_host_orig="$cc_host"
cxx_host_orig="$cxx_host" cxx_host_orig="$cxx_host"
CFLAGS_orig="$CFLAGS"
LDFLAGS_orig="$LDFLAGS"
if [ -n "$osx_sdk_104_path" ]; then
# Use 10.4 SDK for 32-bit targets
CFLAGS="-isysroot $osx_sdk_104_path $CFLAGS_orig"
LDFLAGS="-Wl,-syslibroot,$osx_sdk_104_path $LDFLAGS_orig"
fi
BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc" BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc"
cc_host="$cc_host_orig -arch ppc -mmacosx-version-min=10.3" cc_host="$cc_host_orig -arch ppc -mmacosx-version-min=10.3"
@ -2872,6 +2929,10 @@ generate_src_osx() {
if [ "$enable_universal" = "64" ]; then if [ "$enable_universal" = "64" ]; then
# 64 bits is always 10.5 or higher. Furthermore it has a broken ICONV # 64 bits is always 10.5 or higher. Furthermore it has a broken ICONV
# and they also removed support for QuickTime/QuickDraw # and they also removed support for QuickTime/QuickDraw
if [ -n "$osx_sdk_path" ]; then
CFLAGS="-isysroot $osx_sdk_path $CFLAGS_orig"
LDFLAGS="-Wl,-syslibroot,$osx_sdk_path $LDFLAGS_orig"
fi
CFLAGS="$CFLAGS -D_SQ64 -DHAVE_BROKEN_ICONV -DNO_QUICKTIME -UENABLE_COCOA_QUICKDRAW" CFLAGS="$CFLAGS -D_SQ64 -DHAVE_BROKEN_ICONV -DNO_QUICKTIME -UENABLE_COCOA_QUICKDRAW"
LIBS="`echo $LIBS | sed 's/-framework QuickTime//'`" LIBS="`echo $LIBS | sed 's/-framework QuickTime//'`"

Loading…
Cancel
Save