]> jfr.im git - irc/evilnet/x3.git/blame - configure.in
selectable ban types
[irc/evilnet/x3.git] / configure.in
CommitLineData
d76ed9a9 1dnl Process this file with autoconf to create a configure script.
2
3dnl General initialization.
4AC_REVISION([$Id$])
697f4c9a 5AC_PREREQ(2.59)
6AC_INIT([X3],[1.4],[x2serv-general@lists.sourceforge.net])
ceafd592 7CODENAME=X3
d76ed9a9 8AC_CONFIG_HEADERS(src/config.h)
9AC_CONFIG_SRCDIR(src/opserv.c)
10dnl AM_CANONICAL_TARGET must be before AM_INIT_AUTOMAKE() or autoconf whines
11AC_CANONICAL_TARGET
12AM_INIT_AUTOMAKE([gnu 1.6])
13AM_MAINTAINER_MODE
14
15dnl Compiler/runtime feature checks.
16AC_TYPE_SIGNAL
17AC_C_CONST
18AC_C_INLINE
19
20dnl Checks for programs.
21AC_PROG_AWK
22AC_PROG_CC
d76ed9a9 23AC_PROG_INSTALL
2f61d1d7 24AC_PROG_LIBTOOL
d76ed9a9 25AC_PROG_LN_S
26AC_PROG_MAKE_SET
27AC_PROG_GCC_TRADITIONAL
28
29dnl nice that unixes can all follow a standard.
30case $target in
31 *-freebsd2* | *-freebsdelf2* | *-freebsd*out3*)
32 ANSI_SRC=""
33 ;;
34 *-freebsd3* | *-freebsdelf3* | *-freebsd*out3*)
35 ANSI_SRC=""
36 AC_DEFINE(BROKEN_REGEX, 1, [Define if the system regex library is unreliable.])
37 BROKEN_REGEX=yes
38 ;;
39 *-solaris*)
40 EXTRA_DEFINE="-D__SOLARIS__"
41 ANSI_SRC="-fno-builtin"
42 ;;
43 *-cygwin)
44 ANSI_SRC="-fno-builtin"
45 ;;
46 *-linux*)
47 dnl -D_GNU_SOURCE needed for strsignal()
48 EXTRA_DEFINE="-D_GNU_SOURCE"
49 ANSI_SRC=""
50 ;;
51 *)
52 ANSI_SRC=""
53 ;;
54esac
55CFLAGS="$CFLAGS $EXTRA_DEFINE"
56
57dnl Checks for libraries.
58AC_CHECK_LIB(socket, socket)
59AC_CHECK_LIB(nsl, gethostbyname)
d8cf9c21 60AC_CHECK_LIB(m, main)
d76ed9a9 61
62dnl Checks for header files.
63AC_HEADER_STDC
64
65dnl will be used for portability stuff
66AC_HEADER_TIME
67AC_STRUCT_TM
68
69dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi
23475fc6 70AC_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,,)
d76ed9a9 71
d76ed9a9 72dnl portability stuff, hurray! -Jedi
2f61d1d7 73AC_CHECK_MEMBER([struct sockaddr.sa_len],
74 [AC_DEFINE([HAVE_SOCKADDR_SA_LEN],,[Define if struct sockaddr has sa_len field])],
75 [],[#include <sys/types.h>
76#include <sys/socket.h>])
77AC_CHECK_MEMBER([struct addrinfo.ai_flags],
78 [AC_DEFINE([HAVE_STRUCT_ADDRINFO],,[Define if struct addrinfo declared])],
79 [],[#include <sys/types.h>
80#include <sys/socket.h>
81#include <netdb.h>])
d76ed9a9 82AC_CHECK_FUNCS(gettimeofday)
83if test $ac_cv_func_gettimeofday = no; then
2f61d1d7 84 AC_CHECK_FUNCS(ftime,,AC_MSG_ERROR([ftime or gettimeofday required. X3 build will fail.]))
d76ed9a9 85fi
86
87dnl We have fallbacks in case these are missing, so just check for them.
2f61d1d7 88AC_CHECK_FUNCS(freeaddrinfo getaddrinfo getnameinfo getpagesize memcpy memset strdup strerror strsignal localtime_r setrlimit getopt getopt_long regcomp regexec regfree sysconf,,)
89
d76ed9a9 90dnl Check for absolutely required library functions.
2f61d1d7 91AC_CHECK_FUNCS(select socket strcspn strspn strtod strtoul,,AC_MSG_ERROR([a required function was not found. X3 build will fail.]))
d76ed9a9 92
93dnl Check for functions (and how to get them).
94AC_FUNC_ALLOCA
95AC_FUNC_MMAP
96
97AC_CACHE_CHECK([for sin_len], ac_cv_sin_len,
98[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
99#include <netinet/in.h>],[struct sockaddr_in *sin; sin->sin_len = 0;])],
100ac_cv_sin_len="yes", ac_cv_sin_len="no")])
101if test $ac_cv_sin_len = yes ; then
102 AC_DEFINE(HAVE_SIN_LEN, 1, [Define if struct sockaddr_in contains a sin_len field])
103fi
104
697f4c9a 105dnl Check for socklen_t. In traditional BSD this is an int, but some
106dnl OSes use a different type. Test until we find something that will
107dnl work properly. Test borrowed from a patch submitted for Python.
108AC_CHECK_TYPE([socklen_t], ,[
109 AC_MSG_CHECKING([for socklen_t equivalent])
110 AC_CACHE_VAL([curl_cv_socklen_t_equiv],
111 [
112dnl Systems have either "struct sockaddr*" or "void*" as second
113dnl arg to getpeername.
114 curl_cv_socklen_t_equiv=
115 for arg2 in "struct sockaddr" void ; do
116 for t in int size_t unsigned long "unsigned long" ; do
117 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
118#include <sys/socket.h>
119int getpeername (int $arg2 *, $t *);]], [[$t len;
120 getpeername(0, 0, &len);]])],[curl_cv_socklen_t_equiv="$t"
121 break],[])
122 done
123 done
124 ])
125 AC_MSG_RESULT($curl_cv_socklen_t_equiv)
126 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
127 [type to use in place of socklen_t if not defined])],
128 [#include <sys/types.h>
129#include<sys/socket.h>])
130
d76ed9a9 131dnl Can only check with -Werror, but the rest of configure doesn't like -Werror
132OLD_CFLAGS=$CFLAGS
133CFLAGS="$CFLAGS -W -Wall -Werror"
134
135dnl Now figure out how to printf() a time_t
136AC_MSG_CHECKING(for time_t format)
137AC_CACHE_VAL(ac_cv_fmt_time_t, [
138ac_cv_fmt_time_t=no
139AC_COMPILE_IFELSE([#include <sys/types.h>
140#include <stdio.h>
141void myfunc(void) {
142 time_t test=0;
143 printf("%li", test);
144}], ac_cv_fmt_time_t="\"%li\"")
145if test $ac_cv_fmt_time_t = no; then
146AC_COMPILE_IFELSE([#include <sys/types.h>
147#include <stdio.h>
148void myfunc(void) {
149 time_t test=0;
150 printf("%i", test);
151}], ac_cv_fmt_time_t="\"%i\"")
152fi
153if test $ac_cv_fmt_time_t = no; then
154AC_MSG_ERROR([Cannot detect format string for time_t
155Please check sys/types.h for the typedef of time_t and submit to a developer])
156fi
157])
158AC_DEFINE_UNQUOTED(FMT_TIME_T, $ac_cv_fmt_time_t, [Define to printf format for a time_t variable])
159AC_MSG_RESULT($ac_cv_fmt_time_t)
160
161dnl How to copy one va_list to another?
162AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy, [AC_LINK_IFELSE(
163 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])],
164 [ac_cv_c_va_copy="yes"],
165 [ac_cv_c_va_copy="no"]
166)])
167if test "$ac_cv_c_va_copy" = "yes" ; then
168 AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
169fi
170
171AC_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"]
175)])
176if test "$ac_cv_c___va_copy" = "yes" ; then
177 AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
178fi
179
180dnl Now fix things back up
181CFLAGS=$OLD_CFLAGS
182
183dnl Optional features.
184AC_MSG_CHECKING(which malloc to use)
185AC_ARG_WITH(malloc,
186[ --with-malloc=type Enables use of a special malloc library; one of:
b8cb2a14 187 system (the default), boehm-gc, dmalloc, mpatrol, x3, slab],
d76ed9a9 188[],
189[withval="system"])
190if test "x$withval" = "xsystem" ; then
191 AC_MSG_RESULT(system)
192 AC_DEFINE(WITH_MALLOC_SYSTEM, 1, [Define if using the system's malloc])
193elif test "x$withval" = "xdmalloc" ; then
194 AC_MSG_RESULT(dmalloc)
195 AC_CHECK_HEADERS(dmalloc.h,,AC_MSG_ERROR([dmalloc header file missing. dmalloc build will fail.]))
196 AC_CHECK_LIB(dmalloc,malloc,,AC_MSG_ERROR([dmalloc library is missing. dmalloc build will fail.]))
197 AC_DEFINE(WITH_MALLOC_DMALLOC, 1, [Define if using the dmalloc debugging malloc package])
198elif test "x$withval" = "xmpatrol" ; then
199 AC_MSG_RESULT(mpatrol)
200 AC_CHECK_HEADERS(mpatrol.h,,AC_MSG_ERROR([mpatrol header file missing. mpatrol build will fail.]))
201 dnl Using mpatrol requires linking against libelf, at least on Linux.
202 AC_CHECK_LIB(elf, elf_begin)
203 AC_CHECK_LIB(mpatrol,__mp_atexit,,AC_MSG_ERROR([mpatrol library is missing completely. mpatrol build will fail.]))
204 AC_DEFINE(WITH_MALLOC_MPATROL, 1, [Define if using the mpatrol malloc debugging package])
205elif test "x$withval" = "xboehm-gc" ; then
206 AC_MSG_RESULT(boehm-gc)
207 AC_CHECK_HEADERS(gc/gc.h,,AC_MSG_ERROR([Boehm GC header file missing. boehm-gc build will fail.]))
208 AC_CHECK_LIB(dl, dlopen, , AC_MSG_ERROR([libdl library is missing. boehm-gc build will fail.]))
209 AC_CHECK_LIB(gc, GC_gcollect, , AC_MSG_ERROR([Boehm GC library is missing. boehm-gc build will fail.]))
210 AC_DEFINE(WITH_MALLOC_BOEHM_GC, 1, [Define if using the Boehm GC to garbage collect and check memory leaks])
b8cb2a14 211elif test "x$withval" = "xx3" ; then
212 AC_MSG_RESULT(x3)
2f61d1d7 213 AC_DEFINE(WITH_MALLOC_X3, 1, [Define if using the X3 internal debug allocator])
b8cb2a14 214 MODULE_OBJS="$MODULE_OBJS alloc-x3.\$(OBJEXT)"
0d16e639 215elif test "x$withval" = "xslab" ; then
216 AC_MSG_RESULT(slab)
217 AC_DEFINE(WITH_MALLOC_SLAB, 1, [Define if using the slab internal debug allocator])
218 MODULE_OBJS="$MODULE_OBJS alloc-slab.\$(OBJEXT)"
d76ed9a9 219else
220 AC_MSG_ERROR([Unknown malloc type $withval])
221fi
222
223AC_MSG_CHECKING(which protocol to use)
224AC_ARG_WITH(protocol,
225[ --with-protocol=name Choose IRC dialect to support; one of:
226 p10 (the default), bahamut],
227[],
228[withval="p10"])
229if test "x$withval" = "xp10" ; then
230 AC_MSG_RESULT(P10)
231 AC_DEFINE(WITH_PROTOCOL_P10, 1, [Define if using the P10 dialect of IRC])
2f61d1d7 232 MODULE_OBJS="$MODULE_OBJS proto-p10.\$(OBJEXT)"
d76ed9a9 233 PROTO_FILES=proto-p10.c
234elif test "x$withval" = "xbahamut" ; then
235 AC_MSG_RESULT(Bahamut)
236 AC_DEFINE(WITH_PROTOCOL_BAHAMUT, 1, [Define if using the Bahamut dialect of IRC])
2f61d1d7 237 MODULE_OBJS="$MODULE_OBJS proto-bahamut.\$(OBJEXT)"
d76ed9a9 238else
239 AC_MSG_ERROR([Unknown IRC dialect $withval])
240fi
241
242AC_ARG_WITH(getopt,
243[ --without-getopt Disables building of the GNU getopt library],
244[if test "$withval" = no; then
245 AC_DEFINE(IGNORE_GETOPT, 1, [Define to disable built-in getopt library])
246fi])
247
248AC_MSG_CHECKING(whether to enable tokenization)
249AC_ARG_ENABLE(tokens,
250[ --disable-tokens Disables tokenization of P10 protocol output
251 (tokens required if linking to ircu 2.10.11)],
252[],[enableval=yes])
253if test "z$enableval" = zno ; then
254 AC_MSG_RESULT(no)
255else
256 AC_DEFINE(ENABLE_TOKENS, 1, [Define if tokenized P10 desired])
257 AC_MSG_RESULT(yes)
258fi
259
260AC_MSG_CHECKING(whether to enable debug behaviors)
261AC_ARG_ENABLE(debug,
262[ --enable-debug Enables debugging behaviors],
263[
264 CPPFLAGS="$CPPFLAGS"
265 AC_MSG_RESULT(yes)
266],
267[
268 CPPFLAGS="$CPPFLAGS -DNDEBUG"
269 AC_MSG_RESULT(no)
270])
271
272if test -e src ; then
273 if test ! -d src ; then
274 AC_MSG_ERROR([src exists but is not a directory; please move it out of the way.])
275 fi
276else
277 mkdir src
278fi
279AC_MSG_CHECKING(for extra module files)
280MODULE_DEFINES="src/modules-list.h"
281echo > $MODULE_DEFINES
282touch $MODULE_DEFINES
283AC_ARG_ENABLE(modules,
284[ --enable-modules=list,of,modules Enable extra modules],
285[
286 OIFS="$IFS"
287 IFS=','
288 EXTRA_MODULE_OBJS=""
289 module_list=""
290 dnl Must use a separate file because autoconf can't stand newlines in an AC_SUBSTed variable.
291 for module in $enableval ; do
292 module=`echo $module | sed -e s/^mod-// -e s/\.c\$//`
2f61d1d7 293 EXTRA_MODULE_OBJS="$EXTRA_MODULE_OBJS mod-$module.\$(OBJEXT)"
d76ed9a9 294 module_list="$module_list $module"
295 echo "WITH_MODULE($module)" >> $MODULE_DEFINES
ec311f39 296 if test "x$module" = "xtrack" ; then
297 TRACK="-D HAVE_TRACK"
298 fi
d76ed9a9 299 done
300 IFS="$OIFS"
301 MODULE_OBJS="$MODULE_OBJS $EXTRA_MODULE_OBJS"
302 AC_MSG_RESULT($module_list)
303],
304[
305 AC_MSG_RESULT(none)
306])
307
308MY_SUBDIRS=""
309RX_INCLUDES=""
310RX_LIBS=""
311if 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"
315fi
316MY_SUBDIRS="$MY_SUBDIRS src"
317CFLAGS="$CFLAGS $ANSI_SRC -W -Wall"
318if test "z$USE_MAINTAINER_MODE" = zyes ; then
319 CFLAGS="$CFLAGS -Werror"
320fi
321
322AC_DEFINE_UNQUOTED(CODENAME, "${CODENAME}", [Code name for this release])
323AC_SUBST(MODULE_OBJS)
324AC_SUBST(MY_SUBDIRS)
325AC_SUBST(RX_INCLUDES)
326AC_SUBST(RX_LIBS)
ec311f39 327AC_SUBST(TRACK)
d76ed9a9 328AC_CONFIG_FILES(Makefile rx/Makefile src/Makefile)
329AC_OUTPUT