-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_lame_for_iOS.sh
85 lines (66 loc) · 1.83 KB
/
build_lame_for_iOS.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
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
################################################################################
## Build-lame-for-iOS
##
################################################################################
set -ev
# Min version for lame
MIN_VERSION="6.0"
# Set default output folder is build
OUTPUT_FOLDER=${OUTPUT-build}
# Set default make from Xcode
MAKE=${MAKE-$(xcrun --find make)}
# Set default compiler from Xcode
CC=${CC-$(xcrun --find gcc)}
# Set lipo from Xcode
LIPO=${LIPO-$(xcrun --find lipo)}
# Make output folder
mkdir -p $OUTPUT_FOLDER
function build_lame()
{
if [ -f "Makefile" ];then
${MAKE} distclean
fi
# SDK must lower case
_SDK=$(echo ${SDK} | tr '[:upper:]' '[:lower:]')
SDK_ROOT=$(xcrun --sdk ${_SDK} --show-sdk-path)
# C compiler flags
# gcc in xcode is clang
# Ref: http://clang.llvm.org/docs/CommandGuide/clang.html
CFLAGS="-arch ${PLATFORM} -pipe -std=c99 ${BITCODE} -isysroot ${SDK_ROOT} -miphoneos-version-min=${MIN_VERSION}"
# GNU Autoconf
./configure \
CFLAGS="${CFLAGS}" \
--host="${HOST}-apple-darwin" \
--enable-static \
--disable-decoder \
--disable-frontend \
--disable-debug \
--disable-dependency-tracking
${MAKE}
cp "libmp3lame/.libs/libmp3lame.a" "${OUTPUT_FOLDER}/libmp3lame-${PLATFORM}.a"
}
# Bulid simulator version
HOST="i686"
SDK="iPhoneSimulator"
BITCODE="-fembed-bitcode-marker"
PLATFORM="i386"
build_lame
PLATFORM="x86_64"
build_lame
# Build device version
HOST="arm"
SDK="iPhoneOS"
BITCODE="-fembed-bitcode"
PLATFORM="armv7"
build_lame
PLATFORM="armv7s"
build_lame
PLATFORM="arm64"
build_lame
# Remove old libmp3lame.a or lipo will failed
OUTPUT_LIB=${OUTPUT_FOLDER}/libmp3lame.a
if [ -f $OUTPUT_LIB ]; then
rm $OUTPUT_LIB
fi
${LIPO} -create ${OUTPUT_FOLDER}/* -output ${OUTPUT_LIB}