mirror of
https://github.com/jellyfin/jellyfin-ffmpeg.git
synced 2026-09-03 05:09:58 +03:00
feat: macOS build scripts
This commit is contained in:
Executable
+73
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
set -xe
|
||||
cd "$(dirname "$0")"
|
||||
#source util/vars.sh
|
||||
|
||||
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
|
||||
|
||||
export FFBUILD_PREFIX="/opt/ffbuild/prefix"
|
||||
|
||||
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")"
|
||||
|
||||
cd ..
|
||||
if [[ -f "debian/patches/series" ]]; then
|
||||
ln -s /ffbuild/ffmpeg/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
|
||||
@@ -0,0 +1,9 @@
|
||||
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
|
||||
cp ./images/base/git-mini-clone.sh /usr/local/bin/git-mini-clone
|
||||
chmod +x /usr/local/bin/git-mini-clone
|
||||
cp ./images/base/retry-tool.sh /usr/local/bin/retry-tool
|
||||
chmod +x /usr/local/bin/retry-tool
|
||||
cp ./images/base/check-wget.sh /usr/local/bin/check-wget
|
||||
chmod +x /usr/local/bin/check-wget
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
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=/opt/ffbuild/prefix/var \
|
||||
-Dgio_module_dir=/opt/ffbuild/prefix/lib/gio/modules \
|
||||
-Dbsymbolic_functions=false \
|
||||
-Ddtrace=false \
|
||||
-Druntime_dir=/opt/ffbuild/prefix/var/run \
|
||||
-Dtests=false \
|
||||
--prefix=/opt/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
|
||||
@@ -0,0 +1,19 @@
|
||||
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=/opt/ffbuild/prefix \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DENABLE_SHARED=OFF \
|
||||
-DENABLE_STATIC=ON \
|
||||
-DBUILD_STATIC_LIBS=ON
|
||||
make -j$(nproc)
|
||||
make install
|
||||
@@ -0,0 +1,10 @@
|
||||
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
|
||||
@@ -0,0 +1,9 @@
|
||||
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=/opt/ffbuild/prefix \
|
||||
--disable-shared \
|
||||
--enable-static \
|
||||
--disable-silent-rules
|
||||
make -j$(nproc)
|
||||
make install
|
||||
@@ -0,0 +1,15 @@
|
||||
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=/opt/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
|
||||
@@ -0,0 +1,6 @@
|
||||
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=/opt/ffbuild/prefix/share --disable-java --disable-csharp --without-git --without-cvs --without-xz --with-included-gettext --prefix=/opt/ffbuild/prefix
|
||||
make -j$(nproc)
|
||||
make install
|
||||
@@ -50,5 +50,9 @@ ffbuild_configure() {
|
||||
}
|
||||
|
||||
ffbuild_unconfigure() {
|
||||
echo --disable-iconv
|
||||
if [[ $TARGET == mac* ]]; then
|
||||
echo --enable-iconv
|
||||
else
|
||||
echo --disable-iconv
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -40,5 +40,9 @@ ffbuild_configure() {
|
||||
}
|
||||
|
||||
ffbuild_unconfigure() {
|
||||
echo --disable-libxml2
|
||||
if [[ $TARGET == mac* ]]; then
|
||||
echo --enable-libxml2
|
||||
else
|
||||
echo --disable-libxml2
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -33,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() {
|
||||
|
||||
@@ -11,10 +11,6 @@ ffbuild_dockerbuild() {
|
||||
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" fc
|
||||
cd fc
|
||||
|
||||
if [[ $TARGET == mac* ]]; then
|
||||
sed -i '' 's/LIBTOOLIZE=\${LIBTOOLIZE-libtoolize}/LIBTOOLIZE=glibtoolize/' ./autogen.sh
|
||||
fi
|
||||
|
||||
if [[ $TARGET == mac* ]]; then
|
||||
autoreconf -iv
|
||||
else
|
||||
@@ -41,7 +37,8 @@ ffbuild_dockerbuild() {
|
||||
--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
|
||||
@@ -50,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() {
|
||||
|
||||
@@ -23,7 +23,8 @@ ffbuild_dockerbuild() {
|
||||
--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
|
||||
|
||||
@@ -58,5 +58,9 @@ ffbuild_configure() {
|
||||
}
|
||||
|
||||
ffbuild_unconfigure() {
|
||||
echo --disable-opencl
|
||||
if [[ $TARGET == mac* ]]; then
|
||||
echo --enable-opencl
|
||||
else
|
||||
echo --disable-opencl
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
FF_CFLAGS+="-I/opt/ffbuild/prefix/include"
|
||||
FF_LDFLAGS+="-L/opt/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/opt/ffbuild/prefix/include"
|
||||
FF_HOST_LDFLAGS="-Wl,-ld_classic -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -L/opt/ffbuild/prefix/lib"
|
||||
PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig:/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/14:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/14"
|
||||
CMAKE_PREFIX_PATH="/opt/ffbuild/prefix"
|
||||
PKG_CONFIG_PATH="/opt/ffbuild/prefix/lib/pkgconfig"
|
||||
LDFLAGS="-Wl,-ld_classic"
|
||||
|
||||
@@ -1,3 +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
|
||||
|
||||
@@ -1,3 +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
|
||||
|
||||
Reference in New Issue
Block a user