2023-03-24 15:28:42 +01:00
#!/bin/bash
2023-05-01 18:46:11 +02:00
# 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 } "
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( ) {
2023-04-26 10:01:11 +02:00
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
2023-04-04 21:39:38 +02:00
[ -n " $( ldconfig -p | grep libconfig) " ] && printf "libconfig found\n" && libconfig = true || libconfig = false
2023-04-26 10:01:11 +02:00
else
2023-05-08 12:03:31 +02:00
gen_manual = "false"
2023-04-26 10:01:11 +02:00
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
if [ " $libconfig " != "true" ] ; then
libconfig_text = "libconfig = false"
else
libconfig_text = "libconfig = true"
2023-03-24 15:28:42 +01:00
fi
2023-05-08 10:43:42 +02:00
if [ " $pango " != "true" ] || [ " $pangoxft " != "true" ] ; then
pango_text = "pango = false"
pangoxft_text = "pangoxft = false"
else
pango_text = "pango = true"
2023-05-08 11:11:49 +02:00
pangoxft_text = "pangoxft = true"
2023-03-24 15:28:42 +01:00
fi
2023-05-08 10:43:42 +02:00
if [ " $openssl " != "true" ] || [ " $imlib2 " != "true" ] ; then
imlib2_text = "imlib2 = false"
openssl_text = "openssl = false"
else
imlib2_text = "imlib2 = true"
openssl_text = "openssl = true"
2023-03-28 21:46:23 +02:00
fi
2023-05-08 10:43:42 +02:00
if [ " $xinerama " != "true" ] ; then
xinerama_text = "xinerama = false"
else
xinerama_text = "xinerama = true"
2023-03-24 15:28:42 +01:00
fi
2023-05-08 10:43:42 +02:00
if [ " $fribidi " != "true" ] ; then
fribidi_text = "fribidi = false"
else
fribidi_text = "fribidi = true"
2023-04-04 21:39:38 +02:00
fi
2023-05-08 10:43:42 +02:00
if [ " $xresources " != "true" ] ; then
xresources_text = "xresources = false"
else
xresources_text = "xresources = true"
2023-05-06 22:01:28 +02:00
fi
2023-05-08 10:43:42 +02:00
sed -i " s/libconfig = true/ $libconfig_text / " meson.build
sed -i " s/pango = true/ $pango_text / " meson.build
sed -i " s/pangoxft = true/ $pangoxft_text / " meson.build
sed -i " s/imlib2 = true/ $imlib2_text / " meson.build
sed -i " s/openssl = true/ $openssl_text / " meson.build
sed -i " s/xinerama = true/ $xinerama_text / " meson.build
sed -i " s/fribidi = true/ $fribidi_text / " meson.build
sed -i " s/xresources = true/ $xresources_text / " meson.build
sed -i " s/opt = '-O2'/opt = ' $opt '/g " meson.build
mkdir -p build/
if [ " $reconfigure " = "true" ] ; then
meson setup --reconfigure build
2023-03-25 15:29:51 +01:00
else
2023-05-08 10:43:42 +02:00
meson setup 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
2023-03-24 15:28:42 +01:00
}
2023-04-26 10:01:11 +02: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