|author||Guy Harris <email@example.com>||2014-10-31 12:11:22 -0700|
|committer||Guy Harris <firstname.lastname@example.org>||2014-10-31 19:16:10 +0000|
For OS X, don't rigidly tie the SDK version to the minimum target version.
According to https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html#//apple_ref/doc/uid/10000163i-CH1-SW1 the deployment target (minimum target OS version) and SDK version aren't necessarily the same and, in fact, Apple typically only ship two SDKs with each Xcode release, so if you want to build for 10.6 with the 10.6 SDK, you have to use a version of Xcode sufficiently old to have the 10.6 SDK. Here, we instead search for the oldest SDK for an OS whose version is greater than or equal to the deployment target. Note that this may not work for X11-based Wireshark, as the X11 libraries can change incompatibly between releases. (Fortunately, our plan is to kick X11-based Wireshark to the curb for OS X, removing a large pile of aggravation for users.) This also requires some fixes when building Qt and gdk-pixbuf, as some cases where we were using the minimum OS target version we needed to be using the SDK version. For CMake, we're using its native "deployment target" support for OS X, and hope that it will somehow do the right thing. Change-Id: Ie8f42c5e4719e7ebdc56b9ba5a330665bee06280 Reviewed-on: https://code.wireshark.org/review/5031 Reviewed-by: Guy Harris <email@example.com>
Diffstat (limited to 'macosx-setup.sh')
1 files changed, 76 insertions, 23 deletions
diff --git a/macosx-setup.sh b/macosx-setup.sh
index 08c50d7530..e042ffd73e 100755
@@ -72,7 +72,7 @@ PKG_CONFIG_VERSION=0.28
# If you don't want to build with GTK+ at all, comment out both lines.
if [ "$GTK_VERSION" ]; then
@@ -452,6 +452,11 @@ do
if [ -d "$i" ]
min_osx_target=`sw_vers -productVersion | sed 's/\([[0-9]]*\).\([[0-9]]*\).[[0-9]]*/\1.\2/'`
+ # That's also the OS whose SDK we'd be using.
@@ -518,32 +523,80 @@ if [ -z "$MAKE_BUILD_OPTS" ] ; then
-# If we have a target release, look for its SDK, and build libraries
-# against it rather than against the headers and, more importantly,
-# libraries that come with the OS, so that we don't end up with
-# support libraries that only work on the OS version on which
-# we built them, not earlier versions of the same release, or
-# earlier releases if the minimum is earlier.
+# If we have a target release, look for the oldest SDK that's for an
+# OS equal to or later than that one, and build libraries against it
+# rather than against the headers and, more importantly, libraries
+# that come with the OS, so that we don't end up with support libraries
+# that only work on the OS version on which we built them, not earlier
+# versions of the same release, or earlier releases if the minimum is
if [ ! -z "$min_osx_target" ]
- for i in /Developer/SDKs \
+ # Get the real version - strip off the "10.".
+ # We'll worry about that if, as, and when there's ever
+ # an OS XI.
+ deploy_real_version=`echo "$min_osx_target" | sed -n 's/10\.\(.*\)/\1/p'`
+ # Search each directory that might contain SDKs.
+ for sdksdir in /Developer/SDKs \
- if [ -d "$i"/"MacOSX$min_osx_target.sdk" ]
+ # Get a list of all the SDKs.
+ if ! test -d "$sdksdir"
+ # There is no directory with that name.
+ # Move on to the next one in the list, if any.
+ # Get a list of all the SDKs in that directory, if any.
+ sdklist=`(cd "$sdksdir"; ls -d MacOSX10.[0-9]*.sdk 2>/dev/null)`
+ for sdk in $sdklist
+ # Get the real version for this SDK.
+ sdk_real_version=`echo "$sdk" | sed -n 's/MacOSX10\.\(.*\)\.sdk/\1/p'`
+ # Is it for the deployment target or some later release?
+ if test "$sdk_real_version" -ge "$deploy_real_version"
+ # Yes, use it.
+ qt_sdk_arg="-sdk $sdk"
+ break 2
- if [ -z "$SDKPATH" ]
+ if [ -z "$sdkpath" ]
- echo "macosx-setup.sh: Couldn't find the SDK for OS X $min_osx_target" 1>&2
+ echo "macosx-setup.sh: Couldn't find an SDK for OS X $min_osx_target or later" 1>&2
+ echo "Using the 10.$sdk_real_version SDK"
# Make sure there are links to /usr/local/include and /usr/local/lib
# in the SDK's usr/local.
@@ -948,7 +1001,7 @@ if [ "$QT_VERSION" -a ! -f qt-$QT_VERSION-done ]; then
# Qt 5.x fails to build on OS X with -no-opengl due to bug
- ./configure -v -sdk macosx$min_osx_target -platform $TARGET_PLATFORM \
+ ./configure -v $qt_sdk_arg -platform $TARGET_PLATFORM \
-opensource -confirm-license -no-c++11 -no-dbus \
-no-sql-sqlite -no-xcb -nomake examples \
-skip qtdoc -skip qtquickcontrols -skip qtwebkit \
@@ -1121,16 +1174,16 @@ if [ "$GTK_VERSION" ]; then
xzcat gdk-pixbuf-$GDK_PIXBUF_VERSION.tar.xz | tar xf - || exit 1
- # If we're building for 10.6, use libpng12; if you have 10.7.5, including
- # X11, and Xcode 4.3.3, the system has libpng15, complete with pkg-config
- # files, as part of X11, but 10.6's X11 has only libpng12, and the 10.6
- # SDK in Xcode 4.3.3 also has only libpng12, and has no pkg-config files
- # of its own, so we have to explicitly set LIBPNG to override the
- # configure script, and also force the CFLAGS to look for the header
- # files for libpng12 (note that -isysroot doesn't affect the arguments
- # to -I, so we need to include the SDK path explicitly).
+ # If we're building using the 10.6 SDK, force the use of libpng12.
+ # The OS's X11, and corresponding SDK, didn't introduce libpng15,
+ # or pkg-config files, until 10.7, so, for 10.6 have to explicitly
+ # set LIBPNG to override the configure script, and also force the
+ # CFLAGS to look for the header files for libpng12 (note that
+ # -isysroot doesn't affect the arguments to -I, so we need to
+ # include the SDK path explicitly).
- if [[ "$min_osx_target" = 10.6 ]]
+ if [[ "$sdk_target" = 10.6 ]]
LIBPNG="-L/usr/X11/lib -lpng12" CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS -I$SDKPATH/usr/X11/include/libpng12" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --without-libtiff --without-libjpeg || exit 1