build-mac/build_libcurl_dist.sh
changeset 531 a7cc26cc39f2
child 1513 e7f7e42385b5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build-mac/build_libcurl_dist.sh	Wed Apr 20 15:40:00 2016 +0200
     1.3 @@ -0,0 +1,62 @@
     1.4 +#!/bin/bash
     1.5 +
     1.6 +export DEVROOT=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
     1.7 +DFT_DIST_DIR=../libcurl-ios-dist
     1.8 +DIST_DIR=${DIST_DIR:-$DFT_DIST_DIR}
     1.9 +
    1.10 +function check_curl_ver() {
    1.11 +echo "#include \"include/curl/curlver.h\"
    1.12 +#if LIBCURL_VERSION_MAJOR < 7 || LIBCURL_VERSION_MINOR < 40
    1.13 +#error Required curl 7.40.0+; See http://curl.haxx.se/docs/adv_20150108A.html
    1.14 +#endif"|gcc -c -o /dev/null -xc -||exit 9
    1.15 +}
    1.16 +
    1.17 +function build_for_arch() {
    1.18 +  ARCH=$1
    1.19 +  HOST=$2
    1.20 +  SYSROOT=$3
    1.21 +  PREFIX=$4
    1.22 +  IPHONEOS_DEPLOYMENT_TARGET="6.0"
    1.23 +  export PATH="${DEVROOT}/usr/bin/:${PATH}"
    1.24 +  export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${SYSROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -fembed-bitcode"
    1.25 +  export LDFLAGS="-arch ${ARCH} -isysroot ${SYSROOT}"
    1.26 +  ./configure --disable-shared --enable-static ${SSL_FLAG} --host="${HOST}" --prefix=${PREFIX} && make -j8 && make install
    1.27 +}
    1.28 +
    1.29 +if [ "$1" == "openssl" ]
    1.30 +then
    1.31 +  if [ ! -d ${HOME}/Desktop/openssl-ios-dist ]
    1.32 +  then
    1.33 +    echo "Please use https://github.com/sinofool/build-openssl-ios/ to build OpenSSL for iOS first"
    1.34 +    exit 8
    1.35 +  fi
    1.36 +  export SSL_FLAG=--with-ssl=${HOME}/Desktop/openssl-ios-dist
    1.37 +else
    1.38 +  check_curl_ver
    1.39 +  export SSL_FLAG=--with-darwinssl
    1.40 +fi
    1.41 +
    1.42 +TMP_DIR=/tmp/build_libcurl_$$
    1.43 +
    1.44 +build_for_arch i386 i386-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ${TMP_DIR}/i386 || exit 1
    1.45 +build_for_arch x86_64 x86_64-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ${TMP_DIR}/x86_64 || exit 2
    1.46 +build_for_arch arm64 arm-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/arm64 || exit 3
    1.47 +build_for_arch armv7s armv7s-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/armv7s || exit 4
    1.48 +build_for_arch armv7 armv7-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/armv7 || exit 5
    1.49 +
    1.50 +mkdir -p ${TMP_DIR}/lib/
    1.51 +${DEVROOT}/usr/bin/lipo \
    1.52 +	-arch i386 ${TMP_DIR}/i386/lib/libcurl.a \
    1.53 +	-arch x86_64 ${TMP_DIR}/x86_64/lib/libcurl.a \
    1.54 +	-arch armv7 ${TMP_DIR}/armv7/lib/libcurl.a \
    1.55 +	-arch armv7s ${TMP_DIR}/armv7s/lib/libcurl.a \
    1.56 +	-arch arm64 ${TMP_DIR}/arm64/lib/libcurl.a \
    1.57 +	-output ${TMP_DIR}/lib/libcurl.a -create
    1.58 +
    1.59 +cp -r ${TMP_DIR}/armv7s/include ${TMP_DIR}/
    1.60 +curl -O https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/patch-include.patch
    1.61 +patch ${TMP_DIR}/include/curl/curlbuild.h < patch-include.patch
    1.62 +
    1.63 +mkdir -p ${DIST_DIR}
    1.64 +cp -r ${TMP_DIR}/include ${TMP_DIR}/lib ${DIST_DIR}
    1.65 +