spmenu/scripts/make/build.sh

77 lines
2.2 KiB
Bash
Raw Normal View History

2023-03-24 15:28:42 +01:00
#!/bin/bash
# spmenu build script
2023-06-03 15:19:29 +02:00
# See LICENSE file for copyright and license details.
2023-04-22 00:26:50 +02:00
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-05-09 12:10:23 +02:00
cp_build="${cp_build:-false}"
prefix="${prefix:-/usr}"
2023-03-24 15:28:42 +01:00
check() { [ "$mac" != "false" ] && gen_manual="false" && prefix="/usr/local"; }
2023-03-24 15:28:42 +01:00
loadconf() {
[ ! -f spmenu.c ] && printf "You're probably in the wrong directory.\n" && exit 1
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
}
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
[ -z "$wayland" ] && wayland=true
[ -z "$x11" ] && x11=true
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/
2023-05-12 16:46:34 +02:00
[ "$static" = "true" ] && STATIC="--prefer-static"
2023-05-08 10:43:42 +02:00
if [ "$reconfigure" = "true" ]; then
2023-05-12 16:46:34 +02:00
meson setup --reconfigure $STATIC \
-Dxresources="$xresources" \
-Dfribidi="$fribidi" \
-Dxinerama="$xinerama" \
-Dimlib2="$imlib2" \
-Dopenssl="$openssl" \
-Dlibconfig="$libconfig" \
-Dwayland="$wayland" \
-Dx11="$x11" \
--prefix "$prefix" \
build || exit 1
2023-03-25 15:29:51 +01:00
else
meson setup \
2023-05-12 16:46:34 +02:00
-Dxresources="$xresources" $STATIC \
-Dfribidi="$fribidi" \
-Dxinerama="$xinerama" \
-Dimlib2="$imlib2" \
-Dopenssl="$openssl" \
-Dlibconfig="$libconfig" \
-Dwayland="$wayland" \
-Dx11="$x11" \
--prefix "$prefix" \
build || exit 1
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
}
[ "$(id -u)" != "0" ] && [ "$install" != "false" ] && printf "Run as root.\n" && exit 1
2023-03-24 15:28:42 +01:00
check
loadconf
build
2023-03-28 22:16:30 +02:00
[ "$install" != "false" ] && install