ios_thirdparty
SDK=4.3 # for example

# Platforms to build for (changing this may break the build)
PLATFORMS="iPhoneSimulator iPhoneOS-V6 iPhoneOS-V7"

# Build projects
DEVELOPER=`xcode-select --print-path`

 if [ "${PLATFORM}" == "iPhoneOS-V7" ]
  then
    PLATFORM="iPhoneOS"
    ARCH="armv7"                                                                                                                                        
  elif [ "${PLATFORM}" == "iPhoneOS-V6" ]
  then
    PLATFORM="iPhoneOS"
    ARCH="armv6"
  else
    ARCH="i386"
  fi 

CC="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/usr/bin/gcc"
CFLAGS="-D_DARWIN_C_SOURCE -UOPENSSL_BN_ASM_PART_WORDS -arch ${ARCH} -isysroot ${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer/SDKs/${PLATFORM}${SDK}.sdk"
LDFLAGS="-arch ${ARCH} -dynamiclib"

iOS 5.0 SDK

It seems that iOS 5.0 SDK will use llvm instead of gcc, we need to change the config.

export DEVROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export SDKROOT="${DEVROOT}/SDKs/${PLATFORM}${SDK}.sdk"
export CC=${DEVROOT}/usr/bin/gcc
export LD=${DEVROOT}/usr/bin/ld
#export CPP=${DEVROOT}/usr/bin/cpp
export CPP=${DEVROOT}/usr/bin/llvm-cpp-4.2
export CXX=${DEVROOT}/usr/bin/g++
unset AR
unset AS
export NM=${DEVROOT}/usr/bin/nm
#export CXXCPP=${DEVROOT}/usr/bin/cpp
export CXXCPP=${DEVROOT}/usr/bin/llvm-cpp-4.2
export RANLIB=${DEVROOT}/usr/bin/ranlib
export LDFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -L${ROOTDIR}/lib"
export CFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${ROOTDIR}/include"
export CXXFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${ROOTDIR}/include"

Or create soft link to solve build error.
$ pwd
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
$ ln -s llvm-cpp-4.2 cpp

And this patch for llvm asm on libgcrypt-1.4.6.tar.bz2 and gnupg-1.4.11

diff -Naur libgcrypt-1.4.0-org/mpi/longlong.h libgcrypt-1.4.0/mpi/longlong.h
--- libgcrypt-1.4.0-org/mpi/longlong.h    2005-07-29 21:31:17.000000000 +0800
+++ libgcrypt-1.4.0/mpi/longlong.h    2012-02-17 15:49:44.000000000 +0800
@@ -226,7 +226,7 @@
 #else
 #define umul_ppmm(xh, xl, a, b)                                         \
   __asm__ ("%@ Inlined umul_ppmm\n"                                     \
-       "umull %r1, %r0, %r2, %r3"                                   \
+       "umull %1, %0, %2, %3"                                   \
            : "=&r" ((USItype)(xh)),                             \
              "=r" ((USItype)(xl))                               \
            : "r" ((USItype)(a)),                                \

Reference
https://forums.oracle.com/forums/thread.jspa?messageID=10105861

check library architecture

$ lipo -info xxx.a
ios
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License