1 dnl Process this file with autoconf to create a configure script.
3 dnl General initialization.
5 AC_INIT([srvx],[1.3.1],[srvx-bugs@lists.sourceforge.net])
7 AC_CONFIG_HEADERS(src/config.h)
8 AC_CONFIG_SRCDIR(src/opserv.c)
9 dnl AM_CANONICAL_TARGET must be before AM_INIT_AUTOMAKE() or autoconf whines
11 AM_INIT_AUTOMAKE([gnu 1.6])
14 dnl Compiler/runtime feature checks.
17 dnl "const" *should* be in the -Werror section, but that breaks Linux. gg gcc.
19 dnl Checks for programs.
26 AC_PROG_GCC_TRADITIONAL
28 dnl Look for a git client
29 AC_CHECK_PROGS(GIT, [git])
30 AM_CONDITIONAL(HAS_GIT, test z$GIT != z)
32 dnl nice that unixes can all follow a standard.
34 *-freebsd2* | *-freebsdelf2* | *-freebsd*out3*)
37 *-freebsd3* | *-freebsdelf3* | *-freebsd*out3*)
39 AC_DEFINE(BROKEN_REGEX, 1, [Define if the system regex library is unreliable.])
43 EXTRA_DEFINE="-D__SOLARIS__"
44 ANSI_SRC="-fno-builtin"
47 ANSI_SRC="-fno-builtin"
50 dnl -D_GNU_SOURCE needed for strsignal()
51 EXTRA_DEFINE="-D_GNU_SOURCE"
58 CFLAGS="$CFLAGS $EXTRA_DEFINE"
60 dnl Checks for libraries.
61 AC_CHECK_LIB(socket, socket)
62 AC_CHECK_LIB(nsl, gethostbyname)
64 dnl Checks for header files.
67 dnl will be used for portability stuff
71 dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi
72 AC_CHECK_HEADERS(fcntl.h malloc.h netdb.h arpa/inet.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 sys/epoll.h,,)
74 dnl portability stuff, hurray! -Jedi
75 AC_CHECK_MEMBER([struct sockaddr.sa_len],
76 [AC_DEFINE([HAVE_SOCKADDR_SA_LEN],,[Define if struct sockaddr has sa_len field])],
77 [],[#include <sys/types.h>
78 #include <sys/socket.h>])
79 AC_CHECK_MEMBER([struct addrinfo.ai_flags],
80 [AC_DEFINE([HAVE_STRUCT_ADDRINFO],,[Define if struct addrinfo declared])],
81 [],[#include <sys/types.h>
82 #include <sys/socket.h>
85 dnl We have fallbacks in case these are missing, so just check for them.
86 AC_CHECK_FUNCS(freeaddrinfo getaddrinfo gai_strerror getnameinfo getpagesize memcpy memset strdup strerror strsignal localtime_r setrlimit getopt getopt_long regcomp regexec regfree sysconf inet_aton epoll_create select gettimeofday times GetProcessTimes,,)
88 dnl Check for the fallbacks for functions missing above.
89 if test $ac_cv_func_gettimeofday = no; then
90 AC_CHECK_FUNCS(ftime,,AC_MSG_ERROR([ftime or gettimeofday required. srvx build will fail.]))
93 dnl Check for absolutely required library functions.
94 AC_CHECK_FUNCS(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"
137 if test "z$USE_MAINTAINER_MODE" = zyes ; then
138 CFLAGS="$CFLAGS -ansi"
141 dnl Check for post-C89 keywords
144 dnl Now figure out how to printf() a time_t
145 AC_MSG_CHECKING(for time_t format)
146 AC_CACHE_VAL(ac_cv_fmt_time_t, [
148 AC_COMPILE_IFELSE([#include <sys/types.h>
153 }], ac_cv_fmt_time_t="\"%li\"")
154 if test $ac_cv_fmt_time_t = no; then
155 AC_COMPILE_IFELSE([#include <sys/types.h>
160 }], ac_cv_fmt_time_t="\"%i\"")
162 if test $ac_cv_fmt_time_t = no; then
163 AC_MSG_ERROR([Cannot detect format string for time_t
164 Please check sys/types.h for the typedef of time_t and submit to a developer])
167 AC_DEFINE_UNQUOTED(FMT_TIME_T, $ac_cv_fmt_time_t, [Define to printf format for a time_t variable])
168 AC_MSG_RESULT($ac_cv_fmt_time_t)
170 dnl How to copy one va_list to another?
171 AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy, [AC_LINK_IFELSE(
172 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])],
173 [ac_cv_c_va_copy="yes"],
174 [ac_cv_c_va_copy="no"]
176 if test "$ac_cv_c_va_copy" = "yes" ; then
177 AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
180 AC_CACHE_CHECK([for __va_copy], ac_cv_c___va_copy, [AC_LINK_IFELSE(
181 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);])],
182 [ac_cv_c___va_copy="yes"],
183 [ac_cv_c___va_copy="no"]
185 if test "$ac_cv_c___va_copy" = "yes" ; then
186 AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
189 dnl Now fix things back up
192 dnl Optional features.
193 AC_MSG_CHECKING(which malloc to use)
195 [ --with-malloc=type Enables use of a special malloc library; one of:
196 system (the default), boehm-gc, dmalloc, mpatrol, srvx, slab],
199 if test "x$withval" = "xsystem" ; then
200 AC_MSG_RESULT(system)
201 AC_DEFINE(WITH_MALLOC_SYSTEM, 1, [Define if using the system's malloc])
202 elif test "x$withval" = "xdmalloc" ; then
203 AC_MSG_RESULT(dmalloc)
204 AC_CHECK_HEADERS(dmalloc.h,,AC_MSG_ERROR([dmalloc header file missing. dmalloc build will fail.]))
205 AC_CHECK_LIB(dmalloc,malloc,,AC_MSG_ERROR([dmalloc library is missing. dmalloc build will fail.]))
206 AC_DEFINE(WITH_MALLOC_DMALLOC, 1, [Define if using the dmalloc debugging malloc package])
207 elif test "x$withval" = "xmpatrol" ; then
208 AC_MSG_RESULT(mpatrol)
209 AC_CHECK_HEADERS(mpatrol.h,,AC_MSG_ERROR([mpatrol header file missing. mpatrol build will fail.]))
210 dnl Using mpatrol requires linking against libelf, at least on Linux.
211 AC_CHECK_LIB(elf, elf_begin)
212 AC_CHECK_LIB(mpatrol,__mp_atexit,,AC_MSG_ERROR([mpatrol library is missing completely. mpatrol build will fail.]))
213 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])
220 elif test "x$withval" = "xsrvx" ; then
222 AC_DEFINE(WITH_MALLOC_SRVX, 1, [Define if using the srvx internal debug allocator])
223 MODULE_OBJS="$MODULE_OBJS alloc-srvx.\$(OBJEXT)"
224 elif test "x$withval" = "xslab" ; then
226 AC_DEFINE(WITH_MALLOC_SLAB, 1, [Define if using the slab internal debug allocator])
227 MODULE_OBJS="$MODULE_OBJS alloc-slab.\$(OBJEXT)"
229 AC_MSG_ERROR([Unknown malloc type $withval])
232 AC_MSG_CHECKING(which protocol to use)
233 AC_ARG_WITH(protocol,
234 [ --with-protocol=name Choose IRC dialect to support; one of:
235 p10 (the default), bahamut],
238 if test "x$withval" = "xp10" ; then
240 AC_DEFINE(WITH_PROTOCOL_P10, 1, [Define if using the P10 dialect of IRC])
241 MODULE_OBJS="$MODULE_OBJS proto-p10.\$(OBJEXT)"
242 elif test "x$withval" = "xbahamut" ; then
243 AC_MSG_RESULT([Bahamut])
244 AC_DEFINE(WITH_PROTOCOL_BAHAMUT, 1, [Define if using the Bahamut dialect of IRC])
245 MODULE_OBJS="$MODULE_OBJS proto-bahamut.\$(OBJEXT)"
246 elif test -r "${srcdir}/src/proto-${withval}.c" ; then
247 AC_MSG_RESULT([$withval])
248 MODULE_OBJS="$MODULE_OBJS proto-${withval}.\$(OBJEXT)"
250 AC_MSG_ERROR([Unknown IRC dialect $withval])
253 AC_MSG_CHECKING(how to send mail)
255 [ --with-mail=name How to send mail; one of:
256 sendmail (the default)],
258 [withval="sendmail"])
259 if test -r "${srcdir}/src/mail-${withval}.c" ; then
260 AC_MSG_RESULT([$withval])
261 MODULE_OBJS="$MODULE_OBJS mail-${withval}.\$(OBJEXT)"
263 AC_MSG_ERROR([Unknown mail method $withval])
266 AC_MSG_CHECKING([I/O multiplexing backends])
269 if test "x$ac_cv_func_select" = xyes ; then
270 AC_DEFINE(WITH_IOSET_SELECT, 1, [Define if using the select() I/O backend])
271 MODULE_OBJS="$MODULE_OBJS ioset-select.\$(OBJEXT)"
272 IOMUXES="$IOMUXES select"
276 [ --without-epoll Disables the epoll_*() I/O backend],
278 [withval="$ac_cv_func_epoll_create"])
279 if test "x$withval" = xyes ; then
280 AC_DEFINE(WITH_IOSET_EPOLL, 1, [Define if using the epoll I/O backend])
281 MODULE_OBJS="$MODULE_OBJS ioset-epoll.\$(OBJEXT)"
282 IOMUXES="$IOMUXES epoll"
285 IOMUXES=`echo $IOMUXES | sed 's/^ +//'`
286 if test "x$IOMUXES" = "x" ; then
287 AC_MSG_ERROR([No supported I/O multiplexing backend found])
289 AC_MSG_RESULT($IOMUXES)
293 [ --without-getopt Disables building of the GNU getopt library],
294 [if test "$withval" = no; then
295 AC_DEFINE(IGNORE_GETOPT, 1, [Define to disable built-in getopt library])
298 AC_MSG_CHECKING(whether to enable tokenization)
299 AC_ARG_ENABLE(tokens,
300 [ --disable-tokens Disables tokenization of P10 protocol output
301 (tokens required if linking to ircu 2.10.11)],
303 if test "z$enableval" = zno ; then
306 AC_DEFINE(ENABLE_TOKENS, 1, [Define if tokenized P10 desired])
310 AC_MSG_CHECKING(whether to enable debug behaviors)
312 [ --enable-debug Enables debugging behaviors],
318 CPPFLAGS="$CPPFLAGS -DNDEBUG"
322 if test -e src ; then
323 if test ! -d src ; then
324 AC_MSG_ERROR([src exists but is not a directory; please move it out of the way.])
329 AC_MSG_CHECKING(for extra module files)
330 MODULE_DEFINES="src/modules-list.h"
331 echo > $MODULE_DEFINES
332 touch $MODULE_DEFINES
333 AC_ARG_ENABLE(modules,
334 [ --enable-modules=list,of,modules Enable extra modules],
340 dnl Must use a separate file because autoconf can't stand newlines in an AC_SUBSTed variable.
341 for module in $enableval ; do
342 module=`echo $module | sed -e s/^mod-// -e s/\.c\$//`
343 EXTRA_MODULE_OBJS="$EXTRA_MODULE_OBJS mod-$module.\$(OBJEXT)"
344 module_list="$module_list $module"
345 echo "WITH_MODULE($module)" >> $MODULE_DEFINES
348 MODULE_OBJS="$MODULE_OBJS $EXTRA_MODULE_OBJS"
349 AC_MSG_RESULT($module_list)
358 if test "${BROKEN_REGEX}" = yes -o "${ac_cv_func_regcomp}" = no; then
359 MY_SUBDIRS="rx $MY_SUBDIRS"
360 RX_INCLUDES="-I../rx"
361 RX_LIBS="../rx/librx.a"
363 MY_SUBDIRS="$MY_SUBDIRS src"
364 CFLAGS="$CFLAGS $ANSI_SRC -W -Wall"
365 if test "z$USE_MAINTAINER_MODE" = zyes ; then
366 CFLAGS="$CFLAGS -Werror -ansi"
369 AC_DEFINE_UNQUOTED(CODENAME, "${CODENAME}", [Code name for this release])
370 AC_SUBST(MODULE_OBJS)
372 AC_SUBST(RX_INCLUDES)
374 AC_CONFIG_FILES(Makefile rx/Makefile src/Makefile)