2014-03-02 21:20:49 +01:00
|
|
|
#!/bin/sh
|
2014-06-13 02:41:03 +02:00
|
|
|
|
2018-09-30 13:36:34 +02:00
|
|
|
ERESSEA_DB=memory
|
2018-09-26 20:36:27 +02:00
|
|
|
pkg-config --exists sqlite3 && ERESSEA_DB=sqlite
|
2018-09-30 13:36:34 +02:00
|
|
|
|
|
|
|
GETOPT=getopt
|
|
|
|
GETOPT_LONG=1
|
|
|
|
|
2020-10-12 08:50:54 +02:00
|
|
|
if [ -z "$(luarocks show lunitx)" ] ; then
|
2020-09-30 05:08:23 +02:00
|
|
|
luarocks install lunitx --local
|
|
|
|
fi
|
2018-09-30 13:36:34 +02:00
|
|
|
if [ "Darwin" = "$(uname)" ] ; then
|
|
|
|
if [ -x "/usr/local/opt/gnu-getopt/bin/getopt" ] ; then
|
|
|
|
GETOPT="/usr/local/opt/gnu-getopt/bin/getopt"
|
|
|
|
else
|
|
|
|
GETOPT_LONG=0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $GETOPT_LONG -eq 1 ]; then
|
|
|
|
options=$(${GETOPT} -o d: -l db: -- "$@")
|
|
|
|
else # assume GNU getopt (long arguments)
|
|
|
|
options=$(${GETOPT} d: "$@")
|
|
|
|
fi
|
|
|
|
|
2018-02-02 18:25:18 +01:00
|
|
|
# Parse command line arguments
|
2018-09-30 13:36:34 +02:00
|
|
|
eval set -- "$options"
|
|
|
|
until [ -z "$1" ] ; do
|
|
|
|
case $1 in
|
|
|
|
-d|--db)
|
|
|
|
ERESSEA_DB=$2
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--) shift; break;;
|
|
|
|
(-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
|
|
|
|
(*) break;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2018-02-02 18:25:18 +01:00
|
|
|
while [ ! -z "$1" ] ; do
|
|
|
|
if [ "$1" = "--with-db" ] ; then
|
|
|
|
ERESSEA_DB=db
|
|
|
|
elif [ "$1" = "--with-sqlite" ] ; then
|
|
|
|
ERESSEA_DB=sqlite
|
2018-09-30 13:36:34 +02:00
|
|
|
elif [ "$1" = "--with-memory" ] ; then
|
|
|
|
ERESSEA_DB=memory
|
2018-02-02 18:25:18 +01:00
|
|
|
fi
|
|
|
|
shift 1
|
|
|
|
done
|
|
|
|
|
2021-02-16 10:09:14 +01:00
|
|
|
git submodule update --init
|
2017-01-30 10:26:08 +01:00
|
|
|
ROOT=$(git rev-parse --show-toplevel)
|
2014-06-29 01:54:10 +02:00
|
|
|
[ -z $BUILD ] && BUILD=Debug
|
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"
|
2016-11-25 17:01:28 +01:00
|
|
|
|
|
|
|
MACHINE=`$CC -dumpmachine`
|
|
|
|
[ -z $MACHINE ] && MACHINE=`uname -m`
|
2015-07-11 20:48:54 +02:00
|
|
|
BIN_DIR="$ROOT/build-$MACHINE-$CC-$BUILD"
|
2017-03-27 21:10:30 +02:00
|
|
|
rm -rf $BIN_DIR
|
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
|
|
|
# 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
|
|
|
|
|
2017-01-14 17:19:08 +01:00
|
|
|
DEST=$(dirname $ROOT)/server
|
2015-07-12 03:08:29 +02:00
|
|
|
|
2018-03-10 18:26:56 +01:00
|
|
|
LUA_INCLUDE=/usr/include
|
2018-01-11 17:13:49 +01:00
|
|
|
LUA_DIR=/usr
|
2021-02-12 21:10:41 +01:00
|
|
|
if [ -d /usr/local/include/lua ]; then
|
|
|
|
LUA_INCLUDE=/usr/local/include/lua
|
2021-02-14 15:07:46 +01:00
|
|
|
elif [ -d /usr/include/lua5.4 ]; then
|
|
|
|
LUA_INCLUDE=/usr/include/lua5.4
|
|
|
|
elif [ -d /usr/include/lua5.3 ]; then
|
|
|
|
LUA_INCLUDE=/usr/include/lua5.3
|
2018-03-10 18:26:56 +01:00
|
|
|
elif [ -d /usr/include/lua5.2 ]; then
|
|
|
|
LUA_INCLUDE=/usr/include/lua5.2
|
2020-05-03 15:05:22 +02:00
|
|
|
elif [ -d /usr/include/lua5.1 ]; then
|
|
|
|
LUA_INCLUDE=/usr/include/lua5.1
|
2018-01-11 17:13:49 +01:00
|
|
|
elif [ -d /usr/local/include/lua5.1 ]; then
|
2021-02-12 21:10:41 +01:00
|
|
|
LUA_DIR=/usr/local
|
2018-03-10 18:26:56 +01:00
|
|
|
LUA_INCLUDE=/usr/local/include/lua5.1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -e ${LUA_INCLUDE}/lua.h ]; then
|
2018-03-10 18:26:56 +01:00
|
|
|
echo "no compatible version of lua is installed in $LUA_INCLUDE."
|
2018-03-10 18:26:56 +01:00
|
|
|
exit 1
|
2018-01-11 17:13:49 +01:00
|
|
|
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
|
|
|
set -e
|
2015-07-12 01:04:39 +02:00
|
|
|
|
2015-07-11 20:48:54 +02:00
|
|
|
cd $BIN_DIR
|
2018-02-02 18:25:18 +01:00
|
|
|
cmake -C config.cmake .. $*
|
2014-07-03 06:35:16 +02:00
|
|
|
cd $OLDPWD
|
2014-07-04 08:20:49 +02:00
|
|
|
|