2024-09-08 08:16:54 +02:00
|
|
|
#!/bin/bash
|
|
|
|
OS=$(uname)
|
2024-09-28 11:57:33 +02:00
|
|
|
DISTRO=""
|
|
|
|
|
|
|
|
# Detect Linux distribution
|
|
|
|
if [ "$OS" = "Linux" ]; then
|
|
|
|
if [ -f /etc/os-release ]; then
|
|
|
|
DISTRO=$(awk -F= '/^ID=/{print $2}' /etc/os-release)
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2024-09-08 08:16:54 +02:00
|
|
|
echo "Martin Eesmaa / VVC Compiler (vvenc and vvdec)"
|
2024-09-28 11:57:33 +02:00
|
|
|
|
|
|
|
if [ "$OS" = "Linux" ]; then
|
|
|
|
echo "You're running on $OS with distribution $DISTRO of bash script version to compile VVC binaries"
|
|
|
|
else
|
|
|
|
echo "You're running on $OS of bash script version to compile VVC binaries"
|
|
|
|
fi
|
|
|
|
|
2024-09-08 12:34:48 +02:00
|
|
|
echo "Checking and installing required packages..."
|
2024-09-08 08:16:54 +02:00
|
|
|
|
2024-09-28 11:57:33 +02:00
|
|
|
setup_debian() {
|
2024-09-08 08:16:54 +02:00
|
|
|
sudo apt update && sudo apt upgrade -y
|
2024-09-28 11:57:33 +02:00
|
|
|
sudo apt install build-essential cmake git -y
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_fedora() {
|
|
|
|
sudo dnf update -y
|
|
|
|
sudo dnf install cmake gcc gcc-c++ make git -y
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_arch() {
|
|
|
|
sudo pacman -Syu --noconfirm
|
|
|
|
sudo pacman -S --noconfirm base-devel cmake git
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_gentoo() {
|
|
|
|
sudo emerge --sync
|
|
|
|
sudo emerge cmake git
|
2024-09-08 08:16:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
setup_macos() {
|
|
|
|
echo "Please make sure Xcode is installed in your Applications."
|
|
|
|
if ! command -v brew &> /dev/null; then
|
|
|
|
echo "Homebrew is not installed. Please install Homebrew and rerun the script."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if ! brew list | grep -q cmake; then
|
|
|
|
echo "Installing cmake..."
|
|
|
|
brew install cmake
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_msys64() {
|
|
|
|
pacman -Syu --noconfirm
|
|
|
|
pacman -S --noconfirm base-devel cmake git
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_freebsd() {
|
|
|
|
pkg update && pkg upgrade -y
|
|
|
|
pkg install -y cmake git gmake
|
|
|
|
}
|
|
|
|
|
|
|
|
build_repos() {
|
|
|
|
if [ ! -d vvenc ]; then
|
|
|
|
git clone --depth=1 https://github.com/fraunhoferhhi/vvenc
|
|
|
|
else
|
2024-09-28 11:57:33 +02:00
|
|
|
git -C vvenc pull
|
2024-09-08 08:16:54 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d vvdec ]; then
|
|
|
|
git clone --depth=1 https://github.com/fraunhoferhhi/vvdec
|
|
|
|
else
|
2024-09-28 11:57:33 +02:00
|
|
|
git -C vvdec pull
|
2024-09-08 08:16:54 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
for REPO in vvenc vvdec; do
|
|
|
|
cd $REPO
|
2024-09-28 11:57:33 +02:00
|
|
|
mkdir -p build && cd build
|
2024-09-08 08:16:54 +02:00
|
|
|
if [ "$OS" = "Darwin" ]; then
|
2024-09-28 11:57:33 +02:00
|
|
|
CORES=$(sysctl -n hw.ncpu || echo 1)
|
2024-09-08 08:16:54 +02:00
|
|
|
cmake -DCMAKE_BUILD_TYPE=Release ..
|
2024-09-28 11:57:33 +02:00
|
|
|
cmake --build . -j $CORES
|
2024-09-08 08:16:54 +02:00
|
|
|
else
|
2024-09-28 11:57:33 +02:00
|
|
|
CORES=$(nproc || echo 1)
|
2024-09-08 08:16:54 +02:00
|
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS="-static" ..
|
2024-09-28 11:57:33 +02:00
|
|
|
cmake --build . -j $CORES
|
|
|
|
fi
|
|
|
|
cd -
|
|
|
|
done
|
2024-09-08 08:16:54 +02:00
|
|
|
echo "Please see the build files starting with (vvenc/vvdec)/bin/release-static."
|
|
|
|
}
|
|
|
|
|
|
|
|
# Main script execution
|
|
|
|
case "$OS" in
|
|
|
|
Linux)
|
2024-09-28 11:57:33 +02:00
|
|
|
case "$DISTRO" in
|
|
|
|
debian|ubuntu)
|
|
|
|
setup_debian
|
|
|
|
;;
|
|
|
|
fedora)
|
|
|
|
setup_fedora
|
|
|
|
;;
|
|
|
|
arch)
|
|
|
|
setup_arch
|
|
|
|
;;
|
|
|
|
gentoo)
|
|
|
|
setup_gentoo
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unsupported Linux distribution: $DISTRO"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2024-09-08 08:16:54 +02:00
|
|
|
;;
|
|
|
|
Darwin)
|
|
|
|
setup_macos
|
|
|
|
;;
|
|
|
|
MSYS_NT*|MINGW64*)
|
|
|
|
setup_msys64
|
|
|
|
;;
|
|
|
|
FreeBSD)
|
|
|
|
setup_freebsd
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unsupported OS: $OS"
|
|
|
|
echo "Supports Windows MSYS64, macOS, Linux & FreeBSD"
|
|
|
|
echo "May coming soon for some platforms..."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
build_repos
|
2024-09-28 11:57:33 +02:00
|
|
|
read -p "Finished building vvenc & vvdec. Press [Enter] to continue..."
|