-
Notifications
You must be signed in to change notification settings - Fork 64
/
build-lame-framework.sh
executable file
·133 lines (113 loc) · 2.49 KB
/
build-lame-framework.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/sh
LAME_FILE=lame-3.99.5.tar.gz
LAME_DIR=lame-3.99.5
rm -rf $LAME_DIR;
if ! [ -f $LAME_FILE ];then
echo "downloading $LAME_FILE ..."
curl -o $LAME_FILE http://ncu.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
if [ $? != 0 ];then
echo "downloading $LAME_FILE error ...";
exit -1;
else
echo "downloading $LAME_FILE done ...";
fi
fi
tar xf $LAME_FILE;
if [ $? != 0 ];then
echo "extract $LAME_FILE error ...";
rm -rf $LAME_FILE;
rm -rf $LAME_DIR;
exit -1;
fi
#ln -s $LAME_DIR lame;
CONFIGURE_FLAGS="--disable-shared --disable-frontend"
ARCHS="arm64 armv7s x86_64 i386 armv7"
# directories
#SOURCE="lame"
SOURCE=$LAME_DIR
FAT=".fat-lame"
SCRATCH=".scratch-lame"
# must be an absolute path
THIN=`pwd`/".thin-lame"
COMPILE="y"
LIPO="y"
FRAMEWORK="y"
if [ "$*" ]
then
if [ "$*" = "lipo" ]
then
# skip compile
COMPILE=
else
ARCHS="$*"
if [ $# -eq 1 ]
then
# skip lipo
LIPO=
fi
fi
fi
if [ "$COMPILE" ]
then
CWD=`pwd`
for ARCH in $ARCHS
do
echo "building $ARCH..."
mkdir -p "$SCRATCH/$ARCH"
cd "$SCRATCH/$ARCH"
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
if [ "$ARCH" = "x86_64" ]
then
SIMULATOR="-mios-simulator-version-min=7.0"
HOST=x86_64-apple-darwin
else
SIMULATOR="-mios-simulator-version-min=5.0"
HOST=i386-apple-darwin
fi
else
PLATFORM="iPhoneOS"
SIMULATOR=
HOST=arm-apple-darwin
fi
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
CC="xcrun -sdk $XCRUN_SDK clang -arch $ARCH"
#AS="$CWD/$SOURCE/extras/gas-preprocessor.pl $CC"
CFLAGS="-arch $ARCH $SIMULATOR -fembed-bitcode"
CXXFLAGS="$CFLAGS"
LDFLAGS="$CFLAGS"
CC=$CC $CWD/$SOURCE/configure \
$CONFIGURE_FLAGS \
--host=$HOST \
--prefix="$THIN/$ARCH" \
CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS"
make -j3 install
cd $CWD
done
fi
if [ "$LIPO" ]
then
echo "building fat binaries..."
mkdir -p $FAT/lib
set - $ARCHS
CWD=`pwd`
cd $THIN/$1/lib
for LIB in *.a
do
cd $CWD
lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB
done
cd $CWD
cp -rf $THIN/$1/include $FAT
fi
if [ "$FRAMEWORK" ]
then
rm -rf lame.framework
echo "building lame.framework..."
mkdir -p lame.framework/Headers/
cp -rf $FAT/include/lame/* lame.framework/Headers/
cp -f $FAT/lib/libmp3lame.a lame.framework/lame
fi
# clean tmp directories
rm -rf $SOURCE $FAT $SCRATCH $THIN