]> jfr.im git - irc/evilnet/x3.git/blame - configure.in
woopsie
[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$])
5AC_PREREQ(2.57)
6AC_INIT(srvx, 1.3, srvx-bugs@lists.sourceforge.net)
7CODENAME=surge
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
23AC_PROG_RANLIB
24AC_PROG_INSTALL
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
70AC_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,,)
71
72dnl Cygwin does not have d_type in struct dirent. We use stat() as a fallback.
73AC_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>])
75
76dnl portability stuff, hurray! -Jedi
77AC_CHECK_FUNCS(gettimeofday)
78if test $ac_cv_func_gettimeofday = no; then
79 AC_CHECK_FUNCS(ftime,,AC_MSG_ERROR([ftime or gettimeofday required. srvx build will fail.]))
80fi
81
82dnl We have fallbacks in case these are missing, so just check for them.
83AC_CHECK_FUNCS(bcopy memcpy memset strdup strerror strsignal localtime_r setrlimit inet_ntoa getopt getopt_long regcomp regexec regfree sysconf,,)
84
85dnl Check for absolutely required library functions.
86AC_CHECK_FUNCS(select socket strcspn strspn strtod strtoul,,AC_MSG_ERROR([a required function was not found. srvx build will fail.]))
87
88dnl Check for functions (and how to get them).
89AC_FUNC_ALLOCA
90AC_FUNC_MMAP
91
92AC_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;])],
95ac_cv_sin_len="yes", ac_cv_sin_len="no")])
96if test $ac_cv_sin_len = yes ; then
97 AC_DEFINE(HAVE_SIN_LEN, 1, [Define if struct sockaddr_in contains a sin_len field])
98fi
99
100dnl Can only check with -Werror, but the rest of configure doesn't like -Werror
101OLD_CFLAGS=$CFLAGS
102CFLAGS="$CFLAGS -W -Wall -Werror"
103
104dnl Now figure out how to printf() a time_t
105AC_MSG_CHECKING(for time_t format)
106AC_CACHE_VAL(ac_cv_fmt_time_t, [
107ac_cv_fmt_time_t=no
108AC_COMPILE_IFELSE([#include <sys/types.h>
109#include <stdio.h>
110void myfunc(void) {
111 time_t test=0;
112 printf("%li", test);
113}], ac_cv_fmt_time_t="\"%li\"")
114if test $ac_cv_fmt_time_t = no; then
115AC_COMPILE_IFELSE([#include <sys/types.h>
116#include <stdio.h>
117void myfunc(void) {
118 time_t test=0;
119 printf("%i", test);
120}], ac_cv_fmt_time_t="\"%i\"")
121fi
122if test $ac_cv_fmt_time_t = no; then
123AC_MSG_ERROR([Cannot detect format string for time_t
124Please check sys/types.h for the typedef of time_t and submit to a developer])
125fi
126])
127AC_DEFINE_UNQUOTED(FMT_TIME_T, $ac_cv_fmt_time_t, [Define to printf format for a time_t variable])
128AC_MSG_RESULT($ac_cv_fmt_time_t)
129
130dnl How to copy one va_list to another?
131AC_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"]
135)])
136if test "$ac_cv_c_va_copy" = "yes" ; then
137 AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
138fi
139
140AC_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"]
144)])
145if test "$ac_cv_c___va_copy" = "yes" ; then
146 AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
147fi
148
149dnl Now fix things back up
150CFLAGS=$OLD_CFLAGS
151
152dnl Optional features.
153AC_MSG_CHECKING(which malloc to use)
154AC_ARG_WITH(malloc,
155[ --with-malloc=type Enables use of a special malloc library; one of:
ec1a68c8 156 system (the default), boehm-gc, dmalloc, mpatrol, srvx],
d76ed9a9 157[],
158[withval="system"])
159if test "x$withval" = "xsystem" ; then
160 AC_MSG_RESULT(system)
161 AC_DEFINE(WITH_MALLOC_SYSTEM, 1, [Define if using the system's malloc])
162elif 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])
167elif 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])
174elif 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])
ec1a68c8 180elif test "x$withval" = "xsrvx" ; then
181 AC_MSG_RESULT(srvx)
182 AC_DEFINE(WITH_MALLOC_SRVX, 1, [Define if using the srvx internal debug allocator])
183 MODULE_OBJS="$MODULE_OBJS alloc-srvx.\$(OBJEXT)"
d76ed9a9 184else
185 AC_MSG_ERROR([Unknown malloc type $withval])
186fi
187
188AC_MSG_CHECKING(which protocol to use)
189AC_ARG_WITH(protocol,
190[ --with-protocol=name Choose IRC dialect to support; one of:
191 p10 (the default), bahamut],
192[],
193[withval="p10"])
194if test "x$withval" = "xp10" ; then
195 AC_MSG_RESULT(P10)
196 AC_DEFINE(WITH_PROTOCOL_P10, 1, [Define if using the P10 dialect of IRC])
b2cf3d66 197 MODULE_OBJS="$MODULE_OBJS proto-p10.o"
d76ed9a9 198 PROTO_FILES=proto-p10.c
199elif test "x$withval" = "xbahamut" ; then
200 AC_MSG_RESULT(Bahamut)
201 AC_DEFINE(WITH_PROTOCOL_BAHAMUT, 1, [Define if using the Bahamut dialect of IRC])
b2cf3d66 202 MODULE_OBJS="$MODULE_OBJS proto-bahamut.o"
d76ed9a9 203else
204 AC_MSG_ERROR([Unknown IRC dialect $withval])
205fi
206
207AC_ARG_WITH(getopt,
208[ --without-getopt Disables building of the GNU getopt library],
209[if test "$withval" = no; then
210 AC_DEFINE(IGNORE_GETOPT, 1, [Define to disable built-in getopt library])
211fi])
212
213AC_MSG_CHECKING(whether to enable tokenization)
214AC_ARG_ENABLE(tokens,
215[ --disable-tokens Disables tokenization of P10 protocol output
216 (tokens required if linking to ircu 2.10.11)],
217[],[enableval=yes])
218if test "z$enableval" = zno ; then
219 AC_MSG_RESULT(no)
220else
221 AC_DEFINE(ENABLE_TOKENS, 1, [Define if tokenized P10 desired])
222 AC_MSG_RESULT(yes)
223fi
224
225AC_MSG_CHECKING(whether to enable debug behaviors)
226AC_ARG_ENABLE(debug,
227[ --enable-debug Enables debugging behaviors],
228[
229 CPPFLAGS="$CPPFLAGS"
230 AC_MSG_RESULT(yes)
231],
232[
233 CPPFLAGS="$CPPFLAGS -DNDEBUG"
234 AC_MSG_RESULT(no)
235])
236
237if test -e src ; then
238 if test ! -d src ; then
239 AC_MSG_ERROR([src exists but is not a directory; please move it out of the way.])
240 fi
241else
242 mkdir src
243fi
244AC_MSG_CHECKING(for extra module files)
245MODULE_DEFINES="src/modules-list.h"
246echo > $MODULE_DEFINES
247touch $MODULE_DEFINES
248AC_ARG_ENABLE(modules,
249[ --enable-modules=list,of,modules Enable extra modules],
250[
251 OIFS="$IFS"
252 IFS=','
253 EXTRA_MODULE_OBJS=""
254 module_list=""
255 dnl Must use a separate file because autoconf can't stand newlines in an AC_SUBSTed variable.
256 for module in $enableval ; do
257 module=`echo $module | sed -e s/^mod-// -e s/\.c\$//`
b2cf3d66 258 EXTRA_MODULE_OBJS="$EXTRA_MODULE_OBJS mod-$module.o"
d76ed9a9 259 module_list="$module_list $module"
260 echo "WITH_MODULE($module)" >> $MODULE_DEFINES
261 done
262 IFS="$OIFS"
263 MODULE_OBJS="$MODULE_OBJS $EXTRA_MODULE_OBJS"
264 AC_MSG_RESULT($module_list)
265],
266[
267 AC_MSG_RESULT(none)
268])
269
270MY_SUBDIRS=""
271RX_INCLUDES=""
272RX_LIBS=""
273if test "${BROKEN_REGEX}" = yes -o "${ac_cv_func_regcomp}" = no; then
274 MY_SUBDIRS="rx $MY_SUBDIRS"
275 RX_INCLUDES="-I../rx"
276 RX_LIBS="../rx/librx.a"
277fi
278MY_SUBDIRS="$MY_SUBDIRS src"
279CFLAGS="$CFLAGS $ANSI_SRC -W -Wall"
280if test "z$USE_MAINTAINER_MODE" = zyes ; then
281 CFLAGS="$CFLAGS -Werror"
282fi
283
284AC_DEFINE_UNQUOTED(CODENAME, "${CODENAME}", [Code name for this release])
285AC_SUBST(MODULE_OBJS)
286AC_SUBST(MY_SUBDIRS)
287AC_SUBST(RX_INCLUDES)
288AC_SUBST(RX_LIBS)
289AC_CONFIG_FILES(Makefile rx/Makefile src/Makefile)
290AC_OUTPUT