# PIC is probably what we want when building shared libs
enabled shared && soft_enable pic
- # Handle darwin variants
+ # Handle darwin variants. Newer SDKs allow targeting older
+ # platforms, so find the newest SDK available.
+ if [ -d "/Developer/SDKs/MacOSX10.4u.sdk" ]; then
+ osx_sdk_dir="/Developer/SDKs/MacOSX10.4u.sdk"
+ fi
+ if [ -d "/Developer/SDKs/MacOSX10.5.sdk" ]; then
+ osx_sdk_dir="/Developer/SDKs/MacOSX10.5.sdk"
+ fi
+ if [ -d "/Developer/SDKs/MacOSX10.6.sdk" ]; then
+ osx_sdk_dir="/Developer/SDKs/MacOSX10.6.sdk"
+ fi
+
case ${toolchain} in
*-darwin8-*)
- add_cflags "-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
+ add_cflags "-isysroot ${osx_sdk_dir}"
add_cflags "-mmacosx-version-min=10.4"
- add_ldflags "-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
+ add_ldflags "-isysroot ${osx_sdk_dir}"
add_ldflags "-mmacosx-version-min=10.4"
;;
*-darwin9-*)
- add_cflags "-isysroot /Developer/SDKs/MacOSX10.5.sdk"
+ add_cflags "-isysroot ${osx_sdk_dir}"
add_cflags "-mmacosx-version-min=10.5"
- add_ldflags "-isysroot /Developer/SDKs/MacOSX10.5.sdk"
+ add_ldflags "-isysroot ${osx_sdk_dir}"
add_ldflags "-mmacosx-version-min=10.5"
;;
*-darwin10-*)
- add_cflags "-isysroot /Developer/SDKs/MacOSX10.6.sdk"
+ add_cflags "-isysroot ${osx_sdk_dir}"
add_cflags "-mmacosx-version-min=10.6"
- add_ldflags "-isysroot /Developer/SDKs/MacOSX10.6.sdk"
+ add_ldflags "-isysroot ${osx_sdk_dir}"
add_ldflags "-mmacosx-version-min=10.6"
;;
esac