1#!/bin/bash 2#*************************************************************************** 3# _ _ ____ _ 4# Project ___| | | | _ \| | 5# / __| | | | |_) | | 6# | (__| |_| | _ <| |___ 7# \___|\___/|_| \_\_____| 8# 9# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. 10# 11# This software is licensed as described in the file COPYING, which 12# you should have received as part of this distribution. The terms 13# are also available at https://curl.haxx.se/docs/copyright.html. 14# 15# You may opt to use, copy, modify, merge, publish, distribute and/or sell 16# copies of the Software, and permit persons to whom the Software is 17# furnished to do so, under the terms of the COPYING file. 18# 19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 20# KIND, either express or implied. 21# 22########################################################################### 23# This script performs all of the steps needed to build a 24# universal binary libcurl.framework for Mac OS X 10.4 or greater. 25# 26# Hendrik Visage: 27# Generalizations added since Snowleopard (10.6) do not include 28# the 10.4u SDK. 29# 30# Also note: 31# 10.5 is the *ONLY* SDK that support PPC64 :( -- 10.6 do not have ppc64 support 32#If you need to have PPC64 support then change below to 1 33PPC64_NEEDED=0 34# Apple does not support building for PPC anymore in Xcode 4 and later. 35# If you're using Xcode 3 or earlier and need PPC support, then change 36# the setting below to 1 37PPC_NEEDED=0 38 39# For me the default is to develop for the platform I am on, and if you 40#desire compatibility with older versions then change USE_OLD to 1 :) 41USE_OLD=0 42 43VERSION=`/usr/bin/sed -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' include/curl/curlver.h` 44FRAMEWORK_VERSION=Versions/Release-$VERSION 45 46#I also wanted to "copy over" the system, and thus the reason I added the 47# version to Versions/Release-7.20.1 etc. 48# now a simple rsync -vaP libcurl.framework /Library/Frameworks will install it 49# and setup the right paths to this version, leaving the system version 50# "intact", so you can "fix" it later with the links to Versions/A/... 51 52DEVELOPER_PATH=`xcode-select --print-path` 53# Around Xcode 4.3, SDKs were moved from the Developer folder into the 54# MacOSX.platform folder 55if test -d "$DEVELOPER_PATH/Platforms/MacOSX.platform/Developer/SDKs"; then 56 SDK_PATH="$DEVELOPER_PATH/Platforms/MacOSX.platform/Developer/SDKs" 57else 58 SDK_PATH="$DEVELOPER_PATH/SDKs"; 59fi 60OLD_SDK=`ls $SDK_PATH|head -1` 61NEW_SDK=`ls -r $SDK_PATH|head -1` 62 63if test "0"$USE_OLD -gt 0 64then 65 SDK32=$OLD_SDK 66else 67 SDK32=$NEW_SDK 68fi 69 70MACVER=`echo $SDK32|sed -e s/[a-zA-Z]//g -e s/.\$//` 71 72SDK32_DIR=$SDK_PATH/$SDK32 73MINVER32='-mmacosx-version-min='$MACVER 74if test $PPC_NEEDED -gt 0; then 75 ARCHES32='-arch i386 -arch ppc' 76else 77 ARCHES32='-arch i386' 78fi 79 80if test $PPC64_NEEDED -gt 0 81then 82 SDK64=10.5 83 ARCHES64='-arch x86_64 -arch ppc64' 84 SDK64=`ls $SDK_PATH|grep 10.5|head -1` 85else 86 ARCHES64='-arch x86_64' 87 #We "know" that 10.4 and earlier do not support 64bit 88 OLD_SDK64=`ls $SDK_PATH|egrep -v "10.[0-4]"|head -1` 89 NEW_SDK64=`ls -r $SDK_PATH|egrep -v "10.[0-4][^0-9]" | head -1` 90 if test $USE_OLD -gt 0 91 then 92 SDK64=$OLD_SDK64 93 else 94 SDK64=$NEW_SDK64 95 fi 96fi 97 98SDK64_DIR=$SDK_PATH/$SDK64 99MACVER64=`echo $SDK64|sed -e s/[a-zA-Z]//g -e s/.\$//` 100 101MINVER64='-mmacosx-version-min='$MACVER64 102 103if test ! -z $SDK32; then 104 echo "----Configuring libcurl for 32 bit universal framework..." 105 make clean 106 ./configure --disable-dependency-tracking --disable-static --with-gssapi --with-secure-transport \ 107 CFLAGS="-Os -isysroot $SDK32_DIR $ARCHES32" \ 108 LDFLAGS="-Wl,-syslibroot,$SDK32_DIR $ARCHES32 -Wl,-headerpad_max_install_names" \ 109 CC=$CC 110 111 echo "----Building 32 bit libcurl..." 112 make -j `sysctl -n hw.logicalcpu_max` 113 114 echo "----Creating 32 bit framework..." 115 rm -r libcurl.framework 116 mkdir -p libcurl.framework/${FRAMEWORK_VERSION}/Resources 117 cp lib/.libs/libcurl.dylib libcurl.framework/${FRAMEWORK_VERSION}/libcurl 118 install_name_tool -id @rpath/libcurl.framework/${FRAMEWORK_VERSION}/libcurl libcurl.framework/${FRAMEWORK_VERSION}/libcurl 119 /usr/bin/sed -e "s/7\.12\.3/$VERSION/" lib/libcurl.plist >libcurl.framework/${FRAMEWORK_VERSION}/Resources/Info.plist 120 mkdir -p libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl 121 cp include/curl/*.h libcurl.framework/${FRAMEWORK_VERSION}/Headers/curl 122 pushd libcurl.framework 123 ln -fs ${FRAMEWORK_VERSION}/libcurl libcurl 124 ln -fs ${FRAMEWORK_VERSION}/Resources Resources 125 ln -fs ${FRAMEWORK_VERSION}/Headers Headers 126 cd Versions 127 ln -fs $(basename "${FRAMEWORK_VERSION}") Current 128 129 echo Testing for SDK64 130 if test -d $SDK64_DIR; then 131 echo entering... 132 popd 133 make clean 134 echo "----Configuring libcurl for 64 bit universal framework..." 135 ./configure --disable-dependency-tracking --disable-static --with-gssapi --with-secure-transport \ 136 CFLAGS="-Os -isysroot $SDK64_DIR $ARCHES64" \ 137 LDFLAGS="-Wl,-syslibroot,$SDK64_DIR $ARCHES64 -Wl,-headerpad_max_install_names" \ 138 CC=$CC 139 140 echo "----Building 64 bit libcurl..." 141 make -j `sysctl -n hw.logicalcpu_max` 142 143 echo "----Appending 64 bit framework to 32 bit framework..." 144 cp lib/.libs/libcurl.dylib libcurl.framework/${FRAMEWORK_VERSION}/libcurl64 145 install_name_tool -id @rpath/libcurl.framework/${FRAMEWORK_VERSION}/libcurl libcurl.framework/${FRAMEWORK_VERSION}/libcurl64 146 cp libcurl.framework/${FRAMEWORK_VERSION}/libcurl libcurl.framework/${FRAMEWORK_VERSION}/libcurl32 147 pwd 148 lipo libcurl.framework/${FRAMEWORK_VERSION}/libcurl32 libcurl.framework/${FRAMEWORK_VERSION}/libcurl64 -create -output libcurl.framework/${FRAMEWORK_VERSION}/libcurl 149 rm libcurl.framework/${FRAMEWORK_VERSION}/libcurl32 libcurl.framework/${FRAMEWORK_VERSION}/libcurl64 150 fi 151 152 pwd 153 lipo -info libcurl.framework/${FRAMEWORK_VERSION}/libcurl 154 echo "libcurl.framework is built and can now be included in other projects." 155 echo "Copy libcurl.framework to your bundle's Contents/Frameworks folder, ~/Library/Frameworks or /Library/Frameworks." 156else 157 echo "Building libcurl.framework requires Mac OS X 10.4 or later with the MacOSX10.4/5/6 SDK installed." 158fi 159