1 dnl Process this file with autoconf to create a configure script.
3 dnl General initialization.
6 AC_INIT([X3],[1.6],[evilnet-devel@lists.sourceforge.net])
8 AC_CONFIG_HEADERS(src/config.h)
9 AC_CONFIG_SRCDIR(src/opserv.c)
10 dnl AM_CANONICAL_TARGET must be before AM_INIT_AUTOMAKE() or autoconf whines
12 AM_INIT_AUTOMAKE([gnu 1.6])
15 dnl Compiler/runtime feature checks.
20 dnl Checks for programs.
32 AC_PROG_GCC_TRADITIONAL
33 AC_CHECK_PROG(MAKER, gmake, gmake, make)
35 dnl nice that unixes can all follow a standard.
37 *-freebsd2* | *-freebsdelf2* | *-freebsd*out3*)
40 *-freebsd3* | *-freebsdelf3* | *-freebsd*out3*)
44 EXTRA_DEFINE="-D__SOLARIS__"
45 ANSI_SRC="-fno-builtin"
48 ANSI_SRC="-fno-builtin"
51 dnl -D_GNU_SOURCE needed for strsignal()
52 EXTRA_DEFINE="-D_GNU_SOURCE"
59 CFLAGS="$CFLAGS $EXTRA_DEFINE"
61 dnl Checks for libraries.
62 AC_CHECK_LIB(socket, socket)
63 AC_CHECK_LIB(nsl, gethostbyname)
65 AC_CHECK_LIB(GeoIP, GeoIP_open)
67 dnl Checks for header files.
70 dnl will be used for portability stuff
74 dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi
75 AC_CHECK_HEADERS(GeoIP.h GeoIPCity.h fcntl.h math.h tgmath.h malloc.h netdb.h netinet/in.h sys/resource.h sys/timeb.h sys/times.h sys/param.h sys/socket.h sys/time.h sys/types.h sys/wait.h unistd.h getopt.h memory.h arpa/inet.h sys/mman.h sys/stat.h dirent.h ,,)
77 dnl portability stuff, hurray! -Jedi
78 AC_CHECK_MEMBER([struct sockaddr.sa_len],
79 [AC_DEFINE([HAVE_SOCKADDR_SA_LEN],,[Define if struct sockaddr has sa_len field])],
80 [],[#include <sys/types.h>
81 #include <sys/socket.h>])
82 AC_CHECK_MEMBER([struct addrinfo.ai_flags],
83 [AC_DEFINE([HAVE_STRUCT_ADDRINFO],,[Define if struct addrinfo declared])],
84 [],[#include <sys/types.h>
85 #include <sys/socket.h>
88 AC_CHECK_FUNCS(gettimeofday)
89 if test $ac_cv_func_gettimeofday = no; then
90 AC_CHECK_FUNCS(ftime,,AC_MSG_ERROR([ftime or gettimeofday required. X3 build will fail.]))
93 dnl We have fallbacks in case these are missing, so just check for them.
94 AC_CHECK_FUNCS(freeaddrinfo getaddrinfo getnameinfo getpagesize memcpy memset strdup strerror strsignal localtime_r setrlimit getopt getopt_long sysconf,,)
96 dnl Check for absolutely required library functions.
97 AC_CHECK_FUNCS(select socket strcspn strspn strtod strtoul,,AC_MSG_ERROR([a required function was not found. X3 build will fail.]))
99 dnl Check for functions (and how to get them).
103 AC_CACHE_CHECK([for sin_len], ac_cv_sin_len,
104 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
105 #include <netinet/in.h>],[struct sockaddr_in *sin; sin->sin_len = 0;])],
106 ac_cv_sin_len="yes", ac_cv_sin_len="no")])
107 if test $ac_cv_sin_len = yes ; then
108 AC_DEFINE(HAVE_SIN_LEN, 1, [Define if struct sockaddr_in contains a sin_len field])
111 dnl Check for socklen_t. In traditional BSD this is an int, but some
112 dnl OSes use a different type. Test until we find something that will
113 dnl work properly. Test borrowed from a patch submitted for Python.
114 AC_CHECK_TYPE([socklen_t], ,[
115 AC_MSG_CHECKING([for socklen_t equivalent])
116 AC_CACHE_VAL([curl_cv_socklen_t_equiv],
118 dnl Systems have either "struct sockaddr*" or "void*" as second
119 dnl arg to getpeername.
120 curl_cv_socklen_t_equiv=
121 for arg2 in "struct sockaddr" void ; do
122 for t in int size_t unsigned long "unsigned long" ; do
123 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
124 #include <sys/socket.h>
125 int getpeername (int $arg2 *, $t *);]], [[$t len;
126 getpeername(0, 0, &len);]])],[curl_cv_socklen_t_equiv="$t"
131 AC_MSG_RESULT($curl_cv_socklen_t_equiv)
132 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
133 [type to use in place of socklen_t if not defined])],
134 [#include <sys/types.h>
135 #include<sys/socket.h>])
137 dnl Can only check with -Werror, but the rest of configure doesn't like -Werror
139 CFLAGS="$CFLAGS -W -Wall -Werror"
141 dnl Now figure out how to printf() a time_t
142 AC_MSG_CHECKING(for time_t format)
143 AC_CACHE_VAL(ac_cv_fmt_time_t, [
145 AC_COMPILE_IFELSE([#include <sys/types.h>
150 }], ac_cv_fmt_time_t="\"%li\"")
151 if test $ac_cv_fmt_time_t = no; then
152 AC_COMPILE_IFELSE([#include <sys/types.h>
157 }], ac_cv_fmt_time_t="\"%i\"")
159 if test $ac_cv_fmt_time_t = no; then
160 AC_MSG_ERROR([Cannot detect format string for time_t
161 Please check sys/types.h for the typedef of time_t and submit to a developer])
164 AC_DEFINE_UNQUOTED(FMT_TIME_T, $ac_cv_fmt_time_t, [Define to printf format for a time_t variable])
165 AC_MSG_RESULT($ac_cv_fmt_time_t)
167 dnl How to copy one va_list to another?
168 AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy, [AC_LINK_IFELSE(
169 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])],
170 [ac_cv_c_va_copy="yes"],
171 [ac_cv_c_va_copy="no"]
173 if test "$ac_cv_c_va_copy" = "yes" ; then
174 AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
177 AC_CACHE_CHECK([for __va_copy], ac_cv_c___va_copy, [AC_LINK_IFELSE(
178 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);])],
179 [ac_cv_c___va_copy="yes"],
180 [ac_cv_c___va_copy="no"]
182 if test "$ac_cv_c___va_copy" = "yes" ; then
183 AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
186 dnl Now fix things back up
189 dnl Optional features.
190 AC_MSG_CHECKING(which malloc to use)
192 [ --with-malloc=type Enables use of a special malloc library; one of:
193 system (the default), boehm-gc, dmalloc, mpatrol, x3, slab],
196 if test "x$withval" = "xsystem" ; then
197 AC_MSG_RESULT(system)
198 AC_DEFINE(WITH_MALLOC_SYSTEM, 1, [Define if using the system's malloc])
200 elif test "x$withval" = "xdmalloc" ; then
201 AC_MSG_RESULT(dmalloc)
202 AC_CHECK_HEADERS(dmalloc.h,,AC_MSG_ERROR([dmalloc header file missing. dmalloc build will fail.]))
203 AC_CHECK_LIB(dmalloc,malloc,,AC_MSG_ERROR([dmalloc library is missing. dmalloc build will fail.]))
204 AC_DEFINE(WITH_MALLOC_DMALLOC, 1, [Define if using the dmalloc debugging malloc package])
206 elif test "x$withval" = "xmpatrol" ; then
207 AC_MSG_RESULT(mpatrol)
208 AC_CHECK_HEADERS(mpatrol.h,,AC_MSG_ERROR([mpatrol header file missing. mpatrol build will fail.]))
209 dnl Using mpatrol requires linking against libelf, at least on Linux.
210 AC_CHECK_LIB(elf, elf_begin)
211 AC_CHECK_LIB(mpatrol,__mp_atexit,,AC_MSG_ERROR([mpatrol library is missing completely. mpatrol build will fail.]))
212 AC_DEFINE(WITH_MALLOC_MPATROL, 1, [Define if using the mpatrol malloc debugging package])
214 elif test "x$withval" = "xboehm-gc" ; then
215 AC_MSG_RESULT(boehm-gc)
216 AC_CHECK_HEADERS(gc/gc.h,,AC_MSG_ERROR([Boehm GC header file missing. boehm-gc build will fail.]))
217 AC_CHECK_LIB(dl, dlopen, , AC_MSG_ERROR([libdl library is missing. boehm-gc build will fail.]))
218 AC_CHECK_LIB(gc, GC_gcollect, , AC_MSG_ERROR([Boehm GC library is missing. boehm-gc build will fail.]))
219 AC_DEFINE(WITH_MALLOC_BOEHM_GC, 1, [Define if using the Boehm GC to garbage collect and check memory leaks])
221 elif test "x$withval" = "xx3" ; then
223 AC_DEFINE(WITH_MALLOC_X3, 1, [Define if using the X3 internal debug allocator])
224 MODULE_OBJS="$MODULE_OBJS alloc-x3.\$(OBJEXT)"
226 elif test "x$withval" = "xslab" ; then
228 AC_DEFINE(WITH_MALLOC_SLAB, 1, [Define if using the slab internal debug allocator])
229 MODULE_OBJS="$MODULE_OBJS alloc-slab.\$(OBJEXT)"
232 AC_MSG_ERROR([Unknown malloc type $withval])
235 AC_MSG_CHECKING(which protocol to use)
236 AC_ARG_WITH(protocol,
237 [ --with-protocol=name Choose IRC dialect to support; one of:
241 if test "x$withval" = "xp10" ; then
243 AC_DEFINE(WITH_PROTOCOL_P10, 1, [Define if using the P10 dialect of IRC])
244 MODULE_OBJS="$MODULE_OBJS proto-p10.\$(OBJEXT)"
245 PROTO_FILES=proto-p10.c
248 AC_MSG_ERROR([Unknown IRC dialect $withval])
252 [ --without-getopt Disables building of the GNU getopt library],
253 [if test "$withval" = no; then
254 AC_DEFINE(IGNORE_GETOPT, 1, [Define to disable built-in getopt library])
257 AC_MSG_CHECKING(whether to enable tokenization)
258 AC_ARG_ENABLE(tokens,
259 [ --disable-tokens Disables tokenization of P10 protocol output
260 (tokens required if linking to ircu 2.10.11)],
262 if test "z$enableval" = zno ; then
265 AC_DEFINE(ENABLE_TOKENS, 1, [Define if tokenized P10 desired])
269 AC_MSG_CHECKING(whether to enable debug behaviors)
271 [ --enable-debug Enables debugging behaviors],
278 CPPFLAGS="$CPPFLAGS -DNDEBUG"
283 if test -e src ; then
284 if test ! -d src ; then
285 AC_MSG_ERROR([src exists but is not a directory; please move it out of the way.])
290 AC_MSG_CHECKING(for extra module files)
291 MODULE_DEFINES="src/modules-list.h"
292 echo > $MODULE_DEFINES
293 touch $MODULE_DEFINES
294 AC_ARG_ENABLE(modules,
295 [ --enable-modules=list,of,modules Enable extra modules],
301 dnl Must use a separate file because autoconf can't stand newlines in an AC_SUBSTed variable.
302 for module in $enableval ; do
303 module=`echo $module | sed -e s/^mod-// -e s/\.c\$//`
304 EXTRA_MODULE_OBJS="$EXTRA_MODULE_OBJS mod-$module.\$(OBJEXT)"
305 module_list="$module_list $module"
306 echo "WITH_MODULE($module)" >> $MODULE_DEFINES
307 if test "x$module" = "xtrack" ; then
308 TRACK="-D HAVE_TRACK"
309 AC_DEFINE(HAVE_TRACK, 1, [Define this if you are using mod-track])
311 if test "x$module" = "xhelpserv" ; then
312 TRACK="-D HAVE_HELPSERV"
313 AC_DEFINE(HAVE_HELPSERV, 1, [Define this if you are using mod-helpserv])
317 MODULE_OBJS="$MODULE_OBJS $EXTRA_MODULE_OBJS"
318 AC_MSG_RESULT($module_list)
324 AC_ARG_ENABLE(python,
325 [ --disable-python don't build the python plugin],
326 python=$enableval, python=yes)
332 if test "${BROKEN_REGEX}" = yes -o "${ac_cv_func_regcomp}" = no; then
333 MY_SUBDIRS="rx $MY_SUBDIRS"
334 RX_INCLUDES="-I../rx"
335 RX_LIBS="../rx/librx.a"
337 MY_SUBDIRS="$MY_SUBDIRS src"
338 CFLAGS="$CFLAGS $ANSI_SRC -W -Wall"
339 if test "z$USE_MAINTAINER_MODE" = zyes ; then
340 CFLAGS="$CFLAGS -Werror"
343 dnl I am not comfortable running make install from ./configure. This has to be done correctly or not at all. -Rubin
344 dnl REMEMBER TO CHANGE WITH A NEW TRE RELEASE!
345 dnl AC_MSG_RESULT(extracting TRE regex library)
348 dnl remove old tre directory to force a recompile...
349 dnl rm -rf tre-$tre_version
350 dnl if test "x$ac_cv_path_GUNZIP" = "x" ; then
351 dnl tar xfz tre.tar.gz
353 dnl cp tre.tar.gz tre.tar.gz.bak
354 dnl gunzip -f tre.tar.gz
355 dnl cp tre.tar.gz.bak tre.tar.gz
358 dnl AC_MSG_RESULT(configuring TRE regex library)
359 dnl cd tre-$tre_version
360 dnl tre_prefix=$prefix
361 dnl if test $tre_prefix = "NONE"; then
362 dnl tre_prefix="$HOME"
364 dnl ./configure --disable-agrep --disable-shared --disable-system-abi --disable-wchar --disable-multibyte --prefix=$tre_prefix || exit 1
366 dnl AC_MSG_RESULT(compiling TRE regex library)
367 dnl $ac_cv_prog_MAKER || exit 1
368 dnl AC_MSG_RESULT(installing TRE regex library)
369 dnl $ac_cv_prog_MAKER install || exit 1
370 dnl TREINCDIR="$tre_prefix/include"
371 dnl AC_SUBST(TREINCDIR)
372 dnl if test "x$ac_cv_path_PKGCONFIG" = "x" ; then
373 dnl TRELIBS="-L$tre_prefix/lib -ltre"
375 dnl TRELIBS=`$ac_cv_path_PKGCONFIG --libs tre.pc`
377 dnl AC_SUBST(TRELIBS)
381 dnl libTRE (regex library) checking
385 [ --with-tre=PATH Base path to where libtre is installed, such that
386 PATH/lib/libtre.so and PATH/include/tre/regex.h exist.], )
387 if test "x$withval" != "x"; then
388 AC_MSG_RESULT(Using include dir $withval to find libtre)
389 CPPFLAGS="$CPPFLAGS -I$withval/include -L$withval/lib"
390 LIBS="$LIBS -L$withval/lib"
392 AC_MSG_RESULT([Looking for tre in system and home dirs (${HOME})...])
393 CPPFLAGS="$CPPFLAGS -I${HOME}/include -L${HOME}/lib"
394 LIBS="$LIBS -L${HOME}/lib"
396 AC_CHECK_HEADER(tre/regex.h, , [AC_MSG_ERROR([tre/regex.h, the TRE regex headers, were not found. Install tre or use --with-tre=PATH to tell me how to find it, where PATH/include/tre/regex.h exists. For convenience, just type 'tools/tre_install.sh' now, to install tre in your home directory.])],)
397 AC_CHECK_LIB(tre, regexec, , [AC_MSG_ERROR([TRE regex library not found. Install tre, or use --with-tre=PATH to tell me how to find it, where PATH/lib/libtre.so exists. For convenience, just type 'tools/tre_install.sh' now, to install tre in your home directory.])])
399 dnl core dumper checking
402 AC_ARG_WITH(coredumper,
403 [ --with-coredumper=PATH Base path to where core dumper is installed, such
404 that PATH/lib/libcoredumper.so and
405 PATH/include/google/coredumper.h exist.], )
406 if test "x$withval" != "x"; then
407 AC_MSG_RESULT(Using include dir $withval to find coredumper)
408 CPPFLAGS="$CPPFLAGS -I$withval/include -L$withval/lib"
409 LIBS="$LIBS -L$withval/lib"
411 AC_MSG_RESULT([Looking for coredumper in system and home dirs (${HOME})...])
412 CPPFLAGS="$CPPFLAGS -I${HOME}/include -L${HOME}/lib"
413 LIBS="$LIBS -Wl,--rpath -Wl,${HOME}/lib"
415 AC_CHECK_HEADER(google/coredumper.h, , [AC_MSG_RESULT([google/coredumper.h, the coredumper headers, were not found. Install coredumper or use --with-coredumper=PATH to tell me how to find it, where PATH/include/google/coredumper.h exists. For convenience, just type 'tools/core_install.sh' now, to install coredumper in your home directory.])],)
416 AC_CHECK_LIB(coredumper, WriteCoreDump, , [AC_MSG_RESULT([Coredumper library not found. Install coredumper, or use --with-coredumper=PATH to tell me how to find it, where PATH/lib/libcoredumper.so exists. For convenience, just type 'tools/core_install.sh' now, to install coredumper in your home directory.])])
421 [ --with-ssl=PATH Base path to where openssl is installed],)
422 if test "x$withval" != "x"; then
423 AC_MSG_RESULT(Using include dir $withval to find openssl)
424 CPPFLAGS="$CPPFLAGS -I$withval/include -L$withval/lib"
425 LIBS="$LIBS -L$withval/lib"
427 AC_MSG_RESULT([Looking for openssl in system ])
430 AC_CHECK_LIB(ssl, BIO_new,
433 AC_CHECK_HEADERS(openssl/bio.h,
435 AC_DEFINE(WITH_SSL, 1, [Define if SSL libs are linked])
436 ssl_message="LDAP library: enabled"
439 if test "x$withval" != "x"; then
440 AC_MSG_ERROR([ssl headers not found])
445 if test "x$withval" != "x"; then
446 AC_MSG_ERROR([libldap not found or not valid])
456 [ --with-ldap=PATH Base path to where the ldap library and headers are installed,
457 such that PATH/include/ldap.h and PATH/lib/libldap.so exist.],)
458 if test "x$withval" != "x"; then
459 AC_MSG_RESULT(Using include dir $withval to find libldap)
460 CPPFLAGS="$CPPFLAGS -I$withval/include -L$withval/lib"
461 LIBS="$LIBS -L$withval/lib"
463 AC_MSG_RESULT([Looking for ldap in system ])
466 AC_CHECK_LIB(ldap, ldap_simple_bind_s,
469 AC_CHECK_HEADERS(ldap.h,
471 AC_DEFINE(WITH_LDAP, 1, [Define if LDAP libs are linked])
472 ldap_message="LDAP library: enabled"
475 if test "x$withval" != "x"; then
476 AC_MSG_ERROR([ldap.h not found])
481 if test "x$withval" != "x"; then
482 AC_MSG_ERROR([libldap not found or not valid])
487 dnl *********************************************************************
488 dnl ** PYTHON ***********************************************************
489 dnl *********************************************************************
491 if test "$python" = yes; then
492 AC_PATH_PROG(pythonpath, python2)
493 if test "_$pythonpath" = _ ; then
494 AC_PATH_PROG(pythonpath, python)
496 if test "_$pythonpath" = _ ; then
499 AC_MSG_CHECKING(Python version)
500 changequote(<<, >>)dnl
501 PY_VER=`$pythonpath -c 'import distutils.sysconfig; print distutils.sysconfig.get_config_vars("VERSION")[0];'`
502 PY_LIB=`$pythonpath -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib(standard_lib=1);'`
503 PY_INC=`$pythonpath -c 'import distutils.sysconfig; print distutils.sysconfig.get_config_vars("INCLUDEPY")[0];'`
504 $pythonpath -c "import sys; map(int,sys.version[:3].split('.')) >= [2,2] or sys.exit(1)"
506 AC_MSG_RESULT($PY_VER)
507 if test "$?" != "1"; then
508 AC_MSG_CHECKING(Python compile flags)
509 PY_PREFIX=`$pythonpath -c 'import sys; print sys.prefix'`
510 PY_EXEC_PREFIX=`$pythonpath -c 'import sys; print sys.exec_prefix'`
511 if test -f $PY_INC/Python.h; then
512 AC_DEFINE(WITH_PYTHON, 1, [Define if using python])
513 PY_LIBS="-L$PY_LIB/config -lpython$PY_VER -lpthread -lutil"
514 PY_CFLAGS="-I$PY_INC"
516 CFLAGS="$CFLAGS $PY_CFLAGS"
517 LIBS="$LIBS $PY_LIBS"
520 AC_MSG_RESULT([Can't find Python.h])
523 echo "Python too old. Only 2.2 or above is supported."
529 AM_CONDITIONAL(DO_PYTHON, test "x$python" = "xyes")
533 AC_DEFINE_UNQUOTED(CODENAME, "${CODENAME}", [Code name for this release])
534 AC_SUBST(MODULE_OBJS)
536 AC_SUBST(RX_INCLUDES)
542 AC_CONFIG_FILES(Makefile rx/Makefile src/Makefile)
546 dnl Print configuration summary
550 Configuration summary
551 =====================
553 X3 is now configured as follows:
555 * Compilation environment
568 Extra Modules: $module_list
571 Regexp Library TRE $tre_version
572 Coredumper Library Coredumper $core_version
578 Now you can proceed with compiling X3