]> jfr.im git - irc/evilnet/x3.git/blob - configure.in
make chanserv.c use global_message_args
[irc/evilnet/x3.git] / configure.in
1 dnl Process this file with autoconf to create a configure script.
2
3 dnl General initialization.
4 AC_REVISION([$Id$])
5 AC_PREREQ(2.59)
6 AC_INIT([X3],[1.5],[evilnet-devel@lists.sourceforge.net])
7 CODENAME=X3
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
11 AC_CANONICAL_TARGET
12 AM_INIT_AUTOMAKE([gnu 1.6])
13 AM_MAINTAINER_MODE
14
15 dnl Compiler/runtime feature checks.
16 AC_TYPE_SIGNAL
17 AC_C_CONST
18 AC_C_INLINE
19
20 dnl Checks for programs.
21 AC_PROG_AWK
22 AC_PROG_CC
23 AC_PROG_INSTALL
24
25 dnl -- squish errors in autogen.sh -rubin
26 AC_PROG_RANLIB
27 dnl AC_PROG_LIBTOOL
28
29 AC_PROG_LN_S
30 AC_PROG_MAKE_SET
31 AC_PROG_GCC_TRADITIONAL
32 AC_CHECK_PROG(MAKER, gmake, gmake, make)
33
34 dnl nice that unixes can all follow a standard.
35 case $target in
36 *-freebsd2* | *-freebsdelf2* | *-freebsd*out3*)
37 ANSI_SRC=""
38 ;;
39 *-freebsd3* | *-freebsdelf3* | *-freebsd*out3*)
40 ANSI_SRC=""
41 ;;
42 *-solaris*)
43 EXTRA_DEFINE="-D__SOLARIS__"
44 ANSI_SRC="-fno-builtin"
45 ;;
46 *-cygwin)
47 ANSI_SRC="-fno-builtin"
48 ;;
49 *-linux*)
50 dnl -D_GNU_SOURCE needed for strsignal()
51 EXTRA_DEFINE="-D_GNU_SOURCE"
52 ANSI_SRC=""
53 ;;
54 *)
55 ANSI_SRC=""
56 ;;
57 esac
58 CFLAGS="$CFLAGS $EXTRA_DEFINE"
59
60 dnl Checks for libraries.
61 AC_CHECK_LIB(socket, socket)
62 AC_CHECK_LIB(nsl, gethostbyname)
63 AC_CHECK_LIB(m, main)
64
65 dnl Checks for header files.
66 AC_HEADER_STDC
67
68 dnl will be used for portability stuff
69 AC_HEADER_TIME
70 AC_STRUCT_TM
71
72 dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi
73 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 arpa/inet.h sys/mman.h sys/stat.h dirent.h,,)
74
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>
84 #include <netdb.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. X3 build will fail.]))
88 fi
89
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 sysconf,,)
92
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. X3 build will fail.]))
95
96 dnl Check for functions (and how to get them).
97 AC_FUNC_ALLOCA
98 AC_FUNC_MMAP
99
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])
106 fi
107
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],
114 [
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"
124 break],[])
125 done
126 done
127 ])
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>])
133
134 dnl Can only check with -Werror, but the rest of configure doesn't like -Werror
135 OLD_CFLAGS=$CFLAGS
136 CFLAGS="$CFLAGS -W -Wall -Werror"
137
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, [
141 ac_cv_fmt_time_t=no
142 AC_COMPILE_IFELSE([#include <sys/types.h>
143 #include <stdio.h>
144 void myfunc(void) {
145 time_t test=0;
146 printf("%li", test);
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>
150 #include <stdio.h>
151 void myfunc(void) {
152 time_t test=0;
153 printf("%i", test);
154 }], ac_cv_fmt_time_t="\"%i\"")
155 fi
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])
159 fi
160 ])
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)
163
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"]
169 )])
170 if test "$ac_cv_c_va_copy" = "yes" ; then
171 AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
172 fi
173
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"]
178 )])
179 if test "$ac_cv_c___va_copy" = "yes" ; then
180 AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
181 fi
182
183 dnl Now fix things back up
184 CFLAGS=$OLD_CFLAGS
185
186 dnl Optional features.
187 AC_MSG_CHECKING(which malloc to use)
188 AC_ARG_WITH(malloc,
189 [ --with-malloc=type Enables use of a special malloc library; one of:
190 system (the default), boehm-gc, dmalloc, mpatrol, x3, slab],
191 [],
192 [withval="system"])
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 x3_malloc="System"
197 elif test "x$withval" = "xdmalloc" ; then
198 AC_MSG_RESULT(dmalloc)
199 AC_CHECK_HEADERS(dmalloc.h,,AC_MSG_ERROR([dmalloc header file missing. dmalloc build will fail.]))
200 AC_CHECK_LIB(dmalloc,malloc,,AC_MSG_ERROR([dmalloc library is missing. dmalloc build will fail.]))
201 AC_DEFINE(WITH_MALLOC_DMALLOC, 1, [Define if using the dmalloc debugging malloc package])
202 x3_malloc="DMalloc"
203 elif test "x$withval" = "xmpatrol" ; then
204 AC_MSG_RESULT(mpatrol)
205 AC_CHECK_HEADERS(mpatrol.h,,AC_MSG_ERROR([mpatrol header file missing. mpatrol build will fail.]))
206 dnl Using mpatrol requires linking against libelf, at least on Linux.
207 AC_CHECK_LIB(elf, elf_begin)
208 AC_CHECK_LIB(mpatrol,__mp_atexit,,AC_MSG_ERROR([mpatrol library is missing completely. mpatrol build will fail.]))
209 AC_DEFINE(WITH_MALLOC_MPATROL, 1, [Define if using the mpatrol malloc debugging package])
210 x3_malloc="MPatrol"
211 elif test "x$withval" = "xboehm-gc" ; then
212 AC_MSG_RESULT(boehm-gc)
213 AC_CHECK_HEADERS(gc/gc.h,,AC_MSG_ERROR([Boehm GC header file missing. boehm-gc build will fail.]))
214 AC_CHECK_LIB(dl, dlopen, , AC_MSG_ERROR([libdl library is missing. boehm-gc build will fail.]))
215 AC_CHECK_LIB(gc, GC_gcollect, , AC_MSG_ERROR([Boehm GC library is missing. boehm-gc build will fail.]))
216 AC_DEFINE(WITH_MALLOC_BOEHM_GC, 1, [Define if using the Boehm GC to garbage collect and check memory leaks])
217 x3_malloc="Boehm"
218 elif test "x$withval" = "xx3" ; then
219 AC_MSG_RESULT(x3)
220 AC_DEFINE(WITH_MALLOC_X3, 1, [Define if using the X3 internal debug allocator])
221 MODULE_OBJS="$MODULE_OBJS alloc-x3.\$(OBJEXT)"
222 x3_malloc="X3"
223 elif test "x$withval" = "xslab" ; then
224 AC_MSG_RESULT(slab)
225 AC_DEFINE(WITH_MALLOC_SLAB, 1, [Define if using the slab internal debug allocator])
226 MODULE_OBJS="$MODULE_OBJS alloc-slab.\$(OBJEXT)"
227 x3_malloc="Slab"
228 else
229 AC_MSG_ERROR([Unknown malloc type $withval])
230 fi
231
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],
236 [],
237 [withval="p10"])
238 if test "x$withval" = "xp10" ; then
239 AC_MSG_RESULT(P10)
240 AC_DEFINE(WITH_PROTOCOL_P10, 1, [Define if using the P10 dialect of IRC])
241 MODULE_OBJS="$MODULE_OBJS proto-p10.\$(OBJEXT)"
242 PROTO_FILES=proto-p10.c
243 x3_ircd="P10"
244 elif test "x$withval" = "xbahamut" ; then
245 AC_MSG_RESULT(Bahamut)
246 AC_DEFINE(WITH_PROTOCOL_BAHAMUT, 1, [Define if using the Bahamut dialect of IRC])
247 MODULE_OBJS="$MODULE_OBJS proto-bahamut.\$(OBJEXT)"
248 x3_ircd="Bahamut"
249 else
250 AC_MSG_ERROR([Unknown IRC dialect $withval])
251 fi
252
253 AC_ARG_WITH(getopt,
254 [ --without-getopt Disables building of the GNU getopt library],
255 [if test "$withval" = no; then
256 AC_DEFINE(IGNORE_GETOPT, 1, [Define to disable built-in getopt library])
257 fi])
258
259 AC_MSG_CHECKING(whether to enable tokenization)
260 AC_ARG_ENABLE(tokens,
261 [ --disable-tokens Disables tokenization of P10 protocol output
262 (tokens required if linking to ircu 2.10.11)],
263 [],[enableval=yes])
264 if test "z$enableval" = zno ; then
265 AC_MSG_RESULT(no)
266 else
267 AC_DEFINE(ENABLE_TOKENS, 1, [Define if tokenized P10 desired])
268 AC_MSG_RESULT(yes)
269 fi
270
271 AC_MSG_CHECKING(whether to enable debug behaviors)
272 AC_ARG_ENABLE(debug,
273 [ --enable-debug Enables debugging behaviors],
274 [
275 CPPFLAGS="$CPPFLAGS"
276 AC_MSG_RESULT(yes)
277 x3_debug="Enabled"
278 ],
279 [
280 CPPFLAGS="$CPPFLAGS -DNDEBUG"
281 AC_MSG_RESULT(no)
282 x3_debug="Disabled"
283 ])
284
285 if test -e src ; then
286 if test ! -d src ; then
287 AC_MSG_ERROR([src exists but is not a directory; please move it out of the way.])
288 fi
289 else
290 mkdir src
291 fi
292 AC_MSG_CHECKING(for extra module files)
293 MODULE_DEFINES="src/modules-list.h"
294 echo > $MODULE_DEFINES
295 touch $MODULE_DEFINES
296 AC_ARG_ENABLE(modules,
297 [ --enable-modules=list,of,modules Enable extra modules],
298 [
299 OIFS="$IFS"
300 IFS=','
301 EXTRA_MODULE_OBJS=""
302 module_list=""
303 dnl Must use a separate file because autoconf can't stand newlines in an AC_SUBSTed variable.
304 for module in $enableval ; do
305 module=`echo $module | sed -e s/^mod-// -e s/\.c\$//`
306 EXTRA_MODULE_OBJS="$EXTRA_MODULE_OBJS mod-$module.\$(OBJEXT)"
307 module_list="$module_list $module"
308 echo "WITH_MODULE($module)" >> $MODULE_DEFINES
309 if test "x$module" = "xtrack" ; then
310 TRACK="-D HAVE_TRACK"
311 fi
312 done
313 IFS="$OIFS"
314 MODULE_OBJS="$MODULE_OBJS $EXTRA_MODULE_OBJS"
315 AC_MSG_RESULT($module_list)
316 ],
317 [
318 AC_MSG_RESULT(none)
319 ])
320
321 MY_SUBDIRS=""
322 RX_INCLUDES=""
323 RX_LIBS=""
324 if test "${BROKEN_REGEX}" = yes -o "${ac_cv_func_regcomp}" = no; then
325 MY_SUBDIRS="rx $MY_SUBDIRS"
326 RX_INCLUDES="-I../rx"
327 RX_LIBS="../rx/librx.a"
328 fi
329 MY_SUBDIRS="$MY_SUBDIRS src"
330 CFLAGS="$CFLAGS $ANSI_SRC -W -Wall"
331 if test "z$USE_MAINTAINER_MODE" = zyes ; then
332 CFLAGS="$CFLAGS -Werror"
333 fi
334
335 dnl I am not comfortable running make install from ./configure. This has to be done correctly or not at all. -Rubin
336 dnl REMEMBER TO CHANGE WITH A NEW TRE RELEASE!
337 dnl tre_version="0.7.4"
338 dnl AC_MSG_RESULT(extracting TRE regex library)
339 dnl cur_dir=`pwd`
340 dnl cd tools
341 dnl remove old tre directory to force a recompile...
342 dnl rm -rf tre-$tre_version
343 dnl if test "x$ac_cv_path_GUNZIP" = "x" ; then
344 dnl tar xfz tre.tar.gz
345 dnl else
346 dnl cp tre.tar.gz tre.tar.gz.bak
347 dnl gunzip -f tre.tar.gz
348 dnl cp tre.tar.gz.bak tre.tar.gz
349 dnl tar xf tre.tar
350 dnl fi
351 dnl AC_MSG_RESULT(configuring TRE regex library)
352 dnl cd tre-$tre_version
353 dnl tre_prefix=$prefix
354 dnl if test $tre_prefix = "NONE"; then
355 dnl tre_prefix="$HOME"
356 dnl fi
357 dnl ./configure --disable-agrep --disable-shared --disable-system-abi --disable-wchar --disable-multibyte --prefix=$tre_prefix || exit 1
358 dnl
359 dnl AC_MSG_RESULT(compiling TRE regex library)
360 dnl $ac_cv_prog_MAKER || exit 1
361 dnl AC_MSG_RESULT(installing TRE regex library)
362 dnl $ac_cv_prog_MAKER install || exit 1
363 dnl TREINCDIR="$tre_prefix/include"
364 dnl AC_SUBST(TREINCDIR)
365 dnl if test "x$ac_cv_path_PKGCONFIG" = "x" ; then
366 dnl TRELIBS="-L$tre_prefix/lib -ltre"
367 dnl else
368 dnl TRELIBS=`$ac_cv_path_PKGCONFIG --libs tre.pc`
369 dnl fi
370 dnl AC_SUBST(TRELIBS)
371 dnl
372 dnl cd $cur_dir
373
374 dnl libTRE (regex library) checking
375 withval=''
376 AC_ARG_WITH(tre, [ --with-tre=PATH Base path to where libtre is installed, such that PATH/lib/libtre.so and PATH/include/tre/regex.h exist.], )
377 if test "x$withval" != "x"; then
378 AC_MSG_RESULT(Using include dir $withval to find libtre)
379 CPPFLAGS="-I$withval/include -L$withval/lib"
380 LIBS="$LIBS -L$withval/lib"
381 else
382 AC_MSG_RESULT([Looking for tre in system and home dirs (${HOME})...])
383 CPPFLAGS="-I${HOME}/include -L${HOME}/lib"
384 LIBS="$LIBS -L${HOME}/lib"
385 fi
386 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 conveniance, just type 'tools/tre_install.sh' now, to install tre in your home directory.])],)
387 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 conveniance, just type 'tools/tre_install.sh' now, to install tre in your home directory.])])
388
389 AC_DEFINE_UNQUOTED(CODENAME, "${CODENAME}", [Code name for this release])
390 AC_SUBST(MODULE_OBJS)
391 AC_SUBST(MY_SUBDIRS)
392 AC_SUBST(RX_INCLUDES)
393 AC_SUBST(RX_LIBS)
394 AC_SUBST(TRACK)
395 AC_CONFIG_FILES(Makefile rx/Makefile src/Makefile)
396 AC_OUTPUT
397
398
399 dnl Print configuration summary
400
401 cat <<EOF
402
403 Configuration summary
404 =====================
405
406 X3 is now configured as follows:
407
408 * Compilation environment
409
410 CC = $CC
411 CFLAGS = $CFLAGS
412 CPP = $CPP
413 CPPFLAGS = $CPPFLAGS
414 LD = $LD
415 LDFLAGS = $LDFLAGS
416 LIBS = $LIBS
417
418 * X3 options
419
420 Debug: $x3_debug
421 Extra Modules: $module_list
422 Malloc: $x3_malloc
423 Protocol: $x3_ircd
424 Regexp Library TRE $tre_version
425
426 Install to: $prefix
427
428 Now you can proceed with compiling X3
429
430 EOF
431