2009-02-23 20:39:06 +08:00
|
|
|
#!/bin/bash
|
2010-02-15 03:40:18 +08:00
|
|
|
# This script performs all of the steps needed to build a
|
2009-02-23 20:39:06 +08:00
|
|
|
# universal binary libcurl.framework for Mac OS X 10.4 or greater.
|
2010-09-21 06:07:45 +08:00
|
|
|
#
|
|
|
|
# Hendrik Visage:
|
|
|
|
# Generalizations added since Snowleopard (10.6) do not include
|
|
|
|
# the 10.4u SDK.
|
|
|
|
#
|
|
|
|
# Also note:
|
|
|
|
# 10.5 is the *ONLY* SDK that support PPC64 :( -- 10.6 do not have ppc64 support
|
|
|
|
#If you need to have PPC64 support then change below to 1
|
|
|
|
PPC64_NEEDED=0
|
2013-02-18 05:30:38 +08:00
|
|
|
# Apple does not support building for PPC anymore in Xcode 4 and later.
|
|
|
|
# If you're using Xcode 3 or earlier and need PPC support, then change
|
|
|
|
# the setting below to 1
|
|
|
|
PPC_NEEDED=0
|
2010-09-21 06:07:45 +08:00
|
|
|
|
|
|
|
# For me the default is to develop for the platform I am on, and if you
|
|
|
|
#desire compatibility with older versions then change USE_OLD to 1 :)
|
|
|
|
USE_OLD=0
|
2009-02-23 20:39:06 +08:00
|
|
|
|
|
|
|
VERSION=`/usr/bin/sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' include/curl/curlver.h`
|
2010-09-21 06:07:45 +08:00
|
|
|
FRAMEWORK_VERSION=Versions/Release-$VERSION
|
|
|
|
|
|
|
|
#I also wanted to "copy over" the system, and thus the reason I added the
|
|
|
|
# version to Versions/Release-7.20.1 etc.
|
|
|
|
# now a simple rsync -vaP libcurl.framework /Library/Frameworks will install it
|
|
|
|
# and setup the right paths to this version, leaving the system version
|
|
|
|
# "intact", so you can "fix" it later with the links to Versions/A/...
|
|
|
|
|
2013-02-18 05:30:38 +08:00
|
|
|
DEVELOPER_PATH=`xcode-select --print-path`
|
|
|
|
# Around Xcode 4.3, SDKs were moved from the Developer folder into the
|
|
|
|
# MacOSX.platform folder
|
|
|
|
if test -d "$DEVELOPER_PATH/Platforms/MacOSX.platform/Developer/SDKs"; then
|
|
|
|
SDK_PATH="$DEVELOPER_PATH/Platforms/MacOSX.platform/Developer/SDKs"
|
|
|
|
else
|
|
|
|
SDK_PATH="$DEVELOPER_PATH/SDKs";
|
|
|
|
fi
|
|
|
|
OLD_SDK=`ls $SDK_PATH|head -1`
|
|
|
|
NEW_SDK=`ls -r $SDK_PATH|head -1`
|
2010-09-21 06:07:45 +08:00
|
|
|
|
|
|
|
if test "0"$USE_OLD -gt 0
|
|
|
|
then
|
|
|
|
SDK32=$OLD_SDK
|
|
|
|
else
|
|
|
|
SDK32=$NEW_SDK
|
|
|
|
fi
|
2009-02-23 20:39:06 +08:00
|
|
|
|
2010-09-21 06:07:45 +08:00
|
|
|
MACVER=`echo $SDK32|sed -e s/[a-zA-Z]//g -e s/.\$//`
|
2009-02-23 20:39:06 +08:00
|
|
|
|
2013-02-18 05:30:38 +08:00
|
|
|
SDK32_DIR=$SDK_PATH/$SDK32
|
2010-09-21 06:07:45 +08:00
|
|
|
MINVER32='-mmacosx-version-min='$MACVER
|
2013-02-18 05:30:38 +08:00
|
|
|
if test $PPC_NEEDED -gt 0; then
|
|
|
|
ARCHES32='-arch i386 -arch ppc'
|
|
|
|
else
|
|
|
|
ARCHES32='-arch i386'
|
|
|
|
fi
|
2009-02-23 20:39:06 +08:00
|
|
|
|
2010-09-21 06:07:45 +08:00
|
|
|
if test $PPC64_NEEDED -gt 0
|
|
|
|
then
|
|
|
|
SDK64=10.5
|
|
|
|
ARCHES64='-arch x86_64 -arch ppc64'
|
2013-02-18 05:30:38 +08:00
|
|
|
SDK64=`ls $SDK_PATH|grep 10.5|head -1`
|
2010-09-21 06:07:45 +08:00
|
|
|
else
|
|
|
|
ARCHES64='-arch x86_64'
|
|
|
|
#We "know" that 10.4 and earlier do not support 64bit
|
2013-02-18 05:30:38 +08:00
|
|
|
OLD_SDK64=`ls $SDK_PATH|egrep -v "10.[0-4]"|head -1`
|
|
|
|
NEW_SDK64=`ls -r $SDK_PATH|egrep -v "10.[0-4]"|head -1`
|
2010-09-21 06:07:45 +08:00
|
|
|
if test $USE_OLD -gt 0
|
|
|
|
then
|
|
|
|
SDK64=$OLD_SDK64
|
|
|
|
else
|
|
|
|
SDK64=$NEW_SDK64
|
|
|
|
fi
|
|
|
|
fi
|
2009-02-23 20:39:06 +08:00
|
|
|
|
2013-02-18 05:30:38 +08:00
|
|
|
SDK64_DIR=$SDK_PATH/$SDK64
|
2010-09-21 06:07:45 +08:00
|
|
|
MACVER64=`echo $SDK64|sed -e s/[a-zA-Z]//g -e s/.\$//`
|
2009-02-23 20:39:06 +08:00
|
|
|
|
2010-09-21 06:07:45 +08:00
|
|
|
MINVER64='-mmacosx-version-min='$MACVER64
|
2009-04-10 10:50:21 +08:00
|
|
|
|
2010-09-21 06:07:45 +08:00
|
|
|
if test ! -z $SDK32; then
|
2009-04-10 10:50:21 +08:00
|
|
|
echo "----Configuring libcurl for 32 bit universal framework..."
|
2010-09-21 06:07:45 +08:00
|
|
|
make clean
|
2013-02-18 05:30:38 +08:00
|
|
|
./configure --disable-dependency-tracking --disable-static --with-gssapi --with-darwinssl \
|
|
|
|
CFLAGS="-Os -isysroot $SDK32_DIR $ARCHES32" \
|
|
|
|
LDFLAGS="-Wl,-syslibroot,$SDK32_DIR $ARCHES32 -Wl,-headerpad_max_install_names" \
|
2009-04-10 10:50:21 +08:00
|
|
|
CC=$CC
|
2010-02-15 03:40:18 +08:00
|
|
|
|
2009-04-10 10:50:21 +08:00
|
|
|
echo "----Building 32 bit libcurl..."
|
2013-02-18 05:30:38 +08:00
|
|
|
make -j `sysctl -n hw.logicalcpu_max`
|
2010-02-15 03:40:18 +08:00
|
|
|
|
2009-04-10 10:50:21 +08:00
|
|
|
echo "----Creating 32 bit framework..."
|
2009-02-23 20:39:06 +08:00
|
|
|
rm -r libcurl.framework
|
2010-09-21 06:07:45 +08:00
|
|
|
mkdir -p libcurl.framework/${FRAMEWORK_VERSION}/Resources
|
|
|
|
cp lib/.libs/libcurl.dylib libcurl.framework/${FRAMEWORK_VERSION}/libcurl
|
|
|
|
install_name_tool -id @executable_path/../Frameworks/libcurl.framework/${FRAMEWORK_VERSION}/libcurl libcurl.framework/${FRAMEWORK_VERSION}/libcurl
|
|
|
|
/usr/bin/sed -e "s/7\.12\.3/$VERSION/" lib/libcurl.plist >libcurl.framework/${FRAMEWORK_VERSION}/Resources/Info.plist
|
|
|
|
mkdir -p libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl
|
|
|
|
cp include/curl/*.h libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl
|
2009-04-10 10:50:21 +08:00
|
|
|
pushd libcurl.framework
|
2010-09-21 06:07:45 +08:00
|
|
|
ln -fs ${FRAMEWORK_VERSION}/libcurl libcurl
|
|
|
|
ln -fs ${FRAMEWORK_VERSION}/Resources Resources
|
|
|
|
ln -fs ${FRAMEWORK_VERSION}/Headers Headers
|
2009-02-23 20:39:06 +08:00
|
|
|
cd Versions
|
2013-05-09 23:31:56 +08:00
|
|
|
ln -fs $(basename "${FRAMEWORK_VERSION}") Current
|
2010-02-15 03:40:18 +08:00
|
|
|
|
2013-02-18 05:30:38 +08:00
|
|
|
echo Testing for SDK64
|
2010-09-21 06:07:45 +08:00
|
|
|
if test -d $SDK64_DIR; then
|
|
|
|
echo entering...
|
2009-04-10 10:50:21 +08:00
|
|
|
popd
|
|
|
|
make clean
|
|
|
|
echo "----Configuring libcurl for 64 bit universal framework..."
|
2013-02-18 05:30:38 +08:00
|
|
|
./configure --disable-dependency-tracking --disable-static --with-gssapi --with-darwinssl \
|
|
|
|
CFLAGS="-Os -isysroot $SDK64_DIR $ARCHES64" \
|
|
|
|
LDFLAGS="-Wl,-syslibroot,$SDK64_DIR $ARCHES64 -Wl,-headerpad_max_install_names" \
|
2009-04-10 10:50:21 +08:00
|
|
|
CC=$CC
|
2010-02-15 03:40:18 +08:00
|
|
|
|
2009-04-10 10:50:21 +08:00
|
|
|
echo "----Building 64 bit libcurl..."
|
2013-02-18 05:30:38 +08:00
|
|
|
make -j `sysctl -n hw.logicalcpu_max`
|
2010-02-15 03:40:18 +08:00
|
|
|
|
2009-04-10 10:50:21 +08:00
|
|
|
echo "----Appending 64 bit framework to 32 bit framework..."
|
2010-09-21 06:07:45 +08:00
|
|
|
cp lib/.libs/libcurl.dylib libcurl.framework/${FRAMEWORK_VERSION}/libcurl64
|
|
|
|
install_name_tool -id @executable_path/../Frameworks/libcurl.framework/${FRAMEWORK_VERSION}/libcurl libcurl.framework/${FRAMEWORK_VERSION}/libcurl64
|
|
|
|
cp libcurl.framework/${FRAMEWORK_VERSION}/libcurl libcurl.framework/${FRAMEWORK_VERSION}/libcurl32
|
|
|
|
pwd
|
|
|
|
lipo libcurl.framework/${FRAMEWORK_VERSION}/libcurl32 libcurl.framework/${FRAMEWORK_VERSION}/libcurl64 -create -output libcurl.framework/${FRAMEWORK_VERSION}/libcurl
|
|
|
|
rm libcurl.framework/${FRAMEWORK_VERSION}/libcurl32 libcurl.framework/${FRAMEWORK_VERSION}/libcurl64
|
|
|
|
cp libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl/curlbuild.h libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl/curlbuild32.h
|
|
|
|
cp include/curl/curlbuild.h libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl/curlbuild64.h
|
|
|
|
cat >libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl/curlbuild.h <<EOF
|
2009-04-10 10:50:21 +08:00
|
|
|
#ifdef __LP64__
|
|
|
|
#include "curl/curlbuild64.h"
|
|
|
|
#else
|
|
|
|
#include "curl/curlbuild32.h"
|
|
|
|
#endif
|
|
|
|
EOF
|
|
|
|
fi
|
2010-02-15 03:40:18 +08:00
|
|
|
|
2010-09-21 06:07:45 +08:00
|
|
|
pwd
|
|
|
|
lipo -info libcurl.framework/${FRAMEWORK_VERSION}/libcurl
|
2009-02-23 20:39:06 +08:00
|
|
|
echo "libcurl.framework is built and can now be included in other projects."
|
2009-04-10 10:50:21 +08:00
|
|
|
echo "Copy libcurl.framework to your bundle's Contents/Frameworks folder, ~/Library/Frameworks or /Library/Frameworks."
|
2009-02-23 20:39:06 +08:00
|
|
|
else
|
2010-09-21 06:07:45 +08:00
|
|
|
echo "Building libcurl.framework requires Mac OS X 10.4 or later with the MacOSX10.4/5/6 SDK installed."
|
2009-02-23 20:39:06 +08:00
|
|
|
fi
|