]>
Commit | Line | Data |
---|---|---|
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 | AC_PROG_LIBTOOL | |
25 | AC_PROG_LN_S | |
26 | AC_PROG_MAKE_SET | |
27 | AC_PROG_GCC_TRADITIONAL | |
28 | AC_CHECK_PROG(MAKER, gmake, gmake, make) | |
29 | ||
30 | dnl nice that unixes can all follow a standard. | |
31 | case $target in | |
32 | *-freebsd2* | *-freebsdelf2* | *-freebsd*out3*) | |
33 | ANSI_SRC="" | |
34 | ;; | |
35 | *-freebsd3* | *-freebsdelf3* | *-freebsd*out3*) | |
36 | ANSI_SRC="" | |
37 | ;; | |
38 | *-solaris*) | |
39 | EXTRA_DEFINE="-D__SOLARIS__" | |
40 | ANSI_SRC="-fno-builtin" | |
41 | ;; | |
42 | *-cygwin) | |
43 | ANSI_SRC="-fno-builtin" | |
44 | ;; | |
45 | *-linux*) | |
46 | dnl -D_GNU_SOURCE needed for strsignal() | |
47 | EXTRA_DEFINE="-D_GNU_SOURCE" | |
48 | ANSI_SRC="" | |
49 | ;; | |
50 | *) | |
51 | ANSI_SRC="" | |
52 | ;; | |
53 | esac | |
54 | CFLAGS="$CFLAGS $EXTRA_DEFINE" | |
55 | ||
56 | dnl Checks for libraries. | |
57 | AC_CHECK_LIB(socket, socket) | |
58 | AC_CHECK_LIB(nsl, gethostbyname) | |
59 | AC_CHECK_LIB(m, main) | |
60 | ||
61 | dnl Checks for header files. | |
62 | AC_HEADER_STDC | |
63 | ||
64 | dnl will be used for portability stuff | |
65 | AC_HEADER_TIME | |
66 | AC_STRUCT_TM | |
67 | ||
68 | dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi | |
69 | 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,,) | |
70 | ||
71 | dnl portability stuff, hurray! -Jedi | |
72 | AC_CHECK_MEMBER([struct sockaddr.sa_len], | |
73 | [AC_DEFINE([HAVE_SOCKADDR_SA_LEN],,[Define if struct sockaddr has sa_len field])], | |
74 | [],[#include <sys/types.h> | |
75 | #include <sys/socket.h>]) | |
76 | AC_CHECK_MEMBER([struct addrinfo.ai_flags], | |
77 | [AC_DEFINE([HAVE_STRUCT_ADDRINFO],,[Define if struct addrinfo declared])], | |
78 | [],[#include <sys/types.h> | |
79 | #include <sys/socket.h> | |
80 | #include <netdb.h>]) | |
81 | AC_CHECK_FUNCS(gettimeofday) | |
82 | if test $ac_cv_func_gettimeofday = no; then | |
83 | AC_CHECK_FUNCS(ftime,,AC_MSG_ERROR([ftime or gettimeofday required. X3 build will fail.])) | |
84 | fi | |
85 | ||
86 | dnl We have fallbacks in case these are missing, so just check for them. | |
87 | AC_CHECK_FUNCS(freeaddrinfo getaddrinfo getnameinfo getpagesize memcpy memset strdup strerror strsignal localtime_r setrlimit getopt getopt_long sysconf,,) | |
88 | ||
89 | dnl Check for absolutely required library functions. | |
90 | AC_CHECK_FUNCS(select socket strcspn strspn strtod strtoul,,AC_MSG_ERROR([a required function was not found. X3 build will fail.])) | |
91 | ||
92 | dnl Check for functions (and how to get them). | |
93 | AC_FUNC_ALLOCA | |
94 | AC_FUNC_MMAP | |
95 | ||
96 | AC_CACHE_CHECK([for sin_len], ac_cv_sin_len, | |
97 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h> | |
98 | #include <netinet/in.h>],[struct sockaddr_in *sin; sin->sin_len = 0;])], | |
99 | ac_cv_sin_len="yes", ac_cv_sin_len="no")]) | |
100 | if test $ac_cv_sin_len = yes ; then | |
101 | AC_DEFINE(HAVE_SIN_LEN, 1, [Define if struct sockaddr_in contains a sin_len field]) | |
102 | fi | |
103 | ||
104 | dnl Check for socklen_t. In traditional BSD this is an int, but some | |
105 | dnl OSes use a different type. Test until we find something that will | |
106 | dnl work properly. Test borrowed from a patch submitted for Python. | |
107 | AC_CHECK_TYPE([socklen_t], ,[ | |
108 | AC_MSG_CHECKING([for socklen_t equivalent]) | |
109 | AC_CACHE_VAL([curl_cv_socklen_t_equiv], | |
110 | [ | |
111 | dnl Systems have either "struct sockaddr*" or "void*" as second | |
112 | dnl arg to getpeername. | |
113 | curl_cv_socklen_t_equiv= | |
114 | for arg2 in "struct sockaddr" void ; do | |
115 | for t in int size_t unsigned long "unsigned long" ; do | |
116 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> | |
117 | #include <sys/socket.h> | |
118 | int getpeername (int $arg2 *, $t *);]], [[$t len; | |
119 | getpeername(0, 0, &len);]])],[curl_cv_socklen_t_equiv="$t" | |
120 | break],[]) | |
121 | done | |
122 | done | |
123 | ]) | |
124 | AC_MSG_RESULT($curl_cv_socklen_t_equiv) | |
125 | AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv, | |
126 | [type to use in place of socklen_t if not defined])], | |
127 | [#include <sys/types.h> | |
128 | #include<sys/socket.h>]) | |
129 | ||
130 | dnl Can only check with -Werror, but the rest of configure doesn't like -Werror | |
131 | OLD_CFLAGS=$CFLAGS | |
132 | CFLAGS="$CFLAGS -W -Wall -Werror" | |
133 | ||
134 | dnl Now figure out how to printf() a time_t | |
135 | AC_MSG_CHECKING(for time_t format) | |
136 | AC_CACHE_VAL(ac_cv_fmt_time_t, [ | |
137 | ac_cv_fmt_time_t=no | |
138 | AC_COMPILE_IFELSE([#include <sys/types.h> | |
139 | #include <stdio.h> | |
140 | void myfunc(void) { | |
141 | time_t test=0; | |
142 | printf("%li", test); | |
143 | }], ac_cv_fmt_time_t="\"%li\"") | |
144 | if test $ac_cv_fmt_time_t = no; then | |
145 | AC_COMPILE_IFELSE([#include <sys/types.h> | |
146 | #include <stdio.h> | |
147 | void myfunc(void) { | |
148 | time_t test=0; | |
149 | printf("%i", test); | |
150 | }], ac_cv_fmt_time_t="\"%i\"") | |
151 | fi | |
152 | if test $ac_cv_fmt_time_t = no; then | |
153 | AC_MSG_ERROR([Cannot detect format string for time_t | |
154 | Please check sys/types.h for the typedef of time_t and submit to a developer]) | |
155 | fi | |
156 | ]) | |
157 | AC_DEFINE_UNQUOTED(FMT_TIME_T, $ac_cv_fmt_time_t, [Define to printf format for a time_t variable]) | |
158 | AC_MSG_RESULT($ac_cv_fmt_time_t) | |
159 | ||
160 | dnl How to copy one va_list to another? | |
161 | AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy, [AC_LINK_IFELSE( | |
162 | [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])], | |
163 | [ac_cv_c_va_copy="yes"], | |
164 | [ac_cv_c_va_copy="no"] | |
165 | )]) | |
166 | if test "$ac_cv_c_va_copy" = "yes" ; then | |
167 | AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy]) | |
168 | fi | |
169 | ||
170 | AC_CACHE_CHECK([for __va_copy], ac_cv_c___va_copy, [AC_LINK_IFELSE( | |
171 | [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);])], | |
172 | [ac_cv_c___va_copy="yes"], | |
173 | [ac_cv_c___va_copy="no"] | |
174 | )]) | |
175 | if test "$ac_cv_c___va_copy" = "yes" ; then | |
176 | AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy]) | |
177 | fi | |
178 | ||
179 | dnl Now fix things back up | |
180 | CFLAGS=$OLD_CFLAGS | |
181 | ||
182 | dnl Optional features. | |
183 | AC_MSG_CHECKING(which malloc to use) | |
184 | AC_ARG_WITH(malloc, | |
185 | [ --with-malloc=type Enables use of a special malloc library; one of: | |
186 | system (the default), boehm-gc, dmalloc, mpatrol, x3, slab], | |
187 | [], | |
188 | [withval="system"]) | |
189 | if test "x$withval" = "xsystem" ; then | |
190 | AC_MSG_RESULT(system) | |
191 | AC_DEFINE(WITH_MALLOC_SYSTEM, 1, [Define if using the system's malloc]) | |
192 | x3_malloc="System" | |
193 | elif 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]) | |
198 | x3_malloc="DMalloc" | |
199 | elif test "x$withval" = "xmpatrol" ; then | |
200 | AC_MSG_RESULT(mpatrol) | |
201 | AC_CHECK_HEADERS(mpatrol.h,,AC_MSG_ERROR([mpatrol header file missing. mpatrol build will fail.])) | |
202 | dnl Using mpatrol requires linking against libelf, at least on Linux. | |
203 | AC_CHECK_LIB(elf, elf_begin) | |
204 | AC_CHECK_LIB(mpatrol,__mp_atexit,,AC_MSG_ERROR([mpatrol library is missing completely. mpatrol build will fail.])) | |
205 | AC_DEFINE(WITH_MALLOC_MPATROL, 1, [Define if using the mpatrol malloc debugging package]) | |
206 | x3_malloc="MPatrol" | |
207 | elif test "x$withval" = "xboehm-gc" ; then | |
208 | AC_MSG_RESULT(boehm-gc) | |
209 | AC_CHECK_HEADERS(gc/gc.h,,AC_MSG_ERROR([Boehm GC header file missing. boehm-gc build will fail.])) | |
210 | AC_CHECK_LIB(dl, dlopen, , AC_MSG_ERROR([libdl library is missing. boehm-gc build will fail.])) | |
211 | AC_CHECK_LIB(gc, GC_gcollect, , AC_MSG_ERROR([Boehm GC library is missing. boehm-gc build will fail.])) | |
212 | AC_DEFINE(WITH_MALLOC_BOEHM_GC, 1, [Define if using the Boehm GC to garbage collect and check memory leaks]) | |
213 | x3_malloc="Boehm" | |
214 | elif test "x$withval" = "xx3" ; then | |
215 | AC_MSG_RESULT(x3) | |
216 | AC_DEFINE(WITH_MALLOC_X3, 1, [Define if using the X3 internal debug allocator]) | |
217 | MODULE_OBJS="$MODULE_OBJS alloc-x3.\$(OBJEXT)" | |
218 | x3_malloc="X3" | |
219 | elif test "x$withval" = "xslab" ; then | |
220 | AC_MSG_RESULT(slab) | |
221 | AC_DEFINE(WITH_MALLOC_SLAB, 1, [Define if using the slab internal debug allocator]) | |
222 | MODULE_OBJS="$MODULE_OBJS alloc-slab.\$(OBJEXT)" | |
223 | x3_malloc="Slab" | |
224 | else | |
225 | AC_MSG_ERROR([Unknown malloc type $withval]) | |
226 | fi | |
227 | ||
228 | AC_MSG_CHECKING(which protocol to use) | |
229 | AC_ARG_WITH(protocol, | |
230 | [ --with-protocol=name Choose IRC dialect to support; one of: | |
231 | p10 (the default), bahamut], | |
232 | [], | |
233 | [withval="p10"]) | |
234 | if test "x$withval" = "xp10" ; then | |
235 | AC_MSG_RESULT(P10) | |
236 | AC_DEFINE(WITH_PROTOCOL_P10, 1, [Define if using the P10 dialect of IRC]) | |
237 | MODULE_OBJS="$MODULE_OBJS proto-p10.\$(OBJEXT)" | |
238 | PROTO_FILES=proto-p10.c | |
239 | x3_ircd="P10" | |
240 | elif test "x$withval" = "xbahamut" ; then | |
241 | AC_MSG_RESULT(Bahamut) | |
242 | AC_DEFINE(WITH_PROTOCOL_BAHAMUT, 1, [Define if using the Bahamut dialect of IRC]) | |
243 | MODULE_OBJS="$MODULE_OBJS proto-bahamut.\$(OBJEXT)" | |
244 | x3_ircd="Bahamut" | |
245 | else | |
246 | AC_MSG_ERROR([Unknown IRC dialect $withval]) | |
247 | fi | |
248 | ||
249 | AC_ARG_WITH(getopt, | |
250 | [ --without-getopt Disables building of the GNU getopt library], | |
251 | [if test "$withval" = no; then | |
252 | AC_DEFINE(IGNORE_GETOPT, 1, [Define to disable built-in getopt library]) | |
253 | fi]) | |
254 | ||
255 | AC_MSG_CHECKING(whether to enable tokenization) | |
256 | AC_ARG_ENABLE(tokens, | |
257 | [ --disable-tokens Disables tokenization of P10 protocol output | |
258 | (tokens required if linking to ircu 2.10.11)], | |
259 | [],[enableval=yes]) | |
260 | if test "z$enableval" = zno ; then | |
261 | AC_MSG_RESULT(no) | |
262 | else | |
263 | AC_DEFINE(ENABLE_TOKENS, 1, [Define if tokenized P10 desired]) | |
264 | AC_MSG_RESULT(yes) | |
265 | fi | |
266 | ||
267 | AC_MSG_CHECKING(whether to enable debug behaviors) | |
268 | AC_ARG_ENABLE(debug, | |
269 | [ --enable-debug Enables debugging behaviors], | |
270 | [ | |
271 | CPPFLAGS="$CPPFLAGS" | |
272 | AC_MSG_RESULT(yes) | |
273 | x3_debug="Enabled" | |
274 | ], | |
275 | [ | |
276 | CPPFLAGS="$CPPFLAGS -DNDEBUG" | |
277 | AC_MSG_RESULT(no) | |
278 | x3_debug="Disabled" | |
279 | ]) | |
280 | ||
281 | if test -e src ; then | |
282 | if test ! -d src ; then | |
283 | AC_MSG_ERROR([src exists but is not a directory; please move it out of the way.]) | |
284 | fi | |
285 | else | |
286 | mkdir src | |
287 | fi | |
288 | AC_MSG_CHECKING(for extra module files) | |
289 | MODULE_DEFINES="src/modules-list.h" | |
290 | echo > $MODULE_DEFINES | |
291 | touch $MODULE_DEFINES | |
292 | AC_ARG_ENABLE(modules, | |
293 | [ --enable-modules=list,of,modules Enable extra modules], | |
294 | [ | |
295 | OIFS="$IFS" | |
296 | IFS=',' | |
297 | EXTRA_MODULE_OBJS="" | |
298 | module_list="" | |
299 | dnl Must use a separate file because autoconf can't stand newlines in an AC_SUBSTed variable. | |
300 | for module in $enableval ; do | |
301 | module=`echo $module | sed -e s/^mod-// -e s/\.c\$//` | |
302 | EXTRA_MODULE_OBJS="$EXTRA_MODULE_OBJS mod-$module.\$(OBJEXT)" | |
303 | module_list="$module_list $module" | |
304 | echo "WITH_MODULE($module)" >> $MODULE_DEFINES | |
305 | if test "x$module" = "xtrack" ; then | |
306 | TRACK="-D HAVE_TRACK" | |
307 | fi | |
308 | done | |
309 | IFS="$OIFS" | |
310 | MODULE_OBJS="$MODULE_OBJS $EXTRA_MODULE_OBJS" | |
311 | AC_MSG_RESULT($module_list) | |
312 | ], | |
313 | [ | |
314 | AC_MSG_RESULT(none) | |
315 | ]) | |
316 | ||
317 | MY_SUBDIRS="" | |
318 | RX_INCLUDES="" | |
319 | RX_LIBS="" | |
320 | if test "${BROKEN_REGEX}" = yes -o "${ac_cv_func_regcomp}" = no; then | |
321 | MY_SUBDIRS="rx $MY_SUBDIRS" | |
322 | RX_INCLUDES="-I../rx" | |
323 | RX_LIBS="../rx/librx.a" | |
324 | fi | |
325 | MY_SUBDIRS="$MY_SUBDIRS src" | |
326 | CFLAGS="$CFLAGS $ANSI_SRC -W -Wall" | |
327 | if test "z$USE_MAINTAINER_MODE" = zyes ; then | |
328 | CFLAGS="$CFLAGS -Werror" | |
329 | fi | |
330 | ||
331 | dnl REMEMBER TO CHANGE WITH A NEW TRE RELEASE! | |
332 | tre_version="0.7.4" | |
333 | AC_MSG_RESULT(extracting TRE regex library) | |
334 | cur_dir=`pwd` | |
335 | cd tools | |
336 | dnl remove old tre directory to force a recompile... | |
337 | rm -rf tre-$tre_version | |
338 | if test "x$ac_cv_path_GUNZIP" = "x" ; then | |
339 | tar xfz tre.tar.gz | |
340 | else | |
341 | cp tre.tar.gz tre.tar.gz.bak | |
342 | gunzip -f tre.tar.gz | |
343 | cp tre.tar.gz.bak tre.tar.gz | |
344 | tar xf tre.tar | |
345 | fi | |
346 | AC_MSG_RESULT(configuring TRE regex library) | |
347 | cd tre-$tre_version | |
348 | ./configure --disable-agrep --disable-shared --disable-system-abi --disable-wchar --disable-multibyte --prefix=$prefix || exit 1 | |
349 | AC_MSG_RESULT(compiling TRE regex library) | |
350 | $ac_cv_prog_MAKER || exit 1 | |
351 | AC_MSG_RESULT(installing TRE regex library) | |
352 | $ac_cv_prog_MAKER install || exit 1 | |
353 | TREINCDIR="$prefix/include" | |
354 | AC_SUBST(TREINCDIR) | |
355 | if test "x$ac_cv_path_PKGCONFIG" = "x" ; then | |
356 | TRELIBS="-L$prefix/lib -ltre" | |
357 | else | |
358 | TRELIBS=`$ac_cv_path_PKGCONFIG --libs tre.pc` | |
359 | fi | |
360 | AC_SUBST(TRELIBS) | |
361 | cd $cur_dir | |
362 | ||
363 | AC_DEFINE_UNQUOTED(CODENAME, "${CODENAME}", [Code name for this release]) | |
364 | AC_SUBST(MODULE_OBJS) | |
365 | AC_SUBST(MY_SUBDIRS) | |
366 | AC_SUBST(RX_INCLUDES) | |
367 | AC_SUBST(RX_LIBS) | |
368 | AC_SUBST(TRACK) | |
369 | AC_CONFIG_FILES(Makefile rx/Makefile src/Makefile) | |
370 | AC_OUTPUT | |
371 | ||
372 | ||
373 | dnl Print configuration summary | |
374 | ||
375 | cat <<EOF | |
376 | ||
377 | Configuration summary | |
378 | ===================== | |
379 | ||
380 | X3 is now configured as follows: | |
381 | ||
382 | * Compilation environment | |
383 | ||
384 | CC = $CC | |
385 | CFLAGS = $CFLAGS | |
386 | CPP = $CPP | |
387 | CPPFLAGS = $CPPFLAGS | |
388 | LD = $LD | |
389 | LDFLAGS = $LDFLAGS | |
390 | LIBS = $LIBS | |
391 | ||
392 | * X3 options | |
393 | ||
394 | Debug: $x3_debug | |
395 | Extra Modules: $module_list | |
396 | Malloc: $x3_malloc | |
397 | Protocol: $x3_ircd | |
398 | Regexp Library TRE $tre_version | |
399 | ||
400 | Now you can proceed with compiling X3 | |
401 | ||
402 | EOF | |
403 |