[9624] varargs list (...) auto promote any float value to double and any less int...
[getmangos.git] / configure.ac
blob90b332abc8857b7996809dde3ba98deadb2316a7
1 # Copyright (C) 2005-2010 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.16.0 (trunk)
18 #  BUG-REPORT-ADDRESS: mangos-devs@lists.sourceforge.net
19 AC_INIT( [mangos], [0.16.0], [mangos-devs@lists.sourceforge.net])
20 AC_CONFIG_SRCDIR([src/shared/Common.h])
21 AC_CONFIG_MACRO_DIR([m4])
23 ## Prelude, basic settings for Automake
24 #  Turn on all warnings and error messages, and enforce GNU
25 #  standards for the package.
26 AM_INIT_AUTOMAKE([foreign -Wall -Werror gnu tar-pax])
27 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
29 AM_MAINTAINER_MODE
31 ## Prevent the configure script from continuing any further if
32 # configuration is being performed in the top-level directory.
33 # The idea is to prevent this ,because some maintainers tend
34 # to break parallel build trees (a.k.a. VPATH builds).
35 if test "$srcdir" = "." && test "$enable_maintainer_mode" != "yes"; then
36   AC_MSG_ERROR(
37      [
38       Please configure and build in a directory other than the
39       top-level source directory. This is needed because a lot
40       of maintainers tend to break parallel build trees
41       (a.k.a. VPATH builds). This is kinda real ensurance they
42       will not do it (by enforcing everybody to do VPATH builds).
44       For example, try the following from the top-level source
45       directory:
47           mkdir objdir
48           cd objdir
49           ../configure
50           make
52       This will create a build space in the directory 'objdir' and
53       start a build in that directory.
55       If however you realy want to disable this error,
56       use --enable-maintainer-mode switch.
57      ])
60 ## Disable building of static libraries by default
61 AC_DISABLE_STATIC
63 ## Check for required dependencies.
65 ## Check for a valid build environment.
66 #  Valid equals having:
67 #  - a C++ compiler compliant with the ISO98 C++ specification.
68 #  - a working library tool for creating convenience libraries.
69 #  - a working linker for creating static and shared libraries.
70 AC_PROG_CC
71 AC_PROG_CXX
72 AM_PROG_CC_C_O
73 AC_PROG_LIBTOOL
74 AC_PROG_INSTALL
75 PKG_PROG_PKG_CONFIG
77 # Check for doxygen
78 AC_ARG_ENABLE(doxygen, AC_HELP_STRING([--enable-doxygen], [turn on generating documentation]))
80 enable_doxygen_support=no
82 if test "x$enable_doxygen" = "xyes";
83 then
84   AC_PATH_PROG(DOXYGEN, doxygen, no)
85   if test "x$DOXYGEN" = "xno"; then
86     AC_MSG_ERROR([You need to install the doxygen package])
87   fi
88   enable_doxygen_support=yes
90 AM_CONDITIONAL(DOXYGEN_ENABLED, test x$enable_doxygen_support = xyes)
92 ## Check for required libraries.
93 AC_CHECK_LIB( pthread, pthread_create, [],
94     [LDFLAGS="-pthread $LDFLAGS"
95      AC_TRY_LINK([char pthread_create();],
96          pthread_create();,
97          [], [AC_MSG_ERROR([Missing pthread])])
98     ])
99 AC_CHECK_LIB( z, compress, [ZLIB=-lz],[AC_MSG_ERROR([Missing zlib])] )
100 AC_CHECK_LIB( compat, ftime, [COMPATLIB=-lcompat] )
101 AX_CHECK_OPENSSL([], [AC_MSG_ERROR([Missing OpenSSL])])
103 AC_ARG_WITH(postgresql,
104 [  --with-postgresql       Use PostgreSQL as a backend (default: no)],
105 [case "${withval}" in
106         yes) DO_POSTGRESQL=yes ;;
107         no)  DO_POSTGRESQL=no ;;
108         maybe) DO_POSTGRESQL=maybe ;;
109         *)   AC_MSG_ERROR(Bad value ${withval} for --with-postgresql) ;;
110     esac],
111 [DO_POSTGRESQL=no])
113 AC_ARG_WITH(mysql,
114 [  --with-mysql            Use MySQL as a backend (default: yes)],
115 [case "${withval}" in
116         yes) DO_MYSQL=yes ;;
117         no)  DO_MYSQL=no ;;
118         maybe) DO_MYSQL=maybe ;;
119         *)   AC_MSG_ERROR(Bad value ${withval} for --with-mysql) ;;
120     esac],
121 [DO_MYSQL=yes])
123 # here Postgre
124 AC_MSG_CHECKING(whether to build/link POSTGRESQL)
125 if test "x$DO_POSTGRESQL" = "xyes"; then
126 DO_MYSQL=no
127 POSTGRE_INCLUDES="-I/usr/include/postgresql $POSTGRE_INCLUDES"
128 POSTGRE_LIBS="-L/usr/lib/postresql -lpq -lz -lpthread -lcrypt -lnsl -lm -lpthread -L/usr/lib $OPENSSL_LIBS $POSTGRE_LIBS "
129 CXXFLAGS="-DDO_POSTGRESQL $CXXFLAGS"
131 AC_MSG_RESULT($DO_POSTGRESQL)
133 # here mysql
134 AC_MSG_CHECKING(whether to build/link MYSQL)
135 if test "x$DO_MYSQL" = "xyes"; then
136 AC_MSG_RESULT($DO_MYSQL)
137 AC_PATH_PROGS(MYSQL_CONFIG, mysql_config, mysql_config, $PATH)
138     if test -x "$MYSQL_CONFIG"
139         then
140     # MySQL v4 uses --include while v3 uses --cflags
141         MYSQL_INCLUDES="`$MYSQL_CONFIG --include`" || \
142             MYSQL_INCLUDES="`$MYSQL_CONFIG --cflags`"
143         MYSQL_LIBS="`$MYSQL_CONFIG --libs_r`"
144         CXXFLAGS="-DDO_MYSQL $CXXFLAGS"
145         # Workaround for --as-needed linker flag that comes sometimes from mysql
146         if echo $MYSQL_LIBS|grep "\-Wl,--as-needed" > /dev/null; then
147                 MYSQL_LIBS=`echo $MYSQL_LIBS|sed -e "s/-Wl,--as-needed//"`;
148                 AC_MSG_WARN([Your mysql libs contains -Wl,--as-needed, this is not good, problem fixed in more recent mysql versions])
149         fi
150     fi
151 else
152 AC_MSG_RESULT($DO_MYSQL)
155 ## Check for memory allocator
156 #  Use libc-malloc or libtbb-malloc?
157 AC_MSG_CHECKING(whether to use libc malloc)
158 MANGOSD_STD_MALLOC=no
159 AC_ARG_WITH(std-malloc,
161 Memory allocation options:
163   --with-std-malloc       Use standard malloc],
165     if test "$withval" = "yes" ; then
166         CFLAGS="-DUSE_STANDARD_MALLOC $CFLAGS"
167         CXXFLAGS="-DUSE_STANDARD_MALLOC $CXXFLAGS"
168         MANGOSD_STD_MALLOC=yes
169     elif test "$withval" != "no" ; then
170         AC_MSG_ERROR(Please choose yes or no)
171     fi
173 AC_MSG_RESULT($MANGOSD_STD_MALLOC)
175 ## Check for options
176 #  Include debug info in library?
177 AC_MSG_CHECKING(whether to include debug info in library)
178 MANGOSD_DEBUG_INFO=no
179 AC_ARG_WITH(debug-info,
181 Debugging options:
183   --with-debug-info       Include debug info in library],
185     if test "$withval" = "yes" ; then
186         CFLAGS="-g -DMANGOS_DEBUG $CFLAGS"
187         CXXFLAGS="-g -DMANGOS_DEBUG $CXXFLAGS"
188         MANGOSD_DEBUG_INFO=yes
189     elif test "$withval" != "no" ; then
190         AC_MSG_ERROR(Please choose yes or no)
191     fi
193 AC_MSG_RESULT($MANGOSD_DEBUG_INFO)
195 ## Check for required header files.
196 AC_HEADER_STDC
197 AC_HEADER_DIRENT
198 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  ])
200 AC_CHECK_HEADERS([pthread.h])
201 AC_CHECK_HEADERS([mysql.h mysql/mysql.h])
202 AC_CHECK_HEADERS([libpq-fe.h])
203 AC_CHECK_HEADERS([zlib.h])
205 ## Check for typedefs, structures, and compiler characteristics.
206 AC_HEADER_STDBOOL
207 AC_C_CONST
208 AC_C_INLINE
209 AC_HEADER_TIME
210 AC_STRUCT_TM
211 AC_C_VOLATILE
212 AC_CHECK_TYPES([ptrdiff_t])
214 ## Check for required library functions.
215 AC_FUNC_CLOSEDIR_VOID
216 AC_FUNC_ERROR_AT_LINE
217 AC_FUNC_MALLOC
218 AC_FUNC_MEMCMP
219 AC_FUNC_REALLOC
220 AC_FUNC_SELECT_ARGTYPES
221 AC_TYPE_SIGNAL
222 AC_FUNC_VPRINTF
223 AC_CHECK_FUNCS([atexit ftime gethostbyaddr gethostbyname gethostname gettimeofday memmove memset pow realpath select socket sqrt strchr strdup strerror strstr])
226 # Check for use buildtin ACE sources
227 AC_ARG_ENABLE(builtin_ace, AC_HELP_STRING([--enable-builtin-ace], [turn on/off using builtin ACE sources]))
229 enable_builtin_ace_support=yes
231 if test "x$enable_builtin_ace" = "xno"; then
232   PKG_CHECK_MODULES(ACE, [ACE >= 5.5.2], [need_builtin_ace=no], [need_builtin_ace=yes])
233   if test X$need_builtin_ace = Xyes ; then
234     AC_MSG_ERROR([You need to install ACE package or use built-in ACE sources])
235   fi
236   enable_builtin_ace_support=no
239 if test X$enable_builtin_ace_support = Xno; then
241   # old ace versions might not have ace/Stack_Trace.h...
242   AC_LANG_PUSH([C++])
243   AC_CHECK_HEADERS([ace/Stack_Trace.h])
244   AC_LANG_POP
245 else
246   # ...but we certainly have it in our included version
247   AC_DEFINE(HAVE_ACE_STACK_TRACE_H)
248   ACE_INCLUDES="-I\$(top_srcdir)/dep/ACE_wrappers -I\$(top_builddir)/dep/ACE_wrappers"
249   ACE_LIBS="\$(top_builddir)/dep/ACE_wrappers/ace/libACE.la"
252 AM_CONDITIONAL([MANGOS_BUILD_ACE], [test X$enable_builtin_ace_support = Xyes])
254 ## Unify all additional includes/libs in one variable.
255 # TODO this looks kinda ugly, but when we add m4 folder I will make it look very pritey ( by Derex ).
256 MANGOS_INCLUDES="$ACE_INCLUDES $POSTGRE_INCLUDES $MYSQL_INCLUDES $OPENSSL_INCLUDES $MANGOS_INCLUDES"
257 MANGOS_LIBS="$ACE_LIBS $POSTGRE_LIBS $MYSQL_LIBS $ZLIB $COMPATLIB $OPENSSL_LIBS $MANGOS_LIBS"
259 ## Export defined variables
260 AC_SUBST(DOXYGEN)
261 AC_SUBST(MANGOSD_DEBUG_INFO)
263 ## Additional CPPFLAGS and LDFLAGS.
264 AC_SUBST(MANGOS_INCLUDES)
265 AC_SUBST(MANGOS_LIBS)
267 ## Set output files.
268 AC_CONFIG_HEADERS([config.h])
270 AC_SEARCH_LIBS(poll, [poll], [AC_DEFINE(HAVE_POLL, 1, [Define to 1 if the OS is usabl... err, has poll().])])
272 AH_TOP([
273 #ifndef AC_CONFIG_H
274 #define AC_CONFIG_H
277 AH_BOTTOM([#endif /* !AC_CONFIG_H */])
279 AC_CONFIG_FILES([
280    dep/include/Makefile
281    dep/lib/Makefile
282    dep/src/Makefile
283    dep/src/g3dlite/Makefile
284    dep/src/sockets/Makefile
285    dep/src/zlib/Makefile
286    dep/src/gsoap/Makefile
287    dep/Makefile
288    dep/tbb/Makefile
289    doc/Doxyfile
290    doc/Makefile
291    Makefile
292    sql/Makefile
293    sql/tools/Makefile
294    sql/updates/Makefile
295    src/Makefile
296    src/tools/Makefile
297    src/tools/genrevision/Makefile
298    src/framework/Makefile
299    src/shared/Makefile
300    src/shared/Auth/Makefile
301    src/shared/Config/Makefile
302    src/shared/Database/Makefile
303    src/shared/vmap/Makefile
304    src/shared/SystemConfig.h
305    src/game/Makefile
306    src/realmd/Makefile
307    src/realmd/realmd.conf.dist
308    src/mangosd/Makefile
309    src/mangosd/mangosd.conf.dist
310    src/bindings/Makefile
311    src/bindings/universal/Makefile
314 ## Configure ACE, if needed
315 if test X$enable_builtin_ace_support = Xyes; then
316   AC_CONFIG_SUBDIRS([dep/ACE_wrappers])
319 AC_CONFIG_COMMANDS([default],[
320   echo ""
321   echo "Configuration of MaNGOS $PACKAGE_VERSION is now complete."
322   echo ""
323  ],[PACKAGE_VERSION=$PACKAGE_VERSION])
325 ## Disabled Makefiles, until they are ready for a successful make and
326 #  make dist run.
328 ## Output files.
329 AC_OUTPUT