spmenu/build.sh

102 lines
4.3 KiB
Bash
Raw Normal View History

2023-03-24 15:28:42 +01:00
#!/bin/bash
# spmenu build script
2023-04-22 00:26:50 +02:00
opt="${opt:-${OPT:--O2}}"
warn="${warn:-true}"
2023-05-08 10:43:42 +02:00
reconfigure="${reconfigure:-true}"
2023-05-08 11:11:49 +02:00
version="${version:-1.1}"
xresources="${xresources:-true}"
2023-03-24 15:28:42 +01:00
check_dist() {
2023-04-22 00:26:50 +02:00
[ -f "/etc/pacman.conf" ] && [ "$warn" != "false" ] && printf "hint: detected Pacman. if you want you can run 'makepkg' with proper arguments to install it using pacman.\n" && pacman=true
[ -f "/System/Library/CoreServices/SystemVersion.plist" ] && [ "$warn" != "false" ] && printf "hint: detected a Mac. Please report any issues you find as it is untested.\n" && mac=true
2023-03-24 15:28:42 +01:00
uname -a | grep -q OpenBSD && printf "hint: detected OpenBSD. Please report any issues you find as it is untested.\n" && openbsd=true
}
check() {
if [ "$mac" != "true" ]; then
2023-03-24 15:28:42 +01:00
[ ! -x "$(command -v ldconfig)" ] && printf "ldconfig not found in %s. Please make sure your system is set up properly." "\$PATH" && exit 1
2023-05-08 10:43:42 +02:00
[ ! -x "$(command -v ninja)" ] && printf "ninja not found in %s. Please make sure your system is set up properly." "\$PATH" && exit 1
[ ! -x "$(command -v meson)" ] && printf "meson not found in %s. Please make sure your system is set up properly." "\$PATH" && exit 1
2023-03-24 15:28:42 +01:00
[ -n "$(ldconfig -p | grep Imlib2)" ] && printf "Imlib2 found\n" && imlib2=true || imlib2=false
[ -n "$(ldconfig -p | grep libXft)" ] && printf "libXft found\n" && xft=true || xft=false
[ -n "$(ldconfig -p | grep libX11)" ] && printf "libX11 found\n" && x11=true || x11=false
[ -n "$(ldconfig -p | grep libXrender)" ] && printf "libXrender found\n" && xrender=true || xrender=false
[ -n "$(ldconfig -p | grep libpango)" ] && printf "libpango found\n" && pango=true || pango=false
[ -n "$(ldconfig -p | grep libpangoxft)" ] && printf "libpangoxft found\n" && pangoxft=true || pangoxft=false
[ -n "$(ldconfig -p | grep libxcb-xinerama)" ] && printf "libxcb-xinerama found\n" && xinerama=true || xinerama=false
[ -n "$(ldconfig -p | grep libgnutls-openssl)" ] && printf "openssl found\n" && openssl=true || openssl=false
[ -n "$(ldconfig -p | grep fribidi)" ] && printf "fribidi found\n" && fribidi=true || fribidi=false
[ -n "$(ldconfig -p | grep freetype)" ] && printf "freetype found\n" && freetype=true || freetype=false
[ -n "$(ldconfig -p | grep libconfig)" ] && printf "libconfig found\n" && libconfig=true || libconfig=false
else
2023-05-08 12:03:31 +02:00
gen_manual="false"
fi
2023-03-24 15:28:42 +01:00
}
loadconf() {
2023-05-07 18:58:51 +02:00
[ -x "buildconf" ] && [ ! -x "buildconf_dev" ] && source buildconf
[ -x "buildconf_dev" ] && source buildconf_dev
2023-03-24 15:28:42 +01:00
# mandatory deps
[ "$freetype" = "false" ] && printf "Freetype not found. Install it.\n" && exit 1
2023-03-28 21:46:23 +02:00
[ "$openssl" = "false" ] && [ "$imlib2" = "true" ] && printf "OpenSSL not found. Install it.\n" && exit 1
2023-03-24 15:28:42 +01:00
[ "$xrender" = "false" ] && printf "libXrender not found. Install it.\n" && exit 1
[ "$x11" = "false" ] && printf "libX11 not found. Install it.\n" && exit 1
[ "$xft" = "false" ] && printf "libXft not found. Install it.\n" && exit 1
}
build() {
2023-05-08 11:11:49 +02:00
[ ! -f "meson.build" ] && printf "meson.build does not exist.\n" && exit 1
2023-05-08 12:03:31 +02:00
[ "$gen_manual" != "false" ] && [ -x "$(command -v pandoc)" ] && scripts/make/generate-docs.sh
2023-03-24 15:28:42 +01:00
2023-05-08 10:43:42 +02:00
cp -f meson.build meson.build.orig
2023-03-24 15:28:42 +01:00
2023-05-08 11:11:49 +02:00
[ "$reconfigure" != "false" ] && rm -rf build/
2023-05-08 10:43:42 +02:00
mkdir -p build/
if [ "$reconfigure" = "true" ]; then
meson setup --reconfigure \
-Dxresources="$xresources" \
-Dfribidi="$fribidi" \
-Dxinerama="$xinerama" \
-Dimlib2="$imlib2" \
-Dopenssl="$openssl" \
-Dpango="$pango" \
-Dpangoxft="$pangoxft" \
-Dlibconfig="$libconfig" \
build
2023-03-25 15:29:51 +01:00
else
meson setup \
-Dxresources="$xresources" \
-Dfribidi="$fribidi" \
-Dxinerama="$xinerama" \
-Dimlib2="$imlib2" \
-Dopenssl="$openssl" \
-Dpango="$pango" \
-Dpangoxft="$pangoxft" \
-Dlibconfig="$libconfig" \
build
2023-03-24 15:28:42 +01:00
fi
2023-05-08 10:43:42 +02:00
ninja -C build
2023-05-08 11:11:49 +02:00
[ "$cp_build" = "true" ] && cp meson.build meson.build.used
2023-05-08 10:46:11 +02:00
mv meson.build.orig meson.build
2023-03-24 15:28:42 +01:00
}
install() {
2023-05-08 10:43:42 +02:00
cd build/ || exit 1
meson install
cd .. || exit 1
[ "$reconfigure" = "true" ] && rm -rf build/
2023-03-24 15:28:42 +01:00
}
[ "$1" = "--no-install" ] && install=false
2023-03-29 15:33:58 +02:00
2023-03-24 15:28:42 +01:00
check_dist
check
loadconf
build
2023-03-28 22:16:30 +02:00
[ "$install" != "false" ] && install