server/s/cmake-init

94 lines
2.3 KiB
Plaintext
Raw Normal View History

#!/bin/sh
2018-02-02 18:25:18 +01:00
ERESSEA_DB=db
if [ -e /usr/include/sqlite3.h ] ; then
ERESSEA_DB=sqlite
2018-02-02 18:25:18 +01:00
fi
# Parse command line arguments
while [ ! -z "$1" ] ; do
if [ "$1" = "--with-db" ] ; then
ERESSEA_DB=db
elif [ "$1" = "--with-sqlite" ] ; then
ERESSEA_DB=sqlite
fi
shift 1
done
ROOT=$(git rev-parse --show-toplevel)
2014-06-29 01:54:10 +02:00
[ -z $BUILD ] && BUILD=Debug
[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang"
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
MACHINE=`$CC -dumpmachine`
[ -z $MACHINE ] && MACHINE=`uname -m`
BIN_DIR="$ROOT/build-$MACHINE-$CC-$BUILD"
2017-03-27 21:10:30 +02:00
rm -rf $BIN_DIR
mkdir -p $BIN_DIR
rm -f $BUILD
ln -sf $BIN_DIR $BUILD
# 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
DEST=$(dirname $ROOT)/server
2015-07-12 03:08:29 +02:00
git submodule update --init
LUA_VERSION="5.2"
LUA_DIR=/usr
if [ -d /usr/include/lua5.1 ]; then
LUA_VERSION="5.1"
elif [ -d /usr/local/include/lua5.1 ]; then
2018-02-04 14:59:01 +01:00
export LUA_DIR=/usr/local
LUA_VERSION="5.1"
fi
2018-02-02 18:25:18 +01:00
cat >| $BUILD/config.cmake <<HEREDOC
SET (ERESSEA_DB "$ERESSEA_DB" CACHE STRING "Database driver")
SET (LUA_DIR "$LUA_DIR" CACHE PATH "Lua root path")
2018-02-03 09:58:56 +01:00
SET (CMAKE_BUILD_TYPE "$BUILD" CACHE STRING "")
2018-02-02 18:25:18 +01:00
SET (CMAKE_INSTALL_PREFIX "$DEST" CACHE PATH "")
SET (CMAKE_LIBRARY_PATH "$LIBRARY_PATH" CACHE PATH "")
SET (CMAKE_PREFIX_PATH "$PREFIX_PATH" CACHE PATH "")
HEREDOC
2015-07-12 03:08:29 +02:00
path="$(which tolua)"
if [ "$HAVE_TOLUA" = "0" ] || [ -z $path ] ; then
echo "tolua is not installed, building from source"
cd $ROOT
if [ ! -d tolua ]; then
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
2018-02-04 14:59:01 +01:00
cd -
cat >> $BUILD/config.cmake <<TOLUA
SET(PC_TOLUA_DIR "$ROOT/tolua" CACHE PATH "tolua root")
TOLUA
2015-07-12 03:08:29 +02:00
else
echo "tolua is $path"
fi
2015-07-12 03:08:29 +02:00
unset path
2015-07-12 03:08:29 +02:00
set -e
2015-07-12 01:04:39 +02:00
cd $BIN_DIR
2018-02-02 18:25:18 +01:00
cmake -C config.cmake .. $*
cd $OLDPWD