Last active
January 30, 2019 01:12
-
-
Save c0ming/10976661 to your computer and use it in GitHub Desktop.
A script for build iOS7 universal static library with clang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# e.g. libmms http://sourceforge.net/projects/libmms/ | |
# set -x | |
BUILD_DIR=`pwd`"/build" | |
STATIC_LIB_NAME="libmms.a" | |
STATIC_LIB_NAME_ARM="libmms.a.arm" | |
STATIC_LIB_NAME_X86="libmms.a.x86" | |
ARCHS_IPHONE_OS="-arch armv7 -arch armv7s -arch arm64" | |
ARCHS_IPHONE_SIMULATOR="-arch i386 -arch x86_64" | |
mkdir -p $BUILD_DIR | |
# build in terminal for armv7 armv7s arm64 | |
# | |
# mkdir build | |
# ./configure --host=arm-apple-darwin --prefix=`pwd`/build --disable-shared | |
# make CC="$(xcrun --sdk iphoneos -f clang) -isysroot $(xcrun --sdk iphoneos --show-sdk-path) \ | |
# -arch armv7 -arch armv7s -arch arm64 -miphoneos-version-min=7.0" | |
# make install | |
# | |
SDKROOT=$(xcrun --sdk iphoneos --show-sdk-path) | |
CC="$(xcrun --sdk iphoneos -f clang)" | |
CXX=$(xcrun --sdk iphoneos -f clang++) | |
CFLAGS="-isysroot $SDKROOT $ARCHS_IPHONE_OS -miphoneos-version-min=7.0" | |
CXXFLAGS=$CFLAGS | |
export CC CXX CFLAGS CXXFLAGS | |
make distclean | |
./configure \ | |
--host=arm-apple-darwin \ | |
--prefix=$BUILD_DIR \ | |
--disable-shared | |
make -j4 | |
make install | |
# remane for arm arch | |
mv $BUILD_DIR/lib/$STATIC_LIB_NAME $BUILD_DIR/lib/$STATIC_LIB_NAME_ARM | |
# build in terminal for i386 x86_64 | |
# | |
# mkdir build | |
# ./configure --prefix=`pwd`/build --disable-shared | |
# make CC="$(xcrun --sdk iphonesimulator -f clang) -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path) \ | |
# -arch i386 -arch x86_64 -mios-simulator-version-min=7.0" | |
# make install | |
# | |
SDKROOT=$(xcrun --sdk iphonesimulator --show-sdk-path) | |
CC="$(xcrun --sdk iphonesimulator -f clang)" | |
CXX="$(xcrun --sdk iphonesimulator -f clang++)" | |
CFLAGS=" -isysroot $SDKROOT $ARCHS_IPHONE_SIMULATOR -mios-simulator-version-min=7.0" | |
CXXFLAGS=$CFLAGS | |
export CC CXX CFLAGS CXXFLAGS | |
make distclean | |
./configure \ | |
--prefix=$BUILD_DIR \ | |
--disable-shared | |
make -j4 | |
make install | |
# remane for x86 arch | |
mv $BUILD_DIR/lib/$STATIC_LIB_NAME $BUILD_DIR/lib/$STATIC_LIB_NAME_X86 | |
# create universal static library | |
lipo -create $BUILD_DIR/lib/$STATIC_LIB_NAME_ARM $BUILD_DIR/lib/$STATIC_LIB_NAME_X86 \ | |
-output $BUILD_DIR/lib/$STATIC_LIB_NAME | |
echo "************** Done **************" | |
lipo -info $BUILD_DIR/lib/$STATIC_LIB_NAME_ARM $BUILD_DIR/lib/$STATIC_LIB_NAME_X86 $BUILD_DIR/lib/$STATIC_LIB_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment