├── without-https ├── 99-clean.sh ├── 00-build-all.sh └── 01-build-libcurl.sh ├── with-https-openssl ├── 99-clean.sh ├── 00-build-all.sh ├── 01-build-libssl.sh └── 02-build-libcurl.sh ├── with-https-darwinssl ├── 99-clean.sh ├── 00-build-all.sh └── 01-build-libcurl.sh ├── .gitignore └── README.md /without-https/99-clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf src bin log include lib lib-i386 lib-no-i386 *.tar.* -------------------------------------------------------------------------------- /with-https-openssl/99-clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf src bin log include lib lib-i386 lib-no-i386 *.tar.* -------------------------------------------------------------------------------- /with-https-darwinssl/99-clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf src bin log include lib lib-i386 lib-no-i386 *.tar.* -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | */bin 3 | */src 4 | */log 5 | */include 6 | */lib 7 | */lib-i386 8 | */lib-no-i386 9 | */*.tar.* 10 | -------------------------------------------------------------------------------- /without-https/00-build-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | SCRIPTS="01-build-libcurl2.sh" 3 | 4 | for SCRIPT in ${SCRIPTS} 5 | do 6 | sh ${SCRIPT} 7 | 8 | rc=$? 9 | if [[ $rc != 0 ]] ; then 10 | echo "! Error while running script ${SCRIPT}; aborted." 11 | exit $rc 12 | fi 13 | done 14 | -------------------------------------------------------------------------------- /with-https-darwinssl/00-build-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | SCRIPTS="01-build-libcurl.sh" 3 | 4 | for SCRIPT in ${SCRIPTS} 5 | do 6 | sh ${SCRIPT} 7 | 8 | rc=$? 9 | if [[ $rc != 0 ]] ; then 10 | echo "! Error while running script ${SCRIPT}; aborted." 11 | exit $rc 12 | fi 13 | done 14 | -------------------------------------------------------------------------------- /with-https-openssl/00-build-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | SCRIPTS="01-build-libssl.sh 02-build-libcurl.sh" 3 | 4 | for SCRIPT in ${SCRIPTS} 5 | do 6 | sh ${SCRIPT} 7 | 8 | rc=$? 9 | if [[ $rc != 0 ]] ; then 10 | echo "! Error while running script ${SCRIPT}; aborted." 11 | exit $rc 12 | fi 13 | done 14 | -------------------------------------------------------------------------------- /with-https-openssl/01-build-libssl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION="1.0.1c" 4 | LIBNAME="libssl" 5 | LIBDOWNLOAD="http://www.openssl.org/source/openssl-${VERSION}.tar.gz" 6 | ARCHIVE="${LIBNAME}-${VERSION}.tar.gz" 7 | 8 | SDK="5.1" 9 | CONFIGURE_FLAGS="" 10 | 11 | DIR=`pwd` 12 | XCODE=$(xcode-select --print-path) 13 | ARCHS="i386 armv7" 14 | 15 | 16 | # Download or use existing tar.gz 17 | if [ ! -e ${ARCHIVE} ]; then 18 | echo "" 19 | echo "* Downloading ${ARCHIVE}" 20 | echo "" 21 | curl -o ${ARCHIVE} ${LIBDOWNLOAD} 22 | else 23 | echo "" 24 | echo "* Using ${ARCHIVE}" 25 | fi 26 | 27 | 28 | # Create out dirs 29 | mkdir -p "${DIR}/bin" 30 | mkdir -p "${DIR}/lib" 31 | mkdir -p "${DIR}/src" 32 | 33 | 34 | # Build for all archs 35 | for ARCH in ${ARCHS} 36 | do 37 | if [ "${ARCH}" == "i386" ]; 38 | then 39 | PLATFORM="iPhoneSimulator" 40 | else 41 | PLATFORM="iPhoneOS" 42 | fi 43 | 44 | echo "" 45 | echo "* Building ${LIBNAME} ${VERSION} for ${PLATFORM} ${SDK} ${ARCH}..." 46 | 47 | tar zxf ${ARCHIVE} -C "${DIR}/src" 48 | rm -rf "${DIR}/src/${LIBNAME}-${VERSION}" 49 | mv -f "${DIR}/src/openssl-${VERSION}" "${DIR}/src/${LIBNAME}-${VERSION}" 50 | 51 | if [ "${PLATFORM}" == "iPhoneOS" ]; 52 | then 53 | sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" \ 54 | "${DIR}/src/${LIBNAME}-${VERSION}/crypto/ui/ui_openssl.c" 55 | fi 56 | 57 | mkdir -p "${DIR}/bin/${LIBNAME}-${VERSION}/${PLATFORM}${SDK}-${ARCH}" 58 | 59 | cd "${DIR}/src/${LIBNAME}-${VERSION}" 60 | 61 | DEVROOT="${XCODE}/Platforms/${PLATFORM}.platform/Developer" 62 | SDKROOT="${DEVROOT}/SDKs/${PLATFORM}${SDK}.sdk" 63 | export CC="${DEVROOT}/usr/bin/llvm-gcc-4.2 -arch ${ARCH} -isysroot ${SDKROOT}" 64 | export LD="${DEVROOT}/usr/bin/ld -arch ${ARCH} -isysroot ${SDKROOT}" 65 | export AR="${DEVROOT}/usr/bin/ar" 66 | export AS="${DEVROOT}/usr/bin/as" 67 | export NM="${DEVROOT}/usr/bin/nm" 68 | export RANLIB="${DEVROOT}/usr/bin/ranlib" 69 | 70 | ./configure BSD-generic32 no-shared ${CONFIGURE_FLAGS} \ 71 | --openssldir="${DIR}/bin/${LIBNAME}-${VERSION}/${PLATFORM}${SDK}-${ARCH}" 72 | 73 | make 74 | make install 75 | cd ${DIR} 76 | rm -rf "${DIR}/src/${LIBNAME}-${VERSION}" 77 | done 78 | 79 | 80 | echo "" 81 | echo "* Creating binaries for ${LIBNAME}..." 82 | 83 | # Create a single .a file for all architectures 84 | LIBS="${LIBNAME} libcrypto" 85 | # Build for all archs 86 | for LIB in ${LIBS} 87 | do 88 | lipo -create "${DIR}/bin/${LIBNAME}-${VERSION}/iPhoneSimulator${SDK}-i386/lib/${LIB}.a" \ 89 | "${DIR}/bin/${LIBNAME}-${VERSION}/iPhoneOS${SDK}-armv7/lib/${LIB}.a" \ 90 | -output "${DIR}/lib/${LIB}.a" 91 | 92 | # Create a single .a file for all arm architectures 93 | lipo -create "${DIR}/bin/${LIBNAME}-${VERSION}/iPhoneOS${SDK}-armv7/lib/${LIB}.a" \ 94 | -output "${DIR}/lib/${LIB}-armv7.a" 95 | 96 | # Create a single .a file for i386 97 | lipo -create "${DIR}/bin/${LIBNAME}-${VERSION}/iPhoneSimulator${SDK}-i386/lib/${LIB}.a" \ 98 | -output "${DIR}/lib/${LIB}-i386.a" 99 | done 100 | 101 | 102 | # Copy the header files to include 103 | mkdir -p "${DIR}/include/" 104 | FIRST_ARCH="${ARCHS%% *}" 105 | if [ "${FIRST_ARCH}" == "i386" ]; 106 | then 107 | PLATFORM="iPhoneSimulator" 108 | else 109 | PLATFORM="iPhoneOS" 110 | fi 111 | cp -R "${DIR}/bin/${LIBNAME}-${VERSION}/${PLATFORM}${SDK}-${FIRST_ARCH}/include/" \ 112 | "${DIR}/include/" 113 | 114 | echo "" 115 | echo "* Finished; ${LIBNAME} binary created for archs: ${ARCHS}" 116 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Curl iOS build scripts 2 | ====================== 3 | 4 | Automated scripts to build curl for iOS. Supports: 5 | 6 | - iPhoneSimulator (i386) 7 | - newer iPhones/iPads (arm v7) 8 | 9 | > **NOTE** 10 | > These scripts **no longer compile for armv6** 11 | 12 | --- 13 | 14 | ## Default configuration 15 | 16 | The scripts are configured to produce the smallest binary possible, with Curl being configured only to support the HTTP protocol (no FTP, DICT, FILE, etc). 17 | 18 | All builds scripts share this configuration, although you can chose to include/exclude HTTPS support. 19 | 20 | --- 21 | 22 | ## Building without HTTPS support 23 | 24 | The smallest possible binary you can achieve is by compiling curl without HTTPS support (which removes the dependency on external libs). 25 | 26 | You can find the build scripts for curl without HTTPS support on `without-https/` folder. 27 | 28 | - **Dependencies:** none 29 | - **Total binary size:** ~900KB (~900KB for libcurl.a) 30 | 31 | --- 32 | 33 | ## Building with HTTPS support via native iOS/OSX SSL (darwin ssl) 34 | 35 | > **NOTE** 36 | > This is only present in curl 7.27's nightly builds, so it's still unstable. Use at your risk. 37 | 38 | If you want the generated curl binary to have HTTPS support via native iOS/OSX SSL implementation (darwin ssl), use the build scripts at `with-https-darwinssl/` folder. 39 | 40 | **This is the recommended SSL implementation** 41 | 42 | - **Dependencies:** none 43 | - **Total binary size:** ~900KB (~900KB for libcurl.a) 44 | 45 | --- 46 | 47 | ## Building with HTTPS support via OpenSSL 48 | 49 | If you want the generated curl binary to have HTTPS support via OpenSSL (Apache-style license), use the build scripts at `with-https-openssl/` folder. 50 | 51 | - **Dependencies:** libssl 52 | - **Total binary size:** ~2.1MB (~900KB for libcurl.a, ~1.2MB for libssl.a) 53 | 54 | --- 55 | 56 | ## Using on your project 57 | 58 | After you've compiled the project, all you need to do is include one of the generated `*.a` files (the universal, i386 or armv7) on your project and all the headers. The `*.a` files can be found on `lib/` folder and the header files under `include/`. 59 | 60 | When you add the files to the Xcode project, Xcode will automatically add the library files to the link build stage, i.e. you just need to add the `*.a` and `*.h` files to your project and it'll all work. 61 | 62 | These scripts build CURL with libz support so you'll need to add `libz.dylib` to your projects. 63 | If you're using the native SSL implementation, you'll need the `Security.framework` as well. 64 | 65 | > **NOTE** 66 | > The directories above are relative to the directory of the build branch you chose: `without-https`, `with-https-openssl` or `with-https-gnutls` 67 | 68 | --- 69 | 70 | ## Optimizing for space on your apps 71 | 72 | The scripts generate 3 kinds of binaries: 73 | 74 | 1. One with all the architectures combined (i386 and armv7); 75 | 2. One with just i386, to use on OSX development; 76 | 3. One with just armv7, to use on phones; 77 | 78 | For development on iOS, the first one is recommended - allows you to run the app on both the simulator and the physical devices. 79 | 80 | When you're about to build the final release (to submit to the app store), you should use the third one, as it is slightly smaller in size. 81 | 82 | > **ProTip™** 83 | > Use different build targets, and include different variations of the above files in each of them so this process is automatic. 84 | 85 | --- 86 | 87 | ## Acknowledgments 88 | 89 | These scripts are based on the excellent work of [Felix Schulze (x2on)](https://github.com/x2on), with some help from [Bob](http://stackoverflow.com/questions/9039554/using-libcurl-on-ios-5-as-an-alternative-to-nsurlconnection/9528936#9528936). 90 | 91 | Also huge thanks to [Jonas Schnelli](https://github.com/jonasschnelli) for the pull request that included native Darwin SSL support. -------------------------------------------------------------------------------- /without-https/01-build-libcurl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION="7.26.0" 4 | LIBNAME="libcurl" 5 | LIBDOWNLOAD="http://curl.haxx.se/download/curl-${VERSION}.tar.gz" 6 | ARCHIVE="${LIBNAME}-${VERSION}.tar.gz" 7 | 8 | # Enabled/disabled protocols (the fewer, the smaller the final binary size) 9 | PROTOCOLS="--enable-http --disable-rtsp --disable-ftp --disable-file --disable-ldap --disable-ldaps \ 10 | --disable-rtsp --disable-dict --disable-telnet --disable-tftp \ 11 | --disable-pop3 --disable-imap --disable-smtp --disable-gopher" 12 | 13 | CONFIGURE_FLAGS="--without-ssl --without-libssh2 --without-ca-bundle ${PROTOCOLS}" 14 | 15 | DIR=`pwd` 16 | XCODE_SELECT="xcode-select" 17 | XCODE=$(${XCODE_SELECT} --print-path) 18 | SDK_VERSION="5.1" 19 | ARCHS="i386 armv7" 20 | 21 | 22 | # Download or use existing tar.gz 23 | if [ ! -e ${ARCHIVE} ] 24 | then 25 | echo "" 26 | echo "* Downloading ${ARCHIVE}" 27 | echo "" 28 | curl -o ${ARCHIVE} ${LIBDOWNLOAD} 29 | else 30 | echo "" 31 | echo "* Using ${ARCHIVE}" 32 | fi 33 | 34 | 35 | # Create out dirs 36 | mkdir -p "${DIR}/bin" 37 | mkdir -p "${DIR}/lib" 38 | mkdir -p "${DIR}/src" 39 | 40 | 41 | # Build for all archs 42 | for ARCH in ${ARCHS} 43 | do 44 | if [ "${ARCH}" == "i386" ] 45 | then 46 | PLATFORM="iPhoneSimulator" 47 | else 48 | PLATFORM="iPhoneOS" 49 | fi 50 | 51 | echo "" 52 | echo "* Building ${LIBNAME} ${VERSION} for ${PLATFORM} ${SDK_VERSION} (${ARCH})..." 53 | 54 | # Expand source code, prepare output directory and set log 55 | tar zxf ${ARCHIVE} -C "${DIR}/src" 56 | rm -rf "${DIR}/src/${LIBNAME}-${VERSION}" 57 | mv -f "${DIR}/src/curl-${VERSION}" "${DIR}/src/${LIBNAME}-${VERSION}" 58 | 59 | mkdir -p "${DIR}/bin/${LIBNAME}-${VERSION}/${ARCH}" 60 | 61 | cd "${DIR}/src/${LIBNAME}-${VERSION}" 62 | 63 | # compilation binaries 64 | XCRUN_SDK=$(echo ${PLATFORM} | tr '[:upper:]' '[:lower:]') 65 | export CC="$(xcrun -sdk ${XCRUN_SDK} -find llvm-gcc-4.2)" 66 | export LD="$(xcrun -sdk ${XCRUN_SDK} -find ld)" 67 | export AR="$(xcrun -sdk ${XCRUN_SDK} -find ar)" 68 | export AS="$(xcrun -sdk ${XCRUN_SDK} -find as)" 69 | export NM="$(xcrun -sdk ${XCRUN_SDK} -find nm)" 70 | export RANLIB="$(xcrun -sdk ${XCRUN_SDK} -find ranlib)" 71 | 72 | # compilation flags 73 | SDK="${XCODE}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDK_VERSION}.sdk" 74 | export LDFLAGS="-arch ${ARCH} -pipe -isysroot ${SDK} -L${DIR}/lib" 75 | export CFLAGS="-arch ${ARCH} -pipe -isysroot ${SDK} -I${DIR}/include" 76 | 77 | ./configure --host=${ARCH}-apple-darwin --disable-shared --enable-static ${CONFIGURE_FLAGS} \ 78 | --prefix="${DIR}/bin/${LIBNAME}-${VERSION}/${ARCH}" 79 | 80 | make 81 | make install 82 | cd ${DIR} 83 | rm -rf "${DIR}/src/${LIBNAME}-${VERSION}" 84 | done 85 | 86 | 87 | echo "" 88 | echo "* Creating binaries for ${LIBNAME}..." 89 | 90 | I386_LIB="${DIR}/bin/${LIBNAME}-${VERSION}/i386/lib/${LIBNAME}.a" 91 | ARMV7_LIB="${DIR}/bin/${LIBNAME}-${VERSION}/armv7/lib/${LIBNAME}.a" 92 | 93 | # Create a single .a file for all architectures 94 | if [ -e ${I386_LIB} -a -e ${ARMV7_LIB} ] 95 | then 96 | lipo -create ${I386_LIB} ${ARMV7_LIB} -output "${DIR}/lib/${LIBNAME}.a" 97 | fi 98 | 99 | # Create a single .a file for all arm architectures 100 | if [ -e ${ARMV7_LIB} ] 101 | then 102 | lipo -create ${ARMV7_LIB} -output "${DIR}/lib/${LIBNAME}-armv7.a" 103 | fi 104 | 105 | # Create a single .a file for i386 (iphonesimulator or macosx both generate the exact same output) 106 | if [ -e ${I386_LIB} ] 107 | then 108 | lipo -create ${I386_LIB} -output "${DIR}/lib/${LIBNAME}-i386.a" 109 | fi 110 | 111 | # Copy the header files to include 112 | mkdir -p "${DIR}/include/" 113 | FIRST_ARCH="${ARCHS%% *}" 114 | cp -R "${DIR}/bin/${LIBNAME}-${VERSION}/${FIRST_ARCH}/include/" \ 115 | "${DIR}/include/" 116 | 117 | echo "" 118 | echo "* Finished; ${LIBNAME} binary created for platforms: ${ARCHS}" 119 | -------------------------------------------------------------------------------- /with-https-darwinssl/01-build-libcurl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION="7.27.0" 4 | LIBNAME="libcurl" 5 | LIBDOWNLOAD="http://curl.haxx.se/download/curl-${VERSION}.tar.gz" 6 | ARCHIVE="${LIBNAME}-${VERSION}.tar.gz" 7 | 8 | # Enabled/disabled protocols (the fewer, the smaller the final binary size) 9 | PROTOCOLS="--enable-http --disable-rtsp --disable-ftp --disable-file --disable-ldap --disable-ldaps \ 10 | --disable-rtsp --disable-dict --disable-telnet --disable-tftp \ 11 | --disable-pop3 --disable-imap --disable-smtp --disable-gopher" 12 | 13 | CONFIGURE_FLAGS="--with-darwinssl --without-ssl --without-libssh2 --without-ca-bundle ${PROTOCOLS}" 14 | 15 | DIR=`pwd` 16 | XCODE_SELECT="xcode-select" 17 | XCODE=$(${XCODE_SELECT} --print-path) 18 | SDK_VERSION="5.1" 19 | ARCHS="i386 armv7" 20 | 21 | 22 | # Download or use existing tar.gz 23 | if [ ! -e ${ARCHIVE} ] 24 | then 25 | echo "" 26 | echo "* Downloading ${ARCHIVE}" 27 | echo "" 28 | curl -o ${ARCHIVE} ${LIBDOWNLOAD} 29 | else 30 | echo "" 31 | echo "* Using ${ARCHIVE}" 32 | fi 33 | 34 | 35 | # Create out dirs 36 | mkdir -p "${DIR}/bin" 37 | mkdir -p "${DIR}/lib" 38 | mkdir -p "${DIR}/src" 39 | 40 | 41 | # Build for all archs 42 | for ARCH in ${ARCHS} 43 | do 44 | if [ "${ARCH}" == "i386" ] 45 | then 46 | PLATFORM="iPhoneSimulator" 47 | else 48 | PLATFORM="iPhoneOS" 49 | fi 50 | 51 | echo "" 52 | echo "* Building ${LIBNAME} ${VERSION} for ${PLATFORM} ${SDK_VERSION} (${ARCH})..." 53 | 54 | # Expand source code, prepare output directory and set log 55 | tar zxf ${ARCHIVE} -C "${DIR}/src" 56 | rm -rf "${DIR}/src/${LIBNAME}-${VERSION}" 57 | mv -f "${DIR}/src/curl-${VERSION}" "${DIR}/src/${LIBNAME}-${VERSION}" 58 | 59 | mkdir -p "${DIR}/bin/${LIBNAME}-${VERSION}/${ARCH}" 60 | 61 | cd "${DIR}/src/${LIBNAME}-${VERSION}" 62 | 63 | # compilation binaries 64 | XCRUN_SDK=$(echo ${PLATFORM} | tr '[:upper:]' '[:lower:]') 65 | export CC="$(xcrun -sdk ${XCRUN_SDK} -find llvm-gcc-4.2)" 66 | export LD="$(xcrun -sdk ${XCRUN_SDK} -find ld)" 67 | export AR="$(xcrun -sdk ${XCRUN_SDK} -find ar)" 68 | export AS="$(xcrun -sdk ${XCRUN_SDK} -find as)" 69 | export NM="$(xcrun -sdk ${XCRUN_SDK} -find nm)" 70 | export RANLIB="$(xcrun -sdk ${XCRUN_SDK} -find ranlib)" 71 | 72 | # compilation flags 73 | SDK="${XCODE}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDK_VERSION}.sdk" 74 | export LDFLAGS="-arch ${ARCH} -pipe -isysroot ${SDK} -L${DIR}/lib" 75 | export CFLAGS="-arch ${ARCH} -pipe -isysroot ${SDK} -I${DIR}/include" 76 | 77 | ./configure --host=${ARCH}-apple-darwin --disable-shared --enable-static ${CONFIGURE_FLAGS} \ 78 | --prefix="${DIR}/bin/${LIBNAME}-${VERSION}/${ARCH}" 79 | 80 | make 81 | make install 82 | cd ${DIR} 83 | rm -rf "${DIR}/src/${LIBNAME}-${VERSION}" 84 | done 85 | 86 | 87 | echo "" 88 | echo "* Creating binaries for ${LIBNAME}..." 89 | 90 | I386_LIB="${DIR}/bin/${LIBNAME}-${VERSION}/i386/lib/${LIBNAME}.a" 91 | ARMV7_LIB="${DIR}/bin/${LIBNAME}-${VERSION}/armv7/lib/${LIBNAME}.a" 92 | 93 | # Create a single .a file for all architectures 94 | if [ -e ${I386_LIB} -a -e ${ARMV7_LIB} ] 95 | then 96 | lipo -create ${I386_LIB} ${ARMV7_LIB} -output "${DIR}/lib/${LIBNAME}.a" 97 | fi 98 | 99 | # Create a single .a file for all arm architectures 100 | if [ -e ${ARMV7_LIB} ] 101 | then 102 | lipo -create ${ARMV7_LIB} -output "${DIR}/lib/${LIBNAME}-armv7.a" 103 | fi 104 | 105 | # Create a single .a file for i386 (iphonesimulator or macosx both generate the exact same output) 106 | if [ -e ${I386_LIB} ] 107 | then 108 | lipo -create ${I386_LIB} -output "${DIR}/lib/${LIBNAME}-i386.a" 109 | fi 110 | 111 | # Copy the header files to include 112 | mkdir -p "${DIR}/include/" 113 | FIRST_ARCH="${ARCHS%% *}" 114 | cp -R "${DIR}/bin/${LIBNAME}-${VERSION}/${FIRST_ARCH}/include/" \ 115 | "${DIR}/include/" 116 | 117 | echo "" 118 | echo "* Finished; ${LIBNAME} binary created for platforms: ${ARCHS}" 119 | -------------------------------------------------------------------------------- /with-https-openssl/02-build-libcurl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION="7.26.0" 4 | PRECEDENT_VERSION="1.0.1c" 5 | PRECEDENT_LIBNAME="libssl" 6 | LIBNAME="libcurl" 7 | LIBDOWNLOAD="http://curl.haxx.se/download/curl-${VERSION}.tar.gz" 8 | ARCHIVE="${LIBNAME}-${VERSION}.tar.gz" 9 | 10 | SDK="5.1" 11 | 12 | # Enabled/disabled protocols (the fewer, the smaller the final binary size) 13 | PROTOCOLS="--enable-http --disable-rtsp --disable-ftp --disable-file --disable-ldap --disable-ldaps \ 14 | --disable-rtsp --disable-dict --disable-telnet --disable-tftp \ 15 | --disable-pop3 --disable-imap --disable-smtp --disable-gopher" 16 | 17 | CONFIGURE_FLAGS="--without-libssh2 --without-ca-bundle ${PROTOCOLS}" 18 | 19 | DIR=`pwd` 20 | XCODE=$(xcode-select --print-path) 21 | ARCHS="i386 armv7" 22 | 23 | 24 | # Download or use existing tar.gz 25 | if [ ! -e ${ARCHIVE} ]; then 26 | echo "" 27 | echo "* Downloading ${ARCHIVE}" 28 | echo "" 29 | curl -o ${ARCHIVE} ${LIBDOWNLOAD} 30 | else 31 | echo "" 32 | echo "* Using ${ARCHIVE}" 33 | fi 34 | 35 | 36 | # Create out dirs 37 | mkdir -p "${DIR}/bin" 38 | mkdir -p "${DIR}/lib" 39 | mkdir -p "${DIR}/src" 40 | 41 | 42 | # Build for all archs 43 | for ARCH in ${ARCHS} 44 | do 45 | if [ "${ARCH}" == "i386" ]; 46 | then 47 | PLATFORM="iPhoneSimulator" 48 | else 49 | PLATFORM="iPhoneOS" 50 | fi 51 | 52 | echo "" 53 | echo "* Building ${LIBNAME} ${VERSION} for ${PLATFORM} ${SDK} ${ARCH}..." 54 | 55 | # Ensure precedent lib is available for this architecture 56 | if [ -f "${DIR}/bin/${PRECEDENT_LIBNAME}-${PRECEDENT_VERSION}/${PLATFORM}${SDK}-${ARCH}/lib/${PRECEDENT_LIBNAME}.a" ]; 57 | then 58 | echo "" 59 | echo "* Using ${PRECEDENT_LIBNAME} ${PRECEDENT_VERSION} (${ARCH})..." 60 | else 61 | echo "" 62 | echo "! Please build ${PRECEDENT_LIBNAME} ${PRECEDENT_VERSION} for ${ARCH} first" 63 | exit 1 64 | fi 65 | 66 | # Expand source code, prepare output directory and set log 67 | tar zxf ${ARCHIVE} -C "${DIR}/src" 68 | rm -rf "${DIR}/src/${LIBNAME}-${VERSION}" 69 | mv -f "${DIR}/src/curl-${VERSION}" "${DIR}/src/${LIBNAME}-${VERSION}" 70 | 71 | mkdir -p "${DIR}/bin/${LIBNAME}-${VERSION}/${PLATFORM}${SDK}-${ARCH}" 72 | 73 | cd "${DIR}/src/${LIBNAME}-${VERSION}" 74 | 75 | DEVROOT="${XCODE}/Platforms/${PLATFORM}.platform/Developer" 76 | SDKROOT="${DEVROOT}/SDKs/${PLATFORM}${SDK}.sdk" 77 | export CC="${DEVROOT}/usr/bin/llvm-gcc-4.2" 78 | export LD="${DEVROOT}/usr/bin/ld" 79 | export CPP="${DEVROOT}/usr/bin/llvm-cpp-4.2" 80 | export CXX="${DEVROOT}/usr/bin/llvm-g++-4.2" 81 | export AR="${DEVROOT}/usr/bin/ar" 82 | export AS="${DEVROOT}/usr/bin/as" 83 | export NM="${DEVROOT}/usr/bin/nm" 84 | export RANLIB="${DEVROOT}/usr/bin/ranlib" 85 | export LDFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -L${DIR}/lib" 86 | export CFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${DIR}/include" 87 | export CXXFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${DIR}/include" 88 | 89 | ./configure --host=${ARCH}-apple-darwin --disable-shared --enable-static ${CONFIGURE_FLAGS} \ 90 | --with-ssl="${DIR}/bin/${PRECEDENT_LIBNAME}-${PRECEDENT_VERSION}/${PLATFORM}${SDK}-${ARCH}" \ 91 | --prefix="${DIR}/bin/${LIBNAME}-${VERSION}/${PLATFORM}${SDK}-${ARCH}" 92 | 93 | make 94 | make install 95 | cd ${DIR} 96 | rm -rf "${DIR}/src/${LIBNAME}-${VERSION}" 97 | done 98 | 99 | 100 | # Create a single .a file for all architectures 101 | echo "" 102 | echo "* Creating binaries for ${LIBNAME}..." 103 | lipo -create "${DIR}/bin/${LIBNAME}-${VERSION}/iPhoneSimulator${SDK}-i386/lib/${LIBNAME}.a" \ 104 | "${DIR}/bin/${LIBNAME}-${VERSION}/iPhoneOS${SDK}-armv7/lib/${LIBNAME}.a" \ 105 | -output "${DIR}/lib/${LIBNAME}.a" 106 | 107 | # Create a single .a file for all arm architectures 108 | lipo -create "${DIR}/bin/${LIBNAME}-${VERSION}/iPhoneOS${SDK}-armv7/lib/${LIBNAME}.a" \ 109 | -output "${DIR}/lib/${LIBNAME}-armv7.a" 110 | 111 | # Create a single .a file for i386 112 | lipo -create "${DIR}/bin/${LIBNAME}-${VERSION}/iPhoneSimulator${SDK}-i386/lib/${LIBNAME}.a" \ 113 | -output "${DIR}/lib/${LIBNAME}-i386.a" 114 | 115 | 116 | # Copy the header files to include 117 | mkdir -p "${DIR}/include/" 118 | FIRST_ARCH="${ARCHS%% *}" 119 | if [ "${FIRST_ARCH}" == "i386" ]; 120 | then 121 | PLATFORM="iPhoneSimulator" 122 | else 123 | PLATFORM="iPhoneOS" 124 | fi 125 | cp -R "${DIR}/bin/${LIBNAME}-${VERSION}/${PLATFORM}${SDK}-${FIRST_ARCH}/include/" \ 126 | "${DIR}/include/" 127 | 128 | echo "" 129 | echo "* Finished; ${LIBNAME} binary created for archs: ${ARCHS}" 130 | 131 | --------------------------------------------------------------------------------