anotherim-desktop/configure

100 lines
2.1 KiB
Plaintext
Raw Normal View History

2017-03-02 14:37:32 +00:00
#!/bin/bash
cont() {
read c
if [ "$c" != "yes" ] && [ "$c" != "Yes" ] && [ "$c" != "y" ] && [ "$c" != "Y" ]
then
exit 3
fi
}
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"
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
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
if [ ! -f "build/.cmake_type" ]
then
2017-03-10 18:34:56 +00:00
printf "-!- ./build exists but was not created by ./configure script, continue? [y/N] "
2017-03-02 14:37:32 +00:00
cont
fi
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" ..
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
if [[ "$exec_bin" == "$make_bin" ]]; then
echo "-- Running with make. Using Ninja (ninja-build) might improve build experience."
fi