build-mac/build_libcurl_dist.sh
author Krista Grothoff <krista@pep-project.org>
Wed, 23 Nov 2016 15:38:27 +0100
branchENGINE-74
changeset 1428 aefb57561f8e
parent 531 a7cc26cc39f2
child 1513 e7f7e42385b5
permissions -rw-r--r--
Merged in default
dirk@531
     1
#!/bin/bash
dirk@531
     2
dirk@531
     3
export DEVROOT=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
dirk@531
     4
DFT_DIST_DIR=../libcurl-ios-dist
dirk@531
     5
DIST_DIR=${DIST_DIR:-$DFT_DIST_DIR}
dirk@531
     6
dirk@531
     7
function check_curl_ver() {
dirk@531
     8
echo "#include \"include/curl/curlver.h\"
dirk@531
     9
#if LIBCURL_VERSION_MAJOR < 7 || LIBCURL_VERSION_MINOR < 40
dirk@531
    10
#error Required curl 7.40.0+; See http://curl.haxx.se/docs/adv_20150108A.html
dirk@531
    11
#endif"|gcc -c -o /dev/null -xc -||exit 9
dirk@531
    12
}
dirk@531
    13
dirk@531
    14
function build_for_arch() {
dirk@531
    15
  ARCH=$1
dirk@531
    16
  HOST=$2
dirk@531
    17
  SYSROOT=$3
dirk@531
    18
  PREFIX=$4
dirk@531
    19
  IPHONEOS_DEPLOYMENT_TARGET="6.0"
dirk@531
    20
  export PATH="${DEVROOT}/usr/bin/:${PATH}"
dirk@531
    21
  export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${SYSROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -fembed-bitcode"
dirk@531
    22
  export LDFLAGS="-arch ${ARCH} -isysroot ${SYSROOT}"
dirk@531
    23
  ./configure --disable-shared --enable-static ${SSL_FLAG} --host="${HOST}" --prefix=${PREFIX} && make -j8 && make install
dirk@531
    24
}
dirk@531
    25
dirk@531
    26
if [ "$1" == "openssl" ]
dirk@531
    27
then
dirk@531
    28
  if [ ! -d ${HOME}/Desktop/openssl-ios-dist ]
dirk@531
    29
  then
dirk@531
    30
    echo "Please use https://github.com/sinofool/build-openssl-ios/ to build OpenSSL for iOS first"
dirk@531
    31
    exit 8
dirk@531
    32
  fi
dirk@531
    33
  export SSL_FLAG=--with-ssl=${HOME}/Desktop/openssl-ios-dist
dirk@531
    34
else
dirk@531
    35
  check_curl_ver
dirk@531
    36
  export SSL_FLAG=--with-darwinssl
dirk@531
    37
fi
dirk@531
    38
dirk@531
    39
TMP_DIR=/tmp/build_libcurl_$$
dirk@531
    40
dirk@531
    41
build_for_arch i386 i386-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ${TMP_DIR}/i386 || exit 1
dirk@531
    42
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
dirk@531
    43
build_for_arch arm64 arm-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/arm64 || exit 3
dirk@531
    44
build_for_arch armv7s armv7s-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/armv7s || exit 4
dirk@531
    45
build_for_arch armv7 armv7-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/armv7 || exit 5
dirk@531
    46
dirk@531
    47
mkdir -p ${TMP_DIR}/lib/
dirk@531
    48
${DEVROOT}/usr/bin/lipo \
dirk@531
    49
	-arch i386 ${TMP_DIR}/i386/lib/libcurl.a \
dirk@531
    50
	-arch x86_64 ${TMP_DIR}/x86_64/lib/libcurl.a \
dirk@531
    51
	-arch armv7 ${TMP_DIR}/armv7/lib/libcurl.a \
dirk@531
    52
	-arch armv7s ${TMP_DIR}/armv7s/lib/libcurl.a \
dirk@531
    53
	-arch arm64 ${TMP_DIR}/arm64/lib/libcurl.a \
dirk@531
    54
	-output ${TMP_DIR}/lib/libcurl.a -create
dirk@531
    55
dirk@531
    56
cp -r ${TMP_DIR}/armv7s/include ${TMP_DIR}/
dirk@531
    57
curl -O https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/patch-include.patch
dirk@531
    58
patch ${TMP_DIR}/include/curl/curlbuild.h < patch-include.patch
dirk@531
    59
dirk@531
    60
mkdir -p ${DIST_DIR}
dirk@531
    61
cp -r ${TMP_DIR}/include ${TMP_DIR}/lib ${DIST_DIR}
dirk@531
    62