changeset 13195:518b44df704b draft

(svn r17702) -Change: [OSX] Assure that the minimal OSX version is defined in all cases. -Codechange: [OSX] Improve conditional defines for OS version dependant code.
author michi_cc <michi_cc@openttd.org>
date Sun, 04 Oct 2009 20:53:22 +0000
parents 4b124fd22c06
children c6910d5806a2
files config.lib src/os/macosx/macos.h src/os/macosx/macos.mm src/os/macosx/osx_stdafx.h src/video/cocoa/wnd_quickdraw.mm
diffstat 5 files changed, 26 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/config.lib
+++ b/config.lib
@@ -1240,8 +1240,21 @@
 			CFLAGS="$CFLAGS -DNO_QUICKTIME"
 		fi
 
-		if [ "$cpu_type" = "64" ]; then
-			CFLAGS="$CFLAGS -mmacosx-version-min=10.5"
+		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.
+			if [ "$cpu_type" = "64" ]; then
+				CFLAGS="$CFLAGS -mmacosx-version-min=10.5"
+			else
+				gcc_cpu=`$cc_host -dumpmachine`
+				if [ "`echo $gcc_cpu | cut -c 1-3`" = "ppc" -o "`echo $gcc_cpu | cut -c 1-7`" = "powerpc" ]; then
+					# PowerPC build can run on 10.3
+					CFLAGS="$CFLAGS -mmacosx-version-min=10.3"
+				else
+					# Intel is only available starting from 10.4
+					CFLAGS="$CFLAGS -mmacosx-version-min=10.4"
+				fi
+			fi
 		fi
 	fi
 
@@ -1690,8 +1703,8 @@
 	fi
 
 	if [ "$with_osx_sysroot" = "3" ]; then
-		CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX$osx_sysroot_version.sdk -mmacosx-version-min=$osx_target_version"
-		LDFLAGS="$LDFLAGS -Wl,-syslibroot,/Developer/SDKs/MacOSX$osx_sysroot_version.sdk -mmacosx-version-min=$osx_target_version"
+		CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX$osx_sysroot_version.sdk"
+		LDFLAGS="$LDFLAGS -Wl,-syslibroot,/Developer/SDKs/MacOSX$osx_sysroot_version.sdk"
 	fi
 }
 
--- a/src/os/macosx/macos.h
+++ b/src/os/macosx/macos.h
@@ -25,6 +25,10 @@
 #define MAC_OS_X_VERSION_10_5 1050
 #endif
 
+#ifndef MAC_OS_X_VERSION_10_6
+#define MAC_OS_X_VERSION_10_6 1060
+#endif
+
 
 /*
  * Functions to show the popup window
--- a/src/os/macosx/macos.mm
+++ b/src/os/macosx/macos.mm
@@ -182,21 +182,16 @@
 
 	/* Since Apple introduced encoding to CString in OSX 10.4 we have to make a few conditions
 	 * to get the right code for the used version of OSX. */
-#if (MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_4)
-	/* 10.4 can compile both versions just fine and will select the correct version at runtime based
-	 * on the version of OSX at execution time. */
+#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
 	if (MacOSVersionIsAtLeast(10, 4, 0)) {
 		[ preferredLang getCString:retbuf maxLength:32 encoding:NSASCIIStringEncoding ];
 	} else
 #endif
 	{
-		[ preferredLang getCString:retbuf maxLength:32
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
-		/* If 10.5+ is used to compile then encoding is needed here.
-		 * If 10.3 or 10.4 is used for compiling then this line is used by 10.3 and encoding should not be present here. */
-		encoding:NSASCIIStringEncoding
+#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4)
+		/* maxLength does not include the \0 char in contrast to the call above. */
+		[ preferredLang getCString:retbuf maxLength:31 ];
 #endif
-		];
 	}
 	return retbuf;
 }
--- a/src/os/macosx/osx_stdafx.h
+++ b/src/os/macosx/osx_stdafx.h
@@ -30,7 +30,6 @@
 #	error "Compiling 64 bits without _SQ64 set! (or vice versa)"
 #endif
 
-#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_3
 #include <AvailabilityMacros.h>
 
 /* Name conflict */
--- a/src/video/cocoa/wnd_quickdraw.mm
+++ b/src/video/cocoa/wnd_quickdraw.mm
@@ -16,7 +16,7 @@
 #ifdef WITH_COCOA
 #ifdef ENABLE_COCOA_QUICKDRAW
 
-#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 "../../stdafx.h"
 
 #define Rect  OTTDRect