2014-03-02 21:20:49 +01:00
|
|
|
#!/bin/sh
|
2014-06-13 02:41:03 +02:00
|
|
|
ROOT=$(pwd)
|
|
|
|
while [ ! -d $ROOT/.git ]; do
|
|
|
|
ROOT=$(dirname $ROOT)
|
|
|
|
if [ "$ROOT" == "/" ; then
|
|
|
|
echo "could not find root, are you in the git repository?"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2014-06-29 01:54:10 +02:00
|
|
|
[ -z $BUILD ] && BUILD=Debug
|
2014-07-04 08:20:49 +02:00
|
|
|
MACHINE=`uname -m`
|
2015-10-27 12:32:32 +01:00
|
|
|
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
|
2014-06-13 02:41:03 +02:00
|
|
|
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
|
|
|
|
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
|
|
|
|
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
|
2015-07-11 20:48:54 +02:00
|
|
|
BIN_DIR="$ROOT/build-$MACHINE-$CC-$BUILD"
|
2014-07-04 08:20:49 +02:00
|
|
|
mkdir -p $BIN_DIR
|
2016-02-25 23:11:44 +01:00
|
|
|
rm -f $BUILD
|
2014-08-17 11:19:04 +02:00
|
|
|
ln -sf $BIN_DIR $BUILD
|
2014-06-13 02:41:03 +02:00
|
|
|
|
2014-03-02 21:20:49 +01:00
|
|
|
MACHINE=$(gcc -dumpmachine)
|
|
|
|
rm -f CMakeCache.txt
|
|
|
|
|
|
|
|
# use anything installed in /opt or /usr
|
|
|
|
LIBRARY_PATH=/opt/lib:/opt/lib/$MACHINE:/usr/lib/$MACHINE
|
|
|
|
INCLUDE_PATH=/opt/include:/usr/include
|
|
|
|
PREFIX_PATH=/opt
|
|
|
|
|
|
|
|
# I like to put stuff in ~/usr if I don't have permission to install packages on the machine:
|
|
|
|
if [ -d $HOME/usr ]; then
|
|
|
|
LIBRARY_PATH=$HOME/usr/lib:$HOME/usr/lib/$MACHINE:$LIBRARY_PATH
|
|
|
|
INCLUDE_PATH=$HOME/usr/include:$HOME/usr/include/$MACHINE:$INCLUDE_PATH
|
|
|
|
PREFIX_PATH=$HOME/usr:$HOME/usr/local:$PREFIX_PATH
|
|
|
|
fi
|
|
|
|
|
2015-07-12 03:08:29 +02:00
|
|
|
ARGS=" -DCMAKE_MODULE_PATH=$ROOT/cmake/Modules \
|
|
|
|
-DCMAKE_BUILD_TYPE=$BUILD \
|
|
|
|
-DCMAKE_LIBRARY_PATH=$LIBRARY_PATH \
|
|
|
|
-DCMAKE_INCLUDE_PATH=$INCLUDE_PATH \
|
|
|
|
-DCMAKE_PREFIX_PATH=$PREFIX_PATH \
|
|
|
|
-DCMAKE_INSTALL_PREFIX=$HOME/eressea/server"
|
|
|
|
|
|
|
|
path="$(which tolua)"
|
|
|
|
if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then
|
2015-07-11 20:48:54 +02:00
|
|
|
echo "tolua is not installed, building from source"
|
2016-09-30 21:46:29 +02:00
|
|
|
cd $ROOT
|
|
|
|
if [ ! -d tolua ]; then
|
2016-10-30 05:37:12 +01:00
|
|
|
LUA_VERSION="5.2"
|
|
|
|
if [ -d /usr/include/lua5.1 ] || [ -d /usr/local/include/lua5.1 ]; then
|
|
|
|
LUA_VERSION="5.1"
|
2016-09-30 21:46:29 +02:00
|
|
|
fi
|
|
|
|
echo "fetching tolua ${LUA_VERSION} from github..."
|
|
|
|
git clone https://github.com/ennorehling/tolua-${LUA_VERSION}.git tolua
|
|
|
|
fi
|
|
|
|
echo "building tolua..."
|
|
|
|
cd tolua
|
|
|
|
make
|
2015-07-11 20:48:54 +02:00
|
|
|
ARGS="$ARGS -DPC_TOLUA_DIR=$ROOT/tolua"
|
2015-07-12 03:08:29 +02:00
|
|
|
else
|
|
|
|
echo "tolua is $path"
|
2015-07-11 20:48:54 +02:00
|
|
|
fi
|
2015-07-12 03:08:29 +02:00
|
|
|
unset path
|
2015-07-11 20:48:54 +02:00
|
|
|
|
2015-07-12 03:08:29 +02:00
|
|
|
set -e
|
2015-07-12 01:04:39 +02:00
|
|
|
|
2015-07-11 20:48:54 +02:00
|
|
|
cd $BIN_DIR
|
2015-07-12 03:08:29 +02:00
|
|
|
cmake .. $ARGS $*
|
2014-07-03 06:35:16 +02:00
|
|
|
cd $OLDPWD
|
2014-07-04 08:20:49 +02:00
|
|
|
|