dino/configure

83 lines
1.5 KiB
Text
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 [ ! -e `which cmake` ]
then
echo "CMake required."
exit 1
fi
if [ -x "$(which ninja 2>/dev/null)" ]; then
2017-03-10 18:34:56 +00:00
echo "-- Found Ninja: $(which ninja)"
2017-03-02 14:37:32 +00:00
cmake_type="Ninja"
exec_bin="ninja"
elif [ -x "$(which ninja-build 2>/dev/null)" ]; then
2017-03-10 18:34:56 +00:00
echo "-- Found Ninja: $(which ninja-build)"
2017-03-02 14:37:32 +00:00
cmake_type="Ninja"
exec_bin="ninja-build"
elif [ -x "$(which make 2>/dev/null)" ]; then
2017-03-10 18:34:56 +00:00
echo "-- Found Make: $(which make)"
2017-03-02 14:37:32 +00:00
cmake_type="Unix Makefiles"
2017-03-10 18:34:56 +00:00
exec_bin="make -j4"
echo "-- Using Ninja might improve build experience."
2017-03-02 14:37:32 +00:00
cont
else
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
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_bin"
%:
@sh -c "$exec_bin \"\$@\""
EOF
fi
cd ..
cat << EOF > Makefile
default:
@sh -c "cd build; $exec_bin"
%:
@sh -c "cd build; $exec_bin \"\$@\""
EOF