1 dnl Process this file with autoconf to create a configure script.
3 dnl General initialization.
6 AC_INIT(X3, 1.4, x2serv-general@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.
27 AC_PROG_GCC_TRADITIONAL
29 dnl nice that unixes can all follow a standard.
31 *-freebsd2* | *-freebsdelf2* | *-freebsd*out3*)
34 *-freebsd3* | *-freebsdelf3* | *-freebsd*out3*)
36 AC_DEFINE(BROKEN_REGEX, 1, [Define if the system regex library is unreliable.])
40 EXTRA_DEFINE="-D__SOLARIS__"
41 ANSI_SRC="-fno-builtin"
44 ANSI_SRC="-fno-builtin"
47 dnl -D_GNU_SOURCE needed for strsignal()
48 EXTRA_DEFINE="-D_GNU_SOURCE"
55 CFLAGS="$CFLAGS $EXTRA_DEFINE"
57 dnl Checks for libraries.
58 AC_CHECK_LIB(socket, socket)
59 AC_CHECK_LIB(nsl, gethostbyname)
62 dnl Checks for header files.
65 dnl will be used for portability stuff
69 dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi
70 AC_CHECK_HEADERS(fcntl.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 regex.h arpa/inet.h sys/mman.h sys/stat.h dirent.h,,)
72 dnl Cygwin does not have d_type in struct dirent. We use stat() as a fallback.
73 AC_CHECK_MEMBER([struct dirent.d_type],
74 [AC_DEFINE(HAVE_DIRENT_D_TYPE, 1, [Define if struct dirent exists and includes the d_type element.])],,[#include <dirent.h>])
76 dnl portability stuff, hurray! -Jedi
77 AC_CHECK_FUNCS(gettimeofday)
78 if test $ac_cv_func_gettimeofday = no; then
79 AC_CHECK_FUNCS(ftime,,AC_MSG_ERROR([ftime or gettimeofday required. X3 build will fail.]))
82 dnl We have fallbacks in case these are missing, so just check for them.
83 AC_CHECK_FUNCS(bcopy getpagesize memcpy memset strdup strerror strsignal localtime_r setrlimit inet_ntoa getopt getopt_long regcomp regexec regfree sysconf,,)
85 dnl Check for absolutely required library functions.
86 AC_CHECK_FUNCS(select socket strcspn strspn strtod strtoul,,AC_MSG_ERROR([a required function was not found. X3 build will fail.]))
88 dnl Check for functions (and how to get them).
92 AC_CACHE_CHECK([for sin_len], ac_cv_sin_len,
93 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
94 #include <netinet/in.h>],[struct sockaddr_in *sin; sin->sin_len = 0;])],
95 ac_cv_sin_len="yes", ac_cv_sin_len="no")])
96 if test $ac_cv_sin_len = yes ; then
97 AC_DEFINE(HAVE_SIN_LEN, 1, [Define if struct sockaddr_in contains a sin_len field])
100 dnl Can only check with -Werror, but the rest of configure doesn't like -Werror
102 CFLAGS="$CFLAGS -W -Wall -Werror"
104 dnl Now figure out how to printf() a time_t
105 AC_MSG_CHECKING(for time_t format)
106 AC_CACHE_VAL(ac_cv_fmt_time_t, [
108 AC_COMPILE_IFELSE([#include <sys/types.h>
113 }], ac_cv_fmt_time_t="\"%li\"")
114 if test $ac_cv_fmt_time_t = no; then
115 AC_COMPILE_IFELSE([#include <sys/types.h>
120 }], ac_cv_fmt_time_t="\"%i\"")
122 if test $ac_cv_fmt_time_t = no; then
123 AC_MSG_ERROR([Cannot detect format string for time_t
124 Please check sys/types.h for the typedef of time_t and submit to a developer])
127 AC_DEFINE_UNQUOTED(FMT_TIME_T, $ac_cv_fmt_time_t, [Define to printf format for a time_t variable])
128 AC_MSG_RESULT($ac_cv_fmt_time_t)
130 dnl How to copy one va_list to another?
131 AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy, [AC_LINK_IFELSE(
132 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])],
133 [ac_cv_c_va_copy="yes"],
134 [ac_cv_c_va_copy="no"]
136 if test "$ac_cv_c_va_copy" = "yes" ; then
137 AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
140 AC_CACHE_CHECK([for __va_copy], ac_cv_c___va_copy, [AC_LINK_IFELSE(
141 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);])],
142 [ac_cv_c___va_copy="yes"],
143 [ac_cv_c___va_copy="no"]
145 if test "$ac_cv_c___va_copy" = "yes" ; then
146 AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
149 dnl Now fix things back up
152 dnl Optional features.
153 AC_MSG_CHECKING(which malloc to use)
155 [ --with-malloc=type Enables use of a special malloc library; one of:
156 system (the default), boehm-gc, dmalloc, mpatrol, x3, slab],
159 if test "x$withval" = "xsystem" ; then
160 AC_MSG_RESULT(system)
161 AC_DEFINE(WITH_MALLOC_SYSTEM, 1, [Define if using the system's malloc])
162 elif test "x$withval" = "xdmalloc" ; then
163 AC_MSG_RESULT(dmalloc)
164 AC_CHECK_HEADERS(dmalloc.h,,AC_MSG_ERROR([dmalloc header file missing. dmalloc build will fail.]))
165 AC_CHECK_LIB(dmalloc,malloc,,AC_MSG_ERROR([dmalloc library is missing. dmalloc build will fail.]))
166 AC_DEFINE(WITH_MALLOC_DMALLOC, 1, [Define if using the dmalloc debugging malloc package])
167 elif test "x$withval" = "xmpatrol" ; then
168 AC_MSG_RESULT(mpatrol)
169 AC_CHECK_HEADERS(mpatrol.h,,AC_MSG_ERROR([mpatrol header file missing. mpatrol build will fail.]))
170 dnl Using mpatrol requires linking against libelf, at least on Linux.
171 AC_CHECK_LIB(elf, elf_begin)
172 AC_CHECK_LIB(mpatrol,__mp_atexit,,AC_MSG_ERROR([mpatrol library is missing completely. mpatrol build will fail.]))
173 AC_DEFINE(WITH_MALLOC_MPATROL, 1, [Define if using the mpatrol malloc debugging package])
174 elif test "x$withval" = "xboehm-gc" ; then
175 AC_MSG_RESULT(boehm-gc)
176 AC_CHECK_HEADERS(gc/gc.h,,AC_MSG_ERROR([Boehm GC header file missing. boehm-gc build will fail.]))
177 AC_CHECK_LIB(dl, dlopen, , AC_MSG_ERROR([libdl library is missing. boehm-gc build will fail.]))
178 AC_CHECK_LIB(gc, GC_gcollect, , AC_MSG_ERROR([Boehm GC library is missing. boehm-gc build will fail.]))
179 AC_DEFINE(WITH_MALLOC_BOEHM_GC, 1, [Define if using the Boehm GC to garbage collect and check memory leaks])
180 elif test "x$withval" = "xx3" ; then
182 AC_DEFINE(WITH_MALLOC_X3, 1, [Define if using the x3 internal debug allocator])
183 MODULE_OBJS="$MODULE_OBJS alloc-x3.\$(OBJEXT)"
184 elif test "x$withval" = "xslab" ; then
186 AC_DEFINE(WITH_MALLOC_SLAB, 1, [Define if using the slab internal debug allocator])
187 MODULE_OBJS="$MODULE_OBJS alloc-slab.\$(OBJEXT)"
189 AC_MSG_ERROR([Unknown malloc type $withval])
192 AC_MSG_CHECKING(which protocol to use)
193 AC_ARG_WITH(protocol,
194 [ --with-protocol=name Choose IRC dialect to support; one of:
195 p10 (the default), bahamut],
198 if test "x$withval" = "xp10" ; then
200 AC_DEFINE(WITH_PROTOCOL_P10, 1, [Define if using the P10 dialect of IRC])
201 MODULE_OBJS="$MODULE_OBJS proto-p10.o"
202 PROTO_FILES=proto-p10.c
203 elif test "x$withval" = "xbahamut" ; then
204 AC_MSG_RESULT(Bahamut)
205 AC_DEFINE(WITH_PROTOCOL_BAHAMUT, 1, [Define if using the Bahamut dialect of IRC])
206 MODULE_OBJS="$MODULE_OBJS proto-bahamut.o"
208 AC_MSG_ERROR([Unknown IRC dialect $withval])
212 [ --without-getopt Disables building of the GNU getopt library],
213 [if test "$withval" = no; then
214 AC_DEFINE(IGNORE_GETOPT, 1, [Define to disable built-in getopt library])
217 AC_MSG_CHECKING(whether to enable tokenization)
218 AC_ARG_ENABLE(tokens,
219 [ --disable-tokens Disables tokenization of P10 protocol output
220 (tokens required if linking to ircu 2.10.11)],
222 if test "z$enableval" = zno ; then
225 AC_DEFINE(ENABLE_TOKENS, 1, [Define if tokenized P10 desired])
229 AC_MSG_CHECKING(whether to enable debug behaviors)
231 [ --enable-debug Enables debugging behaviors],
237 CPPFLAGS="$CPPFLAGS -DNDEBUG"
241 if test -e src ; then
242 if test ! -d src ; then
243 AC_MSG_ERROR([src exists but is not a directory; please move it out of the way.])
248 AC_MSG_CHECKING(for extra module files)
249 MODULE_DEFINES="src/modules-list.h"
250 echo > $MODULE_DEFINES
251 touch $MODULE_DEFINES
252 AC_ARG_ENABLE(modules,
253 [ --enable-modules=list,of,modules Enable extra modules],
259 dnl Must use a separate file because autoconf can't stand newlines in an AC_SUBSTed variable.
260 for module in $enableval ; do
261 module=`echo $module | sed -e s/^mod-// -e s/\.c\$//`
262 EXTRA_MODULE_OBJS="$EXTRA_MODULE_OBJS mod-$module.o"
263 module_list="$module_list $module"
264 echo "WITH_MODULE($module)" >> $MODULE_DEFINES
267 MODULE_OBJS="$MODULE_OBJS $EXTRA_MODULE_OBJS"
268 AC_MSG_RESULT($module_list)
277 if test "${BROKEN_REGEX}" = yes -o "${ac_cv_func_regcomp}" = no; then
278 MY_SUBDIRS="rx $MY_SUBDIRS"
279 RX_INCLUDES="-I../rx"
280 RX_LIBS="../rx/librx.a"
282 MY_SUBDIRS="$MY_SUBDIRS src"
283 CFLAGS="$CFLAGS $ANSI_SRC -W -Wall"
284 if test "z$USE_MAINTAINER_MODE" = zyes ; then
285 CFLAGS="$CFLAGS -Werror"
288 AC_DEFINE_UNQUOTED(CODENAME, "${CODENAME}", [Code name for this release])
289 AC_SUBST(MODULE_OBJS)
291 AC_SUBST(RX_INCLUDES)
293 AC_CONFIG_FILES(Makefile rx/Makefile src/Makefile)