Fix issue #1 using darwin-ssl

This commit is contained in:
Bochun Bai 2015-10-08 15:57:59 -07:00
parent cd8a93b6df
commit 1de4c71a2c
2 changed files with 33 additions and 5 deletions

View file

@ -2,8 +2,9 @@ libcurl for iOS
================= =================
Build libcurl for iOS development. Build libcurl for iOS development.
This script will generate static library for armv7 armv7s arm64 i386 and x86_64. This script will generate static library for armv7 armv7s arm64 i386 and x86_64.
New Xcode7 bitcode feature supported. Bitcode support.
OpenSSL and Darwin native ssl support.
Script only, please download libcurl from here: http://curl.haxx.se/download.html Script only, please download libcurl from here: http://curl.haxx.se/download.html
Tested iOS SDK 9.0 and MacOSX 10.11 Tested iOS SDK 9.0 and MacOSX 10.11
Tested curl 7.44.0 Tested curl 7.44.0
@ -19,10 +20,17 @@ curl https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/build_l
``` ```
Find the result libcurl-ios-dist on your desktop. Find the result libcurl-ios-dist on your desktop.
OpenSSL
=================
The script link with native ssl by default (--with-darwinssl).
To use OpenSSL, use https://github.com/sinofool/build-openssl-ios/ to build OpenSSL for iOS first, in curl source directory run:
```
curl https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/build_libcurl_dist.sh openssl |bash
```
Binary Binary
================= =================
You can find a prebuild binary here: https://sinofool.net/dl/libcurl-ios-dist.tar.bz2 You can find a prebuild binary (with OpenSSL) here: https://sinofool.net/dl/libcurl-ios-dist.tar.bz2
Double check the binary file before use: Double check the binary file before use:
``` ```

View file

@ -1,6 +1,14 @@
#!/bin/bash #!/bin/bash
export DEVROOT=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain export DEVROOT=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
DIST_DIR=${HOME}/Desktop/libcurl-ios-dist
function check_curl_ver() {
echo "#include \"include/curl/curlver.h\"
#if LIBCURL_VERSION_MAJOR < 7 || LIBCURL_VERSION_MINOR < 40
#error Required curl 7.40.0+; See http://curl.haxx.se/docs/adv_20150108A.html
#endif"|gcc -c -o /dev/null -xc -||exit 9
}
function build_for_arch() { function build_for_arch() {
ARCH=$1 ARCH=$1
@ -11,9 +19,22 @@ function build_for_arch() {
export PATH="${DEVROOT}/usr/bin/:${PATH}" export PATH="${DEVROOT}/usr/bin/:${PATH}"
export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${SYSROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -fembed-bitcode" export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${SYSROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -fembed-bitcode"
export LDFLAGS="-arch ${ARCH} -isysroot ${SYSROOT}" export LDFLAGS="-arch ${ARCH} -isysroot ${SYSROOT}"
./configure --disable-shared --enable-static --with-ssl=${HOME}/Desktop/openssl-ios-dist --host="${HOST}" --prefix=${PREFIX} && make -j8 && make install ./configure --disable-shared --enable-static ${SSL_FLAG} --host="${HOST}" --prefix=${PREFIX} && make -j8 && make install
} }
if [ "$1" == "openssl" ]
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
TMP_DIR=/tmp/build_libcurl_$$ TMP_DIR=/tmp/build_libcurl_$$
build_for_arch i386 i386-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ${TMP_DIR}/i386 || exit 1 build_for_arch i386 i386-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ${TMP_DIR}/i386 || exit 1
@ -35,7 +56,6 @@ cp -r ${TMP_DIR}/armv7s/include ${TMP_DIR}/
curl -O https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/patch-include.patch curl -O https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/patch-include.patch
patch ${TMP_DIR}/include/curl/curlbuild.h < patch-include.patch patch ${TMP_DIR}/include/curl/curlbuild.h < patch-include.patch
DIST_DIR=${HOME}/Desktop/libcurl-ios-dist
rm -rf ${DIST_DIR} rm -rf ${DIST_DIR}
mkdir ${DIST_DIR} mkdir ${DIST_DIR}
cp -r ${TMP_DIR}/include ${TMP_DIR}/lib ${DIST_DIR} cp -r ${TMP_DIR}/include ${TMP_DIR}/lib ${DIST_DIR}