[8813] Re-implement some changes in [8799], but with mutex calls commented.
[getmangos.git] / configure.ac
blobe380dfb24e7d8545af243c5e160a177ba8d7c3ce
1 # Copyright (C) 2005-2009 MaNGOS project <http://getmangos.com/>
3 # This file is free software; as a special exception the author gives
4 # unlimited permission to copy and/or distribute it, with or without
5 # modifications, as long as this notice is preserved.
7 # This program is distributed in the hope that it will be useful, but
8 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
9 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 ## Process this file with autoconf to produce a configure script.
13 # TODO: create m4 directory and put the checks there, because this file got realy poluted ( by Derex )
15 ## Prelude, basic settings for Autoconf
16 #  PACKAGE:            mangos
17 #  VERSION:            0.15.0 (trunk)
18 #  BUG-REPORT-ADDRESS: mangos-devs@lists.sourceforge.net
19 AC_INIT( [mangos], [0.15.0], [mangos-devs@lists.sourceforge.net])
20 AC_CONFIG_SRCDIR([src/shared/Common.h])
22 ## Prelude, basic settings for Automake
23 #  Turn on all warnings and error messages, and enforce GNU
24 #  standards for the package.
25 AM_INIT_AUTOMAKE([foreign -Wall -Werror gnu tar-pax])
26 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
28 AM_MAINTAINER_MODE
30 ## Prevent the configure script from continuing any further if
31 # configuration is being performed in the top-level directory.
32 # The idea is to prevent this ,because some maintainers tend
33 # to break parallel build trees (a.k.a. VPATH builds).
34 if test "$srcdir" = "." && test "$enable_maintainer_mode" != "yes"; then
35   AC_MSG_ERROR(
36      [
37       Please configure and build in a directory other than the
38       top-level source directory. This is needed because a lot
39       of maintainers tend to break parallel build trees
40       (a.k.a. VPATH builds). This is kinda real ensurance they
41       will not do it (by enforcing everybody to do VPATH builds).
43       For example, try the following from the top-level source
44       directory:
46           mkdir objdir
47           cd objdir
48           ../configure
49           make
51       This will create a build space in the directory 'objdir' and
52       start a build in that directory.
54       If however you realy want to disable this error,
55       use --enable-maintainer-mode switch.
56      ])
59 ## Disable building of static libraries by default
60 AC_DISABLE_STATIC
62 ## Check for required dependencies.
64 ## Check for a valid build environment.
65 #  Valid equals having:
66 #  - a C++ compiler compliant with the ISO98 C++ specification.
67 #  - a working library tool for creating convenience libraries.
68 #  - a working linker for creating static and shared libraries.
69 AC_PROG_CC
70 AC_PROG_CXX
71 AM_PROG_CC_C_O
72 AC_PROG_LIBTOOL
73 AC_PROG_INSTALL
74 PKG_PROG_PKG_CONFIG
76 # Check for doxygen
77 AC_ARG_ENABLE(doxygen, AC_HELP_STRING([--enable-doxygen], [turn on generating documentation]))
79 enable_doxygen_support=no
81 if test "x$enable_doxygen" = "xyes";
82 then
83   AC_PATH_PROG(DOXYGEN, doxygen, no)
84   if test "x$DOXYGEN" = "xno"; then
85     AC_MSG_ERROR([You need to install the doxygen package])
86   fi
87   enable_doxygen_support=yes
89 AM_CONDITIONAL(DOXYGEN_ENABLED, test x$enable_doxygen_support = xyes)
91 ## Check for required libraries.
92 AC_CHECK_LIB( pthread, pthread_create, [],
93     [LDFLAGS="-pthread $LDFLAGS"
94      AC_TRY_LINK([char pthread_create();],
95          pthread_create();,
96          [], [AC_MSG_ERROR([Missing pthread])])
97     ])
98 AC_CHECK_LIB( z, compress, [ZLIB=-lz],[AC_MSG_ERROR([Missing zlib])] )
99 AC_CHECK_LIB( compat, ftime, [COMPATLIB=-lcompat] )
100 PKG_CHECK_MODULES(OPENSSL, [openssl], [], [AC_MSG_ERROR([Missing openssl])])
102 AC_ARG_WITH(postgresql,
103 [  --with-postgresql       Use PostgreSQL as a backend (default: no)],
104 [case "${withval}" in
105         yes) DO_POSTGRESQL=yes ;;
106         no)  DO_POSTGRESQL=no ;;
107         maybe) DO_POSTGRESQL=maybe ;;
108         *)   AC_MSG_ERROR(Bad value ${withval} for --with-postgresql) ;;
109     esac],
110 [DO_POSTGRESQL=no])
112 AC_ARG_WITH(mysql,
113 [  --with-mysql            Use MySQL as a backend (default: yes)],
114 [case "${withval}" in
115         yes) DO_MYSQL=yes ;;
116         no)  DO_MYSQL=no ;;
117         maybe) DO_MYSQL=maybe ;;
118         *)   AC_MSG_ERROR(Bad value ${withval} for --with-mysql) ;;
119     esac],
120 [DO_MYSQL=yes])
122 # here Postgre
123 AC_MSG_CHECKING(whether to build/link POSTGRESQL)
124 if test "x$DO_POSTGRESQL" = "xyes"; then
125 DO_MYSQL=no
126 POSTGRE_INCLUDES="-I/usr/include/postgresql $POSTGRE_INCLUDES"
127 POSTGRE_LIBS="-L/usr/lib/postresql -lpq -lz -lpthread -lcrypt -lnsl -lm -lpthread -L/usr/lib $OPENSSL_LIBS $POSTGRE_LIBS "
128 CXXFLAGS="-DDO_POSTGRESQL $CXXFLAGS"
130 AC_MSG_RESULT($DO_POSTGRESQL)
132 # here mysql
133 AC_MSG_CHECKING(whether to build/link MYSQL)
134 if test "x$DO_MYSQL" = "xyes"; then
135 AC_MSG_RESULT($DO_MYSQL)
136 AC_PATH_PROGS(MYSQL_CONFIG, mysql_config, mysql_config, $PATH)
137     if test -x "$MYSQL_CONFIG"
138         then
139     # MySQL v4 uses --include while v3 uses --cflags
140         MYSQL_INCLUDES="`$MYSQL_CONFIG --include`" || \
141             MYSQL_INCLUDES="`$MYSQL_CONFIG --cflags`"
142         MYSQL_LIBS="`$MYSQL_CONFIG --libs_r`"
143         CXXFLAGS="-DDO_MYSQL $CXXFLAGS"
144         # Workaround for --as-needed linker flag that comes sometimes from mysql
145         if echo $MYSQL_LIBS|grep "\-Wl,--as-needed" > /dev/null; then
146                 MYSQL_LIBS=`echo $MYSQL_LIBS|sed -e "s/-Wl,--as-needed//"`;
147                 AC_MSG_WARN([Your mysql libs contains -Wl,--as-needed, this is not good, problem fixed in more recent mysql versions])
148         fi
149     fi
150 else
151 AC_MSG_RESULT($DO_MYSQL)
154 ## Check for memory allocator
155 #  Use libc-malloc or libtbb-malloc?
156 AC_MSG_CHECKING(whether to use libc malloc)
157 MANGOSD_STD_MALLOC=no
158 AC_ARG_WITH(std-malloc,
160 Memory allocation options:
162   --with-std-malloc       Use standard malloc],
164     if test "$withval" = "yes" ; then
165         CFLAGS="-DUSE_STANDARD_MALLOC $CFLAGS"
166         CXXFLAGS="-DUSE_STANDARD_MALLOC $CXXFLAGS"
167         MANGOSD_STD_MALLOC=yes
168     elif test "$withval" != "no" ; then
169         AC_MSG_ERROR(Please choose yes or no)
170     fi
172 AC_MSG_RESULT($MANGOSD_STD_MALLOC)
174 ## Check for options
175 #  Include debug info in library?
176 AC_MSG_CHECKING(whether to include debug info in library)
177 MANGOSD_DEBUG_INFO=no
178 AC_ARG_WITH(debug-info,
180 Debugging options:
182   --with-debug-info       Include debug info in library],
184     if test "$withval" = "yes" ; then
185         CFLAGS="-g -DMANGOS_DEBUG $CFLAGS"
186         CXXFLAGS="-g -DMANGOS_DEBUG $CXXFLAGS"
187         MANGOSD_DEBUG_INFO=yes
188     elif test "$withval" != "no" ; then
189         AC_MSG_ERROR(Please choose yes or no)
190     fi
192 AC_MSG_RESULT($MANGOSD_DEBUG_INFO)
194 ## Check for required header files.
195 AC_HEADER_STDC
196 AC_HEADER_DIRENT
197 AC_CHECK_HEADERS([ arpa/inet.h fcntl.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/timeb.h sys/time.h termios.h unistd.h  ])
199 AC_CHECK_HEADERS([pthread.h])
200 AC_CHECK_HEADERS([mysql.h mysql/mysql.h])
201 AC_CHECK_HEADERS([libpq-fe.h])
202 AC_CHECK_HEADERS([zlib.h])
204 ## Check for typedefs, structures, and compiler characteristics.
205 AC_HEADER_STDBOOL
206 AC_C_CONST
207 AC_C_INLINE
208 AC_HEADER_TIME
209 AC_STRUCT_TM
210 AC_C_VOLATILE
211 AC_CHECK_TYPES([ptrdiff_t])
213 ## Check for required library functions.
214 AC_FUNC_CLOSEDIR_VOID
215 AC_FUNC_ERROR_AT_LINE
216 AC_FUNC_MALLOC
217 AC_FUNC_MEMCMP
218 AC_FUNC_REALLOC
219 AC_FUNC_SELECT_ARGTYPES
220 AC_TYPE_SIGNAL
221 AC_FUNC_VPRINTF
222 AC_CHECK_FUNCS([atexit ftime gethostbyaddr gethostbyname gethostname gettimeofday memmove memset pow realpath select socket sqrt strchr strdup strerror strstr])
225 # Check for use buildtin ACE sources
226 AC_ARG_ENABLE(builtin_ace, AC_HELP_STRING([--enable-builtin-ace], [turn on/off using builtin ACE sources]))
228 enable_builtin_ace_support=yes
230 if test "x$enable_builtin_ace" = "xno"; then
231   PKG_CHECK_MODULES(ACE, [ACE >= 5.5.2], [need_builtin_ace=no], [need_builtin_ace=yes])
232   if test X$need_builtin_ace = Xyes ; then
233     AC_MSG_ERROR([You need to install ACE package or use built-in ACE sources])
234   fi
235   enable_builtin_ace_support=no
238 if test X$enable_builtin_ace_support = Xno; then
240   # old ace versions might not have ace/Stack_Trace.h...
241   AC_LANG_PUSH([C++])
242   AC_CHECK_HEADERS([ace/Stack_Trace.h])
243   AC_LANG_POP
244 else
245   # ...but we certainly have it in our included version
246   AC_DEFINE(HAVE_ACE_STACK_TRACE_H)
247   ACE_INCLUDES="-I\$(top_srcdir)/dep/ACE_wrappers -I\$(top_builddir)/dep/ACE_wrappers"
248   ACE_LIBS="\$(top_builddir)/dep/ACE_wrappers/ace/libACE.la"
251 AM_CONDITIONAL([MANGOS_BUILD_ACE], [test X$enable_builtin_ace_support = Xyes])
253 ## Unify all additional includes/libs in one variable.
254 # TODO this looks kinda ugly, but when we add m4 folder I will make it look very pritey ( by Derex ).
255 MANGOS_INCLUDES="$ACE_INCLUDES $POSTGRE_INCLUDES $MYSQL_INCLUDES $OPENSSL_INCLUDES $MANGOS_INCLUDES"
256 MANGOS_LIBS="$ACE_LIBS $POSTGRE_LIBS $MYSQL_LIBS $ZLIB $COMPATLIB $OPENSSL_LIBS $MANGOS_LIBS"
258 ## Export defined variables
259 AC_SUBST(DOXYGEN)
260 AC_SUBST(MANGOSD_DEBUG_INFO)
262 ## Additional CPPFLAGS and LDFLAGS.
263 AC_SUBST(MANGOS_INCLUDES)
264 AC_SUBST(MANGOS_LIBS)
266 ## Set output files.
267 AC_CONFIG_HEADERS([config.h])
268 AC_CONFIG_FILES([
269    dep/include/Makefile
270    dep/lib/Makefile
271    dep/src/Makefile
272    dep/src/g3dlite/Makefile
273    dep/src/sockets/Makefile
274    dep/src/zlib/Makefile
275    dep/Makefile
276    dep/tbb/Makefile
277    doc/Doxyfile
278    doc/Makefile
279    Makefile
280    sql/Makefile
281    sql/tools/Makefile
282    sql/updates/Makefile
283    src/Makefile
284    src/tools/Makefile
285    src/tools/genrevision/Makefile
286    src/framework/Makefile
287    src/shared/Makefile
288    src/shared/Auth/Makefile
289    src/shared/Config/Makefile
290    src/shared/Database/Makefile
291    src/shared/vmap/Makefile
292    src/shared/SystemConfig.h
293    src/game/Makefile
294    src/realmd/Makefile
295    src/realmd/realmd.conf.dist
296    src/mangosd/Makefile
297    src/mangosd/mangosd.conf.dist
298    src/bindings/Makefile
299    src/bindings/universal/Makefile
302 ## Configure ACE, if needed
303 if test X$enable_builtin_ace_support = Xyes; then
304   AC_CONFIG_SUBDIRS([dep/ACE_wrappers])
307 AC_CONFIG_COMMANDS([default],[
308   echo ""
309   echo "Configuration of MaNGOS $PACKAGE_VERSION is now complete."
310   echo ""
311  ],[PACKAGE_VERSION=$PACKAGE_VERSION])
313 ## Disabled Makefiles, until they are ready for a successful make and
314 #  make dist run.
316 ## Output files.
317 AC_OUTPUT