root/trunk/configure.ac @ 262

Revision 195, 10.7 kB (checked in by yumileroy, 17 years ago)

[svn] One more attempt to fix build in Linux (somebody helps me, I do not even have a Linux).

Original author: megamage
Date: 2008-11-08 09:19:26-06:00

Line 
1# Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
2#
3# Thanks to the original authors: MaNGOS <http://www.mangosproject.org/>
4#
5# This file is free software; as a special exception the author gives
6# unlimited permission to copy and/or distribute it, with or without
7# modifications, as long as this notice is preserved.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
11# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13## Process this file with autoconf to produce a configure script.
14
15# TODO: create m4 directory and put the checks there, because this file got realy poluted ( by Derex )
16
17## Prelude, basic settings for Autoconf
18#  PACKAGE:            trinity
19#  VERSION:            0.0.1 (trunk)
20#  BUG-REPORT-ADDRESS: devs@trinitycore.org
21AC_INIT( [trinitycore], [0.0.1], [devs@trinitycore.org])
22AC_CONFIG_SRCDIR([src/shared/Base.cpp])
23
24## Prelude, basic settings for Automake
25#  Turn on all warnings and error messages, and enforce GNU
26#  standards for the package.
27AM_INIT_AUTOMAKE([-Wall -Werror gnu tar-pax])
28AM_MAINTAINER_MODE
29
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).
34if 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).
42
43      For example, try the following from the top-level source
44      directory:
45
46          mkdir objdir
47          cd objdir
48          ../configure
49          make
50
51      This will create a build space in the directory `objdir' and
52      start a build in that directory.
53
54      If however you realy want to disable this error,
55      use --enable-maintainer-mode switch.
56     ])
57fi
58
59## Disable building of static libraries by default
60AC_DISABLE_STATIC
61
62## Check for required dependencies.
63
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.
69AC_PROG_CC
70AC_PROG_CXX
71AM_PROG_CC_C_O
72AC_PROG_LIBTOOL
73AC_PROG_INSTALL
74
75
76# Check if enable scripts
77AC_ARG_ENABLE([scripts], AC_HELP_STRING([--enable-scripts], [Enable TrinityScripts (default: check) ]), [], [enable_scripts=yes])
78
79AC_MSG_CHECKING(whether to build scripting module)
80if test X$enable_scripts = Xyes -a -d $srcdir/src/bindings/scripts/scripts; then
81  tri_build_scripts=yes
82  AC_MSG_RESULT(yes)
83else
84  tri_build_scripts=no
85  AC_MSG_RESULT(no)
86  if test X$enable_scripts = Xyes; then
87    AC_MSG_WARN([src/bindings/scripts/scripts folder does not exist, scripts will be disabled])
88  fi
89fi
90
91AM_CONDITIONAL([USE_TSCRIPTS], [test X$tri_build_scripts = Xyes])
92
93# Check for doxygen
94AC_ARG_ENABLE(doxygen, AC_HELP_STRING([--enable-doxygen], [turn on generating documentation]))
95
96enable_doxygen_support=no
97
98if test "x$enable_doxygen" = "xyes";
99then
100  AC_PATH_PROG(DOXYGEN, doxygen, no)
101  if test "x$DOXYGEN" = "xno"; then
102    AC_MSG_ERROR([You need to install the doxygen package])
103  fi
104  enable_doxygen_support=yes
105fi
106AM_CONDITIONAL(DOXYGEN_ENABLED, test x$enable_doxygen_support = xyes)
107
108## Check for required libraries.
109AC_CHECK_LIB( pthread, pthread_create, [],
110    [LDFLAGS="-pthread $LDFLAGS"
111     AC_TRY_LINK([char pthread_create();],
112         pthread_create();,
113         [], [AC_MSG_ERROR([Missing pthread])])
114    ])
115AC_CHECK_LIB( z, compress, [ZLIB=-lz],[AC_MSG_ERROR([Missing zlib])] )
116AC_CHECK_LIB( compat, ftime, [COMPATLIB=-lcompat] )
117AC_CHECK_LIB( crypto, SHA1_Init, [SSLLIB=-lssl], [AC_MSG_ERROR([Missing openssl])])
118
119AC_ARG_WITH(postgresql,
120[  --with-postgresql       Use PostgreSQL as a backend (default: no)],
121[case "${withval}" in
122        yes) DO_POSTGRESQL=yes ;;
123        no)  DO_POSTGRESQL=no ;;
124        maybe) DO_POSTGRESQL=maybe ;;
125        *)   AC_MSG_ERROR(Bad value ${withval} for --with-postgresql) ;;
126    esac],
127[DO_POSTGRESQL=no])
128
129AC_ARG_WITH(mysql,
130[  --with-mysql            Use MySQL as a backend (default: yes)],
131[case "${withval}" in
132        yes) DO_MYSQL=yes ;;
133        no)  DO_MYSQL=no ;;
134        maybe) DO_MYSQL=maybe ;;
135        *)   AC_MSG_ERROR(Bad value ${withval} for --with-mysql) ;;
136    esac],
137[DO_MYSQL=yes])
138
139# here Postgre
140AC_MSG_CHECKING(whether to build/link POSTGRESQL)
141if test "x$DO_POSTGRESQL" = "xyes"; then
142DO_MYSQL=no
143POSTGRE_INCLUDES="-I/usr/include/postgresql $POSTGRE_INCLUDES"
144POSTGRE_LIBS="-L/usr/lib/postresql -lpq -lz -lpthread -lcrypt -lnsl -lm -lpthread -L/usr/lib -lssl -lcrypto $POSTGRE_LIBS "
145CXXFLAGS="-DDO_POSTGRESQL $CXXFLAGS"
146fi
147AC_MSG_RESULT($DO_POSTGRESQL)
148
149# here mysql
150AC_MSG_CHECKING(whether to build/link MYSQL)
151if test "x$DO_MYSQL" = "xyes"; then
152AC_MSG_RESULT($DO_MYSQL)
153AC_PATH_PROGS(MYSQL_CONFIG, mysql_config, mysql_config, $PATH)
154    if test -x "$MYSQL_CONFIG"
155        then
156    # MySQL v4 uses --include while v3 uses --cflags
157        MYSQL_INCLUDES="`$MYSQL_CONFIG --include`" || \
158            MYSQL_INCLUDES="`$MYSQL_CONFIG --cflags`"
159        MYSQL_LIBS="`$MYSQL_CONFIG --libs_r`"
160        CXXFLAGS="-DDO_MYSQL $CXXFLAGS"
161    fi
162else
163AC_MSG_RESULT($DO_MYSQL)
164fi
165
166## Check for options
167#  Include debug info in library?
168AC_MSG_CHECKING(whether to include debug info in library)
169TRINITYD_DEBUG_INFO=no
170AC_ARG_WITH(debug-info,
171[
172Debugging options:
173
174  --with-debug-info       Include debug info in library],
175[
176    if test "$withval" = "yes" ; then
177        CFLAGS="-g -DTRINITY_DEBUG $CFLAGS"
178        CXXFLAGS="-g -DTRINITY_DEBUG $CXXFLAGS"
179        TRINITYD_DEBUG_INFO=yes
180    elif test "$withval" != "no" ; then
181        AC_MSG_ERROR(Please choose yes or no)
182    fi
183])
184AC_MSG_RESULT($TRINITYD_DEBUG_INFO)
185
186
187# Enable CLI console?
188AC_MSG_CHECKING(whether cli console is enabled)
189TRINITYD_ENABLE_CLI=no
190AC_ARG_ENABLE(cli,
191[  --enable-cli Turn on command console system],
192[
193    if test "$enableval" = "yes" ; then
194        CFLAGS="-DENABLE_CLI $CFLAGS"
195        CXXFLAGS="-DENABLE_CLI $CXXFLAGS"
196        TRINITYD_ENABLE_CLI=yes
197    elif test "$withval" != "no" ; then
198        AC_MSG_ERROR(Please choose yes or no)
199    fi
200])
201AC_MSG_RESULT($TRINITYD_ENABLE_CLI)
202
203# Enable remote console?
204AC_MSG_CHECKING(whether remote console is enabled)
205TRINITYD_ENABLE_RA=no
206AC_ARG_ENABLE(ra,
207[  --enable-ra Turn on remote console system],
208[
209    if test "$enableval" = "yes" ; then
210        CFLAGS="-DENABLE_RA $CFLAGS"
211        CXXFLAGS="-DENABLE_RA $CXXFLAGS"
212        TRINITYD_ENABLE_RA=yes
213    elif test "$withval" != "no" ; then
214        AC_MSG_ERROR(Please choose yes or no)
215    fi
216])
217AC_MSG_RESULT($TRINITYD_ENABLE_RA)
218
219## Check for required header files.
220AC_HEADER_STDC
221AC_HEADER_DIRENT
222AC_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  ])
223
224AC_CHECK_HEADERS([pthread.h])
225AC_CHECK_HEADERS([openssl/md5.h openssl/rand.h openssl/ssl.h openssl/sha.h openssl/bn.h])
226AC_CHECK_HEADERS([mysql.h mysql/mysql.h])
227AC_CHECK_HEADERS([libpq-fe.h])
228AC_CHECK_HEADERS([zlib.h])
229
230## Check for typedefs, structures, and compiler characteristics.
231AC_HEADER_STDBOOL
232AC_C_CONST
233AC_C_INLINE
234AC_TYPE_SIZE_T
235AC_HEADER_TIME
236AC_STRUCT_TM
237AC_TYPE_UINT64_T
238AC_C_VOLATILE
239AC_CHECK_TYPES([ptrdiff_t])
240
241## Check for required library functions.
242AC_FUNC_CLOSEDIR_VOID
243AC_FUNC_ERROR_AT_LINE
244AC_FUNC_MALLOC
245AC_FUNC_MEMCMP
246AC_FUNC_REALLOC
247AC_FUNC_SELECT_ARGTYPES
248AC_TYPE_SIGNAL
249AC_FUNC_VPRINTF
250AC_CHECK_FUNCS([atexit ftime gethostbyaddr gethostbyname gethostname gettimeofday memmove memset pow realpath select socket sqrt strchr strdup strerror strstr])
251
252## Check what to do with ACE library
253AC_LANG_PUSH([C++])
254AC_CHECK_HEADER([ace/Reactor.h], [tri_have_ace_headers=yes], [tri_have_ace_headers=no])
255AC_CHECK_LIB([ACE], [main], [tri_have_ace_lib=yes], [tri_have_ace_lib=no])
256AC_LANG_POP([C++])
257
258AC_MSG_CHECKING([whether to build ACE])
259if test X$tri_have_ace_headers = Xyes -a X$tri_have_ace_lib = Xyes;
260then
261  tri_need_to_build_ace=no
262  AC_MSG_RESULT([no])
263else
264  if test X$tri_have_ace_headers = Xno -a X$tri_have_ace_lib = Xno; then
265    tri_need_to_build_ace=yes
266    AC_MSG_RESULT([yes])
267  else
268    if test X$tri_have_ace_headers = Xyes; then
269       AC_MSG_ERROR([looks like you have ACE headers, but you do not have ACE libs installed])
270    else
271       tri_need_to_build_ace=yes
272       AC_MSG_RESULT([yes, over-install])
273    fi
274  fi
275fi
276
277if test X$tri_need_to_build_ace = Xyes; then
278   TRINI_INCLUDES="-I\$(top_srcdir)/dep/ACE_wrappers -I\$(top_builddir)/dep/ACE_wrappers $TRINI_INCLUDES"
279   TRINI_LIBS="\$(top_builddir)/dep/ACE_wrappers/ace/libACE.la $TRINI_LIBS"
280else
281   TRINI_LIBS="-lACE $TRINI_LIBS"
282fi
283
284AM_CONDITIONAL([TRI_BUILD_ACE], [test X$tri_need_to_build_ace = Xyes])
285
286
287## Unify all additional includes/libs in one variable.
288# TODO this looks kinda ugly, but when we add m4 folder I will make it look very pritey ( by Derex ).
289TRINI_INCLUDES="$POSTGRE_INCLUDES $MYSQL_INCLUDES $TRINI_INCLUDES"
290TRINI_LIBS="$POSTGRE_LIBS $MYSQL_LIBS $ZLIB $COMPATLIB $SSLLIB $TRINI_LIBS"
291
292## Export defined variables
293AC_SUBST(ZLIB)
294AC_SUBST(COMPATLIB)
295AC_SUBST(SSLLIB)
296AC_SUBST(MYSQL_INCLUDES)
297AC_SUBST(MYSQL_LIBS)
298AC_SUBST(POSTGRE_INCLUDES)
299AC_SUBST(POSTGRE_LIBS)
300AC_SUBST(DOXYGEN)
301AC_SUBST(TRINITYD_DEBUG_INFO)
302AC_SUBST(TRINITYD_ENABLE_CLI)
303AC_SUBST(TRINITYD_ENABLE_RA)
304
305## Additional CPPFLAGS and LDFLAGS.
306AC_SUBST(TRINI_INCLUDES)
307AC_SUBST(TRINI_LIBS)
308
309## Set output files.
310AC_CONFIG_HEADERS([config.h])
311AC_CONFIG_FILES([
312   dep/include/Makefile
313   dep/lib/Makefile
314   dep/src/Makefile
315   dep/src/g3dlite/Makefile
316   dep/src/sockets/Makefile
317   dep/src/zlib/Makefile
318   dep/src/zthread/Makefile
319   dep/Makefile
320   doc/Doxyfile
321   doc/Makefile
322   Makefile
323   src/Makefile
324   src/framework/Makefile
325   src/shared/Makefile
326   src/shared/Auth/Makefile
327   src/shared/Config/Makefile
328   src/shared/Database/Makefile
329   src/shared/vmap/Makefile
330   src/shared/SystemConfig.h
331   src/game/Makefile
332   src/trinityrealm/Makefile
333   src/trinitycore/Makefile
334   src/bindings/Makefile
335   src/bindings/interface/Makefile
336])
337
338## Configure ACE, if needed
339if test X$tri_need_to_build_ace = Xyes; then
340  AC_CONFIG_SUBDIRS([dep/ACE_wrappers])
341fi
342
343## Configure ACE
344if test X$tri_build_scripts = Xyes; then
345AC_CONFIG_FILES([src/bindings/scripts/Makefile])
346fi
347
348AC_CONFIG_COMMANDS([default],[
349  echo ""
350  echo "Configuration of TrinityCore $PACKAGE_VERSION is now complete."
351  echo ""
352 ],[PACKAGE_VERSION=$PACKAGE_VERSION])
353
354## Disabled Makefiles, until they are ready for a successful make and
355#  make dist run.
356
357## Output files.
358AC_OUTPUT
Note: See TracBrowser for help on using the browser.