]> jfr.im git - irc/evilnet/x3.git/blob - configure.in
sync all done, dont worry the language files for en_UK (now en_GB) are still there...
[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.4],[x2serv-general@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_RANLIB
24 AC_PROG_INSTALL
25 AC_PROG_LN_S
26 AC_PROG_MAKE_SET
27 AC_PROG_GCC_TRADITIONAL
28
29 dnl nice that unixes can all follow a standard.
30 case $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 ;;
54 esac
55 CFLAGS="$CFLAGS $EXTRA_DEFINE"
56
57 dnl Checks for libraries.
58 AC_CHECK_LIB(socket, socket)
59 AC_CHECK_LIB(nsl, gethostbyname)
60 AC_CHECK_LIB(m, main)
61
62 dnl Checks for header files.
63 AC_HEADER_STDC
64
65 dnl will be used for portability stuff
66 AC_HEADER_TIME
67 AC_STRUCT_TM
68
69 dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi
70 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 regex.h arpa/inet.h sys/mman.h sys/stat.h dirent.h,,)
71
72 dnl Cygwin does not have d_type in struct dirent. We use stat() as a fallback.
73 AC_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
76 dnl portability stuff, hurray! -Jedi
77 AC_CHECK_FUNCS(gettimeofday)
78 if test $ac_cv_func_gettimeofday = no; then
79 AC_CHECK_FUNCS(ftime,,AC_MSG_ERROR([ftime or gettimeofday required. X3 build will fail.]))
80 fi
81
82 dnl We have fallbacks in case these are missing, so just check for them.
83 AC_CHECK_FUNCS(bcopy getpagesize memcpy memset strdup strerror strsignal localtime_r setrlimit inet_ntoa getopt getopt_long regcomp regexec regfree sysconf,,)
84
85 dnl Check for absolutely required library functions.
86 AC_CHECK_FUNCS(select socket strcspn strspn strtod strtoul,,AC_MSG_ERROR([a required function was not found. X3 build will fail.]))
87
88 dnl Check for functions (and how to get them).
89 AC_FUNC_ALLOCA
90 AC_FUNC_MMAP
91
92 AC_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;])],
95 ac_cv_sin_len="yes", ac_cv_sin_len="no")])
96 if test $ac_cv_sin_len = yes ; then
97 AC_DEFINE(HAVE_SIN_LEN, 1, [Define if struct sockaddr_in contains a sin_len field])
98 fi
99
100 dnl Check for socklen_t. In traditional BSD this is an int, but some
101 dnl OSes use a different type. Test until we find something that will
102 dnl work properly. Test borrowed from a patch submitted for Python.
103 AC_CHECK_TYPE([socklen_t], ,[
104 AC_MSG_CHECKING([for socklen_t equivalent])
105 AC_CACHE_VAL([curl_cv_socklen_t_equiv],
106 [
107 dnl Systems have either "struct sockaddr*" or "void*" as second
108 dnl arg to getpeername.
109 curl_cv_socklen_t_equiv=
110 for arg2 in "struct sockaddr" void ; do
111 for t in int size_t unsigned long "unsigned long" ; do
112 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
113 #include <sys/socket.h>
114 int getpeername (int $arg2 *, $t *);]], [[$t len;
115 getpeername(0, 0, &len);]])],[curl_cv_socklen_t_equiv="$t"
116 break],[])
117 done
118 done
119 ])
120 AC_MSG_RESULT($curl_cv_socklen_t_equiv)
121 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
122 [type to use in place of socklen_t if not defined])],
123 [#include <sys/types.h>
124 #include<sys/socket.h>])
125
126 dnl Can only check with -Werror, but the rest of configure doesn't like -Werror
127 OLD_CFLAGS=$CFLAGS
128 CFLAGS="$CFLAGS -W -Wall -Werror"
129
130 dnl Now figure out how to printf() a time_t
131 AC_MSG_CHECKING(for time_t format)
132 AC_CACHE_VAL(ac_cv_fmt_time_t, [
133 ac_cv_fmt_time_t=no
134 AC_COMPILE_IFELSE([#include <sys/types.h>
135 #include <stdio.h>
136 void myfunc(void) {
137 time_t test=0;
138 printf("%li", test);
139 }], ac_cv_fmt_time_t="\"%li\"")
140 if test $ac_cv_fmt_time_t = no; then
141 AC_COMPILE_IFELSE([#include <sys/types.h>
142 #include <stdio.h>
143 void myfunc(void) {
144 time_t test=0;
145 printf("%i", test);
146 }], ac_cv_fmt_time_t="\"%i\"")
147 fi
148 if test $ac_cv_fmt_time_t = no; then
149 AC_MSG_ERROR([Cannot detect format string for time_t
150 Please check sys/types.h for the typedef of time_t and submit to a developer])
151 fi
152 ])
153 AC_DEFINE_UNQUOTED(FMT_TIME_T, $ac_cv_fmt_time_t, [Define to printf format for a time_t variable])
154 AC_MSG_RESULT($ac_cv_fmt_time_t)
155
156 dnl How to copy one va_list to another?
157 AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy, [AC_LINK_IFELSE(
158 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])],
159 [ac_cv_c_va_copy="yes"],
160 [ac_cv_c_va_copy="no"]
161 )])
162 if test "$ac_cv_c_va_copy" = "yes" ; then
163 AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
164 fi
165
166 AC_CACHE_CHECK([for __va_copy], ac_cv_c___va_copy, [AC_LINK_IFELSE(
167 [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);])],
168 [ac_cv_c___va_copy="yes"],
169 [ac_cv_c___va_copy="no"]
170 )])
171 if test "$ac_cv_c___va_copy" = "yes" ; then
172 AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
173 fi
174
175 dnl Now fix things back up
176 CFLAGS=$OLD_CFLAGS
177
178 dnl Optional features.
179 AC_MSG_CHECKING(which malloc to use)
180 AC_ARG_WITH(malloc,
181 [ --with-malloc=type Enables use of a special malloc library; one of:
182 system (the default), boehm-gc, dmalloc, mpatrol, x3, slab],
183 [],
184 [withval="system"])
185 if test "x$withval" = "xsystem" ; then
186 AC_MSG_RESULT(system)
187 AC_DEFINE(WITH_MALLOC_SYSTEM, 1, [Define if using the system's malloc])
188 elif test "x$withval" = "xdmalloc" ; then
189 AC_MSG_RESULT(dmalloc)
190 AC_CHECK_HEADERS(dmalloc.h,,AC_MSG_ERROR([dmalloc header file missing. dmalloc build will fail.]))
191 AC_CHECK_LIB(dmalloc,malloc,,AC_MSG_ERROR([dmalloc library is missing. dmalloc build will fail.]))
192 AC_DEFINE(WITH_MALLOC_DMALLOC, 1, [Define if using the dmalloc debugging malloc package])
193 elif test "x$withval" = "xmpatrol" ; then
194 AC_MSG_RESULT(mpatrol)
195 AC_CHECK_HEADERS(mpatrol.h,,AC_MSG_ERROR([mpatrol header file missing. mpatrol build will fail.]))
196 dnl Using mpatrol requires linking against libelf, at least on Linux.
197 AC_CHECK_LIB(elf, elf_begin)
198 AC_CHECK_LIB(mpatrol,__mp_atexit,,AC_MSG_ERROR([mpatrol library is missing completely. mpatrol build will fail.]))
199 AC_DEFINE(WITH_MALLOC_MPATROL, 1, [Define if using the mpatrol malloc debugging package])
200 elif test "x$withval" = "xboehm-gc" ; then
201 AC_MSG_RESULT(boehm-gc)
202 AC_CHECK_HEADERS(gc/gc.h,,AC_MSG_ERROR([Boehm GC header file missing. boehm-gc build will fail.]))
203 AC_CHECK_LIB(dl, dlopen, , AC_MSG_ERROR([libdl library is missing. boehm-gc build will fail.]))
204 AC_CHECK_LIB(gc, GC_gcollect, , AC_MSG_ERROR([Boehm GC library is missing. boehm-gc build will fail.]))
205 AC_DEFINE(WITH_MALLOC_BOEHM_GC, 1, [Define if using the Boehm GC to garbage collect and check memory leaks])
206 elif test "x$withval" = "xx3" ; then
207 AC_MSG_RESULT(x3)
208 AC_DEFINE(WITH_MALLOC_X3, 1, [Define if using the x3 internal debug allocator])
209 MODULE_OBJS="$MODULE_OBJS alloc-x3.\$(OBJEXT)"
210 elif test "x$withval" = "xslab" ; then
211 AC_MSG_RESULT(slab)
212 AC_DEFINE(WITH_MALLOC_SLAB, 1, [Define if using the slab internal debug allocator])
213 MODULE_OBJS="$MODULE_OBJS alloc-slab.\$(OBJEXT)"
214 else
215 AC_MSG_ERROR([Unknown malloc type $withval])
216 fi
217
218 AC_MSG_CHECKING(which protocol to use)
219 AC_ARG_WITH(protocol,
220 [ --with-protocol=name Choose IRC dialect to support; one of:
221 p10 (the default), bahamut],
222 [],
223 [withval="p10"])
224 if test "x$withval" = "xp10" ; then
225 AC_MSG_RESULT(P10)
226 AC_DEFINE(WITH_PROTOCOL_P10, 1, [Define if using the P10 dialect of IRC])
227 MODULE_OBJS="$MODULE_OBJS proto-p10.o"
228 PROTO_FILES=proto-p10.c
229 elif test "x$withval" = "xbahamut" ; then
230 AC_MSG_RESULT(Bahamut)
231 AC_DEFINE(WITH_PROTOCOL_BAHAMUT, 1, [Define if using the Bahamut dialect of IRC])
232 MODULE_OBJS="$MODULE_OBJS proto-bahamut.o"
233 else
234 AC_MSG_ERROR([Unknown IRC dialect $withval])
235 fi
236
237 AC_ARG_WITH(getopt,
238 [ --without-getopt Disables building of the GNU getopt library],
239 [if test "$withval" = no; then
240 AC_DEFINE(IGNORE_GETOPT, 1, [Define to disable built-in getopt library])
241 fi])
242
243 AC_MSG_CHECKING(whether to enable tokenization)
244 AC_ARG_ENABLE(tokens,
245 [ --disable-tokens Disables tokenization of P10 protocol output
246 (tokens required if linking to ircu 2.10.11)],
247 [],[enableval=yes])
248 if test "z$enableval" = zno ; then
249 AC_MSG_RESULT(no)
250 else
251 AC_DEFINE(ENABLE_TOKENS, 1, [Define if tokenized P10 desired])
252 AC_MSG_RESULT(yes)
253 fi
254
255 AC_MSG_CHECKING(whether to enable debug behaviors)
256 AC_ARG_ENABLE(debug,
257 [ --enable-debug Enables debugging behaviors],
258 [
259 CPPFLAGS="$CPPFLAGS"
260 AC_MSG_RESULT(yes)
261 ],
262 [
263 CPPFLAGS="$CPPFLAGS -DNDEBUG"
264 AC_MSG_RESULT(no)
265 ])
266
267 if test -e src ; then
268 if test ! -d src ; then
269 AC_MSG_ERROR([src exists but is not a directory; please move it out of the way.])
270 fi
271 else
272 mkdir src
273 fi
274 AC_MSG_CHECKING(for extra module files)
275 MODULE_DEFINES="src/modules-list.h"
276 echo > $MODULE_DEFINES
277 touch $MODULE_DEFINES
278 AC_ARG_ENABLE(modules,
279 [ --enable-modules=list,of,modules Enable extra modules],
280 [
281 OIFS="$IFS"
282 IFS=','
283 EXTRA_MODULE_OBJS=""
284 module_list=""
285 dnl Must use a separate file because autoconf can't stand newlines in an AC_SUBSTed variable.
286 for module in $enableval ; do
287 module=`echo $module | sed -e s/^mod-// -e s/\.c\$//`
288 EXTRA_MODULE_OBJS="$EXTRA_MODULE_OBJS mod-$module.o"
289 module_list="$module_list $module"
290 echo "WITH_MODULE($module)" >> $MODULE_DEFINES
291 done
292 IFS="$OIFS"
293 MODULE_OBJS="$MODULE_OBJS $EXTRA_MODULE_OBJS"
294 AC_MSG_RESULT($module_list)
295 ],
296 [
297 AC_MSG_RESULT(none)
298 ])
299
300 MY_SUBDIRS=""
301 RX_INCLUDES=""
302 RX_LIBS=""
303 if test "${BROKEN_REGEX}" = yes -o "${ac_cv_func_regcomp}" = no; then
304 MY_SUBDIRS="rx $MY_SUBDIRS"
305 RX_INCLUDES="-I../rx"
306 RX_LIBS="../rx/librx.a"
307 fi
308 MY_SUBDIRS="$MY_SUBDIRS src"
309 CFLAGS="$CFLAGS $ANSI_SRC -W -Wall"
310 if test "z$USE_MAINTAINER_MODE" = zyes ; then
311 CFLAGS="$CFLAGS -Werror"
312 fi
313
314 AC_DEFINE_UNQUOTED(CODENAME, "${CODENAME}", [Code name for this release])
315 AC_SUBST(MODULE_OBJS)
316 AC_SUBST(MY_SUBDIRS)
317 AC_SUBST(RX_INCLUDES)
318 AC_SUBST(RX_LIBS)
319 AC_CONFIG_FILES(Makefile rx/Makefile src/Makefile)
320 AC_OUTPUT