50 lines
2.3 KiB
Shell
Executable file
50 lines
2.3 KiB
Shell
Executable file
#!/bin/bash
|
|
# Cross-builds an audio-only FFmpeg (static libs) for iOS arm64 with the swift.org toolchain's clang.
|
|
# Output: Native/ffmpeg/{include,lib}. Run once; build.sh links it when present.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
|
|
SRC=${FFMPEG_SRC:-$HOME/.local/opt/dl/ffmpeg/ffmpeg-7.1.1}
|
|
TC=${SWIFT:-$HOME/.local/opt/swift/usr/bin}
|
|
SDK=${SDK:-$HOME/.local/opt/dl/sdk18/iPhoneOS18.6.sdk}
|
|
PREFIX=$PWD/ffmpeg
|
|
PHONE_LD=$(cd .. && pwd)/tools/phone-ld
|
|
WORK=$PWD/../build/ffmpeg-obj
|
|
mkdir -p "$WORK"
|
|
cd "$WORK"
|
|
|
|
CC="$TC/clang -target arm64-apple-ios17.0 -isysroot $SDK"
|
|
|
|
decoders=(mp3 mp3float mp2 mp2float mp1 aac aac_latm ac3 eac3 alac flac vorbis opus wmav1 wmav2 wmapro wmalossless
|
|
wmavoice ape wavpack mpc7 mpc8 tta tak shorten als truehd mlp dca atrac3 atrac3p cook ra_144 ra_288
|
|
dsd_lsbf dsd_msbf dsd_lsbf_planar dsd_msbf_planar amrnb amrwb gsm gsm_ms speex qdm2 qdmc nellymoser
|
|
adpcm_ima_wav adpcm_ms 'pcm_*')
|
|
demuxers=(ogg matroska webm_dash_manifest asf asf_o ape wv mpc mpc8 tta tak shorten dsf iff aiff wav w64 mp3 aac
|
|
ac3 eac3 flac mov amr caf truehd mlp dts xwma rm voc au sox)
|
|
parsers=(mpegaudio aac aac_latm ac3 flac vorbis opus dca mlp tak gsm amr)
|
|
|
|
join() { local IFS=,; echo "$*"; }
|
|
|
|
"$SRC/configure" \
|
|
--prefix="$PREFIX" \
|
|
--enable-cross-compile --target-os=darwin --arch=aarch64 \
|
|
--cc="$CC" --ld="$PHONE_LD" \
|
|
--ar="$TC/llvm-ar" --ranlib="$TC/llvm-ranlib" --nm="nm" --strip=true \
|
|
--extra-cflags="-mios-version-min=17.0 -fno-stack-check" \
|
|
--extra-ldflags="-mios-version-min=17.0" \
|
|
--disable-everything --disable-programs --disable-doc --disable-debug \
|
|
--disable-avdevice --disable-avfilter --disable-swscale --disable-network \
|
|
--disable-autodetect --enable-pic --enable-static --disable-shared \
|
|
--enable-avformat --enable-avcodec --enable-swresample \
|
|
--enable-protocol=file \
|
|
--enable-decoder="$(join "${decoders[@]}")" \
|
|
--enable-demuxer="$(join "${demuxers[@]}")" \
|
|
--enable-parser="$(join "${parsers[@]}")"
|
|
|
|
# configure finds the symbol prefix with nm, and GNU nm can't read Mach-O: Darwin uses "_".
|
|
sed -i -e 's/^#define EXTERN_PREFIX ""/#define EXTERN_PREFIX "_"/' -e 's/^#define EXTERN_ASM *$/#define EXTERN_ASM _/' config.h
|
|
grep -q 'EXTERN_PREFIX "_"' config.h
|
|
|
|
make -j"${JOBS:-3}"
|
|
make install
|
|
ls -la "$PREFIX/lib"
|