polytreewm/configure

261 lines
5.4 KiB
Text
Raw Permalink Normal View History

2021-11-16 17:02:06 -05:00
#!/bin/sh
set -e
usage() {
cat <<USAGE
There is an error in your command.
More information: ./configure --help
USAGE
exit
}
2021-11-16 17:02:06 -05:00
help() {
cat <<HELP
This script tries to be similar to autotools' \`configure', but is different.
Usage: ./configure [OPTION]...
Defaults for the options are specified in brackets.
Configuration:
-h, --help Display this help and exit
Installation directories:
--prefix PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, \`make install' will install all the files in
\`/usr/local/bin', \`/usr/local/lib' etc. You can specify
an installation prefix other than \`/usr/local' using \`--prefix',
for instance \`--prefix \$HOME'.
For better control, use the options below.
File tuning of the installation directories:
--bindir DIR user executables [EPREFIX/bin]
--datarootdir DIR read-only arch.-independent data root [PREFIX/share]
--mandir DIR man documentation [DATAROOTDIR/man]
Optional Features:
--disable-xinerama disable Xinerama
Optional Packages:
--with-PACKAGE[ ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE no)
2021-12-05 05:16:00 -05:00
--with-locker [i3lock|i3lock-color]
use ARG as screen locker [i3lock]
--without-locker do not use screen locker at all
2021-11-18 08:57:41 -05:00
--with-terminal [alacritty|gnome|st|xterm]
use ARG as terminal [alacritty]
--without-terminal do not use terminal at all
2021-11-16 17:02:06 -05:00
HELP
exit
2021-11-16 17:02:06 -05:00
}
prefix='/usr/local'
eprefix=''
bindir=''
datarootdir=''
mandir=''
enable_xinerama=''
2021-12-05 05:16:00 -05:00
with_locker=''
with_terminal=''
2021-11-16 17:02:06 -05:00
while [ $# -gt 0 ]; do
do_shift='yes'
2021-11-16 17:02:06 -05:00
case "$1" in
-h | -? | --help | -help | help)
help
;;
--prefix)
shift
prefix="$1"
;;
--exec-prefix)
shift
eprefix="$1"
;;
--bindir)
shift
bindir="$1"
;;
--datarootdir)
shift
datarootdir="$1"
;;
--mandir)
shift
mandir="$1"
;;
--disable-xinerama)
enable_xinerama='no'
;;
2021-12-05 05:16:00 -05:00
--without-locker)
if [ "$with_locker" = '' ]; then
with_locker='no'
elif [ "$with_locker" != 'no' ]; then
usage
fi
;;
--without-terminal)
if [ "$with_terminal" = '' ]; then
with_terminal='no'
elif [ "$with_terminal" != 'no' ]; then
usage
fi
;;
2021-12-05 05:16:00 -05:00
--with-locker)
shift
case "$1" in
yes)
if [ "$with_locker" = '' ]; then
with_locker='yes'
elif [ "$with_locker" != 'yes' ]; then
usage
fi
;;
no)
if [ "$with_locker" = '' ]; then
with_locker='no'
elif [ "$with_locker" != 'no' ]; then
usage
fi
;;
i3lock)
if [ "$with_locker" = '' ]; then
with_locker='i3lock'
elif [ "$with_locker" != 'i3lock' ]; then
usage
fi
;;
i3lock-color)
if [ "$with_locker" = '' ]; then
with_locker='i3lock-color'
elif [ "$with_locker" != 'i3lock-color' ]; then
usage
fi
;;
*)
do_shift='no'
;;
esac
;;
--with-terminal)
shift
case "$1" in
yes)
if [ "$with_terminal" = '' ]; then
with_terminal='yes'
elif [ "$with_terminal" != 'yes' ]; then
usage
fi
;;
no)
if [ "$with_terminal" = '' ]; then
with_terminal='no'
elif [ "$with_terminal" != 'no' ]; then
usage
fi
;;
2021-11-18 08:57:41 -05:00
alacritty)
if [ "$with_terminal" = '' ]; then
2021-11-18 08:57:41 -05:00
with_terminal='alacritty'
elif [ "$with_terminal" != 'alacritty' ]; then
usage
fi
;;
2021-11-18 08:57:41 -05:00
gnome)
if [ "$with_terminal" = '' ]; then
2021-11-18 08:57:41 -05:00
with_terminal='gnome'
elif [ "$with_terminal" != 'gnome' ]; then
usage
fi
;;
2021-11-18 08:57:41 -05:00
st)
if [ "$with_terminal" = '' ]; then
2021-11-18 08:57:41 -05:00
with_terminal='st'
elif [ "$with_terminal" != 'st' ]; then
usage
fi
;;
xterm)
if [ "$with_terminal" = '' ]; then
with_terminal='xterm'
elif [ "$with_terminal" != 'xterm' ]; then
usage
fi
;;
*)
do_shift='no'
;;
esac
;;
2021-11-16 17:02:06 -05:00
*)
usage
2021-11-16 17:02:06 -05:00
;;
esac
if [ "$do_shift" = 'yes' ]; then shift; fi
2021-11-16 17:02:06 -05:00
done
if [ "$eprefix" = '' ]; then
eprefix="$prefix"
fi
if [ "$bindir" = '' ]; then
bindir="$eprefix/bin"
fi
if [ "$datarootdir" = '' ]; then
datarootdir="$prefix/share"
fi
if [ "$mandir" = '' ]; then
mandir="$datarootdir/man"
fi
if [ "$enable_xinerama" = '' ]; then
enable_xinerama='yes'
fi
2021-12-05 05:16:00 -05:00
if [ "$with_locker" = '' -o "$with_locker" = 'yes' ]; then
with_locker='i3lock'
fi
if [ "$with_terminal" = '' -o "$with_terminal" = 'yes' ]; then
2021-11-18 08:57:41 -05:00
with_terminal='alacritty'
fi
echo "PREFIX = $prefix"
echo "EPREFIX = $eprefix"
echo "BINDIR = $bindir"
echo "DATAROOTDIR = $datarootdir"
echo "MANDIR = $mandir"
echo "ENABLE_XINERAMA = $enable_xinerama"
2021-12-05 05:16:00 -05:00
echo "WITH_LOCKER = $with_locker"
echo "WITH_TERMINAL = $with_terminal"
2021-11-16 17:02:06 -05:00
2021-11-16 18:05:40 -05:00
cat > 'config/1-generated.mk' << MAKE
PREFIX = $prefix
EPREFIX = $eprefix
BINDIR = $bindir
DATAROOTDIR = $datarootdir
MANDIR = $mandir
ENABLE_XINERAMA = $enable_xinerama
2021-12-05 05:16:00 -05:00
WITH_LOCKER = $with_locker
WITH_TERMINAL = $with_terminal
MAKE
2021-11-16 17:47:45 -05:00
make_help_result="$(make --help 2>&1 || true)"
if [ "$(echo "$make_help_result" | grep 'gnu.org')" = '' ]; then
2021-11-16 18:07:04 -05:00
ln -sf '2-conditionals-bsd.mk' 'config/2-conditionals.mk'
else
2021-11-16 18:07:04 -05:00
ln -sf '2-conditionals-gnu.mk' 'config/2-conditionals.mk'
fi