#!/usr/bin/env bash # ============================================================================= # fetch-or-build-ffmpeg.sh - EditMe spike S2 (build brief section 4.1, "Step 2") # # Builds the LGPL `ffmpeg` and `ffprobe` executables that EditMe ships for # Apple Silicon (arm64, macOS 14+) from pinned OFFICIAL upstream source releases # and installs them into bin/darwin-arm64/. # # "fetch" here means: fetch the pinned source tarballs. This script never # downloads or runs a prebuilt binary (section 4.1 "Step 1: try a prebuilt" was # rejected: third-party binaries from unknown accounts are untrusted). # # Prerequisites # - Apple Silicon Mac, macOS 14 or newer # - Xcode or the Xcode Command Line Tools (clang, make, strip, otool, codesign) # - Homebrew build-time TOOLS (nothing from Homebrew is linked into the result): # brew install pkgconf meson ninja autoconf automake libtool # nasm is not needed: the arm64 assembly is assembled by clang. # # Usage # scripts/fetch-or-build-ffmpeg.sh build (finished steps are skipped) # scripts/fetch-or-build-ffmpeg.sh --clean wipe .build/ffmpeg (keeps downloads), rebuild # scripts/fetch-or-build-ffmpeg.sh --verify only re-run the checks on bin/darwin-arm64 # # Outputs # bin/darwin-arm64/ffmpeg, bin/darwin-arm64/ffprobe not renamed, ad-hoc signed # licenses/-* licence texts taken from the exact sources # ffmpeg-source.txt versions, URLs, SHA-256, configure lines # .build/ffmpeg/ downloads, sources, logs (git-ignored) # # No source patches are applied to any component. # ============================================================================= set -euo pipefail # ---------------------------------------------------------------------------- # Pinned sources (official upstream release artefacts only) # ---------------------------------------------------------------------------- MACOS_MIN=14.0 FFMPEG_VERSION=9.1 FFMPEG_URL="https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz" FFMPEG_SHA256=1a4d394ae63d190a526cd052eb4415c156b5c5e2df37efab41a7de0b8fde2433 FREETYPE_VERSION=2.15.0 FREETYPE_URL="https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.xz" FREETYPE_SHA256=93cd47eb719c325107f2d3cf087d06299e944c3b48a40b55537302304dea1dd5 HARFBUZZ_VERSION=15.2.0 HARFBUZZ_URL="https://github.com/harfbuzz/harfbuzz/releases/download/${HARFBUZZ_VERSION}/harfbuzz-${HARFBUZZ_VERSION}.tar.xz" HARFBUZZ_SHA256=e2ec49090744383cdbe7df808c1cedaafba06a97be8dc4211fe546ba585f12cb FRIBIDI_VERSION=1.0.18 FRIBIDI_URL="https://github.com/fribidi/fribidi/releases/download/v${FRIBIDI_VERSION}/fribidi-${FRIBIDI_VERSION}.tar.xz" FRIBIDI_SHA256=1de5e8073d035388b71d0b2d452b1da1f8caeea8a7702997b401fe1b6250727f LIBASS_VERSION=0.17.5 LIBASS_URL="https://github.com/libass/libass/releases/download/${LIBASS_VERSION}/libass-${LIBASS_VERSION}.tar.xz" LIBASS_SHA256=2dca25c0e0c837ddf00b52011b3f82cac1e4ddd3ad018227806b0c2288864acc # zimg publishes no release tarball; this is GitHub's source archive of the upstream release tag. ZIMG_VERSION=3.0.6 ZIMG_URL="https://github.com/sekrit-twc/zimg/archive/refs/tags/release-${ZIMG_VERSION}.tar.gz" ZIMG_SHA256=be89390f13a5c9b2388ce0f44a5e89364a20c1c57ce46d382b1fcc3967057577 # ---------------------------------------------------------------------------- # Layout # ---------------------------------------------------------------------------- ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" BUILD="$ROOT/.build/ffmpeg" DL="$BUILD/dl" # verified tarballs (mirror these to satisfy the LGPL source offer) SRC="$BUILD/src" # extracted sources PREFIX="$BUILD/prefix" # static FreeType / HarfBuzz / FriBidi / libass / zimg STAGE="$BUILD/stage" # DESTDIR of FFmpeg's `make install` TOOLS="$BUILD/tools" # symlinks to the few Homebrew build tools we allow on PATH LOGS="$BUILD/logs" STAMPS="$BUILD/stamps" BIN_DIR="$ROOT/bin/darwin-arm64" LICENSE_DIR="$ROOT/licenses" SOURCE_RECORD="$ROOT/ffmpeg-source.txt" # FFmpeg embeds its configure line in the binary and prints it in every banner. # A fixed, neutral prefix keeps the build machine's user name and paths out of the # shipped executables; nothing is ever written there (we install with DESTDIR). FF_PREFIX=/opt/editme/ffmpeg # ---------------------------------------------------------------------------- # Configure lines (single source of truth: used for the build AND written to # ffmpeg-source.txt) # ---------------------------------------------------------------------------- LIB_CFLAGS="-O2 -mmacosx-version-min=${MACOS_MIN}" LIB_LDFLAGS="-mmacosx-version-min=${MACOS_MIN}" FREETYPE_CONFIGURE=( ./configure "--prefix=$PREFIX" --disable-shared --enable-static --with-zlib=yes --with-bzip2=no --with-png=no --with-harfbuzz=no --with-brotli=no --with-librsvg=no ) FRIBIDI_CONFIGURE=( meson setup build "--prefix=$PREFIX" --libdir=lib --buildtype=release --default-library=static --wrap-mode=nofallback -Ddocs=false -Dbin=false -Dtests=false ) HARFBUZZ_CONFIGURE=( meson setup build "--prefix=$PREFIX" --libdir=lib --buildtype=release --default-library=static --wrap-mode=nofallback -Dfreetype=enabled -Dcoretext=disabled -Dglib=disabled -Dgobject=disabled -Dcairo=disabled -Dchafa=disabled -Dpng=disabled -Dzlib=disabled -Dicu=disabled -Draster=disabled -Dvector=disabled -Dgpu=disabled -Dgpu_demo=disabled -Dsubset=disabled -Dtests=disabled -Dintrospection=disabled -Ddocs=disabled -Dutilities=disabled -Dbenchmark=disabled ) LIBASS_CONFIGURE=( ./configure "--prefix=$PREFIX" --disable-shared --enable-static --disable-fontconfig --enable-coretext --disable-libunibreak ) ZIMG_CONFIGURE=( ./configure "--prefix=$PREFIX" --disable-shared --enable-static STL_LIBS=-lc++ ) # Section 4.1 line, plus only what the build needs (see ffmpeg-source.txt for why). FFMPEG_CONFIGURE=( ./configure "--prefix=$FF_PREFIX" --arch=arm64 --cc=clang --disable-gpl --disable-nonfree --disable-doc --disable-ffplay --disable-debug --enable-videotoolbox --enable-audiotoolbox --enable-libfreetype --enable-libharfbuzz --enable-libfribidi --enable-libass --enable-libzimg --pkg-config-flags=--static "--extra-cflags=-mmacosx-version-min=${MACOS_MIN}" "--extra-ldflags=-mmacosx-version-min=${MACOS_MIN}" ) # The only Homebrew programs the build may see (see "Hermetic environment" below). BUILD_TOOLS="pkg-config meson ninja autoconf autoheader autom4te autoreconf automake aclocal glibtoolize" # Filters / encoders the product needs (section 4.1 acceptance list). REQUIRED_FILTERS="ass drawtext scdet silencedetect ebur128 loudnorm afftdn alimiter highpass signalstats palettegen blackdetect fps trim atrim select aselect concat overlay zscale tonemap zoompan amix adelay volume afade tile scale crop" REQUIRED_ENCODERS="h264_videotoolbox aac_at pcm_s16le" FORBIDDEN_ENCODERS="libx264 libx265 libfdk_aac" REQUIRED_BUILDCONF="--enable-libass --enable-libzimg --enable-videotoolbox --enable-audiotoolbox --enable-libfreetype --enable-libharfbuzz --enable-libfribidi" # ---------------------------------------------------------------------------- # Helpers # ---------------------------------------------------------------------------- CURRENT_LOG="" log() { printf '\n==> %s\n' "$*"; } die() { printf 'ERROR: %s\n' "$*" >&2; exit 1; } on_exit() { local rc=$? if [ "$rc" -ne 0 ] && [ -n "$CURRENT_LOG" ] && [ -f "$CURRENT_LOG" ]; then printf '\n----- last 40 lines of %s -----\n' "$CURRENT_LOG" >&2 tail -n 40 "$CURRENT_LOG" >&2 fi exit "$rc" } trap on_exit EXIT sha256_of() { shasum -a 256 "$1" | awk '{print $1}'; } fetch() { # url file sha256 local url=$1 file="$DL/$2" want=$3 if [ -f "$file" ] && [ "$(sha256_of "$file")" != "$want" ]; then rm -f "$file"; fi if [ ! -f "$file" ]; then log "download $url" curl -fL --proto '=https' --proto-redir '=https' --tlsv1.2 --retry 3 -sS -o "$file.part" "$url" mv "$file.part" "$file" fi local got; got="$(sha256_of "$file")" [ "$got" = "$want" ] || die "SHA-256 mismatch for $2: got $got, pinned $want" printf 'ok %s %s\n' "$want" "$2" } extract() { # tarball dirname rm -rf "${SRC:?}/$2" tar -xf "$DL/$1" -C "$SRC" [ -d "$SRC/$2" ] || die "$1 did not unpack to $2" } step() { # name version function local stamp="$STAMPS/$1-$2.done" if [ -f "$stamp" ]; then log "$1 $2: already built, skipping"; return 0; fi log "$1 $2: building (log: .build/ffmpeg/logs/$1.log)" CURRENT_LOG="$LOGS/$1.log" ( "$3" ) > "$CURRENT_LOG" 2>&1 CURRENT_LOG="" touch "$stamp" } show_cmd() { # prints a configure array with the machine-specific prefix made symbolic local a out="" for a in "$@"; do a="${a//"$PREFIX"/\$PREFIX}" case "$a" in *" "*) a="\"$a\"" ;; esac out="$out $a" done printf '%s\n' "${out# }" } # ---------------------------------------------------------------------------- # Component builds (each runs in a subshell; see step) # ---------------------------------------------------------------------------- lib_env() { export CFLAGS="$LIB_CFLAGS" CXXFLAGS="$LIB_CFLAGS" LDFLAGS="$LIB_LDFLAGS"; } build_freetype() { extract "freetype-${FREETYPE_VERSION}.tar.xz" "freetype-${FREETYPE_VERSION}" cd "$SRC/freetype-${FREETYPE_VERSION}" lib_env "${FREETYPE_CONFIGURE[@]}" make -j"$JOBS" make install } build_fribidi() { extract "fribidi-${FRIBIDI_VERSION}.tar.xz" "fribidi-${FRIBIDI_VERSION}" cd "$SRC/fribidi-${FRIBIDI_VERSION}" lib_env "${FRIBIDI_CONFIGURE[@]}" meson compile -C build meson install -C build } build_harfbuzz() { extract "harfbuzz-${HARFBUZZ_VERSION}.tar.xz" "harfbuzz-${HARFBUZZ_VERSION}" cd "$SRC/harfbuzz-${HARFBUZZ_VERSION}" lib_env "${HARFBUZZ_CONFIGURE[@]}" meson compile -C build meson install -C build } build_libass() { extract "libass-${LIBASS_VERSION}.tar.xz" "libass-${LIBASS_VERSION}" cd "$SRC/libass-${LIBASS_VERSION}" lib_env "${LIBASS_CONFIGURE[@]}" make -j"$JOBS" make install } build_zimg() { extract "zimg-release-${ZIMG_VERSION}.tar.gz" "zimg-release-${ZIMG_VERSION}" cd "$SRC/zimg-release-${ZIMG_VERSION}" lib_env LIBTOOLIZE=glibtoolize ./autogen.sh "${ZIMG_CONFIGURE[@]}" make -j"$JOBS" make install } build_ffmpeg() { extract "ffmpeg-${FFMPEG_VERSION}.tar.xz" "ffmpeg-${FFMPEG_VERSION}" cd "$SRC/ffmpeg-${FFMPEG_VERSION}" unset CFLAGS CXXFLAGS LDFLAGS "${FFMPEG_CONFIGURE[@]}" make -j"$JOBS" rm -rf "$STAGE" make install DESTDIR="$STAGE" } # ---------------------------------------------------------------------------- # Install: binaries, licence texts, source record # ---------------------------------------------------------------------------- install_binaries() { log "install into bin/darwin-arm64" mkdir -p "$BIN_DIR" local b for b in ffmpeg ffprobe; do rm -f "$BIN_DIR/$b" # never overwrite a signed Mach-O in place cp "$STAGE$FF_PREFIX/bin/$b" "$BIN_DIR/$b" chmod 755 "$BIN_DIR/$b" # The linker signs arm64 output ad hoc and Apple's strip keeps that valid; # re-sign only if the signature did not survive. if ! codesign --verify --strict "$BIN_DIR/$b" 2>/dev/null; then codesign --force --sign - "$BIN_DIR/$b" fi done } install_licenses() { log "copy licence texts into licenses/" mkdir -p "$LICENSE_DIR" cp "$SRC/ffmpeg-${FFMPEG_VERSION}/COPYING.LGPLv2.1" "$LICENSE_DIR/ffmpeg-COPYING.LGPLv2.1.txt" cp "$SRC/ffmpeg-${FFMPEG_VERSION}/LICENSE.md" "$LICENSE_DIR/ffmpeg-LICENSE.md" cp "$SRC/freetype-${FREETYPE_VERSION}/LICENSE.TXT" "$LICENSE_DIR/freetype-LICENSE.txt" cp "$SRC/freetype-${FREETYPE_VERSION}/docs/FTL.TXT" "$LICENSE_DIR/freetype-FTL.txt" cp "$SRC/harfbuzz-${HARFBUZZ_VERSION}/COPYING" "$LICENSE_DIR/harfbuzz-COPYING.txt" cp "$SRC/fribidi-${FRIBIDI_VERSION}/COPYING" "$LICENSE_DIR/fribidi-COPYING.txt" cp "$SRC/libass-${LIBASS_VERSION}/COPYING" "$LICENSE_DIR/libass-COPYING.txt" cp "$SRC/zimg-release-${ZIMG_VERSION}/COPYING" "$LICENSE_DIR/zimg-COPYING.txt" } write_source_record() { log "write ffmpeg-source.txt" cat > "$SOURCE_RECORD" </.build/ffmpeg/prefix COMPONENTS ---------- 1. FFmpeg ${FFMPEG_VERSION} Source: ${FFMPEG_URL} SHA-256: ${FFMPEG_SHA256} Licence: LGPL-2.1-or-later (licenses/ffmpeg-COPYING.LGPLv2.1.txt, licenses/ffmpeg-LICENSE.md) Role: the programs themselves (ffmpeg, ffprobe, libav* linked statically) Configure: $(show_cmd "${FFMPEG_CONFIGURE[@]}") Build: make && make install DESTDIR=/.build/ffmpeg/stage Additions to the build-brief section 4.1 configure line, and why: --prefix=${FF_PREFIX} fixed neutral prefix instead of a path inside the build machine's home directory: the configure line is embedded in the binary and printed in every banner. Nothing is installed there (DESTDIR install). --cc=clang pin the compiler (FFmpeg's default name is "gcc"). --extra-cflags / --extra-ldflags=-mmacosx-version-min=${MACOS_MIN} deployment target macOS ${MACOS_MIN}. 2. FreeType ${FREETYPE_VERSION} Source: ${FREETYPE_URL} SHA-256: ${FREETYPE_SHA256} Licence: FreeType License (FTL), chosen from the FTL / GPL-2.0 dual licence (licenses/freetype-LICENSE.txt, licenses/freetype-FTL.txt) Linking: static Configure: $(show_cmd "${FREETYPE_CONFIGURE[@]}") Build: make && make install 3. HarfBuzz ${HARFBUZZ_VERSION} Source: ${HARFBUZZ_URL} SHA-256: ${HARFBUZZ_SHA256} Licence: MIT ("Old MIT") (licenses/harfbuzz-COPYING.txt) Linking: static Configure: $(show_cmd "${HARFBUZZ_CONFIGURE[@]}") Build: meson compile -C build && meson install -C build 4. GNU FriBidi ${FRIBIDI_VERSION} Source: ${FRIBIDI_URL} SHA-256: ${FRIBIDI_SHA256} Licence: LGPL-2.1-or-later (licenses/fribidi-COPYING.txt) Linking: static Configure: $(show_cmd "${FRIBIDI_CONFIGURE[@]}") Build: meson compile -C build && meson install -C build 5. libass ${LIBASS_VERSION} Source: ${LIBASS_URL} SHA-256: ${LIBASS_SHA256} Licence: ISC (licenses/libass-COPYING.txt) Linking: static; font provider CoreText, no fontconfig Configure: $(show_cmd "${LIBASS_CONFIGURE[@]}") Build: make && make install 6. zimg ${ZIMG_VERSION} Source: ${ZIMG_URL} (upstream publishes no release tarball; this is the archive of tag release-${ZIMG_VERSION}) SHA-256: ${ZIMG_SHA256} Licence: WTFPL version 2 (licenses/zimg-COPYING.txt) Linking: static Configure: LIBTOOLIZE=glibtoolize ./autogen.sh $(show_cmd "${ZIMG_CONFIGURE[@]}") Build: make && make install MACOS SYSTEM LIBRARIES (dynamic, part of the operating system, not redistributed) --------------------------------------------------------------------------------- /usr/lib: libSystem.B, libc++.1, libobjc.A, libz.1, libbz2.1.0, libiconv.2, and libhvf (weak-linked: FreeType's Apple HVF font support, used only on macOS 15.4+ behind a runtime availability check). /System/Library/Frameworks: AppKit, ApplicationServices, AudioToolbox, AVFoundation, CoreAudio, CoreFoundation, CoreGraphics, CoreImage, CoreMedia, CoreServices, CoreText, CoreVideo, Foundation, IOKit, OpenGL, Security, VideoToolbox. The exact list for a given build is the output of otool -L bin/darwin-arm64/ffmpeg bin/darwin-arm64/ffprobe (recorded for the shipped build in docs/verification/S2-ffmpeg.md). NOTES ----- - The FreeType License asks that product documentation credit the FreeType Project: "Portions of this software are copyright (c) The FreeType Project (www.freetype.org). All rights reserved." with taken from the FreeType version in use (see licenses/freetype-FTL.txt). - Keep the six archives (cached in .build/ffmpeg/dl/ after a build) and publish them together with this file and scripts/fetch-or-build-ffmpeg.sh next to the download, so the source offer does not depend on upstream URLs staying alive. EOF } # ---------------------------------------------------------------------------- # Acceptance checks (section 4.1). Every line must be PASS. # ---------------------------------------------------------------------------- VERIFY_FAILED=0 ok() { printf 'PASS %s\n' "$*"; } bad() { printf 'FAIL %s\n' "$*"; VERIFY_FAILED=1; } # here-strings, not pipes: `grep -q` on a pipe can SIGPIPE the writer under pipefail has_word() { grep -qx -- "$2" <<<"$1"; } # list (one per line), word has_text() { grep -q -- "$2" <<<"$1"; } # text, substring verify() { log "section 4.1 checks on $BIN_DIR" local ff="$BIN_DIR/ffmpeg" fp="$BIN_DIR/ffprobe" b w out missing [ -x "$ff" ] && [ -x "$fp" ] || die "ffmpeg/ffprobe missing in $BIN_DIR" for b in "$ff" "$fp"; do out="$("$b" -hide_banner -version | head -n 1)" case "$out" in "$(basename "$b") version ${FFMPEG_VERSION} "*) ok "$(basename "$b"): $out" ;; *) bad "$(basename "$b"): unexpected version line: $out" ;; esac [ "$(lipo -archs "$b")" = "arm64" ] && ok "$(basename "$b"): architecture arm64" \ || bad "$(basename "$b"): architecture is $(lipo -archs "$b")" out="$(otool -l "$b" | awk '/LC_BUILD_VERSION/{f=1} f&&/minos/{print $2; exit}')" [ "$out" = "$MACOS_MIN" ] && ok "$(basename "$b"): minimum macOS $out" \ || bad "$(basename "$b"): minimum macOS is '$out', want $MACOS_MIN" out="$(otool -L "$b" | tail -n +2 | awk '{print $1}' | grep -vE '^(/usr/lib/|/System/Library/)' || true)" [ -z "$out" ] && ok "$(basename "$b"): otool -L lists only /usr/lib and /System/Library" \ || bad "$(basename "$b"): non-system libraries linked: $out" codesign --verify --strict "$b" 2>/dev/null && ok "$(basename "$b"): code signature valid" \ || bad "$(basename "$b"): code signature invalid" out="$(strings -a "$b" | grep -cE '/Users/|/opt/homebrew|/private/|/home/' || true)" [ "$out" = "0" ] && ok "$(basename "$b"): no build-machine paths embedded" \ || bad "$(basename "$b"): $out strings with build-machine paths embedded" done out="$("$ff" -hide_banner -L 2>&1)" case "$out" in *"GNU Lesser General Public"*) ok "ffmpeg -L: LGPL" ;; *) bad "ffmpeg -L does not state the LGPL" ;; esac case "$out" in *"GNU General Public License"*) bad "ffmpeg -L mentions the GPL" ;; esac out="$("$ff" -hide_banner -buildconf 2>&1)" for w in --enable-gpl --enable-nonfree --enable-version3; do if has_text "$out" "$w"; then bad "buildconf contains $w"; else ok "buildconf: no $w"; fi done for w in $REQUIRED_BUILDCONF; do if has_text "$out" "$w"; then ok "buildconf: $w"; else bad "buildconf lacks $w"; fi done out="$("$ff" -hide_banner -filters 2>/dev/null | awk '{print $2}')" missing="" for w in $REQUIRED_FILTERS; do has_word "$out" "$w" || missing="$missing $w"; done [ -z "$missing" ] && ok "filters: all $(printf '%s\n' $REQUIRED_FILTERS | wc -l | tr -d ' ') required filters present" \ || bad "filters missing:$missing" out="$("$ff" -hide_banner -encoders 2>/dev/null | awk '{print $2}')" for w in $REQUIRED_ENCODERS; do has_word "$out" "$w" && ok "encoder present: $w" || bad "encoder missing: $w"; done for w in $FORBIDDEN_ENCODERS; do has_word "$out" "$w" && bad "forbidden encoder present: $w" || ok "encoder absent: $w"; done [ "$VERIFY_FAILED" -eq 0 ] || die "one or more section 4.1 checks failed" log "all section 4.1 checks passed" } # ---------------------------------------------------------------------------- # Main # ---------------------------------------------------------------------------- MODE=build case "${1:-}" in "") ;; --clean) MODE=clean ;; --verify) MODE=verify ;; -h|--help) sed -n '2,32p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;; *) die "unknown option: $1 (try --help)" ;; esac [ "$(uname -s)" = "Darwin" ] && [ "$(uname -m)" = "arm64" ] || die "this script must run natively on an Apple Silicon Mac" case "$ROOT" in *[[:space:]]*) die "the checkout path must not contain whitespace (libtool cannot handle it): $ROOT" ;; esac # The checks need nothing but system tools. if [ "$MODE" = verify ]; then export PATH="/usr/bin:/bin:/usr/sbin:/sbin" LC_ALL=C verify exit 0 fi # Hermetic environment. PATH holds the system directories plus a private folder # with symlinks to exactly the Homebrew build tools named below, NOT Homebrew's # bin directory: configure scripts probe PATH for helpers such as sdl2-config or # libpng-config and would otherwise pull Homebrew libraries into the build. mkdir -p "$BUILD" rm -rf "$TOOLS" && mkdir -p "$TOOLS" for tool in $BUILD_TOOLS; do tool_path="$(command -v "$tool" 2>/dev/null || true)" [ -n "$tool_path" ] || die "missing build tool: $tool (see the prerequisites at the top of this script)" ln -s "$tool_path" "$TOOLS/$tool" done export PATH="/usr/bin:/bin:/usr/sbin:/sbin:$TOOLS" unset CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH OBJC_INCLUDE_PATH LIBRARY_PATH \ CPPFLAGS CFLAGS CXXFLAGS OBJCFLAGS LDFLAGS LIBS \ PKG_CONFIG_PATH PKG_CONFIG_SYSROOT_DIR \ DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH DYLD_FRAMEWORK_PATH SDKROOT export MACOSX_DEPLOYMENT_TARGET="$MACOS_MIN" export CC=clang CXX=clang++ export PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" export LC_ALL=C JOBS="$(sysctl -n hw.ncpu)" for tool in clang clang++ make curl shasum tar strip otool lipo codesign; do command -v "$tool" >/dev/null 2>&1 || die "missing Xcode / system tool: $tool" done if [ "$MODE" = clean ]; then log "clean: removing sources, prefix, stage, logs (downloads are kept)" rm -rf "$SRC" "$PREFIX" "$STAGE" "$LOGS" "$STAMPS" fi mkdir -p "$DL" "$SRC" "$PREFIX/lib/pkgconfig" "$LOGS" "$STAMPS" T0=$(date +%s) log "toolchain: $(clang --version | head -n 1), SDK $(xcrun --show-sdk-version), macOS $(sw_vers -productVersion), deployment target $MACOS_MIN" log "fetch and verify pinned sources" fetch "$FFMPEG_URL" "ffmpeg-${FFMPEG_VERSION}.tar.xz" "$FFMPEG_SHA256" fetch "$FREETYPE_URL" "freetype-${FREETYPE_VERSION}.tar.xz" "$FREETYPE_SHA256" fetch "$HARFBUZZ_URL" "harfbuzz-${HARFBUZZ_VERSION}.tar.xz" "$HARFBUZZ_SHA256" fetch "$FRIBIDI_URL" "fribidi-${FRIBIDI_VERSION}.tar.xz" "$FRIBIDI_SHA256" fetch "$LIBASS_URL" "libass-${LIBASS_VERSION}.tar.xz" "$LIBASS_SHA256" fetch "$ZIMG_URL" "zimg-release-${ZIMG_VERSION}.tar.gz" "$ZIMG_SHA256" step freetype "$FREETYPE_VERSION" build_freetype step fribidi "$FRIBIDI_VERSION" build_fribidi step harfbuzz "$HARFBUZZ_VERSION" build_harfbuzz step libass "$LIBASS_VERSION" build_libass step zimg "$ZIMG_VERSION" build_zimg step ffmpeg "$FFMPEG_VERSION" build_ffmpeg install_binaries install_licenses write_source_record verify T1=$(date +%s) log "done in $((T1 - T0)) s" ls -l "$BIN_DIR/ffmpeg" "$BIN_DIR/ffprobe"