summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuynh Tran <nthuynh75@gmail.com>2005-06-22 20:57:01 +0000
committerHuynh Tran <nthuynh75@gmail.com>2005-06-22 20:57:01 +0000
commit3e4a09a671b5af4c1392eb6e6c5c6e1f4aa74259 (patch)
treea57143493e6bc74d4562700583e991f01d9004c6
parentfeaa46ba3278c1c2dc9c182b4e33a1c8907c9985 (diff)
downloadmanaserv-3e4a09a671b5af4c1392eb6e6c5c6e1f4aa74259.tar.gz
manaserv-3e4a09a671b5af4c1392eb6e6c5c6e1f4aa74259.tar.xz
manaserv-3e4a09a671b5af4c1392eb6e6c5c6e1f4aa74259.zip
Updated configure so that only one database backend can be selected and simplified Makefile.am.
-rw-r--r--AUTHORS1
-rw-r--r--configure.ac256
-rw-r--r--src/Makefile.am105
3 files changed, 205 insertions, 157 deletions
diff --git a/AUTHORS b/AUTHORS
index 1de82bf..32a1909 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,3 @@
Bjorn 'Hammerbear' Lindeijer <b_lindeijer@users.sourceforge.net>
Kiyoshi Kyokai <kyokai@users.sourceforge.net>
+Huynh Ngoc Chau Tran aka kindjal <nthuynh at users dot sourceforge dot net>
diff --git a/configure.ac b/configure.ac
index 78acd96..117aac5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,118 +1,198 @@
+dnl $Id$
+
+
+# TODO: write an M4 PKG_CHECK_MODULES-like for the external libraries that
+# provide an executable <lib>-config (e.g. SDL, MySQL, PostgreSQL) to
+# make this file shorter, more readable and easier to maintain.
+
+
AC_PREREQ(2.59)
-AC_INIT([TMW Server], [0.0.1], [b_lindeijer@users.sourceforge.net])
-AC_CONFIG_HEADERS([config.h:config.h.in])
+AC_INIT([TMW Server], [0.0.1], [b_lindeijer@users.sourceforge.net], [tmwserv])
+AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_RANLIB
+AC_PROG_INSTALL
+
+
+# Checks for libraries.
+AC_CHECK_LIB([crypto], [EVP_md5])
+AC_CHECK_LIB([physfs], [PHYSFS_init])
+
+# libSDL
+AC_PATH_PROG(SDL_CONFIG, [sdl-config], [no])
+if test "$SDL_CONFIG" = "no"; then
+ AC_MSG_ERROR([The sdl-config could not be found. Please check your path.])
+else
+ AC_MSG_CHECKING(SDL_CFLAGS)
+ SDL_CFLAGS=`$SDL_CONFIG --cflags`
+ AC_MSG_RESULT($SDL_CFLAGS)
+
+ AC_MSG_CHECKING(SDL_LIBS)
+ SDL_LIBS=`$SDL_CONFIG --libs`
+ AC_MSG_RESULT($SDL_LIBS)
+
+ # update CXXFLAGS and LIBS.
+ CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
+ LIBS="$LIBS $SDL_LIBS"
+fi
+
+AC_CHECK_LIB([SDL_net], [SDLNet_Init])
+
+
# Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS([string.h])
+AC_HEADER_TIME
+
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
+AC_TYPE_SIZE_T
+AC_STRUCT_TM
+
# Checks for library functions.
-AC_CHECK_FUNCS([atexit])
-
-# Check if with sqlite
-AC_ARG_WITH(sqlite,[ --with-sqlite support SQLite ] )
-if test "x$with_sqlite" == "xyes"; then
- with_sqlite=yes
-
- # Check with pkg-config
- PKG_CHECK_MODULES(SQLITE, [sqlite3 >= 3.0.6],
+AC_FUNC_ALLOCA
+AC_FUNC_ERROR_AT_LINE
+AC_FUNC_SETVBUF_REVERSED
+AC_FUNC_VPRINTF
+AC_CHECK_FUNCS([atexit strrchr])
+
+
+# Checks for the storage backend.
+AC_ARG_WITH(
+ [storage-backend],
+ AS_HELP_STRING(
+ [--with-storage-backend=ARG],
+ [use storage backend [[ARG=mysql,postgresql,sqlite]]
+ [(default=sqlite)]]
+ ),
[],
- [AC_MSG_ERROR([Cannot find SQLite 3])]
- )
-
- # Add define
- SQLITE_CFLAGS=" -DSQLITE_SUPPORT"
-
- AC_SUBST(SQLITE_CFLAGS)
- AC_SUBST(SQLITE_LIBS)
+ [with_storage_backend="sqlite"]
+)
+
+if test "$with_storage_backend" = "mysql"; then
+ # use mysql_config to get the CFLAGS and LIBS values.
+ AC_PATH_PROG(MYSQL_CONFIG, [mysql_config], [no])
+
+ if test "$MYSQL_CONFIG" = "no"; then
+ AC_MSG_ERROR(
+ [The mysql_config could not be found. Please check your path.]
+ )
+ else
+ AC_MSG_CHECKING(MYSQL_CFLAGS)
+ MYSQL_CFLAGS=`$MYSQL_CONFIG --cflags`
+ AC_MSG_RESULT($MYSQL_CFLAGS)
+
+ AC_MSG_CHECKING(MYSQL_LIBS)
+ MYSQL_LIBS=`$MYSQL_CONFIG --libs`
+ AC_MSG_RESULT($MYSQL_LIBS)
+
+ # update CXXFLAGS and LIBS.
+ CXXFLAGS="$CXXFLAGS -DMYSQL_SUPPORT $MYSQL_CFLAGS"
+ LIBS="$LIBS $MYSQL_LIBS"
+ fi
+elif test "$with_storage_backend" = "postgresql"; then
+ # use mysql_config to get the CFLAGS and LIBS values.
+ AC_PATH_PROG(POSTGRESQL_CONFIG, [pg_config], [no])
+
+ if test "$POSTGRESQL_CONFIG" = "no"; then
+ AC_MSG_ERROR(
+ [The pg_config could not be found. Please check your path.]
+ )
+ else
+ AC_MSG_CHECKING(POSTGRESQL_CFLAGS)
+ POSTGRESQL_CFLAGS=`$POSTGRESQL_CONFIG --cflags`
+ AC_MSG_RESULT($POSTGRESQL_CFLAGS)
+
+ AC_MSG_CHECKING(POSTGRESQL_LIBS)
+ POSTGRESQL_LIBS=`$POSTGRESQL_CONFIG --libs`
+ AC_MSG_RESULT($POSTGRESQL_LIBS)
+
+ # update CXXFLAGS and LIBS.
+ CXXFLAGS="$CXXFLAGS -DPOSTGRESQL_SUPPORT $POSTGRESQL_CFLAGS"
+ LIBS="$LIBS $POSTGRESQL_LIBS"
+ fi
+elif test "$with_storage_backend" = "sqlite"; then
+ # use pkg-config to check libsqlite3.
+ # SQLITE_CFLAGS and SQLITE_LIBS are set by PKG_CHECK_MODULES
+ # so nothing much to do here :)
+ PKG_CHECK_MODULES(SQLITE,[sqlite3 >= 3.0.6])
+
+ # update CXXFLAGS and LIBS.
+ CXXFLAGS="$CXXFLAGS -DSQLITE_SUPPORT $SQLITE_CFLAGS"
+ LIBS="$LIBS $SQLITE_LIBS"
else
- with_sqlite=no
+ # at the moment, we support only those three databases as backends.
+ AC_MSG_ERROR([unknown storage backend: $with_storage_backend])
fi
-AM_CONDITIONAL(BUILD_SQLITE, test x$with_sqlite = xyes)
-
-# Check if with Postgre
-AC_ARG_WITH(postgre,[ --with-postgre support PostgreSQL ] )
-if test "x$with_postgre" == "xyes"; then
- with_postgre=yes
-
- # Check with pkg-config
- AC_CHECK_LIB([pq], [PQconnectdb], ,
- AC_MSG_ERROR([Cannot find PostgreSQL]))
-
- # Add define
- POSTGRE_CFLAGS=" -DPOSTGRE_SUPPORT"
- POSTGRE_LIBS=" -lpq"
-
- AC_SUBST(POSTGRE_CFLAGS)
- AC_SUBST(POSTGRE_LIBS)
-else
- with_postgre=no
-fi
-AM_CONDITIONAL(BUILD_POSTGRE, test x$with_postgre = xyes)
-
-# Check if with Postgre
-AC_ARG_WITH(mysql,[ --with-mysql support MySQL ] )
-if test "x$with_mysql" == "xyes"; then
- with_mysql=yes
-
- # TODO: Fix this up! (the lib might not be in the LD path)
- # Check with pkg-config
- AC_CHECK_LIB([mysqlclient], [mysql_init], ,
- AC_MSG_ERROR([Cannot find MySQL]))
-
- # Add define
- MYSQL_CFLAGS=" -DMYSQL_SUPPORT `mysql_config --libs`"
- MYSQL_LIBS=" `mysql_config --libs`"
-
- AC_SUBST(MYSQL_CFLAGS)
- AC_SUBST(MYSQL_LIBS)
-else
- with_mysql=no
+# Checks for the scripting engine.
+AC_ARG_WITH(
+ [scripting-engine],
+ AS_HELP_STRING(
+ [--with-scripting-engine=ARG],
+ [use scripting engine [[ARG=ruby,squirrel]] [(default=squirrel)]]
+ ),
+ [],
+ [with_scripting_engine="no"]
+)
+
+if test "$with_scripting_engine" = "ruby"; then
+ AC_MSG_ERROR([sorry, $with_scripting_engine is not supported yet])
+elif test "$with_scripting_engine" = "squirrel"; then
+ AC_CHECK_LIB([squirrel], [sq_open])
+
+ # update CXXFLAGS and LIBS
+ CXXFLAGS="$CXXFLAGS -DSCRIPT_SUPPORT -DSQUIRREL_SUPPORT"
+ LIBS="$LIBS -lsqstdlib"
+elif test ! "$with_scripting_engine" = "no"; then
+ AC_MSG_ERROR([unknown scripting engine: $with_scripting_engine])
fi
-AM_CONDITIONAL(BUILD_MYSQL, test x$with_mysql = xyes)
-# Checks for programs.
-AC_PROG_CXX
-AC_PROG_CC
-AC_PROG_RANLIB
+# Checks for the unit tests.
+AC_ARG_ENABLE(
+ [unit-tests],
+ AS_HELP_STRING([--enable-unit-tests], [compile the unit tests]),
+ [],
+ [enable_unit_tests="no"]
+)
-# Checks for libraries.
-AC_CHECK_LIB([physfs], [PHYSFS_init])
-AC_CHECK_LIB([SDL_net], [SDLNet_Init])
-AC_CHECK_LIB([crypto], [EVP_Digest])
-AC_CHECK_LIB([crypto], [EVP_md5])
-AC_ARG_WITH(scripting,[ --with-scripting Build with scripting])
-if test "x$with_scripting" == "xyes"; then
- AC_CHECK_LIB([squirrel], [sq_open], ,
- AC_MSG_ERROR([Cannot find Squirrel library (squirrel.sf.net)]))
+# TODO
+# Configure the unit tests.
+#if test "$enable_unit_tests" = "yes" -a -d $srcdir/src/tests; then
+# AC_CONFIG_SUBDIRS([src/tests])
+#fi
- with_scripting=yes
- SCRIPT_CFLAGS=' -DSCRIPT_SUPPORT'
- SCRIPT_LIBS=' -lsquirrel -lsqstdlib'
- AC_SUBST(SCRIPT_CFLAGS)
- AC_SUBST(SCRIPT_LIBS)
-else
- with_scripting=no
-fi
+
+AM_CONDITIONAL(BUILD_MYSQL, test "$with_storage_backend" = "mysql")
+AM_CONDITIONAL(BUILD_POSTGRESQL, test "$with_storage_backend" = "postgresql")
+AM_CONDITIONAL(BUILD_SQLITE, test "$with_storage_backend" = "sqlite")
+
+AM_CONDITIONAL(BUILD_RUBY, test "$with_scripting_engine" = "ruby")
+AM_CONDITIONAL(BUILD_SQUIRREL, test "$with_scripting_engine" = "squirrel")
AC_CONFIG_FILES([Makefile
src/Makefile])
-
AC_OUTPUT
+
+echo
+echo "-------------------------------------------------------"
+echo " $PACKAGE_NAME will be compiled with these options: "
echo
-echo "Building with scripting support: $with_scripting"
-echo "Building with SQLite support: $with_sqlite"
-echo "Building with PostgreSQL support: $with_postgre"
-echo "Building with MySQL support: $with_mysql"
+echo " + storage backend : $with_storage_backend "
+echo " + scripting engine: $with_scripting_engine "
+echo " + with unit tests : $enable_unit_tests "
+echo "-------------------------------------------------------"
echo
diff --git a/src/Makefile.am b/src/Makefile.am
index 33e1836..3c39871 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,79 +1,46 @@
+# $Id$
+
+
bin_PROGRAMS = tmwserv
+
tmwserv_SOURCES = main.cpp \
- accounthandler.h \
- accounthandler.cpp \
- connectionhandler.h \
- connectionhandler.cpp \
- debug.h \
- debug.cpp \
- defines.h \
- messagehandler.h \
- messagehandler.cpp \
- messagein.h \
- messagein.cpp \
- messageout.h \
- messageout.cpp \
- netcomputer.h \
- netcomputer.cpp \
- netsession.h \
- netsession.cpp \
- packet.h \
- packet.cpp \
- skill.h \
- skill.cpp \
- script.h \
- script.cpp \
- script-squirrel.h \
- script-squirrel.cpp \
- storage.cpp storage.h \
- account.h \
- account.cpp \
- object.h \
- object.cpp \
- dal/dataprovider.h \
- dal/dataprovider.cpp \
- dal/dataproviderfactory.h \
- dal/dataproviderfactory.cpp \
- dal/recordset.h \
- dal/recordset.cpp \
- dal/dalexcept.h \
- dalstorage.h \
- dalstoragesql.h \
- dalstorage.cpp \
- utils/singleton.h \
- utils/cipher.h \
- utils/cipher.cpp \
- utils/logger.h \
- utils/logger.cpp
+ accounthandler.cpp \
+ connectionhandler.cpp \
+ debug.cpp \
+ defines.h \
+ messagehandler.cpp \
+ messagein.cpp \
+ messageout.cpp \
+ netcomputer.cpp \
+ netsession.cpp \
+ packet.cpp \
+ skill.cpp \
+ storage.cpp \
+ account.cpp \
+ object.cpp \
+ dalstorage.cpp \
+ dal/dataprovider.cpp \
+ dal/dataproviderfactory.cpp \
+ dal/recordset.cpp \
+ utils/cipher.cpp \
+ utils/logger.cpp
-if BUILD_SQLITE
-tmwserv_SOURCES += dal/sqlitedataprovider.h \
- dal/sqlitedataprovider.cpp
+if BUILD_MYSQL
+tmwserv_SOURCES += dal/mysqldataprovider.cpp
endif
-if BUILD_POSTGRE
-tmwserv_SOURCES += dal/pqdataprovider.h \
- dal/pqdataprovider.cpp
+if BUILD_POSTGRESQL
+tmwserv_SOURCES += dal/pqdataprovider.cpp
endif
-if BUILD_MYSQL
-tmwserv_SOURCES += dal/mysqldataprovider.h \
- dal/mysqldataprovider.cpp
+if BUILD_SQLITE
+tmwserv_SOURCES += dal/sqlitedataprovider.cpp
endif
-# set the include path found by configure
-INCLUDES= $(all_includes)
-LIBS = $(SQLITE_LIBS) $(MYSQL_LIBS) $(POSTGRE_LIBS)
-
-# the library search path.
-tmwserv_LDFLAGS = $(all_libraries) \
- -lSDL_net `sdl-config --libs` \
- `pkg-config --libs libxml-2.0` \
- -lphysfs \
- -lcrypto
-tmwserv_CXXFLAGS = -g -Wall `sdl-config --cflags` `pkg-config --cflags libxml-2.0` -fno-inline $(SCRIPT_CFLAGS) $(POSTGRE_CFLAGS) $(SQLITE_CFLAGS)
-
-#tmwserv_LDADD = $(LIBSDL_LIBS) -lphysfs
-tmwserv_LDADD = $(SCRIPT_LIBS)
-tmwserv_TARGET = ../tmwserv
+if BUILD_SQUIRREL
+tmwserv_SOURCES += script.cpp \
+ script-squirrel.cpp
+endif
+tmwserv_CXXFLAGS = -Wall -fno-inline
+tmwserv_TARGET = tmwserv