Skip to content

Commit e91298e

Browse files
committed
added build-x264.sh
1 parent bcf9637 commit e91298e

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

build-x264.sh

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/sh
2+
3+
CONFIGURE_FLAGS="--enable-static --enable-pic --disable-cli --disable-asm"
4+
5+
ARCHS="arm64 armv7s x86_64 i386 armv7"
6+
7+
# directories
8+
SOURCE="x264"
9+
FAT="fat-x264"
10+
11+
SCRATCH="scratch-x264"
12+
# must be an absolute path
13+
THIN=`pwd`/"thin-x264"
14+
15+
COMPILE="y"
16+
LIPO="y"
17+
18+
if [ "$*" ]
19+
then
20+
if [ "$*" = "lipo" ]
21+
then
22+
# skip compile
23+
COMPILE=
24+
else
25+
ARCHS="$*"
26+
if [ $# -eq 1 ]
27+
then
28+
# skip lipo
29+
LIPO=
30+
fi
31+
fi
32+
fi
33+
34+
if [ "$COMPILE" ]
35+
then
36+
CWD=`pwd`
37+
for ARCH in $ARCHS
38+
do
39+
echo "building $ARCH..."
40+
mkdir -p "$SCRATCH/$ARCH"
41+
cd "$SCRATCH/$ARCH"
42+
43+
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
44+
then
45+
PLATFORM="iPhoneSimulator"
46+
CPU=
47+
if [ "$ARCH" = "x86_64" ]
48+
then
49+
SIMULATOR="-mios-simulator-version-min=7.0"
50+
HOST=
51+
else
52+
SIMULATOR="-mios-simulator-version-min=5.0"
53+
HOST="--host=i386-apple-darwin"
54+
fi
55+
else
56+
PLATFORM="iPhoneOS"
57+
if [ $ARCH = "armv7s" ]
58+
then
59+
CPU="--cpu=swift"
60+
else
61+
CPU=
62+
fi
63+
SIMULATOR=
64+
HOST="--host=arm-apple-darwin"
65+
fi
66+
67+
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
68+
CC="xcrun -sdk $XCRUN_SDK clang"
69+
AS="$CWD/$SOURCE/extras/gas-preprocessor.pl $CC"
70+
CFLAGS="-arch $ARCH $SIMULATOR"
71+
CXXFLAGS="$CFLAGS"
72+
LDFLAGS="$CFLAGS"
73+
74+
CC=$CC $CWD/$SOURCE/configure \
75+
$CONFIGURE_FLAGS \
76+
$HOST \
77+
$CPU \
78+
--extra-cflags="$CFLAGS" \
79+
--extra-ldflags="$LDFLAGS" \
80+
--prefix="$THIN/$ARCH"
81+
82+
make -j3 install
83+
cd $CWD
84+
done
85+
fi
86+
87+
if [ "$LIPO" ]
88+
then
89+
echo "building fat binaries..."
90+
mkdir -p $FAT/lib
91+
set - $ARCHS
92+
CWD=`pwd`
93+
cd $THIN/$1/lib
94+
for LIB in *.a
95+
do
96+
cd $CWD
97+
lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB
98+
done
99+
100+
cd $CWD
101+
cp -rf $THIN/$1/include $FAT
102+
fi

0 commit comments

Comments
 (0)