- 下载所需要的lame版本
- 写自动化脚本
#!/bin/sh
CONFIGURE_FLAGS="--disable-shared --disable-frontend"
ARCHS="arm64 armv7s x86_64 i386 armv7"
# directories
# SOURCE 解压后lame的本地地址
SOURCE="修改为自己的lame地址"
FAT="fat-lame"
# SCRATCH 解压后lame的本地地址
SCRATCH="修改为自己的lame地址"
# must be an absolute path
THIN=`pwd`/"thin-lame"
COMPILE="y"
LIPO="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"
if ! xcodebuild -version | grep "Xcode [1-6]\."
then
CFLAGS="$CFLAGS -fembed-bitcode"
fi
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
- 编译文件
# 进入编译脚本的文件夹
cd /xxx/lame
# -rwxr-xr-x 拥有者有读、写、执行权限;而属组用户和其他用户只有读、执行权限。
chmod 755 ./build-lame.sh
# 执行脚本
sudo sh ./build-lame.sh
- 编译完成, 生成fat-lame目录和thin-lame目录,分别存放合并所有指令集的静态库,以及各指令集的静态库.
- 查看.a文件的指令集
lipo -info libmp3lame.a
- 验证是否支持bitcode
# 解压抽取lame.o
ar -x libmp3lame.a
# 检查是否支持bitcode若输出sectname __bitcode则支持bitcode
otool -l lame.o | grep bitcode