anotherim-desktop/configure

138 lines
3.9 KiB
Plaintext
Raw Normal View History

2017-03-02 14:37:32 +00:00
#!/bin/bash
OPTS=`getopt -o "h" --long prefix:,enable-plugin:,disable-plugin:,valac:,valac-flags:,lib-suffix:,help,disable-fast-vapi,no-debug -n './configure' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
eval set -- "$OPTS"
PREFIX=${PREFIX:-/usr/local}
VALA_EXECUTABLE=${VALA_EXECUTABLE:-$(which valac)}
ENABLED_PLUGINS=
DISABLED_PLUGINS=
VALAC_FLAGS=
DISABLE_FAST_VAPI=
LIB_SUFFIX=
NO_DEBUG=
help() {
cat << EOF
Usage:
./configure [OPTIONS]...
Options:
-h, --help Print this help and exit
--prefix=PREFIX Prepend PREFIX to program installation paths. [$PREFIX]
--lib-suffix=SUFFIX Append SUFFIX to the directory name for libraries
--no-debug Build without debug symbols
--enable-plugin=PLUGIN Enable compilation of plugin PLUGIN.
--disable-plugin=PLUGIN Disable compilation of plugin PLUGIN.
--valac=VALAC Use VALAC as Vala pre-compiler. [$VALA_EXECUTABLE]
--valac-flags=FLAGS Use FLAGS when invoking the vala compiler
--disable-fast-vapi Disable the usage of Vala compilers fast-vapi feature.
EOF
2017-03-02 14:37:32 +00:00
}
while true; do
case "$1" in
--prefix ) PREFIX="$2"; shift; shift ;;
--enable-plugin ) if [ "$ENABLED_PLUGINS" == "" ]; then ENABLED_PLUGINS="$2"; else ENABLED_PLUGINS="ENABLED_PLUGINS;$2"; fi; shift; shift ;;
--disable-plugin ) if [ "$DISABLED_PLUGINS" == "" ]; then DISABLED_PLUGINS="$2"; else DISABLED_PLUGINS="DISABLED_PLUGINS;$2"; fi; shift; shift ;;
--valac ) VALA_EXECUTABLE="$2"; shift; shift ;;
--valac-flags ) VALAC_FLAGS="$2"; shift; shift ;;
--lib-suffix ) LIB_SUFFIX="$2"; shift; shift ;;
--disable-fast-vapi ) DISABLE_FAST_VAPI=yes; shift ;;
--no-debug ) NO_DEBUG=yes; shift ;;
-h | --help ) help; exit 0 ;;
-- ) shift; break ;;
* ) break ;;
esac
done
if [ ! -x "$(which cmake 2>/dev/null)" ]
2017-03-02 14:37:32 +00:00
then
echo "-!- CMake required."
2017-03-02 14:37:32 +00:00
exit 1
fi
ninja_bin="$(which ninja-build 2>/dev/null)"
if ! [ -x "$ninja_bin" ]; then
ninja_bin="$(which ninja 2>/dev/null)"
fi
if [ -x "$ninja_bin" ]; then
ninja_version=$($ninja_bin --version 2>/dev/null)
if [ $? -eq 0 ]; then
echo "-- Found Ninja: $ninja_bin (found version \"$ninja_version\")"
cmake_type="Ninja"
exec_bin="$ninja_bin"
exec_command="$exec_bin"
elif [[ "/usr/sbin/ninja" == "$ninja_bin" ]]; then
echo "-- Ninja at $ninja_bin is not usable. Did you install 'ninja' instead of 'ninja-build'?"
fi
fi
if ! [ -x "$exec_bin" ]; then
make_bin="$(which make 2>/dev/null)"
if [ -x "$make_bin" ]; then
echo "-- Found Make: $make_bin"
cmake_type="Unix Makefiles"
exec_bin="$make_bin"
exec_command="$exec_bin"
echo "-- Running with make. Using Ninja (ninja-build) might improve build experience."
fi
fi
if ! [ -x "$exec_bin" ]; then
2017-03-10 18:34:56 +00:00
echo "-!- No compatible build system (Ninja, Make) found."
2017-03-02 14:37:32 +00:00
exit 4
fi
# TODO don't use git submodule
2017-03-11 00:29:38 +00:00
git submodule update --init --recursive
2017-03-02 14:37:32 +00:00
if [ -f ./build ]
then
2017-03-10 18:34:56 +00:00
echo "-!- ./build file exists. ./configure can't continue"
2017-03-02 14:37:32 +00:00
exit 2
fi
if [ -d build ]
then
last_type=`cat build/.cmake_type`
if [ "$cmake_type" != "$last_type" ]
then
2017-03-10 18:34:56 +00:00
echo "-- Using different build system, cleaning build system files"
2017-03-02 14:37:32 +00:00
cd build
rm -r CMakeCache.txt CMakeFiles
cd ..
fi
fi
mkdir -p build
cd build
echo "$cmake_type" > .cmake_type
cmake -G "$cmake_type" -DCMAKE_INSTALL_PREFIX="$PREFIX" -DENABLED_PLUGINS="$ENABLED_PLUGINS" -DDISABLED_PLUGINS="$DISABLED_PLUGINS" -DVALA_EXECUTABLE="$VALA_EXECUTABLE" -DCMAKE_VALA_FLAGS="$VALAC_FLAGS" -DDISABLE_FAST_VAPI="$DISABLE_FAST_VAPI" -DLIB_SUFFIX="$LIB_SUFFIX" -DNO_DEBUG="$NO_DEBUG" ..
2017-03-02 14:37:32 +00:00
if [ "$cmake_type" == "Ninja" ]
then
cat << EOF > Makefile
default:
@sh -c "$exec_command"
2017-03-02 14:37:32 +00:00
%:
@sh -c "$exec_command \"\$@\""
2017-03-02 14:37:32 +00:00
EOF
fi
cd ..
cat << EOF > Makefile
default:
@sh -c "cd build; $exec_command"
2017-03-02 14:37:32 +00:00
%:
@sh -c "cd build; $exec_command \"\$@\""
2017-03-02 14:37:32 +00:00
EOF
echo "-- Configured. Type 'make' to build, 'make install' to install."