]> jfr.im git - irc/evilnet/x3.git/blame - configure.in
Add calc command from Mystical (really from X2). NOTE: Not tested.
[irc/evilnet/x3.git] / configure.in
CommitLineData
d76ed9a9
AS
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)
60
61dnl Checks for header files.
62AC_HEADER_STDC
63
64dnl will be used for portability stuff
65AC_HEADER_TIME
66AC_STRUCT_TM
67
68dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi
69AC_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,,)
70
71dnl Cygwin does not have d_type in struct dirent. We use stat() as a fallback.
72AC_CHECK_MEMBER([struct dirent.d_type],
73 [AC_DEFINE(HAVE_DIRENT_D_TYPE, 1, [Define if struct dirent exists and includes the d_type element.])],,[#include <dirent.h>])
74
75dnl portability stuff, hurray! -Jedi
76AC_CHECK_FUNCS(gettimeofday)
77if test $ac_cv_func_gettimeofday = no; then
78 AC_CHECK_FUNCS(ftime,,AC_MSG_ERROR([ftime or gettimeofday required. srvx build will fail.]))
79fi
80
81dnl We have fallbacks in case these are missing, so just check for them.
82AC_CHECK_FUNCS(bcopy memcpy memset strdup strerror strsignal localtime_r setrlimit inet_ntoa getopt getopt_long regcomp regexec regfree sysconf,,)
83
84dnl Check for absolutely required library functions.
85AC_CHECK_FUNCS(select socket strcspn strspn strtod strtoul,,AC_MSG_ERROR([a required function was not found. srvx build will fail.]))
86
87dnl Check for functions (and how to get them).
88AC_FUNC_ALLOCA
89AC_FUNC_MMAP
90
91AC_CACHE_CHECK([for sin_len], ac_cv_sin_len,
92[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
93#include <netinet/in.h>],[struct sockaddr_in *sin; sin->sin_len = 0;])],
94ac_cv_sin_len="yes", ac_cv_sin_len="no")])
95if test $ac_cv_sin_len = yes ; then
96 AC_DEFINE(HAVE_SIN_LEN, 1, [Define if struct sockaddr_in contains a sin_len field])
97fi
98
99dnl Can only check with -Werror, but the rest of configure doesn't like -Werror
100OLD_CFLAGS=$CFLAGS
101CFLAGS="$CFLAGS -W -Wall -Werror"
102
103dnl Now figure out how to printf() a time_t
104AC_MSG_CHECKING(for time_t format)
105AC_CACHE_VAL(ac_cv_fmt_time_t, [
106ac_cv_fmt_time_t=no
107AC_COMPILE_IFELSE([#include <sys/types.h>
108#include <stdio.h>
109void myfunc(void) {
110 time_t test=0;
111 printf("%li", test);
112}], ac_cv_fmt_time_t="\"%li\"")
113if test $ac_cv_fmt_time_t = no; then
114AC_COMPILE_IFELSE([#include <sys/types.h>
115#include <stdio.h>
116void myfunc(void) {
117 time_t test=0;
118 printf("%i", test);
119}], ac_cv_fmt_time_t="\"%i\"")
120fi
121if test $ac_cv_fmt_time_t = no; then
122AC_MSG_ERROR([Cannot detect format string for time_t
123Please check sys/types.h for the typedef of time_t and submit to a developer])
124fi
125])
126AC_DEFINE_UNQUOTED(FMT_TIME_T, $ac_cv_fmt_time_t, [Define to printf format for a time_t variable])
127AC_MSG_RESULT($ac_cv_fmt_time_t)
128
129dnl How to copy one va_list to another?
130AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy, [AC_LINK_IFELSE(
131 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])],
132 [ac_cv_c_va_copy="yes"],
133 [ac_cv_c_va_copy="no"]
134)])
135if test "$ac_cv_c_va_copy" = "yes" ; then
136 AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
137fi
138
139AC_CACHE_CHECK([for __va_copy], ac_cv_c___va_copy, [AC_LINK_IFELSE(
140 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);])],
141 [ac_cv_c___va_copy="yes"],
142 [ac_cv_c___va_copy="no"]
143)])
144if test "$ac_cv_c___va_copy" = "yes" ; then
145 AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
146fi
147
148dnl Now fix things back up
149CFLAGS=$OLD_CFLAGS
150
151dnl Optional features.
152AC_MSG_CHECKING(which malloc to use)
153AC_ARG_WITH(malloc,
154[ --with-malloc=type Enables use of a special malloc library; one of:
155 system (the default), boehm-gc, dmalloc, mpatrol],
156[],
157[withval="system"])
158if test "x$withval" = "xsystem" ; then
159 AC_MSG_RESULT(system)
160 AC_DEFINE(WITH_MALLOC_SYSTEM, 1, [Define if using the system's malloc])
161elif test "x$withval" = "xdmalloc" ; then
162 AC_MSG_RESULT(dmalloc)
163 AC_CHECK_HEADERS(dmalloc.h,,AC_MSG_ERROR([dmalloc header file missing. dmalloc build will fail.]))
164 AC_CHECK_LIB(dmalloc,malloc,,AC_MSG_ERROR([dmalloc library is missing. dmalloc build will fail.]))
165 AC_DEFINE(WITH_MALLOC_DMALLOC, 1, [Define if using the dmalloc debugging malloc package])
166elif test "x$withval" = "xmpatrol" ; then
167 AC_MSG_RESULT(mpatrol)
168 AC_CHECK_HEADERS(mpatrol.h,,AC_MSG_ERROR([mpatrol header file missing. mpatrol build will fail.]))
169 dnl Using mpatrol requires linking against libelf, at least on Linux.
170 AC_CHECK_LIB(elf, elf_begin)
171 AC_CHECK_LIB(mpatrol,__mp_atexit,,AC_MSG_ERROR([mpatrol library is missing completely. mpatrol build will fail.]))
172 AC_DEFINE(WITH_MALLOC_MPATROL, 1, [Define if using the mpatrol malloc debugging package])
173elif test "x$withval" = "xboehm-gc" ; then
174 AC_MSG_RESULT(boehm-gc)
175 AC_CHECK_HEADERS(gc/gc.h,,AC_MSG_ERROR([Boehm GC header file missing. boehm-gc build will fail.]))
176 AC_CHECK_LIB(dl, dlopen, , AC_MSG_ERROR([libdl library is missing. boehm-gc build will fail.]))
177 AC_CHECK_LIB(gc, GC_gcollect, , AC_MSG_ERROR([Boehm GC library is missing. boehm-gc build will fail.]))
178 AC_DEFINE(WITH_MALLOC_BOEHM_GC, 1, [Define if using the Boehm GC to garbage collect and check memory leaks])
179else
180 AC_MSG_ERROR([Unknown malloc type $withval])
181fi
182
183AC_MSG_CHECKING(which protocol to use)
184AC_ARG_WITH(protocol,
185[ --with-protocol=name Choose IRC dialect to support; one of:
186 p10 (the default), bahamut],
187[],
188[withval="p10"])
189if test "x$withval" = "xp10" ; then
190 AC_MSG_RESULT(P10)
191 AC_DEFINE(WITH_PROTOCOL_P10, 1, [Define if using the P10 dialect of IRC])
192 MODULE_OBJS="$MODULE_OBJS proto-p10.\$(OBJEXT)"
193 PROTO_FILES=proto-p10.c
194elif test "x$withval" = "xbahamut" ; then
195 AC_MSG_RESULT(Bahamut)
196 AC_DEFINE(WITH_PROTOCOL_BAHAMUT, 1, [Define if using the Bahamut dialect of IRC])
197 MODULE_OBJS="$MODULE_OBJS proto-bahamut.\$(OBJEXT)"
198else
199 AC_MSG_ERROR([Unknown IRC dialect $withval])
200fi
201
202AC_ARG_WITH(getopt,
203[ --without-getopt Disables building of the GNU getopt library],
204[if test "$withval" = no; then
205 AC_DEFINE(IGNORE_GETOPT, 1, [Define to disable built-in getopt library])
206fi])
207
208AC_MSG_CHECKING(whether to enable tokenization)
209AC_ARG_ENABLE(tokens,
210[ --disable-tokens Disables tokenization of P10 protocol output
211 (tokens required if linking to ircu 2.10.11)],
212[],[enableval=yes])
213if test "z$enableval" = zno ; then
214 AC_MSG_RESULT(no)
215else
216 AC_DEFINE(ENABLE_TOKENS, 1, [Define if tokenized P10 desired])
217 AC_MSG_RESULT(yes)
218fi
219
220AC_MSG_CHECKING(whether to enable debug behaviors)
221AC_ARG_ENABLE(debug,
222[ --enable-debug Enables debugging behaviors],
223[
224 CPPFLAGS="$CPPFLAGS"
225 AC_MSG_RESULT(yes)
226],
227[
228 CPPFLAGS="$CPPFLAGS -DNDEBUG"
229 AC_MSG_RESULT(no)
230])
231
232if test -e src ; then
233 if test ! -d src ; then
234 AC_MSG_ERROR([src exists but is not a directory; please move it out of the way.])
235 fi
236else
237 mkdir src
238fi
239AC_MSG_CHECKING(for extra module files)
240MODULE_DEFINES="src/modules-list.h"
241echo > $MODULE_DEFINES
242touch $MODULE_DEFINES
243AC_ARG_ENABLE(modules,
244[ --enable-modules=list,of,modules Enable extra modules],
245[
246 OIFS="$IFS"
247 IFS=','
248 EXTRA_MODULE_OBJS=""
249 module_list=""
250 dnl Must use a separate file because autoconf can't stand newlines in an AC_SUBSTed variable.
251 for module in $enableval ; do
252 module=`echo $module | sed -e s/^mod-// -e s/\.c\$//`
253 EXTRA_MODULE_OBJS="$EXTRA_MODULE_OBJS mod-$module.\$(OBJEXT)"
254 module_list="$module_list $module"
255 echo "WITH_MODULE($module)" >> $MODULE_DEFINES
256 done
257 IFS="$OIFS"
258 MODULE_OBJS="$MODULE_OBJS $EXTRA_MODULE_OBJS"
259 AC_MSG_RESULT($module_list)
260],
261[
262 AC_MSG_RESULT(none)
263])
264
265MY_SUBDIRS=""
266RX_INCLUDES=""
267RX_LIBS=""
268if test "${BROKEN_REGEX}" = yes -o "${ac_cv_func_regcomp}" = no; then
269 MY_SUBDIRS="rx $MY_SUBDIRS"
270 RX_INCLUDES="-I../rx"
271 RX_LIBS="../rx/librx.a"
272fi
273MY_SUBDIRS="$MY_SUBDIRS src"
274CFLAGS="$CFLAGS $ANSI_SRC -W -Wall"
275if test "z$USE_MAINTAINER_MODE" = zyes ; then
276 CFLAGS="$CFLAGS -Werror"
277fi
278
279AC_DEFINE_UNQUOTED(CODENAME, "${CODENAME}", [Code name for this release])
280AC_SUBST(MODULE_OBJS)
281AC_SUBST(MY_SUBDIRS)
282AC_SUBST(RX_INCLUDES)
283AC_SUBST(RX_LIBS)
284AC_CONFIG_FILES(Makefile rx/Makefile src/Makefile)
285AC_OUTPUT