123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755 |
- # -*- Autoconf -*-
- # Process this file with autoconf to produce a configure script.
- AC_INIT(rAthena)
- AC_REVISION($Revision$)
- AC_PREREQ([2.59])
- AC_CONFIG_SRCDIR([src/common/cbasetypes.h])
- AC_CONFIG_FILES([Makefile src/common/Makefile])
- AC_CONFIG_FILES([3rdparty/mt19937ar/Makefile])
- AC_CONFIG_FILES([src/char/Makefile src/login/Makefile])
- AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile src/tool/Makefile])
- #
- # Memory managers
- #
- AC_ARG_ENABLE(
- [manager],
- AC_HELP_STRING(
- [--enable-manager=ARG],
- [memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin)]
- ),
- [
- enable_manager="$enableval"
- case $enableval in
- "no");;
- "builtin");;
- "memwatch");;
- "dmalloc");;
- "gcollect");;
- "bcheck");;
- *) AC_MSG_ERROR([[unknown memory manager '$enableval'... stopping]]);;
- esac
- ],
- [enable_manager="builtin"]
- )
- #
- # packetver
- #
- AC_ARG_ENABLE(
- [packetver],
- AC_HELP_STRING(
- [--enable-packetver=ARG],
- [Sets the PACKETVER define of the map-server. (see src/map/clif.h)]
- ),
- [enable_packetver="$enableval"],
- [enable_packetver=""]
- )
- #
- # debug
- #
- AC_ARG_ENABLE(
- [debug],
- AC_HELP_STRING(
- [--enable-debug@<:@=ARG@:>@],
- [
- Compiles extra debug code. (disabled by default)
- (available options: yes, no, gdb)
- ]
- ),
- [
- enable_debug="$enableval"
- case $enableval in
- "no");;
- "yes");;
- "gdb");;
- *) AC_MSG_ERROR([[invalid argument --enable-debug=$enableval... stopping]]);;
- esac
- ],
- [enable_debug="no"]
- )
- #
- # Buildbot
- #
- AC_ARG_ENABLE(
- [buildbot],
- AC_HELP_STRING(
- [--enable-buildbot@<:@=ARG@:>@],
- [(available options: yes, no)]
- ),
- [
- enable_buildbot="$enableval"
- case $enableval in
- "no");;
- "yes");;
- *) AC_MSG_ERROR([[invalid argument --enable-buildbot=$enableval... stopping]]);;
- esac
- ],
- [enable_buildbot="no"]
- )
- #
- # RDTSC as Tick Source
- #
- AC_ARG_ENABLE(
- [rdtsc],
- AC_HELP_STRING(
- [--enable-rdtsc],
- [
- Uses rdtsc as timing source (disabled by default)
- Enable it when you've timing issues.
- (For example: in conjunction with XEN or Other Virtualization mechanisms)
-
- Note:
- Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options.
- (On the most modern Dedicated Servers cpufreq is preconfigured, see your distribution's manual
- how to disable it)
- ]
- ),
- [
- enable_rdtsc=1
- ],
- [enable_rdtsc=0]
- )
- #
- # Profiler
- #
- AC_ARG_ENABLE(
- [profiler],
- AC_HELP_STRING(
- [--enable-profiler=ARG],
- [Profilers: no, gprof (disabled by default)]
- ),
- [
- enable_profiler="$enableval"
- case $enableval in
- "no");;
- "gprof");;
- *) AC_MSG_ERROR([[invalid argument --enable-profiler=$enableval... stopping]]);;
- esac
- ],
- [enable_profiler="no"]
- )
- #
- # 64bit
- #
- AC_ARG_ENABLE(
- [64bit],
- AC_HELP_STRING(
- [--enable-64bit],
- [
- Don't force 32 bit. (disabled by default)
- 64bit support is still being tested, not recommended for production servers.
- ]
- ),
- [
- enable_64bit="$enableval"
- case $enableval in
- "no");;
- "yes");;
- *) AC_MSG_ERROR([[invalid argument --enable-64bit=$enableval... stopping]]);;
- esac
- ],
- [enable_64bit="no"]
- )
- #
- # Optionally specify the path to mysql_config
- #
- AC_ARG_WITH(
- [mysql],
- AC_HELP_STRING(
- [--with-mysql@<:@=ARG@:>@],
- [optionally specify the path to the mysql_config executable]
- ),
- [
- if test "$withval" != "no" ; then
- if test ! -x "$withval" ; then
- AC_MSG_ERROR([$withval is not an executable file])
- fi
- MYSQL_CONFIG_HOME="$withval"
- fi
- ]
- )
- #
- # Manual MYSQL_CFLAGS (optional)
- #
- AC_ARG_WITH(
- [MYSQL_CFLAGS],
- AC_HELP_STRING(
- [--with-MYSQL_CFLAGS=ARG],
- [specify MYSQL_CFLAGS manually (instead of using "mysql_config --include")]
- ),
- [
- manual_MYSQL_CFLAGS="yes"
- MYSQL_CFLAGS="$withval"
- ],
- [manual_MYSQL_CFLAGS="no"]
- )
- #
- # Manual MYSQL_LIBS (optional)
- #
- AC_ARG_WITH(
- [MYSQL_LIBS],
- AC_HELP_STRING(
- [--with-MYSQL_LIBS=ARG],
- [specify MYSQL_LIBS manually (instead of using "mysql_config --libs")]
- ),
- [
- manual_MYSQL_LIBS="yes"
- MYSQL_LIBS="$withval"
- ],
- [manual_MYSQL_LIBS="no"]
- )
- #
- # Enable/disable PCRE and optionally specify the path (optional library)
- #
- AC_ARG_WITH(
- [pcre],
- AC_HELP_STRING(
- [--with-pcre@<:@=ARG@:>@],
- [use PCRE library, optionally specify the full path of pcre installation directory (by default pcre is used if found)]
- ),
- [
- if test "$withval" = "no" ; then
- want_pcre="no"
- else
- want_pcre="yes"
- require_pcre="yes"
- if test "$withval" != "yes" ; then
- if test ! -d "$withval" ; then
- AC_MSG_ERROR([$withval is not a directoy])
- fi
- PCRE_HOME="$withval"
- fi
- fi
- ],
- [want_pcre="yes" require_pcre="no"]
- )
- #
- # Specify the path of the zlib library (required library)
- #
- AC_ARG_WITH(
- [zlib],
- AC_HELP_STRING(
- [--with-zlib=DIR],
- [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local).
- Assumes that the header files are in DIR/include and the library files are in DIR/lib]
- ),
- [
- test -n "$withval" && ZLIB_HOME="$withval"
- ],
- [
- ZLIB_HOME=/usr/local
- test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr
- ]
- )
- ###############################################################################
- # Check for programs and types.
- #
- AC_PROG_MAKE_SET
- AC_PROG_CC
- AC_PROG_CPP
- AC_LANG([C])
- CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wno-sign-compare"
- CPPFLAGS="$CPPFLAGS -I../common"
- AC_C_BIGENDIAN(
- [AC_MSG_ERROR([[bigendian is not supported... stopping]])],
- ,
- [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])]
- )
- if test "$enable_64bit" = "no" ; then
- AC_MSG_CHECKING([whether pointers can be stored in ints (old code)])
- pointers_fit_in_ints="no"
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])],
- [pointers_fit_in_ints="yes"],
- []
- )
- if test "$pointers_fit_in_ints" = "no" ; then
- CFLAGS="$CFLAGS -m32"
- LDFLAGS="$LDFLAGS -m32"
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])],
- [pointers_fit_in_ints="yes (with -m32)"],
- []
- )
- fi
- AC_MSG_RESULT($pointers_fit_in_ints)
- if test "$pointers_fit_in_ints" = "no" ; then
- AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping])
- fi
- fi
- AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
- OLD_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Wno-unused-parameter"
- AC_COMPILE_IFELSE(
- [int foo;],
- [AC_MSG_RESULT([yes])],
- [
- AC_MSG_RESULT([no])
- CFLAGS="$OLD_CFLAGS"
- ]
- )
- AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
- OLD_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Wno-pointer-sign"
- AC_COMPILE_IFELSE(
- [int foo;],
- [
- AC_MSG_RESULT([yes])
- AC_MSG_CHECKING([whether $CC can actually use -Wno-pointer-sign])
- # This option causes warnings in C++ mode
- # Note: -Werror must be before -Wno-pointer-sign, otherwise it does not do anything
- CFLAGS="$OLD_CFLAGS -Werror -Wno-pointer-sign"
- AC_COMPILE_IFELSE(
- [int foo;],
- [
- AC_MSG_RESULT([yes])
- CFLAGS="$OLD_CFLAGS -Wno-pointer-sign"
- ],
- [
- AC_MSG_RESULT([no])
- CFLAGS="$OLD_CFLAGS"
- ]
- )
- ],
- [
- AC_MSG_RESULT([no])
- CFLAGS="$OLD_CFLAGS"
- ]
- )
- AC_MSG_CHECKING([whether $CC supports -Wno-switch])
- OLD_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Wno-switch"
- AC_COMPILE_IFELSE(
- [int foo;],
- [AC_MSG_RESULT([yes])],
- [
- AC_MSG_RESULT([no])
- CFLAGS="$OLD_CFLAGS"
- ]
- )
- AC_MSG_CHECKING([whether $CC supports -fPIC])
- OLD_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -fPIC"
- AC_COMPILE_IFELSE(
- [int foo;],
- [
- AC_MSG_RESULT([yes])
- compiler_supports_pic="yes"
- ],
- [
- AC_MSG_RESULT([no])
- compiler_supports_pic="no"
- ]
- )
- CFLAGS="$OLD_CFLAGS"
- #
- # -shared needs position independent code; some platforms emit it
- # always, others need -fPIC
- #
- AC_MSG_CHECKING([whether $CC needs -fPIC for shared objects])
- OLD_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -shared"
- WITH_PLUGINS="yes"
- AC_LINK_IFELSE(
- [
- int foo(void)
- {
- return 0;
- }
- ],
- [
- AC_MSG_RESULT([no])
- CFLAGS="$OLD_CFLAGS"
- ],
- [
- if test "$compiler_supports_pic" = "yes" ; then
- # Verify if -shared really fails due to lack of -fPIC or something else
- CFLAGS="$CFLAGS -fPIC"
- AC_LINK_IFELSE(
- [
- int foo(void)
- {
- return 0;
- }
- ],
- [
- AC_MSG_RESULT([yes])
- CFLAGS="$OLD_CFLAGS -fPIC"
- ],
- [
- AC_MSG_RESULT([no, but fails for another reason])
- AC_MSG_ERROR([compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping])
- ]
- )
- else
- # Disable compilation of plugins (optional), so 'make all' does not fail
- AC_MSG_RESULT([yes, but unsupported])
- AC_MSG_NOTICE([compiler is unable to generate position independent code, disabled plugins (optional)])
- WITH_PLUGINS="no"
- fi
- ]
- )
- AC_SUBST([WITH_PLUGINS])
- #
- # -O2 implies -fstrict-aliasing, but the code is not safe for that
- #
- AC_MSG_CHECKING([whether $CC supports -fno-strict-aliasing])
- OLD_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -fno-strict-aliasing"
- AC_COMPILE_IFELSE(
- [int foo;],
- [AC_MSG_RESULT([yes])],
- [
- AC_MSG_RESULT([no])
- CFLAGS="$OLD_CFLAGS"
- ]
- )
- ###############################################################################
- # Check for libraries and header files.
- #
- #
- # setrlimit - used to set the socket limit
- #
- AC_CHECK_FUNC([setrlimit],[CFLAGS="$CFLAGS -DHAVE_SETRLIMIT"])
- #
- # strnlen - string length with upper scan bound
- #
- AC_CHECK_FUNC([strnlen],[CFLAGS="$CFLAGS -DHAVE_STRNLEN"])
- #
- # Memory manager
- #
- case $enable_manager in
- "no")
- CFLAGS="$CFLAGS -DNO_MEMMGR"
- ;;
- "builtin")
- # enabled by default
- ;;
- "memwatch")
- CFLAGS="$CFLAGS -DMEMWATCH"
- AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
- ;;
- "dmalloc")
- CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
- LIBS="$LIBS -ldmalloc"
- AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
- ;;
- "gcollect")
- CFLAGS="$CFLAGS -DGCOLLECT"
- LIBS="$LIBS -lgc"
- AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
- ;;
- "bcheck")
- CFLAGS="$CFLAGS -DBCHECK"
- ;;
- esac
- #
- # Packetver
- #
- if test -n "$enable_packetver" ; then
- CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver"
- fi
- #
- # Debug
- #
- case $enable_debug in
- "no")
- # default value
- CFLAGS="$CFLAGS -Wno-unused -Wno-parentheses"
- ;;
- "yes")
- CFLAGS="$CFLAGS -g -DDEBUG"
- ;;
- "gdb")
- CFLAGS="$CFLAGS -ggdb -DDEBUG"
- ;;
- esac
- #
- # Buildbot
- #
- case $enable_buildbot in
- "no")
- # default value
- ;;
- "yes")
- CFLAGS="$CFLAGS -DBUILDBOT"
- ;;
- esac
- #
- # RDTSC
- #
- case $enable_rdtsc in
- 0)
- #default value
- ;;
- 1)
- CFLAGS="$CFLAGS -DENABLE_RDTSC"
- ;;
- esac
- #
- # Profiler
- #
- case $enable_profiler in
- "no")
- # default value
- ;;
- "gprof")
- CFLAGS="$CFLAGS -pg"
- LDFLAGS="$LDFLAGS -pg"
- ;;
- esac
- #
- # zlib library (required)
- #
- if test -n "${ZLIB_HOME}" ; then
- LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
- CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
- fi
- AC_CHECK_LIB([z], [inflateEnd], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
- AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
- #
- # math library (required)
- #
- AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])])
- #
- # clock_gettime (optional, rt on Debian)
- #
- AC_SEARCH_LIBS([clock_gettime], [rt])
- #
- # CLOCK_MONOTONIC clock for clock_gettime
- # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
- # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
- # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
- # checked but some systems define them even when they do not support it
- # (ref. bugreport:1003).
- #
- if test "$ac_cv_search_clock_gettime" != "no" ; then
- AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
- AC_RUN_IFELSE(
- [
- #include <sys/time.h>
- #include <time.h>
- #include <unistd.h>
-
- int main(int argc, char** argv)
- {
- struct timespec tval;
- return clock_gettime(CLOCK_MONOTONIC, &tval);
- }
- ],
- [
- AC_MSG_RESULT([yes])
- CFLAGS="$CFLAGS -DHAVE_MONOTONIC_CLOCK"
- ],
- [
- # either it failed to compile (CLOCK_MONOTONIC undefined)
- # or clock_gettime has returned a non-zero value
- AC_MSG_RESULT([no])
- ],
- [
- AC_MSG_RESULT([guessing no])
- ]
- )
- fi
- #
- # MySQL library
- #
- if test -z "$MYSQL_CONFIG_HOME"; then
- AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
- fi
- if test "$MYSQL_CONFIG_HOME" != "no" ; then
- MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
- if test "$manual_MYSQL_CFLAGS" = "no" ; then
- MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
- fi
- if test "$manual_MYSQL_LIBS" = "no" ; then
- MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
- fi
- else
- MYSQL_VERSION="unknown"
- fi
- MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
- MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
- AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
- AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
- CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
- LDFLAGS="$MYSQL_OLD_LDFLAGS"
- AC_MSG_CHECKING([MySQL library (required)])
- if test "$HAVE_MYSQL" = "yes" ; then
- AC_MSG_RESULT([yes ($MYSQL_VERSION)])
- else
- AC_MSG_RESULT([no])
- AC_MSG_ERROR([MySQL not found or incompatible])
- fi
- AC_SUBST([HAVE_MYSQL])
- AC_SUBST([MYSQL_VERSION])
- AC_SUBST([MYSQL_CFLAGS])
- AC_SUBST([MYSQL_LIBS])
- #
- # PCRE library (optional)
- #
- ##TODO PCRE version
- PCRE_LIBS=""
- PCRE_CFLAGS=""
- if test "$want_pcre" = "no" ; then
- AC_MSG_NOTICE([ignoring PCRE (optional)])
- else
- if test -z "$PCRE_HOME" ; then
- AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], [])
- if test "$HAVE_PCRE" = "yes" ; then
- PCRE_LIBS="-lpcre"
- fi
- else
- PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
- PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
- AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
- CPPFLAGS="$PCRE_OLD_CPPFLAGS"
- LDFLAGS="$PCRE_OLD_LDFLAGS"
- if test "$HAVE_PCRE" = "yes" ; then
- PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
- test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
- fi
- fi
- AC_MSG_CHECKING([PCRE library (optional)])
- if test "$HAVE_PCRE" = "yes" ; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- if test "$require_pcre" = "yes" ; then
- AC_MSG_ERROR([PCRE not found or incompatible (requested)])
- else
- AC_MSG_NOTICE([disabling PCRE (optional)])
- fi
- fi
- fi
- AC_SUBST([HAVE_PCRE])
- AC_SUBST([PCRE_LIBS])
- AC_SUBST([PCRE_CFLAGS])
- #
- # Host specific stuff
- #
- AC_MSG_CHECKING([host OS])
- host_os="`uname`"
- AC_MSG_RESULT([$host_os])
- fd_setsize=""
- DLLEXT=".so"
- case $host_os in
- Solaris* )
- LIBS="$LIBS -lsocket -lnsl -ldl"
- ;;
- Linux* )
- LIBS="$LIBS -ldl"
- ;;
- FreeBSD*)
- CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
- ;;
- NetBSD*)
- CPPFLAGS="$CPPFLAGS -D__NETBSD__"
- ;;
- CYGWIN*)
- CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
- fd_setsize="done"
- DLLEXT=".dll"
- ;;
- esac
- AC_SUBST([DLLEXT])
- AC_MSG_CHECKING([for MinGW])
- if test -n "`$CC --version | grep -i mingw`" ; then
- AC_MSG_RESULT([yes])
- CPPFLAGS="$CPPFLAGS -DMINGW"
- if test -z "$fd_setsize" ; then
- CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
- fi
- LIBS="$LIBS -lws2_32"
- else
- AC_MSG_RESULT([no])
- fi
- ###############################################################################
- AC_OUTPUT
|