2020-01-28 07:20:23 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DATA_DIR=$HOME/.local/share/MangoHud
|
2020-01-29 10:35:42 +00:00
|
|
|
LAYER=build/release/usr/share/vulkan/implicit_layer.d/mangohud.json
|
2020-01-28 07:20:23 +00:00
|
|
|
IMPLICIT_LAYER_DIR=$HOME/.local/share/vulkan/implicit_layer.d
|
|
|
|
|
2020-02-01 18:52:37 +00:00
|
|
|
dependencies() {
|
|
|
|
if [[ ! -f build/release/usr/lib64/libMangoHud.so ]]; then
|
|
|
|
DISTRO=$(sed 1q /etc/os-release | sed 's/NAME=//g' | sed 's/"//g')
|
|
|
|
echo "# Checking Dependencies"
|
|
|
|
|
|
|
|
missing_deps() {
|
|
|
|
echo "# Missing dependencies!"
|
|
|
|
echo "# Attempting to install '$INSTALL'"
|
|
|
|
}
|
|
|
|
case $DISTRO in
|
|
|
|
"Arch Linux"|"Manjaro")
|
|
|
|
for i in {gcc,meson,pkgconf,python-mako,glslang,libglvnd,lib32-libglvnd}; do
|
|
|
|
pacman -Q $i &> /dev/null
|
|
|
|
if [[ $? == 1 ]]; then
|
|
|
|
INSTALL=$INSTALL" "$i
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [[ ! -z "$INSTALL" ]]; then
|
|
|
|
missing_deps
|
|
|
|
sudo pacman -S $INSTALL
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"Fedora")
|
|
|
|
for i in {meson,gcc,g++,libX11-devel,glslang,python-mako,mesa-libGL-devel,glibc-devel.i686,libstdc++-devel.i686}; do
|
|
|
|
dnf list installed | grep $i &> /dev/null
|
|
|
|
if [[ $? == 1 ]]; then
|
|
|
|
INSTALL=$INSTALL" "$i
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [[ ! -z "$INSTALL" ]]; then
|
|
|
|
missing_deps
|
|
|
|
sudo dnf install $INSTALL
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"Ubuntu"|"Linux Mint"|"Debian")
|
2020-02-01 19:16:44 +00:00
|
|
|
for i in {gcc,g++,gcc-multilib,g++-multilib,ninja-build,python3-pip,python3-setuptools,python3-wheel,pkg-config,mesa-common-dev,libx11-dev:i386}; do
|
2020-02-01 18:52:37 +00:00
|
|
|
dpkg-query -l $i &> /dev/null
|
|
|
|
if [[ $? == 1 ]]; then
|
|
|
|
INSTALL=$INSTALL" "$i
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [[ ! -z "$INSTALL" ]]; then
|
|
|
|
missing_deps
|
|
|
|
sudo apt install $INSTALL
|
|
|
|
sudo pip3 install meson mako
|
|
|
|
fi
|
|
|
|
if [[ ! -f /usr/local/bin/glslangValidator ]]; then
|
|
|
|
wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip
|
|
|
|
unzip glslang-master-linux-Release.zip bin/glslangValidator
|
|
|
|
sudo install -m755 bin/glslangValidator /usr/local/bin/
|
|
|
|
rm bin/glslangValidator glslang-master-linux-Release.zip
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "# Unable to find distro information!"
|
|
|
|
echo "# Attempting to build regardless"
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-01-28 07:20:23 +00:00
|
|
|
configure() {
|
2020-02-01 18:52:37 +00:00
|
|
|
dependencies
|
|
|
|
git submodule update --init --depth 50
|
2020-01-28 07:20:23 +00:00
|
|
|
if [[ ! -d build/meson64 ]]; then
|
2020-01-29 10:35:42 +00:00
|
|
|
meson build/meson64 --libdir lib64 --prefix $PWD/build/release/usr
|
2020-01-28 07:20:23 +00:00
|
|
|
|
2020-02-01 19:16:44 +00:00
|
|
|
CC="gcc -m32" \
|
|
|
|
CXX="g++ -m32" \
|
|
|
|
PKG_CONFIG_PATH="/usr/lib32/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig:${PKG_CONFIG_PATH_32}" \
|
|
|
|
LLVM_CONFIG="/usr/bin/llvm-config32" \
|
2020-01-29 10:35:42 +00:00
|
|
|
meson build/meson32 --libdir lib32 --prefix $PWD/build/release/usr
|
2020-01-28 07:20:23 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
build() {
|
|
|
|
ninja -C build/meson32 install
|
|
|
|
ninja -C build/meson64 install
|
|
|
|
}
|
|
|
|
|
|
|
|
install() {
|
|
|
|
mkdir -p $IMPLICIT_LAYER_DIR
|
|
|
|
mkdir -p $DATA_DIR
|
|
|
|
|
2020-01-29 10:35:42 +00:00
|
|
|
cp build/release/usr/lib32/libMangoHud.so $DATA_DIR/libMangoHud32.so
|
|
|
|
cp build/release/usr/lib64/libMangoHud.so $DATA_DIR/libMangoHud.so
|
2020-01-28 07:20:23 +00:00
|
|
|
cp $LAYER $IMPLICIT_LAYER_DIR/mangohud64.json
|
|
|
|
cp $LAYER $IMPLICIT_LAYER_DIR/mangohud32.json
|
|
|
|
|
|
|
|
sed -i "s|libMangoHud.so|$HOME/.local/share/MangoHud/libMangoHud32.so|g" $IMPLICIT_LAYER_DIR/mangohud32.json
|
|
|
|
sed -i "s|libMangoHud.so|$HOME/.local/share/MangoHud/libMangoHud.so|g" $IMPLICIT_LAYER_DIR/mangohud64.json
|
|
|
|
sed -i "s|64bit|32bit|g" $IMPLICIT_LAYER_DIR/mangohud32.json
|
|
|
|
}
|
|
|
|
|
2020-01-29 10:35:42 +00:00
|
|
|
package() {
|
2020-01-29 10:43:01 +00:00
|
|
|
VERSION=$(printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)")
|
2020-01-29 10:35:42 +00:00
|
|
|
cd build/release
|
2020-01-29 10:43:01 +00:00
|
|
|
tar czf ../../MangoHud-$VERSION.tar.gz *
|
2020-01-29 10:35:42 +00:00
|
|
|
}
|
|
|
|
|
2020-01-28 07:20:23 +00:00
|
|
|
clean() {
|
2020-02-01 18:52:37 +00:00
|
|
|
rm -rf build
|
2020-01-28 07:20:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uninstall() {
|
|
|
|
rm -r $HOME/.local/share/MangoHud
|
|
|
|
rm $IMPLICIT_LAYER_DIR/{mangohud64,mangohud32}.json
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
"") configure; build;;
|
|
|
|
"build") configure; build;;
|
|
|
|
"install") configure; build; install;;
|
2020-02-01 18:52:37 +00:00
|
|
|
"update") git pull &> /dev/null; configure; build; install;;
|
2020-01-29 10:35:42 +00:00
|
|
|
"package") package;;
|
2020-01-28 07:20:23 +00:00
|
|
|
"clean") clean;;
|
|
|
|
"uninstall") uninstall;;
|
|
|
|
*)
|
|
|
|
echo "Unrecognized command argument: $1"
|
2020-02-01 18:52:37 +00:00
|
|
|
echo 'Accepted arguments: "", "build", "install", "update", "package", "clean", "uninstall".'
|
2020-01-28 07:20:23 +00:00
|
|
|
esac
|