- [ -z "${OSX_VERSION}" ] && echo "OSX_VERSION not specified, assuming 10.5" && OSX_VERSION=10.5
- SDK="/Developer/SDKs/MacOSX${OSX_VERSION}.sdk"
- if [ ! -d "${SDK}" ]
+ [ -z "${OSX_VERSION}" ] && echo "OSX_VERSION not specified, assuming 10.7" && OSX_VERSION=10.7
+ if test -z "$SDKROOT"
+ then
+ SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
+ echo "SDKROOT not specified, assuming $SDKROOT"
+ fi
+
+ if [ ! -d "${SDKROOT}" ]
+ then
+ SDKROOT_NOT_FOUND=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
+ SDKROOT=`xcode-select -print-path`/SDKs/MacOSX$OSX_VERSION.sdk
+ echo "SDKROOT not found at $SDKROOT_NOT_FOUND, trying $SDKROOT"
+ fi
+
+ if [ ! -d "${SDKROOT}" ]