Commits

Juri Pakaste committed 39c74d8

build-zeromq-ios.zsh now builds a fat library with arm and i386 targets.

Comments (0)

Files changed (1)

build-zeromq-ios.zsh

 #!/usr/bin/env zsh
 
-SDK="iPhoneOS5.1.sdk"
 
 make clean &>>|/dev/null
 
-BUILD_DIR=`pwd`/build
+BUILD_DIR="$(pwd)/build"
+XCODE_ROOT="$(xcode-select -print-path)"
 
-if [[ -d $BUILD_DIR ]]; then
-  rm -fr $BUILD_DIR
+IPHONE_SDK_ROOT="${XCODE_ROOT}/Platforms/iPhoneOS.platform/Developer"
+IPHONE_COMPILER="arm-apple-darwin10-llvm-gcc-4.2"
+IPHONE_SDK="iPhoneOS5.1.sdk"
+IPHONE_BUILD_SUB="iPhoneOS"
+IPHONE_HOST_PARAM="--host=arm-apple-darwin10"
+
+SIMULATOR_SDK_ROOT="${XCODE_ROOT}/Platforms/iPhoneSimulator.platform/Developer"
+SIMULATOR_COMPILER="i686-apple-darwin11-llvm-gcc-4.2"
+SIMULATOR_SDK="iPhoneSimulator5.1.sdk"
+SIMULATOR_BUILD_SUB="iPhoneSimulator"
+SIMULATOR_HOST_PARAM=""
+
+if [[ -d "$BUILD_DIR" ]]; then
+  rm -fr "$BUILD_DIR"
 fi
 
-mkdir -p $BUILD_DIR
+mkdir -p "$BUILD_DIR"
 
-ZMQ_BUILD_LOG_FILE=$BUILD_DIR/build.log
+ZMQ_BUILD_LOG_FILE="$BUILD_DIR/build.log"
 
-echo "-- Configuring with prefix $BUILD_DIR"
-SDK_ROOT="$(xcode-select -print-path)/Platforms/iPhoneOS.platform/Developer"
 export CPP="cpp"
 export CXXCPP="cpp"
-export CXX="${SDK_ROOT}/usr/bin/arm-apple-darwin10-llvm-g++-4.2"
-export CXXFLAGS="-O -isysroot $SDK_ROOT/SDKs/$SDK"
-export CC="${SDK_ROOT}/usr/bin/arm-apple-darwin10-llvm-gcc-4.2"
-export CFLAGS="-O -isysroot $SDK_ROOT/SDKs/$SDK"
-export AR=$SDK_ROOT"/usr/bin/ar"
-export AS=$SDK_ROOT"/usr/bin/as"
-export LD=$SDK_ROOT"/usr/bin/ld"
-export LDFLAGS="-lstdc++ -isysroot $SDK_ROOT/SDKs/$SDK"
-export LIBTOOL=$SDK_ROOT"/usr/bin/libtool"
-export STRIP=$SDK_ROOT"/usr/bin/strip"
-export RANLIB=$SDKROOT"/usr/bin/ranlib"
 
-./configure --disable-dependency-tracking --enable-static --disable-shared --host=arm-apple-darwin10 --prefix=$BUILD_DIR &>>| $ZMQ_BUILD_LOG_FILE
+function do_build () {
+	sdkroot=$1
+	sdk=$2
+	compiler=$3
+	builddir=$4
+	host=$5
 
-echo "-- Building"
-make &>>| $ZMQ_BUILD_LOG_FILE
+	echo "---- Configuring with prefix ${builddir}"
 
-echo "-- Installing to $BUILD_DIR"
-make install &>>| $ZMQ_BUILD_LOG_FILE
+	mkdir -p "${builddir}"
+	export CXX="${sdkroot}/usr/bin/${compiler}"
+	export CXXFLAGS="-O -isysroot ${sdkroot}/SDKs/${sdk}"
+	export CC="${sdkroot}/usr/bin/${compiler}"
+	export CFLAGS="-O -isysroot ${sdkroot}/SDKs/${sdk}"
+	export AR=${sdkroot}"/usr/bin/ar"
+	export AS=${sdkroot}"/usr/bin/as"
+	export LD=${sdkroot}"/usr/bin/ld"
+	export LDFLAGS="-lstdc++ -isysroot ${sdkroot}/SDKs/${sdk}"
+	export LIBTOOL="${sdkroot}/usr/bin/libtool"
+	export STRIP="${sdkroot}/usr/bin/strip"
+	export RANLIB="${sdkroot}/usr/bin/ranlib"
 
-echo "-- Cleaning up"
-make clean &>>| /dev/null
+	./configure --disable-dependency-tracking --enable-static --disable-shared "$host" "--prefix=${builddir}" &>>| "$ZMQ_BUILD_LOG_FILE"
 
-echo "-- Copying headers"
-mkdir $BUILD_DIR/usr && cp -R include $BUILD_DIR/usr
+	echo "-- Building"
+	make &>>| "$ZMQ_BUILD_LOG_FILE"
+
+	echo "-- Installing to ${builddir}"
+	make install &>>| "$ZMQ_BUILD_LOG_FILE"
+
+	echo "-- Cleaning up"
+	make clean &>>| /dev/null
+
+	echo "-- Copying headers"
+	mkdir "${builddir}/usr" && cp -R include "${builddir}/usr"
+
+}
+
+do_build "$IPHONE_SDK_ROOT" "$IPHONE_SDK" "$IPHONE_COMPILER" "$BUILD_DIR/$IPHONE_BUILD_SUB" "$IPHONE_HOST_PARAM"
+do_build "$SIMULATOR_SDK_ROOT" "$SIMULATOR_SDK" "$SIMULATOR_COMPILER" "$BUILD_DIR/$SIMULATOR_BUILD_SUB" "$SIMULATOR_HOST_PARAM"
+
+echo "---- Creating fat library with lipo"
+
+"${IPHONE_SDK_ROOT}/usr/bin/lipo" -output "${BUILD_DIR}/libzmq-fat.a" -create -arch armv7 "${BUILD_DIR}/${IPHONE_BUILD_SUB}/lib/libzmq.a" -arch i386 "${BUILD_DIR}/${SIMULATOR_BUILD_SUB}/lib/libzmq.a"