├── README.md └── build-fdk-aac.sh /README.md: -------------------------------------------------------------------------------- 1 | # fdk-aac build script for iOS 2 | 3 | See https://github.com/kewlbear/FFmpeg-iOS for .xcframework support, integration with FFmpeg and more. 4 | 5 | Shell script to build fdk-aac for use in iOS apps. 6 | 7 | ## Preparation 8 | 9 | ``` 10 | brew install automake libtool 11 | fdk-aac-X.X.X/autogen.sh 12 | ``` 13 | 14 | ## Usage 15 | 16 | * Build all: 17 | 18 | ``` 19 | build-fdk-aac.sh 20 | ``` 21 | 22 | * Build for some architectures: 23 | 24 | ``` 25 | build-fdk-aac.sh armv7s x86_64 26 | ``` 27 | 28 | * Build universal library from separately built architectures: 29 | 30 | ``` 31 | build-fdk-aac.sh lipo 32 | ``` 33 | -------------------------------------------------------------------------------- /build-fdk-aac.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | CONFIGURE_FLAGS="--enable-static --with-pic=yes --disable-shared" 4 | 5 | ARCHS="arm64 x86_64 i386 armv7" 6 | 7 | # directories 8 | SOURCE="fdk-aac-0.1.5" 9 | FAT="fdk-aac-ios" 10 | 11 | SCRATCH="scratch" 12 | # must be an absolute path 13 | THIN=`pwd`/"thin" 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 | CFLAGS="-arch $ARCH" 44 | 45 | if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ] 46 | then 47 | PLATFORM="iPhoneSimulator" 48 | CPU= 49 | if [ "$ARCH" = "x86_64" ] 50 | then 51 | CFLAGS="$CFLAGS -mios-simulator-version-min=7.0" 52 | HOST="--host=x86_64-apple-darwin" 53 | else 54 | CFLAGS="$CFLAGS -mios-simulator-version-min=7.0" 55 | HOST="--host=i386-apple-darwin" 56 | fi 57 | else 58 | PLATFORM="iPhoneOS" 59 | if [ $ARCH = arm64 ] 60 | then 61 | HOST="--host=aarch64-apple-darwin" 62 | else 63 | HOST="--host=arm-apple-darwin" 64 | fi 65 | CFLAGS="$CFLAGS -fembed-bitcode" 66 | fi 67 | 68 | XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'` 69 | CC="xcrun -sdk $XCRUN_SDK clang -Wno-error=unused-command-line-argument-hard-error-in-future" 70 | AS="$CWD/$SOURCE/extras/gas-preprocessor.pl $CC" 71 | CXXFLAGS="$CFLAGS" 72 | LDFLAGS="$CFLAGS" 73 | 74 | $CWD/$SOURCE/configure \ 75 | $CONFIGURE_FLAGS \ 76 | $HOST \ 77 | $CPU \ 78 | CC="$CC" \ 79 | CXX="$CC" \ 80 | CPP="$CC -E" \ 81 | AS="$AS" \ 82 | CFLAGS="$CFLAGS" \ 83 | LDFLAGS="$LDFLAGS" \ 84 | CPPFLAGS="$CFLAGS" \ 85 | --prefix="$THIN/$ARCH" 86 | 87 | make -j3 install 88 | cd $CWD 89 | done 90 | fi 91 | 92 | if [ "$LIPO" ] 93 | then 94 | echo "building fat binaries..." 95 | mkdir -p $FAT/lib 96 | set - $ARCHS 97 | CWD=`pwd` 98 | cd $THIN/$1/lib 99 | for LIB in *.a 100 | do 101 | cd $CWD 102 | lipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIB 103 | done 104 | 105 | cd $CWD 106 | cp -rf $THIN/$1/include $FAT 107 | fi 108 | --------------------------------------------------------------------------------