root/configure.in @ 22

Revision 1, 10.8 kB (checked in by jinshiro, 17 years ago)
Line 
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_INIT(eAthena)
5AC_REVISION($Revision: 12803 $)
6AC_PREREQ([2.59])
7AC_CONFIG_SRCDIR([src/common/cbasetypes.h])
8AC_CONFIG_FILES([Makefile src/common/Makefile])
9AC_CONFIG_FILES([src/char/Makefile src/login/Makefile src/ladmin/Makefile])
10AC_CONFIG_FILES([src/char_sql/Makefile src/login_sql/Makefile src/txt-converter/Makefile])
11AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile src/tool/Makefile])
12
13
14#
15# Memory managers
16#
17AC_ARG_ENABLE(
18        [manager],
19        AC_HELP_STRING(
20                [--enable-manager=ARG],
21                [memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin)]
22        ),
23        [
24                enable_manager="$enableval"
25                case $enableval in
26                        "no");;
27                        "builtin");;
28                        "memwatch");;
29                        "dmalloc");;
30                        "gcollect");;
31                        "bcheck");;
32                        *) AC_MSG_ERROR([[unknown memory manager '$enableval'... stopping]]);;
33                esac
34        ],
35        [enable_manager="builtin"]
36)
37
38
39#
40# packetver
41#
42AC_ARG_ENABLE(
43        [packetver],
44        AC_HELP_STRING(
45                [--enable-packetver=ARG],
46                [Sets the PACKETVER define of the map-server. (see src/map/clif.h)]
47        ),
48        [enable_packetver="$enableval"],
49        [enable_packetver=""]
50)
51
52
53#
54# mapregsql
55#
56AC_ARG_ENABLE(
57        [mapregsql],
58        AC_HELP_STRING(
59                [--enable-mapregsql],
60                [Makes map-wide script variables be saved to SQL instead of TXT files in the sql map-server. (disabled by default)]
61        ),
62        [
63                enable_mapregsql="$enableval"
64                case $enableval in
65                        no);;
66                        yes);;
67                        *) AC_MSG_ERROR([[invalid argument --enable-mapregsql=$enableval... stopping]]);;
68                esac
69        ],
70        [enable_mapregsql="no"]
71)
72
73
74#
75# debug
76#
77AC_ARG_ENABLE(
78        [debug],
79        AC_HELP_STRING(
80                [--enable-debug],
81                [Compiles in debug mode. (disabled by default)]
82        ),
83        [
84                enable_debug="$enableval"
85                case $enableval in
86                        no);;
87                        yes);;
88                        *) AC_MSG_ERROR([[invalid argument --enable-debug=$enableval... stopping]]);;
89                esac
90        ],
91        [enable_debug="no"]
92)
93
94
95#
96# Enable/disable MySql and optionally specify the path to mysql_config (optional library)
97#
98AC_ARG_WITH(
99        [mysql],
100        AC_HELP_STRING(
101                [--with-mysql@<:@=ARG@:>@],
102                [use MySQL client library, optionally specify the path to the mysql_config executable (by default mysql is used if found)]
103        ),
104        [
105                if test "$withval" = "no" ; then
106                        want_mysql="no"
107                else
108                        want_mysql="yes"
109                        require_mysql="yes"
110                        if test "$withval" != "yes" ; then
111                                if test ! -x "$withval" ; then
112                                        AC_MSG_ERROR([$withval is not an executable file])
113                                fi
114                                MYSQL_CONFIG_HOME="$withval"
115                        fi
116                fi
117        ],
118        [want_mysql="yes" require_mysql="no"]
119)
120
121
122#
123# Manual MYSQL_CFLAGS (optional)
124#
125AC_ARG_WITH(
126        [MYSQL_CFLAGS],
127        AC_HELP_STRING(
128                [--with-MYSQL_CFLAGS=ARG],
129                [specify MYSQL_CFLAGS manually (instead of using "mysql_config --include")]
130        ),
131        [
132                manual_MYSQL_CFLAGS="yes"
133                MYSQL_CFLAGS="$withval"
134        ],
135        [manual_MYSQL_CFLAGS="no"]
136)
137
138
139#
140# Manual MYSQL_LIBS (optional)
141#
142AC_ARG_WITH(
143        [MYSQL_LIBS],
144        AC_HELP_STRING(
145                [--with-MYSQL_LIBS=ARG],
146                [specify MYSQL_LIBS manually (instead of using "mysql_config --libs")]
147        ),
148        [
149                manual_MYSQL_LIBS="yes"
150                MYSQL_LIBS="$withval"
151        ],
152        [manual_MYSQL_LIBS="no"]
153)
154
155
156#
157# Enable/disable PCRE and optionally specify the path (optional library)
158#
159AC_ARG_WITH(
160        [pcre],
161        AC_HELP_STRING(
162                [--with-pcre@<:@=ARG@:>@],
163                [use PCRE library, optionally specify the full path of pcre installation directory (by default pcre is used if found)]
164        ),
165        [
166                if test "$withval" = "no" ; then
167                        want_pcre="no"
168                else
169                        want_pcre="yes"
170                        require_pcre="yes"
171                        if test "$withval" != "yes" ; then
172                                if test ! -d "$withval" ; then
173                                        AC_MSG_ERROR([$withval is not a directoy])
174                                fi
175                                PCRE_HOME="$withval"
176                        fi
177                fi
178        ],
179        [want_pcre="yes" require_pcre="no"]
180)
181
182
183#
184# Specify the path of the zlib library (required library)
185#
186AC_ARG_WITH(
187        [zlib],
188        AC_HELP_STRING(
189                [--with-zlib=DIR],
190                [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local).
191                 Assumes that the header files are in DIR/include and the library files are in DIR/lib]
192        ),
193        [
194                test -n "$withval" && ZLIB_HOME="$withval"
195        ],
196        [
197                ZLIB_HOME=/usr/local
198                test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr
199        ]
200)
201
202
203
204###############################################################################
205# Check for programs and types.
206#
207
208
209
210AC_PROG_MAKE_SET
211AC_PROG_CC
212AC_PROG_CPP
213AC_LANG([C])
214
215
216CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wno-sign-compare"
217CPPFLAGS="$CPPFLAGS -I../common"
218
219
220AC_C_BIGENDIAN(
221        [AC_MSG_ERROR([[bigendian is not supported... stopping]])],
222        ,
223        [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])]
224)
225
226
227AC_MSG_CHECKING([whether pointers can be stored in ints (old code)])
228pointers_fit_in_ints="no"
229AC_COMPILE_IFELSE(
230        [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])],
231        [pointers_fit_in_ints="yes"],
232        []
233)
234if test "$pointers_fit_in_ints" = "no" ; then
235        CFLAGS="$CFLAGS -m32"
236        LDFLAGS="$LDFLAGS -m32"
237        AC_COMPILE_IFELSE(
238                [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])],
239                [pointers_fit_in_ints="yes (with -m32)"],
240                []
241        )
242fi
243AC_MSG_RESULT($pointers_fit_in_ints)
244if test "$pointers_fit_in_ints" = "no" ; then
245        AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping])
246fi
247
248
249AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
250OLD_CFLAGS="$CFLAGS"
251CFLAGS="$CFLAGS -Wno-unused-parameter"
252AC_COMPILE_IFELSE(
253        [int foo;],
254        [AC_MSG_RESULT([yes])],
255        [
256                AC_MSG_RESULT([no])
257                CFLAGS="$OLD_CFLAGS"
258        ]
259)
260
261
262AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
263OLD_CFLAGS="$CFLAGS"
264CFLAGS="$CFLAGS -Wno-pointer-sign"
265AC_COMPILE_IFELSE(
266        [int foo;],
267        [AC_MSG_RESULT([yes])],
268        [
269                AC_MSG_RESULT([no])
270                CFLAGS="$OLD_CFLAGS"
271        ]
272)
273
274
275AC_MSG_CHECKING([whether $CC supports -Wno-switch])
276OLD_CFLAGS="$CFLAGS"
277CFLAGS="$CFLAGS -Wno-switch"
278AC_COMPILE_IFELSE(
279        [int foo;],
280        [AC_MSG_RESULT([yes])],
281        [
282                AC_MSG_RESULT([no])
283                CFLAGS="$OLD_CFLAGS"
284        ]
285)
286
287
288
289###############################################################################
290# Check for libraries and header files.
291#
292
293
294#
295# setrlimit - used to set the socket limit
296#
297AC_CHECK_FUNC([setrlimit],[CFLAGS="$CFLAGS -DHAVE_SETRLIMIT"])
298
299
300
301#
302# Memory manager
303#
304case $enable_manager in
305        "no")
306                CFLAGS="$CFLAGS -DNO_MEMMGR"
307                ;;
308        "builtin")
309                # enabled by default
310                ;;
311        "memwatch")
312                CFLAGS="$CFLAGS -DMEMWATCH"
313                AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
314                ;;
315        "dmalloc")
316                CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
317                LIBS="$LIBS -ldmalloc"
318                AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
319                ;;
320        "gcollect")
321                CFLAGS="$CFLAGS -DGCOLLECT"
322                LIBS="$LIBS -lgc"
323                AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
324                ;;
325        "bcheck")
326                CFLAGS="$CFLAGS -DBCHECK"
327                ;;
328esac
329
330
331#
332# Packetver
333#
334if test -n "$enable_packetver" ; then
335        CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver"
336fi
337
338
339#
340# Mapregsql
341#
342if test "$enable_mapregsql" = "yes" ; then
343        CFLAGS="$CFLAGS -DMAPREGSQL"
344fi
345
346
347#
348# Debug
349#
350if test "$enable_debug" = "yes" ; then
351        CFLAGS="$CFLAGS -g -DDEBUG"
352fi
353
354
355#
356# zlib library (required)
357#
358if test -n "${ZLIB_HOME}" ; then
359        LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
360        CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
361fi
362AC_CHECK_LIB([z], [inflateEnd], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
363AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
364
365
366#
367# math library (required)
368#
369AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])])
370
371
372#
373# clock_gettime (rt on Debian)
374#
375AC_CHECK_LIB([rt], [clock_gettime])
376
377
378#
379# MySQL library (optional)
380#
381
382if test "$want_mysql" = "no" ; then
383        MYSQL_VERSION=""
384        MYSQL_CFLAGS=""
385        MYSQL_LIBS=""
386        AC_MSG_NOTICE([ignoring MySQL (optional)])
387else
388        if test -z "$MYSQL_CONFIG_HOME"; then
389                AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
390        fi
391
392        if test "$MYSQL_CONFIG_HOME" != "no" ; then
393                MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
394                if test "$manual_MYSQL_CFLAGS" = "no" ; then
395                        MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
396                fi
397                if test "$manual_MYSQL_LIBS" = "no" ; then
398                        MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
399                fi
400        else
401                MYSQL_VERSION="unknown"
402        fi
403
404        MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
405        MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
406        AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
407        AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
408        CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
409        LDFLAGS="$MYSQL_OLD_LDFLAGS"
410
411        AC_MSG_CHECKING([MySQL library (optional)])
412        if test "$HAVE_MYSQL" = "yes" ; then
413                AC_MSG_RESULT([yes ($MYSQL_VERSION)])
414        else
415                AC_MSG_RESULT([no])
416                if test "$require_mysql" = "yes" ; then
417                        AC_MSG_ERROR([MySQL not found or incompatible (requested)])
418                else
419                        AC_MSG_NOTICE([disabling MySQL (optional)])
420                        MYSQL_VERSION=""
421                        MYSQL_CFLAGS=""
422                        MYSQL_LIBS=""
423                fi
424        fi
425fi
426
427AC_SUBST([HAVE_MYSQL])
428AC_SUBST([MYSQL_VERSION])
429AC_SUBST([MYSQL_CFLAGS])
430AC_SUBST([MYSQL_LIBS])
431
432
433#
434# PCRE library (optional)
435#
436##TODO PCRE version
437PCRE_LIBS=""
438PCRE_CFLAGS=""
439
440if test "$want_pcre" = "no" ; then
441        AC_MSG_NOTICE([ignoring PCRE (optional)])
442else
443        if test -z "$PCRE_HOME" ; then
444                AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], [])
445                if test "$HAVE_PCRE" = "yes" ; then
446                        PCRE_LIBS="-lpcre"
447                fi
448        else
449                PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
450                PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
451                AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
452                CPPFLAGS="$PCRE_OLD_CPPFLAGS"
453                LDFLAGS="$PCRE_OLD_LDFLAGS"
454                if test "$HAVE_PCRE" = "yes" ; then
455                        PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
456                        test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
457                fi
458        fi
459        AC_MSG_CHECKING([PCRE library (optional)])
460        if test "$HAVE_PCRE" = "yes" ; then
461                AC_MSG_RESULT([yes])
462        else
463                AC_MSG_RESULT([no])
464                if test "$require_pcre" = "yes" ; then
465                        AC_MSG_ERROR([PCRE not found or incompatible (requested)])
466                else
467                        AC_MSG_NOTICE([disabling PCRE (optional)])
468                fi
469        fi
470fi
471
472AC_SUBST([HAVE_PCRE])
473AC_SUBST([PCRE_LIBS])
474AC_SUBST([PCRE_CFLAGS])
475
476
477#
478# Host specific stuff
479#
480AC_MSG_CHECKING([host OS])
481host_os="`uname`"
482AC_MSG_RESULT([$host_os])
483fd_setsize=""
484DLLEXT=".so"
485case $host_os in
486Solaris* )
487        LIBS="$LIBS -lsocket -lnsl -ldl"
488        ;;
489Linux* )
490        LIBS="$LIBS -ldl"
491        ;;
492FreeBSD*)
493        CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
494        ;;
495NetBSD*)
496        CPPFLAGS="$CPPFLAGS -D__NETBSD__"
497        ;;
498CYGWIN*)
499        CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
500        fd_setsize="done"
501        DLLEXT=".dll"
502        ;;
503esac
504AC_SUBST([DLLEXT])
505
506AC_MSG_CHECKING([for MinGW])
507if test -n "`$CC --version | grep -i mingw`" ; then
508        AC_MSG_RESULT([yes])
509        CPPFLAGS="$CPPFLAGS -DMINGW"
510        if test -z "$fd_setsize" ; then
511                CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
512        fi
513        LIBS="$LIBS -lws2_32"
514else
515        AC_MSG_RESULT([no])
516fi
517
518
519
520###############################################################################
521AC_OUTPUT
Note: See TracBrowser for help on using the browser.