1 dnl Process this file with autoconf to create a configure script.
3 dnl General initialization.
4 AC_REVISION([$Id: configure.in,v 1.77 2004/01/02 01:49:15 entrope Exp $])
6 AC_INIT([srvx],[1.3],[srvx-bugs@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 Look for a GNU Arch program
30 AC_CHECK_PROGS(GNU_ARCH, [baz tla])
31 AM_CONDITIONAL(HAS_GNU_ARCH, test z$GNU_ARCH != z)
33 dnl nice that unixes can all follow a standard.
35 *-freebsd2* | *-freebsdelf2* | *-freebsd*out3*)
38 *-freebsd3* | *-freebsdelf3* | *-freebsd*out3*)
40 AC_DEFINE(BROKEN_REGEX, 1, [Define if the system regex library is unreliable.])
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 dnl Checks for header files.
68 dnl will be used for portability stuff
72 dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi
73 AC_CHECK_HEADERS(fcntl.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,,)
75 dnl portability stuff, hurray! -Jedi
76 AC_CHECK_MEMBER([struct sockaddr.sa_len],
77 [AC_DEFINE([HAVE_SOCKADDR_SA_LEN],,[Define if struct sockaddr has sa_len field])],
78 [],[#include <sys/types.h>
79 #include <sys/socket.h>])
80 AC_CHECK_MEMBER([struct addrinfo.ai_flags],
81 [AC_DEFINE([HAVE_STRUCT_ADDRINFO],,[Define if struct addrinfo declared])],
82 [],[#include <sys/types.h>
83 #include <sys/socket.h>
85 AC_CHECK_FUNCS(gettimeofday)
86 if test $ac_cv_func_gettimeofday = no; then
87 AC_CHECK_FUNCS(ftime,,AC_MSG_ERROR([ftime or gettimeofday required. srvx build will fail.]))
90 dnl We have fallbacks in case these are missing, so just check for them.
91 AC_CHECK_FUNCS(freeaddrinfo getaddrinfo getnameinfo getpagesize memcpy memset strdup strerror strsignal localtime_r setrlimit getopt getopt_long regcomp regexec regfree sysconf,,)
93 dnl Check for absolutely required library functions.
94 AC_CHECK_FUNCS(select socket strcspn strspn strtod strtoul,,AC_MSG_ERROR([a required function was not found. srvx build will fail.]))
96 dnl Check for functions (and how to get them).
100 AC_CACHE_CHECK([for sin_len], ac_cv_sin_len,
101 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
102 #include <netinet/in.h>],[struct sockaddr_in *sin; sin->sin_len = 0;])],
103 ac_cv_sin_len="yes", ac_cv_sin_len="no")])
104 if test $ac_cv_sin_len = yes ; then
105 AC_DEFINE(HAVE_SIN_LEN, 1, [Define if struct sockaddr_in contains a sin_len field])
108 dnl Check for socklen_t. In traditional BSD this is an int, but some
109 dnl OSes use a different type. Test until we find something that will
110 dnl work properly. Test borrowed from a patch submitted for Python.
111 AC_CHECK_TYPE([socklen_t], ,[
112 AC_MSG_CHECKING([for socklen_t equivalent])
113 AC_CACHE_VAL([curl_cv_socklen_t_equiv],
115 dnl Systems have either "struct sockaddr*" or "void*" as second
116 dnl arg to getpeername.
117 curl_cv_socklen_t_equiv=
118 for arg2 in "struct sockaddr" void ; do
119 for t in int size_t unsigned long "unsigned long" ; do
120 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
121 #include <sys/socket.h>
122 int getpeername (int $arg2 *, $t *);]], [[$t len;
123 getpeername(0, 0, &len);]])],[curl_cv_socklen_t_equiv="$t"
128 AC_MSG_RESULT($curl_cv_socklen_t_equiv)
129 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
130 [type to use in place of socklen_t if not defined])],
131 [#include <sys/types.h>
132 #include<sys/socket.h>])
134 dnl Can only check with -Werror, but the rest of configure doesn't like -Werror
136 CFLAGS="$CFLAGS -W -Wall -Werror"
138 dnl Now figure out how to printf() a time_t
139 AC_MSG_CHECKING(for time_t format)
140 AC_CACHE_VAL(ac_cv_fmt_time_t, [
142 AC_COMPILE_IFELSE([#include <sys/types.h>
147 }], ac_cv_fmt_time_t="\"%li\"")
148 if test $ac_cv_fmt_time_t = no; then
149 AC_COMPILE_IFELSE([#include <sys/types.h>
154 }], ac_cv_fmt_time_t="\"%i\"")
156 if test $ac_cv_fmt_time_t = no; then
157 AC_MSG_ERROR([Cannot detect format string for time_t
158 Please check sys/types.h for the typedef of time_t and submit to a developer])
161 AC_DEFINE_UNQUOTED(FMT_TIME_T, $ac_cv_fmt_time_t, [Define to printf format for a time_t variable])
162 AC_MSG_RESULT($ac_cv_fmt_time_t)
164 dnl How to copy one va_list to another?
165 AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy, [AC_LINK_IFELSE(
166 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])],
167 [ac_cv_c_va_copy="yes"],
168 [ac_cv_c_va_copy="no"]
170 if test "$ac_cv_c_va_copy" = "yes" ; then
171 AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
174 AC_CACHE_CHECK([for __va_copy], ac_cv_c___va_copy, [AC_LINK_IFELSE(
175 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);])],
176 [ac_cv_c___va_copy="yes"],
177 [ac_cv_c___va_copy="no"]
179 if test "$ac_cv_c___va_copy" = "yes" ; then
180 AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
183 dnl Now fix things back up
186 dnl Optional features.
187 AC_MSG_CHECKING(which malloc to use)
189 [ --with-malloc=type Enables use of a special malloc library; one of:
190 system (the default), boehm-gc, dmalloc, mpatrol, srvx, slab],
193 if test "x$withval" = "xsystem" ; then
194 AC_MSG_RESULT(system)
195 AC_DEFINE(WITH_MALLOC_SYSTEM, 1, [Define if using the system's malloc])
196 elif test "x$withval" = "xdmalloc" ; then
197 AC_MSG_RESULT(dmalloc)
198 AC_CHECK_HEADERS(dmalloc.h,,AC_MSG_ERROR([dmalloc header file missing. dmalloc build will fail.]))
199 AC_CHECK_LIB(dmalloc,malloc,,AC_MSG_ERROR([dmalloc library is missing. dmalloc build will fail.]))
200 AC_DEFINE(WITH_MALLOC_DMALLOC, 1, [Define if using the dmalloc debugging malloc package])
201 elif test "x$withval" = "xmpatrol" ; then
202 AC_MSG_RESULT(mpatrol)
203 AC_CHECK_HEADERS(mpatrol.h,,AC_MSG_ERROR([mpatrol header file missing. mpatrol build will fail.]))
204 dnl Using mpatrol requires linking against libelf, at least on Linux.
205 AC_CHECK_LIB(elf, elf_begin)
206 AC_CHECK_LIB(mpatrol,__mp_atexit,,AC_MSG_ERROR([mpatrol library is missing completely. mpatrol build will fail.]))
207 AC_DEFINE(WITH_MALLOC_MPATROL, 1, [Define if using the mpatrol malloc debugging package])
208 elif test "x$withval" = "xboehm-gc" ; then
209 AC_MSG_RESULT(boehm-gc)
210 AC_CHECK_HEADERS(gc/gc.h,,AC_MSG_ERROR([Boehm GC header file missing. boehm-gc build will fail.]))
211 AC_CHECK_LIB(dl, dlopen, , AC_MSG_ERROR([libdl library is missing. boehm-gc build will fail.]))
212 AC_CHECK_LIB(gc, GC_gcollect, , AC_MSG_ERROR([Boehm GC library is missing. boehm-gc build will fail.]))
213 AC_DEFINE(WITH_MALLOC_BOEHM_GC, 1, [Define if using the Boehm GC to garbage collect and check memory leaks])
214 elif test "x$withval" = "xsrvx" ; then
216 AC_DEFINE(WITH_MALLOC_SRVX, 1, [Define if using the srvx internal debug allocator])
217 MODULE_OBJS="$MODULE_OBJS alloc-srvx.\$(OBJEXT)"
218 elif test "x$withval" = "xslab" ; then
220 AC_DEFINE(WITH_MALLOC_SLAB, 1, [Define if using the slab internal debug allocator])
221 MODULE_OBJS="$MODULE_OBJS alloc-slab.\$(OBJEXT)"
223 AC_MSG_ERROR([Unknown malloc type $withval])
226 AC_MSG_CHECKING(which protocol to use)
227 AC_ARG_WITH(protocol,
228 [ --with-protocol=name Choose IRC dialect to support; one of:
229 p10 (the default), bahamut],
232 if test "x$withval" = "xp10" ; then
234 AC_DEFINE(WITH_PROTOCOL_P10, 1, [Define if using the P10 dialect of IRC])
235 MODULE_OBJS="$MODULE_OBJS proto-p10.\$(OBJEXT)"
236 PROTO_FILES=proto-p10.c
237 elif test "x$withval" = "xbahamut" ; then
238 AC_MSG_RESULT(Bahamut)
239 AC_DEFINE(WITH_PROTOCOL_BAHAMUT, 1, [Define if using the Bahamut dialect of IRC])
240 MODULE_OBJS="$MODULE_OBJS proto-bahamut.\$(OBJEXT)"
242 AC_MSG_ERROR([Unknown IRC dialect $withval])
246 [ --without-getopt Disables building of the GNU getopt library],
247 [if test "$withval" = no; then
248 AC_DEFINE(IGNORE_GETOPT, 1, [Define to disable built-in getopt library])
251 AC_MSG_CHECKING(whether to enable tokenization)
252 AC_ARG_ENABLE(tokens,
253 [ --disable-tokens Disables tokenization of P10 protocol output
254 (tokens required if linking to ircu 2.10.11)],
256 if test "z$enableval" = zno ; then
259 AC_DEFINE(ENABLE_TOKENS, 1, [Define if tokenized P10 desired])
263 AC_MSG_CHECKING(whether to enable debug behaviors)
265 [ --enable-debug Enables debugging behaviors],
271 CPPFLAGS="$CPPFLAGS -DNDEBUG"
275 if test -e src ; then
276 if test ! -d src ; then
277 AC_MSG_ERROR([src exists but is not a directory; please move it out of the way.])
282 AC_MSG_CHECKING(for extra module files)
283 MODULE_DEFINES="src/modules-list.h"
284 echo > $MODULE_DEFINES
285 touch $MODULE_DEFINES
286 AC_ARG_ENABLE(modules,
287 [ --enable-modules=list,of,modules Enable extra modules],
293 dnl Must use a separate file because autoconf can't stand newlines in an AC_SUBSTed variable.
294 for module in $enableval ; do
295 module=`echo $module | sed -e s/^mod-// -e s/\.c\$//`
296 EXTRA_MODULE_OBJS="$EXTRA_MODULE_OBJS mod-$module.\$(OBJEXT)"
297 module_list="$module_list $module"
298 echo "WITH_MODULE($module)" >> $MODULE_DEFINES
301 MODULE_OBJS="$MODULE_OBJS $EXTRA_MODULE_OBJS"
302 AC_MSG_RESULT($module_list)
311 if test "${BROKEN_REGEX}" = yes -o "${ac_cv_func_regcomp}" = no; then
312 MY_SUBDIRS="rx $MY_SUBDIRS"
313 RX_INCLUDES="-I../rx"
314 RX_LIBS="../rx/librx.a"
316 MY_SUBDIRS="$MY_SUBDIRS src"
317 CFLAGS="$CFLAGS $ANSI_SRC -W -Wall"
318 if test "z$USE_MAINTAINER_MODE" = zyes ; then
319 CFLAGS="$CFLAGS -Werror"
322 AC_DEFINE_UNQUOTED(CODENAME, "${CODENAME}", [Code name for this release])
323 AC_SUBST(MODULE_OBJS)
325 AC_SUBST(RX_INCLUDES)
327 AC_CONFIG_FILES(Makefile rx/Makefile src/Makefile)