summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2009-10-04 20:53:26 +0000
committermichi_cc <michi_cc@openttd.org>2009-10-04 20:53:26 +0000
commit48106b817aa83b9b265e52c3379cc416ca09b2bb (patch)
treeaa013a8e63a15987476b107c5c3f39e77c089e7f
parent10ca710e9883661566ad436d2747044081a5bb5b (diff)
downloadopenttd-48106b817aa83b9b265e52c3379cc416ca09b2bb.tar.xz
(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.
-rw-r--r--config.lib205
1 files changed, 133 insertions, 72 deletions
diff --git a/config.lib b/config.lib
index e3ef9e3cf..8087e6b00 100644
--- a/config.lib
+++ b/config.lib
@@ -590,6 +590,55 @@ check_params() {
sleep 5
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_sdl
detect_cocoa
@@ -792,36 +841,6 @@ check_params() {
with_threads="0"
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 [ "$with_application_bundle" = "1" ]; then
with_application_bundle="0"
@@ -840,7 +859,6 @@ check_params() {
fi
if [ "$os" = "OSX" ]; then
- check_osx_sdk
# Test on G5
if [ "$enable_osx_g5" != "0" ]; then
@@ -987,8 +1005,6 @@ check_params() {
menu_dir="`echo $menu_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
fi
- # "set_universal_binary_flags" needs to be before "detect_iconv"
- set_universal_binary_flags
detect_iconv
if [ -n "$personal_dir" ]
@@ -1234,12 +1250,18 @@ make_cflags_and_ldflags() {
if [ "$os" = "OSX" ]; then
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"
else
CFLAGS="$CFLAGS -DNO_QUICKTIME"
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
# Only set the min version when not doing an universal build.
# Universal builds set the version elsewhere.
@@ -1319,7 +1341,7 @@ make_cflags_and_ldflags() {
fi
# 64bit machines need -D_SQ64
- if [ "$cpu_type" = "64" ]; then
+ if [ "$cpu_type" = "64" ] && [ "$enable_universal" = "0" ]; then
CFLAGS="$CFLAGS -D_SQ64"
fi
CFLAGS="$CFLAGS -I$SCRIPT_SRC_DIR"
@@ -1688,27 +1710,24 @@ check_lipo() {
fi
}
-set_universal_binary_flags() {
- if [ -z "$osx_target_version" ]; then
- # if we don't speficy a target version then we presume 10.4
- osx_target_version=10.4
- fi
-
- if [ "$osx_target_version" = "10.4" ]; then
- # Apple added u to 10.4 to show that it's universal
- # 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
- osx_sysroot_version=10.4u
- else
- osx_sysroot_version="$osx_target_version"
- fi
+check_osx_sdk() {
+ local sysroot=""
+ if [ -n "$1" ]; then
+ if echo "$1" | grep -q / ; then
+ # Seems to be a file system path
+ osx_sdk_path="$1"
+ else
+ osx_sdk_path="/Developer/SDKs/MacOSX$1.sdk"
+ fi
+ if [ ! -d "$osx_sdk_path" ]; then
+ # No directory, not present or garbage
+ return 1
+ fi
- if [ "$with_osx_sysroot" = "3" ]; then
- CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX$osx_sysroot_version.sdk"
- LDFLAGS="$LDFLAGS -Wl,-syslibroot,/Developer/SDKs/MacOSX$osx_sysroot_version.sdk"
+ # Set minimum version to 10.4 as that's when kCGBitmapByteOrder32Host was introduced
+ sysroot="-isysroot $osx_sdk_path -Wl,-syslibroot,$osx_sdk_path -mmacosx-version-min=10.4"
fi
-}
-check_osx_sdk() {
cat > tmp.osx.mm << EOF
#include <Cocoa/Cocoa.h>
int main() {
@@ -1716,18 +1735,13 @@ int main() {
return 0;
}
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
ret=$?
log 2 "executing $execute"
log 2 " exit code $ret"
rm -f tmp.osx.mm tmp.osx
- if [ "$ret" != "0" ]; then
- log 1 "Your system SDK is probably too old"
- log 1 "Please install/upgrade your Xcode to >= 2.5"
-
- exit 1
- fi
+ return $ret
}
check_direct_music() {
@@ -2034,6 +2048,39 @@ detect_sdl() {
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() {
# 0 means no, 1 is auto-detect, 2 is force
if [ "$with_cocoa" = "0" ]; then
@@ -2084,6 +2131,16 @@ detect_cocoa() {
detect_quickdraw() {
# 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
if [ "$cpu_type" = "64" ]; then
@@ -2092,20 +2149,12 @@ detect_quickdraw() {
return 0
fi
- if [ "$enable_cocoa_quickdraw" = "0" ]; then
- log 1 "checking Quickdraw window subdriver... disabled"
-
- return 0
- fi
-
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>
#import <Cocoa/Cocoa.h>
-int main(int argc, char *argv[]) { return 0; }
+int main(int argc, char *argv[]) { SetEmptyRgn(NULL); return 0; }
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
ret=$?
log 2 "executing $execute"
@@ -2565,7 +2614,7 @@ int main() {
return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
}
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
ret=$?
log 2 "executing $execute"
@@ -2586,7 +2635,7 @@ int main() {
return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
}
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
ret=$?
log 2 "executing $execute"
@@ -2853,6 +2902,14 @@ generate_src_normal() {
generate_src_osx() {
cc_host_orig="$cc_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"
cc_host="$cc_host_orig -arch ppc -mmacosx-version-min=10.3"
@@ -2872,6 +2929,10 @@ generate_src_osx() {
if [ "$enable_universal" = "64" ]; then
# 64 bits is always 10.5 or higher. Furthermore it has a broken ICONV
# 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"
LIBS="`echo $LIBS | sed 's/-framework QuickTime//'`"