[1018] Converted to Unix LF. (Windows users should use dos2unix from http://www.cygwi...
[mangos-git.git] / configure.ac
blob6d45bd669d458741d91bcfb06d503bfbd8cdbba4
1 # Copyright (C) 2005,2006 MaNGOS <http://www.mangosproject.org/>
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 AC_PREREQ(2.59)
14 AC_INIT([MaNGOS],
15         [0.5-SVN],
16         [http://www.mangosproject.org/],
17         [mangos])
18 AM_CONFIG_HEADER([config.h])
19 AC_CONFIG_SRCDIR(src/mangosd/Main.cpp)
21 dnl Automake is needed for the build system.
22 dnl
23 AM_INIT_AUTOMAKE([1.6 dist-bzip2])
24 AM_MAINTAINER_MODE
26 AC_PROG_CC(gcc cc)
27 AC_PROG_CXX
28 AC_PROG_RANLIB
29 AC_PROG_LIBTOOL
30 AC_PROG_INSTALL
31 AC_LANG([C++])
32 AC_EXEEXT
33 AC_OBJEXT
35 dnl Checks for programs.
36 AM_PROG_LIBTOOL
38 dnl
39 dnl use defaults if cross-compiling, otherwise use the default path.
40 dnl
41 if test "$cross_compiling" = "yes"; then
42     MYPATH=":"
43 else
44 #    MYPATH="/bin:/usr/bin:/usr/local/bin:$PATH:/sbin:/usr/sbin:/usr/local/sbin:/opt/gnu/bin"
45     MYPATH=$PATH
48 dnl
49 dnl Find some common programs
50 dnl
51 AC_PATH_PROG(__PYTHON, python, /usr/bin/python, $MYPATH)
53 dnl Set up ZThread build.
54 LIBZTHREAD_MAJOR_VERSION=2
55 LIBZTHREAD_MINOR_VERSION=3
56 LIBZTHREAD_MICRO_VERSION=2
57 LT_RELEASE=$LIBZTHREAD_MAJOR_VERSION.$LIBZTHREAD_MINOR_VERSION.$LIBZTHREAD_MICRO_VERSION
58 LT_CURRENT=$LIBZTHREAD_MAJOR_VERSION
59 LT_REVISION=$LIBZTHREAD_MINOR_VERSION
60 LT_AGE=$LIBZTHREAD_MICRO_VERSION
62 dnl Set up Scripting build.
63 LIBMANGOSSCRIPT_MAJOR_VERSION=0
64 LIBMANGOSSCRIPT_MINOR_VERSION=2
65 LIBMANGOSSCRIPT_MICRO_VERSION=0
66 LTMS_RELEASE=$LIBMANGOSSCRIPT_MAJOR_VERSION.$LIBMANGOSSCRIPT_MINOR_VERSION.$LIBMANGOSSCRIPT_MICRO_VERSION
67 LTMS_CURRENT=$LIBMANGOSSCRIPT_MAJOR_VERSION
68 LTMS_REVISION=$LIBMANGOSSCRIPT_MINOR_VERSION
69 LTMS_AGE=$LIBMANGOSSCRIPT_MICRO_VERSION
71 COMPILER_OPTIONS=""
72 LINKER_OPTIONS=""
74 INCLUDES="-I/usr/include/mysql -I/usr/local/include/mysql -I/usr/include/openssl -I/usr/local/include/openssl"
75 AC_SUBST(INCLUDES)
76 LDFLAGS="-L/usr/lib/mysql -L/usr/local/lib/mysql"
77 AC_SUBST(LDFLAGS)
79 # check for openssl path given
80 AC_MSG_CHECKING(whether openssl path was given)
81 MANGOSD_WITH_OPENSSL=
82 AC_ARG_ENABLE(with-openssl,
83 [  --with-openssl Specify openssl path],
85     if test "$enableval" != "" ; then
86         INCLUDES="-I$enableval/include/openssl -I/usr/include/mysql -I/usr/local/include/mysql"
87         AC_SUBST(INCLUDES)
88     elif test "$enableval" = "" ; then
89         AC_MSG_ERROR(Please choose openssl path)
90     fi
93 AC_MSG_RESULT($MANGOSD_WITH_OPENSSL)
96 # check for mysql path given
97 AC_MSG_CHECKING(whether mysql path was given)
98 MANGOSD_WITH_MYSQL=
99 AC_ARG_ENABLE(with-mysql,
100 [  --with-mysql Specify mysql path],
102     if test "$enableval" != "" ; then
103         INCLUDES="-I$enableval/include/mysql -I/usr/include/openssl -I/usr/local/include/openssl"
104         AC_SUBST(INCLUDES)
105         LDFLAGS="-L$enableval/lib/mysql"
106         AC_SUBST(LDFLAGS)
107     elif test "$enableval" = "" ; then
108         AC_MSG_ERROR(Please choose mysql path)
109     fi
112 AC_MSG_RESULT($MANGOSD_WITH_MYSQL)
116 dnl Checks for libraries.
118 dnl Checks for library functions.
119 AC_CHECK_LIB( pthread, pthread_create, [],
120     [LDFLAGS="-pthread $LDFLAGS"
121      AC_TRY_LINK([char pthread_create();],
122         pthread_create();,
123         [], [AC_MSG_ERROR([Missing pthread])])
124     ])
125 AC_CHECK_LIB( z, compress, [],[AC_MSG_ERROR([Missing zlib])] )
126 AC_CHECK_LIB( compat, ftime )
127 AC_CHECK_LIB( mysqlclient, mysql_init, [],[AC_CHECK_LIB(mysql, mysql_init,[],[AC_MSG_ERROR([Missing mysql])])])
128 AC_CHECK_LIB( ssl, SHA1_Init, [], [AC_CHECK_LIB(ssl, SHA1_Init,[],[AC_MSG_ERROR([Missing openssl])])])
130 CPPFLAGS_SAVE=$CPPFLAGS
131 CPPFLAGS=$INCLUDES $CPPFLAGS
133 dnl Checks for header files.
134 AC_HEADER_STDC
135 AC_HEADER_STDBOOL
136 AC_HEADER_TIME
137 AC_CHECK_HEADERS(                                             \
138    limits.h sys/ioctl.h unistd.h fcntl.h float.h mysql.h      \
139    netdb.h netinet/in.h stddef.h sys/socket.h                 \
140    sys/time.h sys/timeb.h opensslv.h                          \
141  ,[],[AC_MSG_ERROR([Missing required header])])
143 CPPFLAGS=$CPPFLAGS_SAVE
145 dnl Checks for typedefs, structures, and compiler characteristics.
146 AC_C_CONST
147 AC_C_INLINE
148 AC_C_VOLATILE
149 AC_TYPE_SIZE_T
150 AC_TYPE_OFF_T
151 AC_TYPE_SIGNAL
152 AC_STRUCT_TM
153 AC_CHECK_TYPES([ ptrdiff_t ])
155 dnl Checks for library functions.
156 AC_FUNC_MEMCMP
157 AC_FUNC_STRCOLL
158 AC_FUNC_ALLOCA
159 AC_FUNC_MALLOC
160 AC_FUNC_REALLOC
161 AC_FUNC_SELECT_ARGTYPES
162 AC_FUNC_STRFTIME
163 AC_FUNC_STRNLEN
164 AC_FUNC_VPRINTF
165 AC_CHECK_FUNCS(                                               \
166    ftime strcspn strtoul atexit bzero floor gethostbyname     \
167    gettimeofday localtime_r memset rint select socket         \
168    sqrt stpcpy strchr strpbrk strrchr strstr strtol strtoul   \
172 dnl Auto-detect which python bindings should be built.
174 withval=auto
175 AC_ARG_WITH(python, [  --with-python           build python bindings ])
177 WITH_PYTHON_VERSION=$withval
178 if test $withval = auto ; then
180 AC_MSG_CHECKING(for python 2.4)
181 AC_RUN_IFELSE([AC_LANG_SOURCE([[
182 #include <python2.4/Python.h>
183 main() {
184   exit(strncmp("2.4", PY_VERSION, 3));
185 } ]])],[withval=yes],[withval=no],[withval=yes])
186   AC_MSG_RESULT($withval)
187   if test $withval = yes ; then
188     WITH_PYTHON_VERSION="2.4"
189   else
190     
191   AC_MSG_CHECKING(for python 2.3)
192   AC_RUN_IFELSE([AC_LANG_SOURCE([[
193   #include <python2.3/Python.h>
194   main() {
195     exit(strncmp("2.3", PY_VERSION, 3));
196   } ]])],[withval=yes],[withval=no],[withval=yes])
197     AC_MSG_RESULT($withval)
198     if test $withval = yes ; then
199       WITH_PYTHON_VERSION="2.3"
200     else
201     
202       AC_MSG_CHECKING(for python 2.2)
203       AC_RUN_IFELSE([AC_LANG_SOURCE([[
204     #include <python2.2/Python.h>
205     main() {
206       exit(strncmp("2.2", PY_VERSION, 3));
207     } ]])],[withval=yes],[withval=no],[withval=yes])
208       AC_MSG_RESULT($withval)
209       if test $withval = yes ; then
210         WITH_PYTHON_VERSION="2.2"
211       else
212     
213         AC_MSG_CHECKING(for python 1.5.2)
214         AC_RUN_IFELSE([AC_LANG_SOURCE([[
215     #include <python1.5/Python.h>
216     main() {
217       exit(strcmp("1.5.2", PY_VERSION));
218     } ]])],[withval=yes],[withval=no],[withval=yes])
219         AC_MSG_RESULT($withval)
220         if test $withval = yes ; then
221           WITH_PYTHON_VERSION="1.5"
222         fi
223       fi
224     fi
225   fi
228 if test "$WITH_PYTHON_VERSION" != no ; then
229   WITH_PYTHON_SUBDIR=python
230   WITH_PYTHON_SUBPACKAGE=1
231 else
232   WITH_PYTHON_SUBDIR=
233   WITH_PYTHON_SUBPACKAGE=0
236 AC_SUBST(WITH_PYTHON_SUBDIR)
237 AC_SUBST(WITH_PYTHON_SUBPACKAGE)
238 AC_SUBST(WITH_PYTHON_VERSION)
240 AC_PATH_PROG(__DOXYGEN, doxygen, no, $PATH)
242 dnl Auto-detect whether doxygen generated API docs should be included.
244 withval=auto
245 AC_ARG_WITH(apidocs, [  --with-apidocs          build MaNGOS API docs ])
247 if test $withval = auto -a $__DOXYGEN != no ; then
248     withval=yes
249 elif test $withval = yes -a $__DOXYGEN = no ; then
250     AC_MSG_ERROR(--> MaNGOS API docs needs doxygen in PATH)
252     
253 if test $withval = yes; then
254     WITH_APIDOCS_TARGET=apidocs
255     WITH_APIDOCS=1
256 else
257     WITH_APIDOCS=0
259 AC_SUBST(WITH_APIDOCS_TARGET)
260 AC_SUBST(WITH_APIDOCS)
261       
262 AC_MSG_CHECKING(whether to include debug info in library)
263 MANGOSD_DEBUG_INFO=no
264 AC_ARG_WITH(debug-info,
266 Debugging options:
268   --with-debug-info       Include debug info in library],
270     if test "$withval" = "yes" ; then
271         CFLAGS="-g -DMANGOS_DEBUG $CFLAGS"
272         CXXFLAGS="-g -DMANGOS_DEBUG $CXXFLAGS"
273         MANGOSD_DEBUG_INFO=yes
274     elif test "$withval" != "no" ; then
275         AC_MSG_ERROR(Please choose yes or no)
276     fi
278 AC_MSG_RESULT($MANGOSD_DEBUG_INFO)
281 # check for cli console enable
282 AC_MSG_CHECKING(whether cli console is enabled)
283 MANGOSD_ENABLE_CLI=no
284 AC_ARG_ENABLE(cli,
285 [  --enable-cli Turn on command console system],
287     if test "$enableval" = "yes" ; then
288         CFLAGS="-DENABLE_CLI $CFLAGS"
289         CXXFLAGS="-DENABLE_CLI $CXXFLAGS"
290         MANGOSD_ENABLE_CLI=yes
291     elif test "$withval" != "no" ; then
292         AC_MSG_ERROR(Please choose yes or no)
293     fi
295 AC_MSG_RESULT($MANGOSD_ENABLE_CLI)
297 # check for remote console enable
298 AC_MSG_CHECKING(whether remote console is enabled)
299 MANGOSD_ENABLE_RA=no
300 AC_ARG_ENABLE(ra,
301 [  --enable-ra Turn on remote console system],
303     if test "$enableval" = "yes" ; then
304         CFLAGS="-DENABLE_RA $CFLAGS"
305         CXXFLAGS="-DENABLE_RA $CXXFLAGS"
306         MANGOSD_ENABLE_RA=yes
307     elif test "$withval" != "no" ; then
308         AC_MSG_ERROR(Please choose yes or no)
309     fi
311 AC_MSG_RESULT($MANGOSD_ENABLE_RA)
314 MANGOSD_CONFIG_TEMP="$sysconfdir/mangosd.conf"
315 MANGOSD_CONFIGDIR_TEMP="$sysconfdir"
316 if test $sysconfdir = '${prefix}/etc'; then
317     MANGOSD_CONFIG_TEMP="${prefix}/mangos/mangosd.conf"
318     MANGOSD_CONFIGDIR_TEMP="${prefix}/mangos"
319 else
320   if test $sysconfdir = '/'; then
321         MANGOSD_CONFIG_TEMP="/mangosd.conf"
322         MANGOSD_CONFIGDIR_TEMP="/"
323   else
324         MANGOSD_CONFIG_TEMP="$sysconfdir/mangosd.conf"
325         MANGOSD_CONFIGDIR_TEMP="$sysconfdir"
326   fi
329 if test $datadir = '${prefix}/share'; then
330     MANGOSD_DATA_TEMP="${prefix}/share/mangos"
331 else
332    if test $datadir = '/'; then
333         MANGOSD_DATA_TEMP="/mangos"
334    else
335         MANGOSD_DATA_TEMP="$datadir/mangos"
336    fi
339 eval "MANGOSD_CONFIG=$MANGOSD_CONFIG_TEMP"
340 eval "MANGOSD_CONFIGDIR=$MANGOSD_CONFIGDIR_TEMP"
341 eval "MANGOSD_DATA=$MANGOSD_DATA_TEMP"
343 dnl Configure the final compiler & linker options
344 COMPILER_OPTIONS="$COMPILER_OPTIONS $CXXFLAGS"
345 LINKER_OPTIONS="$LINKER_OPTIONS $LDFLAGS"
347 dnl Configured flags for compiling
348 AC_SUBST(LINKER_OPTIONS)
349 AC_SUBST(COMPILER_OPTIONS)
351 dnl Extra variables users can customize
352 AC_SUBST(EXTRA_LINKER_OPTIONS)
353 AC_SUBST(EXTRA_COMPILER_OPTIONS)
355 dnl Configured MaNGOS variables
356 AC_SUBST(MANGOSD_CONFIG)
357 AC_SUBST(MANGOSD_CONFIGDIR)
358 AC_SUBST(MANGOSD_DATA)
359 AC_SUBST(MANGOSD_ENABLE_CLI)
360 AC_SUBST(MANGOSD_ENABLE_RA)
361 AC_SUBST(VERSION)
362 AC_SUBST(LT_RELEASE)
363 AC_SUBST(LT_CURRENT)
364 AC_SUBST(LT_AGE)
365 AC_SUBST(LT_REVISION)
366 AC_SUBST(LTMS_RELEASE)
367 AC_SUBST(LTMS_CURRENT)
368 AC_SUBST(LTMS_AGE)
369 AC_SUBST(LTMS_REVISION)
371 AC_CONFIG_FILES([
372    ./Makefile
373    doc/Doxyfile
374    doc/Makefile
375    sql/Makefile
376    src/Makefile
377    src/shared/Makefile
378    src/shared/SystemConfig.h
379    src/realmd/Makefile
380    src/framework/Makefile
381    src/game/Makefile
382    src/bindings/Makefile
383    src/bindings/python/Makefile
384    src/bindings/universal/Makefile
385    src/mangosd/Makefile
386    src/mangosd/mangosd.conf
387    dep/Makefile
388    dep/src/Makefile
389    dep/src/zlib/Makefile
390    dep/src/zthread/Makefile
393 AC_OUTPUT