[8587] MaNGOS 0.14 release.
[getmangos.git] / configure.ac
blob0aa710d330e97c946c3ce4a3588e0098ca016853
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.14.1
18 #  BUG-REPORT-ADDRESS: mangos-devs@lists.sourceforge.net
19 AC_INIT( [mangos], [0.14.1], [mangos-devs@lists.sourceforge.net])
20 AC_CONFIG_SRCDIR([src/shared/Base.cpp])
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 options
155 #  Include debug info in library?
156 AC_MSG_CHECKING(whether to include debug info in library)
157 MANGOSD_DEBUG_INFO=no
158 AC_ARG_WITH(debug-info,
160 Debugging options:
162   --with-debug-info       Include debug info in library],
164     if test "$withval" = "yes" ; then
165         CFLAGS="-g -DMANGOS_DEBUG $CFLAGS"
166         CXXFLAGS="-g -DMANGOS_DEBUG $CXXFLAGS"
167         MANGOSD_DEBUG_INFO=yes
168     elif test "$withval" != "no" ; then
169         AC_MSG_ERROR(Please choose yes or no)
170     fi
172 AC_MSG_RESULT($MANGOSD_DEBUG_INFO)
174 ## Check for required header files.
175 AC_HEADER_STDC
176 AC_HEADER_DIRENT
177 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  ])
179 AC_CHECK_HEADERS([pthread.h])
180 AC_CHECK_HEADERS([mysql.h mysql/mysql.h])
181 AC_CHECK_HEADERS([libpq-fe.h])
182 AC_CHECK_HEADERS([zlib.h])
184 ## Check for typedefs, structures, and compiler characteristics.
185 AC_HEADER_STDBOOL
186 AC_C_CONST
187 AC_C_INLINE
188 AC_HEADER_TIME
189 AC_STRUCT_TM
190 AC_C_VOLATILE
191 AC_CHECK_TYPES([ptrdiff_t])
193 ## Check for required library functions.
194 AC_FUNC_CLOSEDIR_VOID
195 AC_FUNC_ERROR_AT_LINE
196 AC_FUNC_MALLOC
197 AC_FUNC_MEMCMP
198 AC_FUNC_REALLOC
199 AC_FUNC_SELECT_ARGTYPES
200 AC_TYPE_SIGNAL
201 AC_FUNC_VPRINTF
202 AC_CHECK_FUNCS([atexit ftime gethostbyaddr gethostbyname gethostname gettimeofday memmove memset pow realpath select socket sqrt strchr strdup strerror strstr])
205 # Check for use buildtin ACE sources
206 AC_ARG_ENABLE(builtin_ace, AC_HELP_STRING([--enable-builtin-ace], [turn on/off using builtin ACE sources]))
208 enable_builtin_ace_support=yes
210 if test "x$enable_builtin_ace" = "xno"; then
211   PKG_CHECK_MODULES(ACE, [ACE >= 5.5.2], [need_builtin_ace=no], [need_builtin_ace=yes])
212   if test X$need_builtin_ace = Xyes ; then
213     AC_MSG_ERROR([You need to install ACE package or use built-in ACE sources])
214   fi
215   enable_builtin_ace_support=no
218 if test X$enable_builtin_ace_support = Xno; then
220   # old ace versions might not have ace/Stack_Trace.h...
221   AC_LANG_PUSH([C++])
222   AC_CHECK_HEADERS([ace/Stack_Trace.h])
223   AC_LANG_POP
224 else
225   # ...but we certainly have it in our included version
226   AC_DEFINE(HAVE_ACE_STACK_TRACE_H)
227   ACE_INCLUDES="-I\$(top_srcdir)/dep/ACE_wrappers -I\$(top_builddir)/dep/ACE_wrappers"
228   ACE_LIBS="\$(top_builddir)/dep/ACE_wrappers/ace/libACE.la"
231 AM_CONDITIONAL([MANGOS_BUILD_ACE], [test X$enable_builtin_ace_support = Xyes])
233 ## Unify all additional includes/libs in one variable.
234 # TODO this looks kinda ugly, but when we add m4 folder I will make it look very pritey ( by Derex ).
235 MANGOS_INCLUDES="$ACE_INCLUDES $POSTGRE_INCLUDES $MYSQL_INCLUDES $OPENSSL_INCLUDES $MANGOS_INCLUDES"
236 MANGOS_LIBS="$ACE_LIBS $POSTGRE_LIBS $MYSQL_LIBS $ZLIB $COMPATLIB $OPENSSL_LIBS $MANGOS_LIBS"
238 ## Export defined variables
239 AC_SUBST(DOXYGEN)
240 AC_SUBST(MANGOSD_DEBUG_INFO)
242 ## Additional CPPFLAGS and LDFLAGS.
243 AC_SUBST(MANGOS_INCLUDES)
244 AC_SUBST(MANGOS_LIBS)
246 ## Set output files.
247 AC_CONFIG_HEADERS([config.h])
248 AC_CONFIG_FILES([
249    dep/include/Makefile
250    dep/lib/Makefile
251    dep/src/Makefile
252    dep/src/g3dlite/Makefile
253    dep/src/sockets/Makefile
254    dep/src/zlib/Makefile
255    dep/Makefile
256    doc/Doxyfile
257    doc/Makefile
258    Makefile
259    sql/Makefile
260    sql/tools/Makefile
261    sql/updates/Makefile
262    src/Makefile
263    src/tools/Makefile
264    src/tools/genrevision/Makefile
265    src/framework/Makefile
266    src/shared/Makefile
267    src/shared/Auth/Makefile
268    src/shared/Config/Makefile
269    src/shared/Database/Makefile
270    src/shared/vmap/Makefile
271    src/shared/SystemConfig.h
272    src/game/Makefile
273    src/realmd/Makefile
274    src/realmd/realmd.conf.dist
275    src/mangosd/Makefile
276    src/mangosd/mangosd.conf.dist
277    src/bindings/Makefile
278    src/bindings/universal/Makefile
281 ## Configure ACE, if needed
282 if test X$enable_builtin_ace_support = Xyes; then
283   AC_CONFIG_SUBDIRS([dep/ACE_wrappers])
286 AC_CONFIG_COMMANDS([default],[
287   echo ""
288   echo "Configuration of MaNGOS $PACKAGE_VERSION is now complete."
289   echo ""
290  ],[PACKAGE_VERSION=$PACKAGE_VERSION])
292 ## Disabled Makefiles, until they are ready for a successful make and
293 #  make dist run.
295 ## Output files.
296 AC_OUTPUT