2018-02-20 12:46:21 +00:00
|
|
|
#!/bin/bash -euo pipefail
|
2014-03-29 06:39:06 +00:00
|
|
|
|
|
|
|
export DEVROOT=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
|
2015-12-24 23:31:44 +00:00
|
|
|
DFT_DIST_DIR=${HOME}/Desktop/libcurl-ios-dist
|
|
|
|
DIST_DIR=${DIST_DIR:-$DFT_DIST_DIR}
|
2015-10-08 22:57:59 +00:00
|
|
|
|
|
|
|
function check_curl_ver() {
|
|
|
|
echo "#include \"include/curl/curlver.h\"
|
2017-09-07 01:06:26 +00:00
|
|
|
#if LIBCURL_VERSION_MAJOR < 7 || LIBCURL_VERSION_MINOR < 55
|
2015-10-08 22:57:59 +00:00
|
|
|
#error Required curl 7.40.0+; See http://curl.haxx.se/docs/adv_20150108A.html
|
2017-09-07 01:06:26 +00:00
|
|
|
#error Supported minimal version is 7.55.0 for header file changes, see Issue #12 (https://github.com/sinofool/build-libcurl-ios/issues/12)
|
2017-02-08 19:30:57 +00:00
|
|
|
#endif"|gcc -c -o /dev/null -xc -||exit 9
|
2015-10-08 22:57:59 +00:00
|
|
|
}
|
2014-03-29 06:39:06 +00:00
|
|
|
|
|
|
|
function build_for_arch() {
|
|
|
|
ARCH=$1
|
|
|
|
HOST=$2
|
|
|
|
SYSROOT=$3
|
|
|
|
PREFIX=$4
|
2014-09-27 07:27:02 +00:00
|
|
|
IPHONEOS_DEPLOYMENT_TARGET="6.0"
|
2014-07-25 17:27:51 +00:00
|
|
|
export PATH="${DEVROOT}/usr/bin/:${PATH}"
|
2017-02-08 19:30:57 +00:00
|
|
|
export CFLAGS="-DCURL_BUILD_IOS -arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${SYSROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -fembed-bitcode"
|
2014-03-29 06:39:06 +00:00
|
|
|
export LDFLAGS="-arch ${ARCH} -isysroot ${SYSROOT}"
|
2017-01-30 07:13:36 +00:00
|
|
|
./configure --disable-shared --without-zlib --enable-static --enable-ipv6 ${SSL_FLAG} --host="${HOST}" --prefix=${PREFIX} && make -j8 && make install
|
2014-03-29 06:39:06 +00:00
|
|
|
}
|
|
|
|
|
2018-02-20 12:46:21 +00:00
|
|
|
if [ "${1:-''}" == "openssl" ]
|
2015-10-08 22:57:59 +00:00
|
|
|
then
|
|
|
|
if [ ! -d ${HOME}/Desktop/openssl-ios-dist ]
|
|
|
|
then
|
|
|
|
echo "Please use https://github.com/sinofool/build-openssl-ios/ to build OpenSSL for iOS first"
|
|
|
|
exit 8
|
|
|
|
fi
|
|
|
|
export SSL_FLAG=--with-ssl=${HOME}/Desktop/openssl-ios-dist
|
|
|
|
else
|
|
|
|
check_curl_ver
|
|
|
|
export SSL_FLAG=--with-darwinssl
|
|
|
|
fi
|
|
|
|
|
2014-03-29 06:39:06 +00:00
|
|
|
TMP_DIR=/tmp/build_libcurl_$$
|
|
|
|
|
2017-02-08 19:30:57 +00:00
|
|
|
#build_for_arch i386 i386-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ${TMP_DIR}/i386 || exit 1
|
2015-09-19 18:51:30 +00:00
|
|
|
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
|
|
|
|
build_for_arch arm64 arm-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/arm64 || exit 3
|
|
|
|
build_for_arch armv7s armv7s-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/armv7s || exit 4
|
2018-01-03 13:27:43 +00:00
|
|
|
build_for_arch armv7 armv7-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/armv7 || exit 5
|
2014-03-29 06:39:06 +00:00
|
|
|
|
2014-09-30 20:33:36 +00:00
|
|
|
mkdir -p ${TMP_DIR}/lib/
|
2014-03-29 06:39:06 +00:00
|
|
|
${DEVROOT}/usr/bin/lipo \
|
|
|
|
-arch x86_64 ${TMP_DIR}/x86_64/lib/libcurl.a \
|
2018-01-03 13:27:43 +00:00
|
|
|
-arch armv7 ${TMP_DIR}/armv7/lib/libcurl.a \
|
2014-03-29 06:39:06 +00:00
|
|
|
-arch armv7s ${TMP_DIR}/armv7s/lib/libcurl.a \
|
|
|
|
-arch arm64 ${TMP_DIR}/arm64/lib/libcurl.a \
|
2014-09-30 20:33:36 +00:00
|
|
|
-output ${TMP_DIR}/lib/libcurl.a -create
|
2014-03-29 06:39:06 +00:00
|
|
|
|
2017-09-07 01:06:26 +00:00
|
|
|
cp -r ${TMP_DIR}/arm64/include ${TMP_DIR}/
|
2014-03-29 06:39:06 +00:00
|
|
|
|
2015-12-24 23:31:44 +00:00
|
|
|
mkdir -p ${DIST_DIR}
|
2014-09-30 20:33:36 +00:00
|
|
|
cp -r ${TMP_DIR}/include ${TMP_DIR}/lib ${DIST_DIR}
|
2014-03-29 06:39:06 +00:00
|
|
|
|