Skip to content

Instantly share code, notes, and snippets.

@yume190
Last active May 10, 2022 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yume190/8ec4304aff13c592c109e2d28ce67e22 to your computer and use it in GitHub Desktop.
Save yume190/8ec4304aff13c592c109e2d28ce67e22 to your computer and use it in GitHub Desktop.
lame
#!/bin/sh
# lame source
# https://github.com/luciuskwok/lame-3.100-macos
# build.sh source
# https://github.com/kewlbear/lame-ios-build
# ./build.sh arm64 x86_64
# ./build.sh lipo
CONFIGURE_FLAGS="--disable-shared --disable-frontend"
ARCHS="arm64 x86_64"
# directories
SOURCE="./"
FAT="./fat-lame"
SCRATCH="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" = "arm64" -o "$ARCH" = "x86_64" ]
then
PLATFORM="MacOSX"
if [ "$ARCH" = "x86_64" ]
then
# SIMULATOR="-mios-simulator-version-min=7.0"
SIMULATOR="-mmacosx-version-min=10.9"
HOST=x86_64-apple-macosx
else
# SIMULATOR="-mios-simulator-version-min=5.0"
SIMULATOR="-mmacosx-version-min=10.9"
HOST=x86_64-apple-macosx
fi
else
PLATFORM="MacOSX"
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 \
CC=$CC $CWD/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment