diff --git a/.github/workflows/_meta_mac_portable.yaml b/.github/workflows/_meta_mac_portable.yaml new file mode 100644 index 00000000000..8f34139a0bf --- /dev/null +++ b/.github/workflows/_meta_mac_portable.yaml @@ -0,0 +1,108 @@ +on: + workflow_call: + inputs: + release: + required: false + default: false + type: boolean + secrets: + deploy-host: + required: false + deploy-user: + required: false + deploy-key: + required: false + +jobs: + build: + name: 'Build Portable FFmpeg' + runs-on: ${{ matrix.os.name }} + strategy: + fail-fast: true + matrix: + # Currently, macOS 12 is x86 exclusive and macOS 14 is arm exclusive and we have no other way to specify arch + os: + - name: macos-12 + arch: x86_64 + - name: macos-14 + arch: arm64 + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Set up Homebrew + id: set-up-homebrew + uses: Homebrew/actions/setup-homebrew@master + + - name: Prepare prefix dir + run: | + sudo mkdir /opt/ffbuild + sudo chmod 777 /opt/ffbuild + + - name: Build Portable + run: ./builder/buildmac.sh + + - name: Upload Artifacts + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + with: + name: mac-${{ matrix.os.arch }}-portable + path: ./builder/artifacts + + publish: + name: Publish Portable Release + if: ${{ inputs.release }} + runs-on: ubuntu-latest + needs: + - build + strategy: + fail-fast: true + matrix: + arch: [arm64, x86_64] + + steps: + - name: Set Versions + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + id: set_version + with: + script: | + const tag = context.ref.substring(10) + const no_v = tag.replace('v', '') + const dash_index = no_v.lastIndexOf('-') + const no_dash = (dash_index > -1) ? no_v.substring(0, dash_index) : no_v + core.setOutput('tag', tag) + core.setOutput('no-v', no_v) + core.setOutput('no-dash', no_dash) + + - name: Download Artifacts + uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 + with: + name: mac-${{ matrix.arch }}-portable + path: artifact + + - name: Upload GH Release Assets + uses: shogo82148/actions-upload-release-asset@c91b7fd867cf280772374042252f0dc8e1ade751 # v1.7.3 + with: + upload_url: ${{ github.event.release.upload_url }} + overwrite: true + asset_path: | + ./artifact/**/*.tar.xz + ./artifact/**/*.sha256sum + + - name: Make Sure FFmpeg Directory Exists + uses: appleboy/ssh-action@029f5b4aeeeb58fdfe1410a5d17f967dacf36262 # v1.0.3 + with: + host: ${{ secrets.deploy-host }} + username: ${{ secrets.deploy-user }} + key: ${{ secrets.deploy-key }} + script_stop: true + script: |- + mkdir -p /srv/repository/releases/ffmpeg/${{ steps.set_version.outputs.no-v }}/ + + - name: Upload Release Assets + uses: burnett01/rsync-deployments@45d84ad5f6c174f3e0ffc50e9060a9666d09c16e # 6.0.0 + with: + switches: -vrptz + path: ./artifact/* + remote_path: /srv/repository/releases/ffmpeg/${{ steps.set_version.outputs.no-v }}/ + remote_host: ${{ secrets.deploy-host }} + remote_user: ${{ secrets.deploy-user }} + remote_key: ${{ secrets.deploy-key }} diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ed86dc9a4d5..22c33f720fe 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -47,3 +47,8 @@ jobs: os: 'linux' architectures: '["amd64", "arm64"]' release: false + + build_portable_mac: + uses: ./.github/workflows/_meta_mac_portable.yaml + with: + release: false diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 434b283b349..06dd8521391 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -52,6 +52,15 @@ jobs: deploy-user: ${{ secrets.DEPLOY_USER }} deploy-key: ${{ secrets.DEPLOY_KEY }} + build_publish_mac_portable: + uses: ./.github/workflows/_meta_mac_portable.yaml + with: + release: true + secrets: + deploy-host: ${{ secrets.DEPLOY_HOST }} + deploy-user: ${{ secrets.DEPLOY_USER }} + deploy-key: ${{ secrets.DEPLOY_KEY }} + maintain_repository: name: Maintain Repository runs-on: ubuntu-latest diff --git a/builder/Buildmac.md b/builder/Buildmac.md new file mode 100644 index 00000000000..0130e798a6d --- /dev/null +++ b/builder/Buildmac.md @@ -0,0 +1,64 @@ +# jellyfin-ffmpeg portable versions builder for mac + +Portable versions builder of jellyfin-ffmpeg for macOS. + +This script is generally made for GitHub Actions' CI runner, and there will be some caveats when running it locally. + +A significant limitation is that this script will mutate files in a way that prevents the script from being executed multiple times on a non-clean environment. Follow the instructions below to work with it. + +## Package List + +For a list of included dependencies check the `scripts.d` directory. +Every file corresponds to its respective package. + +For macOS, there will be additionally packages located in `images/macos` as extra static libs. The `00-dep.sh` will also setup necessary environment on a GitHub Runner. You can modify or remove it if you find it unnecessary. + +## How to make a build + +### Prerequisites + +* **[Homebrew](https://brew.sh)**: Make sure Homebrew is installed and set up on your system. +* **[Xcode](https://developer.apple.com/xcode/)**: Ensure that Xcode is installed and properly configured. It's essential to have the full Xcode installation as simply installing the command line toolchain won't include the Metal SDK required for ffmpeg. + - **Verification**: To verify that you have the Metal SDK ready, run the command `xcrun -sdk macosx metal -v`. This command should display version information about the installed Metal SDK. If you encounter an error message such as `xcrun: error: unable to find utility "metal", not a developer tool or in PATH`, it indicates that the incorrect toolchain is selected. In such cases, manually select the Xcode toolchain by running the following command: + ``` + sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer + ``` + +### Prepare Prefix Directory + +You will need to prepare a directory to install all the libraries to. The default is `/opt/ffbuild/prefix`, which is defined in `buildmac.sh` as `FFBUILD_PREFIX`. You can either create this folder manually and give permission to the user who runs the builder, or you can modify that value to point it to another folder. + +### Run Builder + +Once you have your environment set up, you can simply run `buildmac.sh`, and it will download libraries and start building. This may take some time, so please be patient. + +Generated artifacts will be stored to `artifacts` folder. + +### Prepare for next running. + +To run another clean build, the easiest way is to remove the `FFBUILD_PREFIX` folder, and then remove `jellyfin-ffmpeg` and re-clone the repo. + +If you don't want to rebuild all the dependencies, you can keep the `FFBUILD_PREFIX` folder and remove/comment out the following lines: + +```shell +mkdir build +for macbase in images/macos/*.sh; do + cd "$BUILDER_ROOT"/build + source "$BUILDER_ROOT"/"$macbase" + ffbuild_macbase || exit $? +done + +cd "$BUILDER_ROOT" +for lib in scripts.d/*.sh; do + cd "$BUILDER_ROOT"/build + source "$BUILDER_ROOT"/"$lib" + ffbuild_enabled || continue + ffbuild_dockerbuild || exit $? +done +``` + +At this point, the repository could have our patches applied. You want to restore it with `quilt pop -af` before the next run. + +## Known issue + +- If you are on an Intel Mac and have `libx11` installed with Homebrew, ffmpeg will link to Homebrew's `libx11`, making your generated binary non-portable. We work around this on GitHub's Runner by removing all installed packages that use `libx11`. diff --git a/builder/README.md b/builder/README.md index 0951587d4df..26d91a46d1a 100644 --- a/builder/README.md +++ b/builder/README.md @@ -2,6 +2,8 @@ Portable versions builder of jellyfin-ffmpeg for Windows and Linux. +For macOS build instructions, please refer to [this documentation](./Buildmac.md). + ## Package List For a list of included dependencies check the `scripts.d` directory. diff --git a/builder/buildmac.sh b/builder/buildmac.sh new file mode 100755 index 00000000000..9d412a2cbb2 --- /dev/null +++ b/builder/buildmac.sh @@ -0,0 +1,118 @@ +#!/bin/bash +set -xe +cd "$(dirname "$0")" +export BUILDER_ROOT="$(pwd)" +export FFBUILD_PREFIX="/opt/ffbuild/prefix" + +get_output() { + ( + SELF="$1" + source $1 + if ffbuild_enabled; then + ffbuild_$2 || exit 0 + else + ffbuild_un$2 || exit 0 + fi + ) +} + +arch=$(uname -m) +TARGET="macarm64" +VARIANT="gpl" +if [ "$arch" = "arm64" ]; then + TARGET="macarm64" +elif [ "$arch" = "x86_64" ]; then + TARGET="mac64" +else + echo "Unknown architecture" + exit 1 +fi + +source "variants/${TARGET}-gpl.sh" + +for addin in ${ADDINS[*]}; do + source "addins/${addin}.sh" +done + +for script in scripts.d/*.sh; do + FF_CONFIGURE+=" $(get_output $script configure)" + FF_CFLAGS+=" $(get_output $script cflags)" + FF_CXXFLAGS+=" $(get_output $script cxxflags)" + FF_LDFLAGS+=" $(get_output $script ldflags)" + FF_LDEXEFLAGS+=" $(get_output $script ldexeflags)" + FF_LIBS+=" $(get_output $script libs)" +done + +FF_CONFIGURE="$(xargs <<< "$FF_CONFIGURE")" +FF_CFLAGS="$(xargs <<< "$FF_CFLAGS")" +FF_CXXFLAGS="$(xargs <<< "$FF_CXXFLAGS")" +FF_LDFLAGS="$(xargs <<< "$FF_LDFLAGS")" +FF_LDEXEFLAGS="$(xargs <<< "$FF_LDEXEFLAGS")" +FF_LIBS="$(xargs <<< "$FF_LIBS")" +FF_HOST_CFLAGS="$(xargs <<< "$FF_HOST_CFLAGS")" +FF_HOST_LDFLAGS="$(xargs <<< "$FF_HOST_LDFLAGS")" +FFBUILD_TARGET_FLAGS="$(xargs <<< "$FFBUILD_TARGET_FLAGS")" + +mkdir build +for macbase in images/macos/*.sh; do + cd "$BUILDER_ROOT"/build + source "$BUILDER_ROOT"/"$macbase" + ffbuild_macbase || exit $? +done + +cd "$BUILDER_ROOT" +for lib in scripts.d/*.sh; do + cd "$BUILDER_ROOT"/build + source "$BUILDER_ROOT"/"$lib" + ffbuild_enabled || continue + ffbuild_dockerbuild || exit $? +done + +cd "$BUILDER_ROOT" +cd .. +if [[ -f "debian/patches/series" ]]; then + ln -s debian/patches patches + quilt push -a +fi + +./configure --prefix=/ffbuild/prefix \ + $FFBUILD_TARGET_FLAGS \ + --host-cflags="$FF_HOST_CFLAGS" \ + --host-ldflags="$FF_HOST_LDFLAGS" \ + --extra-version="Jellyfin" \ + --extra-cflags="$FF_CFLAGS" \ + --extra-cxxflags="$FF_CXXFLAGS" \ + --extra-ldflags="$FF_LDFLAGS" \ + --extra-ldexeflags="$FF_LDEXEFLAGS" \ + --extra-libs="$FF_LIBS" \ + $FF_CONFIGURE +make -j$(nproc) V=1 + +# We have to manually match lines to get version as there will be no dpkg-parsechangelog on macOS +PKG_VER=0.0.0 +while IFS= read -r line; do + if [[ $line == jellyfin-ffmpeg* ]]; then + if [[ $line =~ \(([^\)]+)\) ]]; then + PKG_VER="${BASH_REMATCH[1]}" + break + fi + fi +done < "$BUILDER_ROOT"/../debian/changelog + +PKG_NAME="jellyfin-ffmpeg_${PKG_VER}_portable_${TARGET}-${VARIANT}${ADDINS_STR:+-}${ADDINS_STR}" +ARTIFACTS_PATH="$BUILDER_ROOT"/artifacts +OUTPUT_FNAME="${PKG_NAME}.tar.xz" +cd "$BUILDER_ROOT" +mkdir -p artifacts +# bsdtar can add files in parent dir, but macOS's native archive utility won't be able to unzip it by double clicking, we have to move it to current dir as a workaround +mv ../ffmpeg ./ +mv ../ffprobe ./ +tar -cJf "${ARTIFACTS_PATH}/${OUTPUT_FNAME}" ffmpeg ffprobe +cd "${ARTIFACTS_PATH}" +sha256sum ./${OUTPUT_FNAME} > ./${OUTPUT_FNAME}.sha256sum +cd "$BUILDER_ROOT"/.. + +if [[ -n "$GITHUB_ACTIONS" ]]; then + echo "build_name=${BUILD_NAME}" >> "$GITHUB_OUTPUT" + echo "${OUTPUT_FNAME}" > "${ARTIFACTS_PATH}/${TARGET}-${VARIANT}${ADDINS_STR:+-}${ADDINS_STR}.txt" +fi diff --git a/builder/images/macos/00-dep.sh b/builder/images/macos/00-dep.sh new file mode 100644 index 00000000000..45338b118d6 --- /dev/null +++ b/builder/images/macos/00-dep.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +ffbuild_macbase() { + if [[ $TARGET == mac64 ]]; then + # For unknown reason ffmpeg insist to link to against libx11 and is hard to debug + # It does not link against libx11 on arm64, which is strange + # Remove everything using libx11 on github's x86 macOS host as a workaround + brew uninstall ant cairo gradle harfbuzz kotlin libxext libxft libxrender maven openjdk r sbt selenium-server libx11 + fi + brew install wget subversion mercurial autoconf automake cmake meson ninja pkg-config coreutils gcc make python-setuptools pcre2 libtool gnu-sed gnu-tar nasm quilt + mkdir /opt/ffbuild/bin + cp "$BUILDER_ROOT"/images/base/git-mini-clone.sh /opt/ffbuild/bin/git-mini-clone + chmod +x /opt/ffbuild/bin/git-mini-clone + cp "$BUILDER_ROOT"/images/base/retry-tool.sh /opt/ffbuild/bin/retry-tool + chmod +x /opt/ffbuild/bin/retry-tool + cp "$BUILDER_ROOT"/images/base/check-wget.sh /opt/ffbuild/bin/check-wget + chmod +x /opt/ffbuild/bin/check-wget + export PATH="/opt/ffbuild/bin:$PATH" +} diff --git a/builder/images/macos/01-gettext.sh b/builder/images/macos/01-gettext.sh new file mode 100644 index 00000000000..257e177adea --- /dev/null +++ b/builder/images/macos/01-gettext.sh @@ -0,0 +1,9 @@ +#!/bin/bash +ffbuild_macbase() { + wget https://ftpmirror.gnu.org/gettext/gettext-0.22.5.tar.gz -O gettext.tar.gz + tar xvf gettext.tar.gz + cd gettext-0.22.5 + ./configure --disable-silent-rules --disable-shared --enable-static --with-included-glib --with-included-libcroco --with-included-libunistring --with-included-libxml --with-emacs --with-lispdir="$FFBUILD_PREFIX"/share --disable-java --disable-csharp --without-git --without-cvs --without-xz --with-included-gettext --prefix="$FFBUILD_PREFIX" + make -j$(nproc) + make install +} diff --git a/builder/images/macos/02-pcre2.sh b/builder/images/macos/02-pcre2.sh new file mode 100644 index 00000000000..40e30cf8384 --- /dev/null +++ b/builder/images/macos/02-pcre2.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Although newer macOS has libpcre built-in, it is absent on macOS12 +ffbuild_macbase() { + wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.bz2 + tar xvf pcre2-10.42.tar.bz2 + cd pcre2-10.42 + ./configure --prefix="$FFBUILD_PREFIX" \ + --disable-shared \ + --enable-static \ + --disable-dependency-tracking \ + --enable-pcre2-16 \ + --enable-pcre2-32 \ + --enable-pcre2grep-libz \ + --enable-pcre2grep-libbz2 \ + --enable-jit + make -j$(nproc) + make install +} diff --git a/builder/images/macos/03-glib2.sh b/builder/images/macos/03-glib2.sh new file mode 100644 index 00000000000..8b6ef03b0ad --- /dev/null +++ b/builder/images/macos/03-glib2.sh @@ -0,0 +1,20 @@ +#!/bin/bash +ffbuild_macbase() { + wget https://download.gnome.org/sources/glib/2.78/glib-2.78.4.tar.xz + tar xvf glib-2.78.4.tar.xz + cd glib-2.78.4 + meson setup build --default-library=both \ + --localstatedir="$FFBUILD_PREFIX"/var \ + -Dgio_module_dir="$FFBUILD_PREFIX"/lib/gio/modules \ + -Dbsymbolic_functions=false \ + -Ddtrace=false \ + -Druntime_dir="$FFBUILD_PREFIX"/var/run \ + -Dtests=false \ + --prefix="$FFBUILD_PREFIX" \ + --buildtype=release \ + --default-library=static + + sed -i '' 's/MacOSX11\.sdk/MacOSX\.sdk/g' build/build.ninja + meson compile -C build --verbose + meson install -C build +} diff --git a/builder/images/macos/04-brotli.sh b/builder/images/macos/04-brotli.sh new file mode 100644 index 00000000000..a4f58e241c0 --- /dev/null +++ b/builder/images/macos/04-brotli.sh @@ -0,0 +1,22 @@ +#!/bin/bash +ffbuild_macbase() { + wget https://github.com/google/brotli/archive/refs/tags/v1.1.0.tar.gz -O broti.tar.gz + tar xvf broti.tar.gz + cd brotli-1.1.0 + + # Google hardcodes their libs to be dynamic and does not horner -DENABLE_STATIC=ON + sed -i '' 's/add_library(brotlicommon/add_library(brotlicommon STATIC/' CMakeLists.txt + sed -i '' 's/add_library(brotlidec/add_library(brotlidec STATIC/' CMakeLists.txt + sed -i '' 's/add_library(brotlienc/add_library(brotlienc STATIC/' CMakeLists.txt + + mkdir build + cd build + + cmake ../ -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_SHARED=OFF \ + -DENABLE_STATIC=ON \ + -DBUILD_STATIC_LIBS=ON + make -j$(nproc) + make install +} diff --git a/builder/images/macos/05-libpng.sh b/builder/images/macos/05-libpng.sh new file mode 100644 index 00000000000..5f2918572b2 --- /dev/null +++ b/builder/images/macos/05-libpng.sh @@ -0,0 +1,13 @@ +#!/bin/bash +ffbuild_macbase() { + git clone https://github.com/glennrp/libpng.git + cd libpng + git checkout v1.6.43 + mkdir build + cd build + + cmake -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DPNG_ARM_NEON=on -DPNG_INTEL_SSE=on -DPNG_SHARED=OFF -DPNG_EXECUTABLES=OFF -DPNG_TESTS=OFF ../ + + make -j$(nproc) + make install +} diff --git a/builder/images/macos/06-libunibreak.sh b/builder/images/macos/06-libunibreak.sh new file mode 100644 index 00000000000..e5e82a27f70 --- /dev/null +++ b/builder/images/macos/06-libunibreak.sh @@ -0,0 +1,12 @@ +#!/bin/bash +ffbuild_macbase() { + wget https://github.com/adah1972/libunibreak/releases/download/libunibreak_5_1/libunibreak-5.1.tar.gz -O libunibreadk.tar.gz + tar xvf libunibreadk.tar.gz + cd libunibreak-5.1 + ./configure --prefix="$FFBUILD_PREFIX" \ + --disable-shared \ + --enable-static \ + --disable-silent-rules + make -j$(nproc) + make install +} diff --git a/builder/scripts.d/20-libiconv.sh b/builder/scripts.d/20-libiconv.sh index 2532b374bbb..f2083e22d9b 100755 --- a/builder/scripts.d/20-libiconv.sh +++ b/builder/scripts.d/20-libiconv.sh @@ -9,6 +9,9 @@ ffbuild_enabled() { } ffbuild_dockerbuild() { + # iconv is macOS built-in + [[ $TARGET == mac* ]] && return 0 + git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" iconv cd iconv @@ -19,7 +22,6 @@ ffbuild_dockerbuild() { EOF ./gitsub.sh pull - ./autogen.sh local myconf=( --prefix="$FFBUILD_PREFIX" @@ -38,6 +40,7 @@ EOF return -1 fi + ./autogen.sh ./configure "${myconf[@]}" make -j$(nproc) make install diff --git a/builder/scripts.d/20-libxml2.sh b/builder/scripts.d/20-libxml2.sh index 334e077e496..3cf0978e1c5 100755 --- a/builder/scripts.d/20-libxml2.sh +++ b/builder/scripts.d/20-libxml2.sh @@ -8,6 +8,9 @@ ffbuild_enabled() { } ffbuild_dockerbuild() { + # libxml2 is macOS built-in + [[ $TARGET == mac* ]] && return 0 + git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" libxml2 cd libxml2 diff --git a/builder/scripts.d/20-zlib.sh b/builder/scripts.d/20-zlib.sh index 12d1abc8d70..fe09d68f94a 100755 --- a/builder/scripts.d/20-zlib.sh +++ b/builder/scripts.d/20-zlib.sh @@ -19,6 +19,8 @@ ffbuild_dockerbuild() { if [[ $TARGET == win* || $TARGET == linux* ]]; then export CC="${FFBUILD_CROSS_PREFIX}gcc" export AR="${FFBUILD_CROSS_PREFIX}ar" + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/25-fftw3f.sh b/builder/scripts.d/25-fftw3f.sh index 3a54d32ae6f..faa9f303c17 100755 --- a/builder/scripts.d/25-fftw3f.sh +++ b/builder/scripts.d/25-fftw3f.sh @@ -10,7 +10,14 @@ ffbuild_enabled() { } ffbuild_dockerbuild() { - git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT_PINNED" fftw3f + if [[ $TARGET != mac* ]]; then + git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT_PINNED" fftw3f + else + # The git does not build on macOS + retry-tool check-wget "fftw-3.3.10.tar.gz" "http://fftw.org/fftw-3.3.10.tar.gz" "2d34b5ccac7b08740dbdacc6ebe451d8a34cf9d9bfec85a5e776e87adf94abfd803c222412d8e10fbaa4ed46f504aa87180396af1b108666cde4314a55610b40" + tar xvf fftw-3.3.10.tar.gz + mv fftw-3.3.10 fftw3f + fi cd fftw3f local myconf=( @@ -45,12 +52,21 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 fi ./bootstrap.sh "${myconf[@]}" - make -j$(nproc) - make install + if [[ $TARGET == mac* ]]; then + sed -i '' 's/CC = gcc/CC = gcc-13/' Makefile + sed -i '' 's/CPP = gcc/CPP = gcc-13/' Makefile + gmake -j$(nproc) + gmake install + else + make -j$(nproc) + make install + fi } diff --git a/builder/scripts.d/25-freetype.sh b/builder/scripts.d/25-freetype.sh index 5face368905..440503bc9d8 100755 --- a/builder/scripts.d/25-freetype.sh +++ b/builder/scripts.d/25-freetype.sh @@ -23,6 +23,8 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 @@ -31,6 +33,11 @@ ffbuild_dockerbuild() { ./configure "${myconf[@]}" make -j$(nproc) make install + + # freetype2 does not link to macOS built-in iconv in its pkgconfig, add it + if [[ $TARGET == mac* ]]; then + sed -i '' '/^Libs:/ s/$/ -liconv/' "$FFBUILD_PREFIX"/lib/pkgconfig/freetype2.pc + fi } ffbuild_configure() { diff --git a/builder/scripts.d/25-fribidi.sh b/builder/scripts.d/25-fribidi.sh index 252ac26c110..34cafdbcaec 100755 --- a/builder/scripts.d/25-fribidi.sh +++ b/builder/scripts.d/25-fribidi.sh @@ -26,6 +26,8 @@ ffbuild_dockerbuild() { myconf+=( --cross-file=/cross.meson ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 @@ -35,7 +37,11 @@ ffbuild_dockerbuild() { ninja -j$(nproc) ninja install - sed -i 's/Cflags:/Cflags: -DFRIBIDI_LIB_STATIC/' "$FFBUILD_PREFIX"/lib/pkgconfig/fribidi.pc + if [[ $TARGET == mac* ]]; then + gsed -i 's/Cflags:/Cflags: -DFRIBIDI_LIB_STATIC/' "$FFBUILD_PREFIX"/lib/pkgconfig/fribidi.pc + else + sed -i 's/Cflags:/Cflags: -DFRIBIDI_LIB_STATIC/' "$FFBUILD_PREFIX"/lib/pkgconfig/fribidi.pc + fi } ffbuild_configure() { diff --git a/builder/scripts.d/25-gmp.sh b/builder/scripts.d/25-gmp.sh index bcdd1d37b67..8d1be489867 100755 --- a/builder/scripts.d/25-gmp.sh +++ b/builder/scripts.d/25-gmp.sh @@ -11,7 +11,11 @@ ffbuild_enabled() { ffbuild_dockerbuild() { retry-tool check-wget "gmp.tar.xz" "$SCRIPT_URL" "$SCRIPT_SHA512" - tar xaf "gmp.tar.xz" + if [[ $TARGET == mac* ]]; then + gtar xaf "gmp.tar.xz" + else + tar xaf "gmp.tar.xz" + fi cd "gmp-$SCRIPT_VERSION" local myconf=( @@ -26,6 +30,15 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + myconf+=( + --enable-cxx + ) + # The shipped configure script relies on an outdated libtool version + # which causes linker errors due to name collisions on macOS + # leads to wrongly compiled libraries + # regenerate the configure ourselves as a workaroud + autoreconf -i -s else echo "Unknown target" return -1 diff --git a/builder/scripts.d/25-libogg.sh b/builder/scripts.d/25-libogg.sh index 5b482323d71..cd11088ed31 100755 --- a/builder/scripts.d/25-libogg.sh +++ b/builder/scripts.d/25-libogg.sh @@ -24,6 +24,8 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/25-openssl.sh b/builder/scripts.d/25-openssl.sh index 77d0b02e117..3f8f342f07b 100755 --- a/builder/scripts.d/25-openssl.sh +++ b/builder/scripts.d/25-openssl.sh @@ -49,6 +49,8 @@ ffbuild_dockerbuild() { --cross-compile-prefix="$FFBUILD_CROSS_PREFIX" linux-aarch64 ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 @@ -57,18 +59,27 @@ ffbuild_dockerbuild() { export CFLAGS="$CFLAGS -fno-strict-aliasing" export CXXFLAGS="$CXXFLAGS -fno-strict-aliasing" - # OpenSSL build system prepends the cross prefix itself - export CC="${CC/${FFBUILD_CROSS_PREFIX}/}" - export CXX="${CXX/${FFBUILD_CROSS_PREFIX}/}" - export AR="${AR/${FFBUILD_CROSS_PREFIX}/}" - export RANLIB="${RANLIB/${FFBUILD_CROSS_PREFIX}/}" + if [[ $TARGET == mac* ]]; then + gsed -i '/^my @disablables =/ s/$/"apps",/' Configure + else + # OpenSSL build system prepends the cross prefix itself + export CC="${CC/${FFBUILD_CROSS_PREFIX}/}" + export CXX="${CXX/${FFBUILD_CROSS_PREFIX}/}" + export AR="${AR/${FFBUILD_CROSS_PREFIX}/}" + export RANLIB="${RANLIB/${FFBUILD_CROSS_PREFIX}/}" - # Actually allow Configure to disable apps - sed -i '/^my @disablables =/ s/$/"apps",/' Configure + # Actually allow Configure to disable apps + sed -i '/^my @disablables =/ s/$/"apps",/' Configure + fi ./Configure "${myconf[@]}" - sed -i -e "/^CFLAGS=/s|=.*|=${CFLAGS}|" -e "/^LDFLAGS=/s|=[[:space:]]*$|=${LDFLAGS}|" Makefile + if [[ $TARGET == mac* ]]; then + gsed -i -e "/^CFLAGS=/s|=.*|=${CFLAGS}|" -e "/^LDFLAGS=/s|=[[:space:]]*$|=${LDFLAGS}|" Makefile + else + sed -i -e "/^CFLAGS=/s|=.*|=${CFLAGS}|" -e "/^LDFLAGS=/s|=[[:space:]]*$|=${LDFLAGS}|" Makefile + + fi make -j$(nproc) build_sw make install_sw diff --git a/builder/scripts.d/25-xz.sh b/builder/scripts.d/25-xz.sh index e51cf0556fb..5d422710bea 100755 --- a/builder/scripts.d/25-xz.sh +++ b/builder/scripts.d/25-xz.sh @@ -25,6 +25,8 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/35-fontconfig.sh b/builder/scripts.d/35-fontconfig.sh index 540734e43f5..8bce05189f5 100755 --- a/builder/scripts.d/35-fontconfig.sh +++ b/builder/scripts.d/35-fontconfig.sh @@ -11,7 +11,11 @@ ffbuild_dockerbuild() { git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" fc cd fc - ./autogen.sh --noconf + if [[ $TARGET == mac* ]]; then + autoreconf -iv + else + ./autogen.sh --noconf + fi local myconf=( --prefix="$FFBUILD_PREFIX" @@ -32,6 +36,9 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + # freetype's pkg-config usage cannot find static libbrotli + export FREETYPE_LIBS="$(pkg-config --libs --static freetype2)" else echo "Unknown target" return -1 @@ -40,6 +47,10 @@ ffbuild_dockerbuild() { ./configure "${myconf[@]}" make -j$(nproc) make install + # Manually tell it to link against macOS builtin and static libintl + if [[ $TARGET == mac* ]]; then + sed -i '' '/^Libs:/ s/$/ -lintl -framework CoreFoundation/' "$FFBUILD_PREFIX"/lib/pkgconfig/fontconfig.pc + fi } ffbuild_configure() { diff --git a/builder/scripts.d/45-harfbuzz.sh b/builder/scripts.d/45-harfbuzz.sh index f10f718eccf..edcb4eabf0d 100755 --- a/builder/scripts.d/45-harfbuzz.sh +++ b/builder/scripts.d/45-harfbuzz.sh @@ -22,6 +22,9 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + # freetype's pkg-config usage cannot find static libbrotli + export FREETYPE_LIBS="$(pkg-config --libs --static freetype2)" else echo "Unknown target" return -1 diff --git a/builder/scripts.d/45-libudfread.sh b/builder/scripts.d/45-libudfread.sh index e46ea843403..41803422d4e 100755 --- a/builder/scripts.d/45-libudfread.sh +++ b/builder/scripts.d/45-libudfread.sh @@ -24,6 +24,8 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/45-libvorbis.sh b/builder/scripts.d/45-libvorbis.sh index 14994314c80..5f4443e92b1 100755 --- a/builder/scripts.d/45-libvorbis.sh +++ b/builder/scripts.d/45-libvorbis.sh @@ -24,6 +24,9 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + # This only make sense for PowerPC + sed -i '' 's/-force_cpusubtype_ALL//g' ./configure else echo "Unknown target" return -1 diff --git a/builder/scripts.d/45-opencl.sh b/builder/scripts.d/45-opencl.sh index 0ff3fffc20b..b39b2f3bfa0 100755 --- a/builder/scripts.d/45-opencl.sh +++ b/builder/scripts.d/45-opencl.sh @@ -11,6 +11,9 @@ ffbuild_enabled() { } ffbuild_dockerbuild() { + # OpenCL headers are macOS built-in + [[ $TARGET == mac* ]] && return 0 + mkdir opencl && cd opencl git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" headers diff --git a/builder/scripts.d/50-amf.sh b/builder/scripts.d/50-amf.sh index 9217bf5b2be..fc378f2dc8a 100755 --- a/builder/scripts.d/50-amf.sh +++ b/builder/scripts.d/50-amf.sh @@ -4,6 +4,7 @@ SCRIPT_REPO="https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git" SCRIPT_COMMIT="8787d3ef5d938425d094170c1b2fec87762683b6" ffbuild_enabled() { + [[ $TARGET == mac* ]] && return -1 [[ $TARGET == *arm64 ]] && return -1 return 0 } diff --git a/builder/scripts.d/50-chromaprint.sh b/builder/scripts.d/50-chromaprint.sh index 4b0024f66a3..01dc16df732 100755 --- a/builder/scripts.d/50-chromaprint.sh +++ b/builder/scripts.d/50-chromaprint.sh @@ -13,7 +13,12 @@ ffbuild_dockerbuild() { mkdir build && cd build - cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DBUILD_TOOLS=OFF -DBUILD_TESTS=OFF -DFFT_LIB=fftw3f .. + if [[ $TARGET == mac* ]]; then + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DBUILD_TOOLS=OFF -DBUILD_TESTS=OFF -DFFT_LIB=fftw3f .. + else + cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DBUILD_TOOLS=OFF -DBUILD_TESTS=OFF -DFFT_LIB=fftw3f .. + fi + make -j$(nproc) make install diff --git a/builder/scripts.d/50-dav1d.sh b/builder/scripts.d/50-dav1d.sh index df7f029cea4..9126da68253 100755 --- a/builder/scripts.d/50-dav1d.sh +++ b/builder/scripts.d/50-dav1d.sh @@ -23,6 +23,8 @@ ffbuild_dockerbuild() { myconf+=( --cross-file=/cross.meson ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/50-fdk-aac-stripped.sh b/builder/scripts.d/50-fdk-aac-stripped.sh index 444e14b76f5..8a7c1850ce0 100755 --- a/builder/scripts.d/50-fdk-aac-stripped.sh +++ b/builder/scripts.d/50-fdk-aac-stripped.sh @@ -4,6 +4,8 @@ SCRIPT_REPO="https://gitlab.freedesktop.org/wtaymans/fdk-aac-stripped.git" SCRIPT_COMMIT="585981a49f2186b0d2e47c64bf6b5abf539395f8" ffbuild_enabled() { + # Prefer AudioToolbox's AAC encoder on macOS + [[ $TARGET == mac* ]] && return -1 return 0 } @@ -25,6 +27,8 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/50-ffnvcodec.sh b/builder/scripts.d/50-ffnvcodec.sh index fac18e14085..3d262048bb3 100755 --- a/builder/scripts.d/50-ffnvcodec.sh +++ b/builder/scripts.d/50-ffnvcodec.sh @@ -4,6 +4,7 @@ SCRIPT_REPO="https://github.com/FFmpeg/nv-codec-headers.git" SCRIPT_COMMIT="451da99614412a7f9526ef301a5ee0c7a6f9ad76" ffbuild_enabled() { + [[ $TARGET == mac* ]] && return -1 [[ $TARGET == *arm64 ]] && return -1 return 0 } diff --git a/builder/scripts.d/50-libass.sh b/builder/scripts.d/50-libass.sh index b263164ff9d..4c72964bf7e 100755 --- a/builder/scripts.d/50-libass.sh +++ b/builder/scripts.d/50-libass.sh @@ -24,6 +24,8 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/50-libbluray.sh b/builder/scripts.d/50-libbluray.sh index 1e71eac0c76..ca3a01a6240 100755 --- a/builder/scripts.d/50-libbluray.sh +++ b/builder/scripts.d/50-libbluray.sh @@ -31,6 +31,10 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + myconf+=( + --disable-dependency-tracking + ) else echo "Unknown target" return -1 diff --git a/builder/scripts.d/50-libmp3lame.sh b/builder/scripts.d/50-libmp3lame.sh index 36d1b5abd18..8451e6841c7 100755 --- a/builder/scripts.d/50-libmp3lame.sh +++ b/builder/scripts.d/50-libmp3lame.sh @@ -28,6 +28,8 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/50-libopus.sh b/builder/scripts.d/50-libopus.sh index 69bd35e9c65..5750b52bfd6 100755 --- a/builder/scripts.d/50-libopus.sh +++ b/builder/scripts.d/50-libopus.sh @@ -24,6 +24,8 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/50-libtheora.sh b/builder/scripts.d/50-libtheora.sh index 11f5ac11455..59b1d2abe7a 100755 --- a/builder/scripts.d/50-libtheora.sh +++ b/builder/scripts.d/50-libtheora.sh @@ -29,6 +29,8 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/50-libvpl.sh b/builder/scripts.d/50-libvpl.sh index 090ec3717eb..2380a907924 100755 --- a/builder/scripts.d/50-libvpl.sh +++ b/builder/scripts.d/50-libvpl.sh @@ -4,6 +4,7 @@ SCRIPT_REPO="https://github.com/intel/libvpl.git" SCRIPT_COMMIT="18e890e7a5d6355306b8f1046b46c378ced453ff" ffbuild_enabled() { + [[ $TARGET == mac* ]] && return -1 [[ $TARGET == *arm64 ]] && return -1 return 0 } diff --git a/builder/scripts.d/50-libvpx.sh b/builder/scripts.d/50-libvpx.sh index 044cdf7b553..fb4d850c1ed 100755 --- a/builder/scripts.d/50-libvpx.sh +++ b/builder/scripts.d/50-libvpx.sh @@ -43,6 +43,8 @@ ffbuild_dockerbuild() { --target=arm64-linux-gcc ) export CROSS="$FFBUILD_CROSS_PREFIX" + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/50-libwebp.sh b/builder/scripts.d/50-libwebp.sh index efc98f344c1..36eb57535fa 100755 --- a/builder/scripts.d/50-libwebp.sh +++ b/builder/scripts.d/50-libwebp.sh @@ -33,6 +33,8 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/50-openmpt.sh b/builder/scripts.d/50-openmpt.sh index 9f307367dba..41df0ee69df 100755 --- a/builder/scripts.d/50-openmpt.sh +++ b/builder/scripts.d/50-openmpt.sh @@ -51,6 +51,10 @@ ffbuild_dockerbuild() { CONFIG=gcc TOOLCHAIN_PREFIX="$FFBUILD_CROSS_PREFIX" ) + elif [[ $TARGET == mac* ]]; then + myconf+=( + CONFIG=clang + ) else echo "Unknown target" return -1 diff --git a/builder/scripts.d/50-srt.sh b/builder/scripts.d/50-srt.sh index dab39180c30..05964732591 100755 --- a/builder/scripts.d/50-srt.sh +++ b/builder/scripts.d/50-srt.sh @@ -13,12 +13,19 @@ ffbuild_dockerbuild() { mkdir build && cd build - cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \ + if [[ $TARGET == mac* ]]; then + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \ -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DENABLE_CXX_DEPS=ON -DUSE_STATIC_LIBSTDCXX=ON -DENABLE_ENCRYPTION=ON -DENABLE_APPS=OFF .. + else + cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \ + -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DENABLE_CXX_DEPS=ON -DUSE_STATIC_LIBSTDCXX=ON -DENABLE_ENCRYPTION=ON -DENABLE_APPS=OFF .. + fi make -j$(nproc) make install - echo "Libs.private: -lstdc++" >> "$FFBUILD_PREFIX"/lib/pkgconfig/srt.pc + if [[ $TARGET != mac* ]]; then + echo "Libs.private: -lstdc++" >> "$FFBUILD_PREFIX"/lib/pkgconfig/srt.pc + fi } ffbuild_configure() { diff --git a/builder/scripts.d/50-svtav1.sh b/builder/scripts.d/50-svtav1.sh index ecbff4d3359..14027716ce3 100755 --- a/builder/scripts.d/50-svtav1.sh +++ b/builder/scripts.d/50-svtav1.sh @@ -13,9 +13,14 @@ ffbuild_dockerbuild() { cd svtav1 git checkout "$SCRIPT_COMMIT" - mkdir build && cd build + mkdir -p build && cd build - cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DBUILD_APPS=OFF -DENABLE_AVX512=ON .. + if [[ $TARGET == mac* ]]; then + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DBUILD_APPS=OFF -DENABLE_AVX512=ON .. + + else + cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DBUILD_APPS=OFF -DENABLE_AVX512=ON .. + fi make -j$(nproc) make install } diff --git a/builder/scripts.d/50-vulkan/45-vulkan.sh b/builder/scripts.d/50-vulkan/45-vulkan.sh index 5828b7eebe5..541a41f2324 100755 --- a/builder/scripts.d/50-vulkan/45-vulkan.sh +++ b/builder/scripts.d/50-vulkan/45-vulkan.sh @@ -5,6 +5,7 @@ SCRIPT_COMMIT="v1.3.276" SCRIPT_TAGFILTER="v?.*.*" ffbuild_enabled() { + [[ $TARGET == mac* ]] && return -1 return 0 } diff --git a/builder/scripts.d/50-vulkan/50-shaderc.sh b/builder/scripts.d/50-vulkan/50-shaderc.sh index 5f798511695..10fced4fa6c 100755 --- a/builder/scripts.d/50-vulkan/50-shaderc.sh +++ b/builder/scripts.d/50-vulkan/50-shaderc.sh @@ -4,6 +4,7 @@ SCRIPT_REPO="https://github.com/google/shaderc.git" SCRIPT_COMMIT="5b892551dd02bbf8704adbc3fcde2fd645f333b2" ffbuild_enabled() { + [[ $TARGET == mac* ]] && return -1 return 0 } diff --git a/builder/scripts.d/50-vulkan/55-spirv-cross.sh b/builder/scripts.d/50-vulkan/55-spirv-cross.sh index bfcec0c6ba1..ad57c2859de 100755 --- a/builder/scripts.d/50-vulkan/55-spirv-cross.sh +++ b/builder/scripts.d/50-vulkan/55-spirv-cross.sh @@ -4,6 +4,7 @@ SCRIPT_REPO="https://github.com/KhronosGroup/SPIRV-Cross.git" SCRIPT_COMMIT="03b485dc47c6e84a15936601e8b121d84d8ddadf" ffbuild_enabled() { + [[ $TARGET == mac* ]] && return -1 return 0 } diff --git a/builder/scripts.d/50-vulkan/60-libplacebo.sh b/builder/scripts.d/50-vulkan/60-libplacebo.sh index 889dfea755c..89daa350a2f 100755 --- a/builder/scripts.d/50-vulkan/60-libplacebo.sh +++ b/builder/scripts.d/50-vulkan/60-libplacebo.sh @@ -4,6 +4,7 @@ SCRIPT_REPO="https://code.videolan.org/videolan/libplacebo.git" SCRIPT_COMMIT="64c1954570f1cd57f8570a57e51fb0249b57bb90" ffbuild_enabled() { + [[ $TARGET == mac* ]] && return -1 return 0 } diff --git a/builder/scripts.d/50-x264.sh b/builder/scripts.d/50-x264.sh index e0e2f4f1ec6..2b66480262a 100755 --- a/builder/scripts.d/50-x264.sh +++ b/builder/scripts.d/50-x264.sh @@ -26,6 +26,8 @@ ffbuild_dockerbuild() { --host="$FFBUILD_TOOLCHAIN" --cross-prefix="$FFBUILD_CROSS_PREFIX" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/50-x265.sh b/builder/scripts.d/50-x265.sh index d61b4f81f7e..153a8dfa9f2 100755 --- a/builder/scripts.d/50-x265.sh +++ b/builder/scripts.d/50-x265.sh @@ -15,13 +15,18 @@ ffbuild_dockerbuild() { local common_config=( -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" - -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DCMAKE_ASM_NASM_FLAGS=-w-macro-params-legacy ) + if [[ $TARGET != mac* ]]; then + common_config+=( + -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" + ) + fi + if [[ $TARGET != *32 ]]; then mkdir 8bit 10bit 12bit cmake "${common_config[@]}" -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_HDR10_PLUS=ON -DMAIN12=ON -S source -B 12bit & @@ -45,6 +50,9 @@ EOF mv ../10bit/libx265.a ../8bit/libx265_main10.a mv libx265.a libx265_main.a + if [[ $TARGET == mac* ]]; then + libtool -static -o libx265.a libx265_main.a libx265_main10.a libx265_main12.a 2>/dev/null + else ${FFBUILD_CROSS_PREFIX}ar -M <> "$FFBUILD_PREFIX"/lib/pkgconfig/x265.pc + if [[ $TARGET != mac* ]]; then + echo "Libs.private: -lstdc++" >> "$FFBUILD_PREFIX"/lib/pkgconfig/x265.pc + fi } ffbuild_configure() { diff --git a/builder/scripts.d/50-zimg.sh b/builder/scripts.d/50-zimg.sh index c985a5cec07..1433226bed0 100755 --- a/builder/scripts.d/50-zimg.sh +++ b/builder/scripts.d/50-zimg.sh @@ -25,6 +25,8 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 diff --git a/builder/scripts.d/50-zvbi.sh b/builder/scripts.d/50-zvbi.sh index d0c803179ba..ee00941eda4 100755 --- a/builder/scripts.d/50-zvbi.sh +++ b/builder/scripts.d/50-zvbi.sh @@ -15,10 +15,18 @@ ffbuild_dockerbuild() { retry-tool sh -c "rm -rf zvbi && svn checkout '${SCRIPT_REPO}@${SCRIPT_REV}' zvbi" cd zvbi - for patch in /patches/*.patch; do - echo "Applying $patch" - patch -p1 < "$patch" - done + if [[ $TARGET == mac* ]]; then + rm -f "$BUILDER_ROOT"/patches/zvbi/0001-ioctl.patch + for patch in "$BUILDER_ROOT"/patches/zvbi/*.patch; do + echo "Applying $patch" + patch -p1 < "$patch" + done + else + for patch in /patches/*.patch; do + echo "Applying $patch" + patch -p1 < "$patch" + done + fi autoreconf -i @@ -39,6 +47,8 @@ ffbuild_dockerbuild() { myconf+=( --host="$FFBUILD_TOOLCHAIN" ) + elif [[ $TARGET == mac* ]]; then + : else echo "Unknown target" return -1 @@ -49,7 +59,11 @@ ffbuild_dockerbuild() { make -C src install make SUBDIRS=. install - sed -i "s/\/[^ ]*libiconv.a/-liconv/" "$FFBUILD_PREFIX"/lib/pkgconfig/zvbi-0.2.pc + if [[ $TARGET == mac* ]]; then + gsed -i "s/\/[^ ]*libiconv.a/-liconv/" "$FFBUILD_PREFIX"/lib/pkgconfig/zvbi-0.2.pc + else + sed -i "s/\/[^ ]*libiconv.a/-liconv/" "$FFBUILD_PREFIX"/lib/pkgconfig/zvbi-0.2.pc + fi } ffbuild_configure() { diff --git a/builder/variants/defaults-mac.sh b/builder/variants/defaults-mac.sh new file mode 100644 index 00000000000..fc94e114037 --- /dev/null +++ b/builder/variants/defaults-mac.sh @@ -0,0 +1,18 @@ +MACOS_MAJOR_VER="$(sw_vers -productVersion | awk -F '.' '{print $1}')" +XCODE_MAJOR_VER="$(xcodebuild -version | grep 'Xcode' | awk '{print $2}' | cut -d '.' -f 1)" + +FF_CFLAGS+="-I"$FFBUILD_PREFIX"/include" +FF_LDFLAGS+="-L"$FFBUILD_PREFIX"/lib" +FF_CONFIGURE+=" --disable-libjack --disable-indev=jack --enable-neon --enable-runtime-cpudetect --enable-audiotoolbox --enable-videotoolbox" +FFBUILD_TARGET_FLAGS="--disable-shared --enable-static --pkg-config-flags=\"--static\" --enable-pthreads --cc=clang" +FF_HOST_CFLAGS="-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I"$FFBUILD_PREFIX"/include" +FF_HOST_LDFLAGS="" +if [ $XCODE_MAJOR_VER -ge 15 ]; then + FF_HOST_LDFLAGS+="-Wl,-ld_classic " + export LDFLAGS="-Wl,-ld_classic" +fi +FF_HOST_LDFLAGS+="-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -L"$FFBUILD_PREFIX"/lib" +export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig:/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/$MACOS_MAJOR_VER:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/$MACOS_MAJOR_VER" +export CMAKE_PREFIX_PATH=""$FFBUILD_PREFIX"" +export PKG_CONFIG_PATH=""$FFBUILD_PREFIX"/lib/pkgconfig" +export RANLIB="/usr/bin/ranlib" diff --git a/builder/variants/mac64-gpl.sh b/builder/variants/mac64-gpl.sh new file mode 100755 index 00000000000..0e018cfb349 --- /dev/null +++ b/builder/variants/mac64-gpl.sh @@ -0,0 +1,4 @@ +#!/bin/bash +source "$(dirname "$BASH_SOURCE")"/default-install.sh +source "$(dirname "$BASH_SOURCE")"/defaults-gpl.sh +source "$(dirname "$BASH_SOURCE")"/defaults-mac.sh diff --git a/builder/variants/macarm64-gpl.sh b/builder/variants/macarm64-gpl.sh new file mode 100755 index 00000000000..0e018cfb349 --- /dev/null +++ b/builder/variants/macarm64-gpl.sh @@ -0,0 +1,4 @@ +#!/bin/bash +source "$(dirname "$BASH_SOURCE")"/default-install.sh +source "$(dirname "$BASH_SOURCE")"/defaults-gpl.sh +source "$(dirname "$BASH_SOURCE")"/defaults-mac.sh