-
Notifications
You must be signed in to change notification settings - Fork 39
/
build_iphone.sh
executable file
·76 lines (62 loc) · 1.7 KB
/
build_iphone.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
SCRATCH="scratch"
DEST=`pwd`/"bin"
ARCHS="arm64 armv7 x86_64 i386"
if [ "$*" ]
then
ARCHS="$*"
fi
CWD=`pwd`
for ARCH in $ARCHS
do
SPHINXBASE_DIR=`pwd`/../sphinxbase/bin/$ARCH
echo "building $ARCH..."
mkdir -p "$SCRATCH/$ARCH"
cd "$SCRATCH/$ARCH"
MIN_IOS_VERSION="6.0"
if [[ "${ARCH}" == "arm64" || "${ARCH}" == "x86_64" ]]; then
MIN_IOS_VERSION="7.0" # 7.0 as this is the minimum for these architectures
fi
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
IOS_CFLAGS="-arch $ARCH -mios-simulator-version-min=$MIN_IOS_VERSION"
else
PLATFORM="iPhoneOS"
IOS_CFLAGS="-arch $ARCH -mios-version-min=$MIN_IOS_VERSION -fembed-bitcode"
fi
HOST_TYPE="${ARCH}-apple-darwin"
if [ "${ARCH}" == "arm64" ]; then
# Fix unknown type for arm64 cpu (which is aarch64)
HOST_TYPE="aarch64-apple-darwin"
fi
export DEVELOPER=`xcode-select --print-path`
export DEVROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export SDKROOT="${DEVROOT}/SDKs/${PLATFORM}${IPHONE_SDK}.sdk"
export CC=`xcrun -find clang`
export LD=`xcrun -find ld`
export CFLAGS="-O3 ${IOS_CFLAGS} -isysroot ${SDKROOT}"
export LDFLAGS="${IOS_CFLAGS} -isysroot ${SDKROOT}"
export CPPFLAGS="${CFLAGS}"
$CWD/configure \
--host="${HOST_TYPE}" \
--prefix="$DEST/$ARCH" \
--without-lapack \
--without-python \
--with-sphinxbase="$SPHINXBASE_DIR" \
|| exit 1
make -j3 install || exit 1
cd $CWD
done
PROJECT=$(basename $PWD)
if [ ! "$*" ]
then
LIPO_ARGS="-output $DEST/fat/lib/lib$PROJECT.a"
mkdir -p "$DEST/fat/lib"
for ARCH in $ARCHS
do
LIPO_ARGS="$LIPO_ARGS $DEST/$ARCH/lib/lib$PROJECT.a"
done
lipo -create $LIPO_ARGS
fi
echo Done