root/trunk/configure.ac @ 11

Revision 8, 9.3 kB (checked in by yumileroy, 17 years ago)

[svn] * Auto detect if ACE is already installed and use it.

Original author: derex_tri
Date: 2008-10-04 10:45:45-05:00

Line 
1# Copyright (C) 2005-2008 MaNGOS project <http://www.mangosproject.org/>
2#
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.
6#
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.
10
11## Process this file with autoconf to produce a configure script.
12
13## Prelude, basic settings for Autoconf
14AC_INIT( [trinitycore], [0.0.1], [devs@trinitycore.org])
15
16AC_CONFIG_SRCDIR([src/shared/Base.cpp])
17
18## Prelude, basic settings for Automake
19#  Turn on all warnings and error messages, and enforce GNU
20#  standards for the package.
21AM_INIT_AUTOMAKE([-Wall -Werror])
22AM_MAINTAINER_MODE
23
24## Prevent the configure script from continuing any further if
25# configuration is being performed in the top-level directory.
26# The idea is to prevent this ,because some maintainers tend
27# to break "off src dir" builds.
28if test "$srcdir" = "." && test "$enable_maintainer_mode" != "yes"; then
29  AC_MSG_ERROR(
30     [
31      Please configure and build in a directory other than the
32      top-level source directory. This is needed because a lot
33      of maintainers tend to break "off src dir" builds. This
34      is kinda real ensurance they wont do it.
35
36      For example, try the following from the top-level source
37      directory:
38
39          mkdir objdir
40          cd objdir
41          ../configure
42          make
43
44      This will create a build space in the directory `objdir' and
45      start a build in that directory.
46
47      If however you realy want to build in src dir,
48      then use --enable-maintainer-mode switch.
49     ])
50fi
51
52## Disable building of static libraries by default
53AC_DISABLE_STATIC
54
55## Check for required dependencies.
56
57## Check for a valid build environment.
58#  Valid equals having:
59#  - a C++ compiler compliant with the ISO98 C++ specification.
60#  - a working library tool for creating convenience libraries.
61#  - a working linker for creating static and shared libraries.
62AC_PROG_CC
63AC_PROG_CXX
64AC_PROG_LIBTOOL
65AC_PROG_INSTALL
66AM_PROG_CC_C_O
67
68# Check if enable scripts
69AC_ARG_ENABLE([scripts], AC_HELP_STRING([--enable-scripts], [Enable TrinityScripts (default: yes) ]), [], [enable_scripts=yes])
70
71AM_CONDITIONAL([USE_TSCRIPTS], [test X$enable_scripts = Xyes])
72
73# Check for doxygen
74AC_ARG_ENABLE(doxygen, AC_HELP_STRING([--enable-doxygen], [turn on generating documentation]))
75
76enable_doxygen_support=no
77
78if test "x$enable_doxygen" = "xyes";
79then
80  AC_PATH_PROG(DOXYGEN, doxygen, no)
81  if test "x$DOXYGEN" = "xno"; then
82    AC_MSG_ERROR([You need to install the doxygen package])
83  fi
84  enable_doxygen_support=yes
85fi
86AM_CONDITIONAL(DOXYGEN_ENABLED, test x$enable_doxygen_support = xyes)
87
88## Check for required libraries.
89AC_CHECK_LIB( pthread, pthread_create, [],
90    [LDFLAGS="-pthread $LDFLAGS"
91     AC_TRY_LINK([char pthread_create();],
92         pthread_create();,
93         [], [AC_MSG_ERROR([Missing pthread])])
94    ])
95AC_CHECK_LIB( z, compress, [ZLIB=-lz],[AC_MSG_ERROR([Missing zlib])] )
96AC_CHECK_LIB( compat, ftime, [COMPATLIB=-lcompat] )
97AC_CHECK_LIB( crypto, SHA1_Init, [SSLLIB=-lssl], [AC_MSG_ERROR([Missing openssl])])
98
99AC_ARG_WITH(postgresql,
100[  --with-postgresql       Use PostgreSQL as a backend (default: no)],
101[case "${withval}" in
102        yes) DO_POSTGRESQL=yes ;;
103        no)  DO_POSTGRESQL=no ;;
104        maybe) DO_POSTGRESQL=maybe ;;
105        *)   AC_MSG_ERROR(Bad value ${withval} for --with-postgresql) ;;
106    esac],
107[DO_POSTGRESQL=no])
108                                 
109AC_ARG_WITH(mysql,
110[  --with-mysql            Use MySQL as a backend (default: yes)],
111[case "${withval}" in
112        yes) DO_MYSQL=yes ;;
113        no)  DO_MYSQL=no ;;
114        maybe) DO_MYSQL=maybe ;;
115        *)   AC_MSG_ERROR(Bad value ${withval} for --with-mysql) ;;
116    esac],
117[DO_MYSQL=yes])
118
119# here Postgre
120AC_MSG_CHECKING(whether to build/link POSTGRESQL)
121if test "x$DO_POSTGRESQL" = "xyes"; then
122DO_MYSQL=no
123POSTGRE_INCLUDES="-I/usr/include/postgresql $POSTGRE_INCLUDES"
124POSTGRE_LIBS="-L/usr/lib/postresql -lpq -lz -lpthread -lcrypt -lnsl -lm -lpthread -L/usr/lib -lssl -lcrypto $POSTGRE_LIBS "
125CXXFLAGS="-DDO_POSTGRESQL $CXXFLAGS"
126fi
127AC_MSG_RESULT($DO_POSTGRESQL)
128       
129# here mysql
130AC_MSG_CHECKING(whether to build/link MYSQL)
131if test "x$DO_MYSQL" = "xyes"; then
132AC_MSG_RESULT($DO_MYSQL)
133AC_PATH_PROGS(MYSQL_CONFIG, mysql_config, mysql_config, $PATH)
134    if test -x "$MYSQL_CONFIG"
135        then
136    # MySQL v4 uses --include while v3 uses --cflags
137        MYSQL_INCLUDES="`$MYSQL_CONFIG --include`" || \
138            MYSQL_INCLUDES="`$MYSQL_CONFIG --cflags`"
139        MYSQL_LIBS="`$MYSQL_CONFIG --libs_r`"
140        CXXFLAGS="-DDO_MYSQL $CXXFLAGS"
141    fi
142else
143AC_MSG_RESULT($DO_MYSQL)
144fi
145
146## Check for options
147#  Include debug info in library?
148AC_MSG_CHECKING(whether to include debug info in library)
149MANGOSD_DEBUG_INFO=no
150AC_ARG_WITH(debug-info,
151[
152Debugging options:
153
154  --with-debug-info       Include debug info in library],
155[
156    if test "$withval" = "yes" ; then
157        CFLAGS="-g -DMANGOS_DEBUG $CFLAGS"
158        CXXFLAGS="-g -DMANGOS_DEBUG $CXXFLAGS"
159        MANGOSD_DEBUG_INFO=yes
160    elif test "$withval" != "no" ; then
161        AC_MSG_ERROR(Please choose yes or no)
162    fi
163])
164AC_MSG_RESULT($MANGOSD_DEBUG_INFO)
165
166
167# Enable CLI console?
168AC_MSG_CHECKING(whether cli console is enabled)
169MANGOSD_ENABLE_CLI=no
170AC_ARG_ENABLE(cli,
171[  --enable-cli Turn on command console system],
172[
173    if test "$enableval" = "yes" ; then
174        CFLAGS="-DENABLE_CLI $CFLAGS"
175        CXXFLAGS="-DENABLE_CLI $CXXFLAGS"
176        MANGOSD_ENABLE_CLI=yes
177    elif test "$withval" != "no" ; then
178        AC_MSG_ERROR(Please choose yes or no)
179    fi
180])
181AC_MSG_RESULT($MANGOSD_ENABLE_CLI)
182
183# Enable remote console?
184AC_MSG_CHECKING(whether remote console is enabled)
185MANGOSD_ENABLE_RA=no
186AC_ARG_ENABLE(ra,
187[  --enable-ra Turn on remote console system],
188[
189    if test "$enableval" = "yes" ; then
190        CFLAGS="-DENABLE_RA $CFLAGS"
191        CXXFLAGS="-DENABLE_RA $CXXFLAGS"
192        MANGOSD_ENABLE_RA=yes
193    elif test "$withval" != "no" ; then
194        AC_MSG_ERROR(Please choose yes or no)
195    fi
196])
197AC_MSG_RESULT($MANGOSD_ENABLE_RA)
198
199## Check for required header files.
200AC_HEADER_STDC
201AC_HEADER_DIRENT
202AC_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  ])
203
204AC_CHECK_HEADERS([pthread.h])
205AC_CHECK_HEADERS([openssl/md5.h openssl/rand.h openssl/ssl.h openssl/sha.h openssl/bn.h])
206AC_CHECK_HEADERS([mysql.h mysql/mysql.h])
207AC_CHECK_HEADERS([libpq-fe.h])
208AC_CHECK_HEADERS([zlib.h])
209
210## Check for typedefs, structures, and compiler characteristics.
211AC_HEADER_STDBOOL
212AC_C_CONST
213AC_C_INLINE
214AC_TYPE_SIZE_T
215AC_HEADER_TIME
216AC_STRUCT_TM
217AC_TYPE_UINT64_T
218AC_C_VOLATILE
219AC_CHECK_TYPES([ptrdiff_t])
220
221## Check for required library functions.
222AC_FUNC_CLOSEDIR_VOID
223AC_FUNC_ERROR_AT_LINE
224AC_FUNC_MALLOC
225AC_FUNC_MEMCMP
226AC_FUNC_REALLOC
227AC_FUNC_SELECT_ARGTYPES
228AC_TYPE_SIGNAL
229AC_FUNC_VPRINTF
230AC_CHECK_FUNCS([atexit ftime gethostbyaddr gethostbyname gethostname gettimeofday memmove memset pow realpath select socket sqrt strchr strdup strerror strstr])
231
232## Check what to do with ACE library
233AC_LANG_PUSH([C++])
234AC_CHECK_HEADER([ace/Reactor.h], [tri_have_ace_headers=yes], [tri_have_ace_headers=no])
235AC_CHECK_LIB([ACE], [main], [tri_have_ace_lib=yes], [tri_have_ace_lib=no])
236AC_LANG_POP([C++])
237
238AC_MSG_CHECKING([whether to build ACE])
239if test X$tri_have_ace_headers = Xyes -a X$tri_have_ace_lib = Xyes;
240then
241  tri_need_to_build_ace=no
242  ACE_LIBS="-lACE"
243  ACE_INCLUDES=""
244  AC_MSG_RESULT([no])
245else
246  if test X$tri_have_ace_headers = Xno -a X$tri_have_ace_lib = Xno; then
247    tri_need_to_build_ace=yes
248    AC_MSG_RESULT([yes])
249  else
250    if test X$tri_have_ace_headers = Xyes; then
251       AC_MSG_ERROR([looks like you have ACE headers, but you do not have ACE libs installed])
252    else
253       tri_need_to_build_ace=yes
254       AC_MSG_RESULT([yes, over-install])
255    fi
256  fi
257fi
258
259if test X$tri_need_to_build_ace = Xyes; then
260   CXXFLAGS="-I\$(top_srcdir)/dep/ACE_wrappers -I\$(top_builddir)/dep/ACE_wrappers $CXXFLAGS"
261   ACE_LIBS="\$(top_builddir)/dep/ACE_wrappers/ace/libACE.la"
262else
263   ACE_LIBS="-lACE"
264fi
265
266AM_CONDITIONAL([TRI_BUILD_ACE], [test X$tri_need_to_build_ace = Xyes])
267
268## Export defined variables
269AC_SUBST(ZLIB)
270AC_SUBST(COMPATLIB)
271AC_SUBST(SSLLIB)
272AC_SUBST(MYSQL_INCLUDES)
273AC_SUBST(MYSQL_LIBS)
274AC_SUBST(POSTGRE_INCLUDES)
275AC_SUBST(POSTGRE_LIBS)
276AC_SUBST(DOXYGEN)
277AC_SUBST(MANGOSD_DEBUG_INFO)
278AC_SUBST(MANGOSD_ENABLE_CLI)
279AC_SUBST(MANGOSD_ENABLE_RA)
280AC_SUBST(ACE_LIBS)
281
282## Set output files.
283AC_CONFIG_HEADERS([config.h])
284AC_CONFIG_FILES([
285   dep/include/Makefile
286   dep/lib/Makefile
287   dep/src/Makefile
288   dep/src/g3dlite/Makefile
289   dep/src/sockets/Makefile
290   dep/src/zlib/Makefile
291   dep/src/zthread/Makefile
292   dep/Makefile
293   doc/Doxyfile
294   doc/Makefile
295   Makefile
296   src/Makefile
297   src/framework/Makefile
298   src/shared/Makefile
299   src/shared/vmap/Makefile
300   src/game/Makefile
301   src/trinityrealm/Makefile
302   src/trinitycore/Makefile
303   src/bindings/Makefile
304   src/bindings/scripts/Makefile
305   src/bindings/interface/Makefile
306])
307
308## Configure ACE
309if test X$tri_need_to_build_ace = Xyes; then
310  AC_CONFIG_SUBDIRS([dep/ACE_wrappers])
311fi
312
313## Disabled Makefiles, until they are ready for a successful make and
314#  make dist run.
315
316AC_CONFIG_COMMANDS([default],[
317  echo ""
318  echo "Configuration of TrinityCore $PACKAGE_VERSION is now complete."
319  echo ""
320 ],[PACKAGE_VERSION=$PACKAGE_VERSION])
321
322## Output files.
323AC_OUTPUT
Note: See TracBrowser for help on using the browser.