]> jfr.im git - solanum.git/blame - configure.ac
SJOIN: Fix crash when both mode parameter and UID list are missing.
[solanum.git] / configure.ac
CommitLineData
88cb7f99 1dnl $Id: configure.ac 3516 2007-06-10 16:14:03Z jilles $
212380e3
AC
2dnl Process this file with autoconf to produce a configure script.
3
4dnl TODO: clean up all the OpenSSL and shared module checking stuff;
5dnl the most major changes have already been made and it looks like
6dnl said functions need to be just about as complex as they already are.
7
8AC_PREREQ(2.57)
9
10dnl Sneaky way to get an Id tag into the configure script
88cb7f99 11AC_COPYRIGHT([$Id: configure.ac 3516 2007-06-10 16:14:03Z jilles $])
212380e3 12
c2a0843d 13AC_INIT([charybdis], [3.5.0-dev])
212380e3 14
a5471f24 15AC_CONFIG_MACRO_DIR([m4])
212380e3
AC
16AC_CONFIG_HEADER(include/setup.h)
17
18AC_PREFIX_DEFAULT($HOME/ircd)
19
20AC_GNU_SOURCE
21
22OLD_CFLAGS="$CFLAGS"
23dnl Checks for programs.
24AC_PROG_CC
25AC_LANG(C)
26
27dnl Make sure autoconf doesn't interfere with cflags -jmallett
28CFLAGS="$OLD_CFLAGS"
29
6573fa4c 30AC_CONFIG_SUBDIRS(libratbox)
db137867 31
212380e3
AC
32dnl Check for various compilers. -jmallett
33dnl But if $CC turns out to be gcc, sure as hell it's, well, gcc. -joshk
34
35if test "$ac_cv_c_compiler_gnu" != yes; then
36
37SGS=no
38AC_MSG_CHECKING($CC -version for TenDRA or MIPSpro)
39case `$CC -version 2>&1` in
40*TenDRA*)
41 AC_MSG_RESULT([yes, TenDRA])
42 IRC_CFLAGS=""
43 CPPFLAGS="$CPPFLAGS -Ylonglong -Yansi -I/usr/include"
44 SGS=yes
45 TenDRA=yes
46;;
47*MIPSpro*)
48 AC_MSG_RESULT([yes, MIPSpro])
49 MIPSpro=yes
50 SGS=yes
51;;
52*)
53 AC_MSG_RESULT(no)
54 TenDRA=no
55 MIPSpro=no
56;;
57esac
58
59AC_MSG_CHECKING([$CC -V for Sun Workshop, Forte, HPUX or Tru64 cc])
60case `$CC -V 2>&1` in
61*Sun*WorkShop* | *Forte*Developer*)
62 AC_MSG_RESULT(Sun Workshop/Forte)
63 IRC_CFLAGS="-fast -xinline=dlinkAdd,dlinkAddBefore,dlinkAddTail,dlinkDelete,dlink_list_length,dlink_node,dlinkMoveList,_MyMalloc,_MyRealloc,_MyFree,_DupString"
64 SunWorkShop=yes
65 SGS=yes
66;;
67*Tru64*)
68 AC_MSG_RESULT(Tru64 cc)
69 IRC_CFLAGS="-O2"
70 CPPFLAGS="-I/usr/local/include"
71 Tru=yes
72;;
73*HP*ANSI*)
74 AC_MSG_RESULT(HPUX cc)
75 HPUX=yes
76 IRC_CFLAGS="+e"
77;;
78*)
79 AC_MSG_RESULT(no)
80;;
81esac
82
83fi
84
d3faa80a 85AC_MSG_CHECKING([uname -s for Solaris, AIX or HPUX])
212380e3
AC
86OSNAME=`uname -s`
87case "$OSNAME" in
88 HP-UX*)
89 dnl only do this if we haven't already detected the newer one
90 dnl and we're not already using gcc
91
92 if test "$HPUX" != yes -a "$ac_cv_c_compiler_gnu" = no; then
93 AC_MSG_RESULT(assuming old HPUX with its own cc)
94 IRC_CFLAGS="$IRC_CFLAGS +e"
95 HPUX=yes
96 else
97 AC_MSG_RESULT(already using newer HPUX)
98 fi
99 ;;
212380e3
AC
100 SunOS*)
101 AC_MSG_RESULT(SunOS or Solaris)
102 AC_DEFINE(__EXTENSIONS__, 1, [This is needed to use strtok_r on Solaris.])
103 SUN=yes
104 ;;
105 AIX*)
106 AC_MSG_RESULT(AIX - Sorry you poor bastard..really we are)
107 IRC_CFLAGS="$IRC_CFLAGS -Wl,-brtl -Wl,-G"
108 ;;
109 *)
110 AC_MSG_RESULT(no)
111 ;;
112esac
113
114if test "$ac_cv_c_compiler_gnu" = yes; then
115 AC_MSG_CHECKING(if $CC is Apple GCC)
116
117 case `$CC -v 2>&1 | tail -n 1` in
118 *Apple*)
119 AC_MSG_RESULT(yes)
120 AppleGCC=yes
121 ;;
122 *)
123 AC_MSG_RESULT(no)
124 AppleGCC=no
125 ;;
126 esac
127
97199fb3 128 IRC_CFLAGS="$IRC_CFLAGS -O0 -Wall -std=gnu99"
212380e3
AC
129fi
130
131dnl If we support -g, use it!
132if test "$ac_cv_prog_cc_g" = yes; then
133 dnl Tru64 needs -g3 for -O2
134 if test "$Tru" = yes; then
135 IRC_CFLAGS="$IRC_CFLAGS -g3"
136 else
137 IRC_CFLAGS="$IRC_CFLAGS -g"
138 fi
139fi
140
141dnl SVR4 SGS based on what we know about the compiler -jmallett
142AC_MSG_CHECKING(if $CC supports the SVR4 SGS interfaces)
143if test "$SGS" = "yes"; then
144 AC_MSG_RESULT(yes)
145else
146 AC_MSG_RESULT(no)
147fi
148
149dnl We prefer gcc -MM because it's a lot less bloated
150AC_PATH_PROG(MKDEP, mkdep)
151AC_PATH_PROG(MAKEDEPEND, makedepend)
152
153AC_MSG_CHECKING(how to generate dependency info)
154
155STDOUT="> .depend"
156
157if test "$ac_cv_c_compiler_gnu" = yes; then
158 AC_MSG_RESULT(gcc -MM)
159 MKDEP="$CC -MM"
160elif test ! -z "$MKDEP"; then
161 AC_MSG_RESULT(mkdep)
162
163 dnl Tru64's mkdep is very loud
164 if test -z "$Tru"; then
165 STDOUT=""
166 else
167 STDOUT=" 2> /dev/null"
168 fi
169elif test "$SunWorkShop" = yes; then
170 AC_MSG_RESULT($CC -xM)
171 MKDEP="$CC -xM"
172 STDOUT="> .depend 2> /dev/null"
173elif test ! -z "$MAKEDEPEND"; then
174 AC_MSG_RESULT(makedepend)
175 MKDEP="$MAKEDEPEND -f-"
176else
177 AC_MSG_RESULT([nothing suitable.. forget it!])
178 MKDEP=":"
179fi
180
181AC_SUBST(MKDEP)
182AC_SUBST(STDOUT)
183
184dnl check for /dev/null so we can use it to hold evil fd's
185AC_MSG_CHECKING([for /dev/null])
186if test -c /dev/null ; then
187 AC_DEFINE(PATH_DEVNULL, "/dev/null", [Path to /dev/null])
188 AC_MSG_RESULT(yes)
189else
190 AC_DEFINE(PATH_DEVNULL, "devnull.log", [Path to /dev/null])
191 AC_MSG_RESULT(no - using devnull.log)
192fi
193
194dnl jdc -- If CFLAGS is defined, best use it everywhere...
195dnl NOTE: jv says it must be added to the *END*, because things like
196dnl "gcc -O9 -O2" will result in -O2 getting preference. How stupid.
197if test ! -z "$CFLAGS"; then
198 IRC_CFLAGS="$IRC_CFLAGS $CFLAGS"
199fi
200
201AC_ISC_POSIX
202AC_C_INLINE
203AC_PROG_GCC_TRADITIONAL
204AC_PROG_MAKE_SET
205AC_PROG_INSTALL
206AC_PATH_PROG(RM, rm)
207AC_PATH_PROG(CP, cp)
208AC_PATH_PROG(MV, mv)
209AC_PATH_PROG(LN, ln)
210AC_PATH_PROG(SED, sed)
211AC_PATH_PROG(AR, ar)
212AC_PATH_PROG(LD, ld)
213AC_PATH_PROG(RANLIB, ranlib)
214AC_PATH_PROG(TOUCH, touch)
215
216AC_PROG_YACC
217
218dnl AC_PROG_YACC defaults to yacc unconditionally if nothing can be found
219if test "$YACC" = "yacc" -a -z "`which $YACC 2>/dev/null`"; then
220 AC_MSG_ERROR([could not locate a suitable parser generator; install bison, yacc, or byacc])
221fi
222
223AC_PROG_LEX
224
225if test "$LEX" = ":"; then
226 AC_MSG_ERROR([could not locate a suitable lexical generator, install flex or lex.])
227fi
228
c74836dc 229AC_ARG_ENABLE([fhs-paths],
6929cd01 230 [AS_HELP_STRING([--enable-fhs-paths], [Use more FHS-like pathnames (for packagers).])],
c74836dc
NPB
231 [],
232 [dnl detect if the user appears to want --enable-fhs-paths
233 AS_IF([test "$libexecdir" = '${exec_prefix}/libexec' && \
234 test "$localstatedir" = '${prefix}/var' && \
235 test "$libdir" = '${exec_prefix}/lib'],
236 [enable_fhs_paths=no],
237 [enable_fhs_paths=yes])
238 ])
212380e3 239dnl use directory structure of cached as default (hack)
c74836dc
NPB
240AS_IF([test "x$enable_fhs_paths" = "xyes"],
241 [dnl Avoid name collisions.
242 pkglibexecdir='${libexecdir}/${PACKAGE_TARNAME}'
243 rundir=${rundir-'${prefix}/run'}
244 pkgrundir='${rundir}/${PACKAGE_TARNAME}'
245 pkglocalstatedir='${localstatedir}/${PACKAGE_TARNAME}'],
246 [libexecdir='${bindir}'
247 pkglibexecdir='${libexecdir}'
248 rundir='${sysconfdir}'
249 pkgrundir='${rundir}'
212380e3 250 localstatedir='${prefix}'
c74836dc
NPB
251 pkglocalstatedir='${sysconfdir}'])
252pkglibdir='${libdir}/${PACKAGE_TARNAME}'
253AC_SUBST([pkglibdir])
254AC_SUBST([rundir])
255AC_SUBST([pkgrundir])
256AC_SUBST([pkglocalstatedir])
1870e06a 257AC_DEFINE_DIR([PKGLOCALSTATEDIR], [pkglocalstatedir], [[Directory in which to store state, such as ban database]])
c74836dc
NPB
258AC_SUBST([pkglibexecdir])
259AC_DEFINE_DIR([PKGLIBEXECDIR], [pkglibexecdir], [Directory where binaries the IRCd itself spawns live])
212380e3
AC
260
261dnl Checks for header files.
262AC_HEADER_STDC
263
264AC_CHECK_HEADERS([crypt.h sys/resource.h sys/param.h errno.h sys/syslog.h stddef.h sys/wait.h wait.h sys/epoll.h sys/uio.h machine/endian.h])
265
266dnl Stuff that the memory manager (imalloc) depends on
267dnl ==================================================
268
269AC_C_CONST
270if test "$ac_cv_header_machine_endian_h" = "no" ; then
271 AC_C_BIGENDIAN
272fi
273AC_TYPE_PID_T
274AC_TYPE_SIZE_T
275AC_CHECK_SIZEOF(short)
276AC_CHECK_SIZEOF(int)
277AC_CHECK_SIZEOF(long)
278AC_CHECK_SIZEOF(long long)
279
212380e3
AC
280dnl Networking Functions
281dnl ====================
282
283AC_SEARCH_LIBS(socket, socket, , [AC_MSG_ERROR([You have no socket()! Aborting.])])
284
285dnl SunOS/Solaris required libnsl for inet_ntoa()
286if test x"$SUN" = xyes; then
287 AC_SEARCH_LIBS(inet_ntoa, nsl,, [AC_MSG_ERROR([libnsl not found! Aborting.])])
288fi
289
212380e3
AC
290AC_CHECK_TYPE(socklen_t, ,
291[AC_DEFINE([socklen_t], [unsigned int],
292[If we don't have a real socklen_t, unsigned int is good enough.])],
293[#include <sys/types.h>
294#include <sys/socket.h>])
295
296AC_ARG_ENABLE(ipv6,
297AC_HELP_STRING([--enable-ipv6],[Enable IPv6 support]),[ipv6=$enableval],[ipv6=no])
298
212380e3
AC
299AC_SEARCH_LIBS(crypt, [crypt descrypt],,)
300
301CRYPT_LIB=$ac_cv_search_crypt
302
303if test "$CRYPT_LIB" = "none required"; then
304 unset CRYPT_LIB
305elif test "$CRYPT_LIB" = no; then
306 unset CRYPT_LIB
307fi
308
309AC_SUBST(CRYPT_LIB)
310
311if test "$ac_cv_header_sys_wait_h" = yes -o "$ac_cv_header_wait_h" = yes; then
312 VICONF=viconf
313 dnl We need one of the above to build viconf. Just a sanity check,
314 dnl we don't want to stop people from building the rest of ircd
315 dnl just because they can't build viconf.
316else
317 VICONF=""
318fi
319
320AC_SUBST(VICONF)
321
322dnl See whether we can include both string.h and strings.h.
323AC_CACHE_CHECK([whether string.h and strings.h may both be included],
324gcc_cv_header_string,
325[
326 AC_COMPILE_IFELSE(
327 [#include <string.h>
328 #include <strings.h>],
329 [gcc_cv_header_string=yes],
330 [gcc_cv_header_string=no])
331])
332
333if test "$gcc_cv_header_string" = "yes"; then
334 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define to 1 if string.h may be included along with strings.h])
335fi
336
337AC_C_BIGENDIAN
338
339dnl Check for stdarg.h - if we can't find it, halt configure
ec86417c 340AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - charybdis will not compile without it **])])
212380e3
AC
341
342dnl Checks for the existence of strlcat, strlcpy, basename...
343dnl This more reliable test only works with gcc though.
344
345if test "$ac_cv_c_compiler_gnu" = yes; then
346
347AC_MSG_CHECKING(for strlcpy)
348save_CFLAGS=$CFLAGS
349CFLAGS="$CFLAGS -Wimplicit -Werror"
350
351AC_LINK_IFELSE(
352 [AC_LANG_PROGRAM(
353 [[#include <string.h>
354 #include <stdlib.h>]],
355 [[char *a = malloc(6);
356 strlcpy(a, "hello", 6);]]
357 )],
358 [AC_MSG_RESULT(yes)
359 AC_DEFINE(HAVE_STRLCPY, 1, [Define if strlcpy is available (most BSDs.)])],
360 [AC_MSG_RESULT(no)]
361)
362
363AC_MSG_CHECKING(for strlcat)
364AC_LINK_IFELSE(
365 [AC_LANG_PROGRAM(
366 [[#include <string.h>
367 #include <stdlib.h>]],
368 [[char *a = malloc(6);
369 a[0] = '\0';
370 strlcat(a, "hello", 6);]]
371 )],
372 [AC_MSG_RESULT(yes)
373 AC_DEFINE(HAVE_STRLCAT, 1, [Define if strlcat is available (most BSDs.)])],
374 [AC_MSG_RESULT(no)]
375)
376
377CFLAGS=$save_CFLAGS
378
379else
380
381dnl Better than nothing. The more complicated test above probably fixes powerpc,
382dnl so who cares.
383
384AC_CHECK_FUNCS([strlcat strlcpy])
385
386fi
387
388AC_CHECK_TYPE([u_int32_t], [],
389[
390 AC_CHECK_TYPE([uint32_t],
391 [
392 AC_DEFINE(u_int32_t, [uint32_t], [If system does not define u_int32_t, define a reasonable substitute.])
393 ],
394 [
395 AC_MSG_WARN([system has no u_int32_t or uint32_t, default to unsigned long int])
396 AC_DEFINE(u_int32_t, [unsigned long int], [If system does not define u_int32_t, define to unsigned long int here.])
397 ])
398])
399
400AC_CHECK_TYPE([u_int16_t], [],
401[
402 AC_CHECK_TYPE([uint16_t],
403 [
404 AC_DEFINE(u_int16_t, [uint16_t], [If system does not define u_int16_t, define a usable substitute])
405 ],
406 [
407 AC_MSG_WARN([system has no u_int16_t or uint16_t, default to unsigned short int])
408 AC_DEFINE(u_int16_t, [unsigned short int], [If system does not define u_int16_t, define a usable substitute.])
409 ])
410])
411
412AC_CHECK_TYPE([in_port_t], [],
413[AC_DEFINE(in_port_t, [u_int16_t], [If system does not define in_port_t, define it to what it should be.])],
414[[#include <sys/types.h>
415#include <netinet/in.h>]])
416
417AC_CHECK_TYPE([sa_family_t], [],
418[AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
419[[#include <sys/types.h>
420#include <sys/socket.h>]])
421
422AC_CHECK_TYPES([uintptr_t])
423
424dnl check for various functions...
425AC_CHECK_FUNCS([socketpair vsnprintf mmap gettimeofday strdup strndup ])
426
427AC_FUNC_ALLOCA
428
429dnl Specialized functions checks
430dnl ============================
431
432dnl check for nanosleep
433AC_CHECK_FUNC(nanosleep,,[AC_CHECK_LIB(rt,nanosleep,
434 LIBS="${LIBS} -lrt",
435 [AC_CHECK_LIB(posix4,nanosleep, LIBS="${LIBS} -lposix4"
436 )])])
437if test x$ac_cv_func_nanosleep = xno && test x$ac_cv_lib_posix4_nanosleep = xno && test x$ac_cv_lib_rt_nanosleep = xno
438then
439 AC_MSG_RESULT("nanosleep not found..using select for delay")
440else
441 AC_DEFINE([HAVE_NANOSLEEP], 1, [Define if nanosleep exists])
442fi
443
444dnl OpenSSL support
445AC_MSG_CHECKING(for OpenSSL)
446AC_ARG_ENABLE(openssl,
447[AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
448AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
449[cf_enable_openssl=$enableval],
450[cf_enable_openssl="auto"])
451
452if test "$cf_enable_openssl" != "no" ; then
453 cf_openssl_basedir=""
454 if test "$cf_enable_openssl" != "auto" &&
455 test "$cf_enable_openssl" != "yes" ; then
456 dnl Support for --enable-openssl=/some/place
457 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
458 else
459 dnl Do the auto-probe here. Check some common directory paths.
460 for dirs in /usr/local/ssl /usr/pkg /usr/local \
461 /usr/local/openssl ; do
462 if test -f "${dirs}/include/openssl/opensslv.h" ; then
463 cf_openssl_basedir="${dirs}"
464 break
465 fi
466 done
467 unset dirs
468 fi
469 dnl Now check cf_openssl_found to see if we found anything.
470 if test ! -z "$cf_openssl_basedir"; then
471 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
472 SSL_INCLUDES="-I${cf_openssl_basedir}/include"
473 SSL_LIBS="-L${cf_openssl_basedir}/lib"
474 else
475 dnl OpenSSL wasn't found in the directory specified. Naughty
476 dnl administrator...
477 cf_openssl_basedir=""
478 fi
479 else
480 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
481 dnl are in /usr/include and /usr/lib. In this case, we don't want to
482 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
483 dnl We can't do this check above, because some people want two versions
484 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
485 dnl and they want /usr/local/ssl to have preference.
486 if test -f "/usr/include/openssl/opensslv.h" ; then
487 cf_openssl_basedir="/usr"
488 fi
489 fi
490
491 dnl If we have a basedir defined, then everything is okay. Otherwise,
492 dnl we have a problem.
493 if test ! -z "$cf_openssl_basedir"; then
494 AC_MSG_RESULT($cf_openssl_basedir)
495 cf_enable_openssl="yes"
496 else
497 AC_MSG_RESULT([not found. Specify a correct path?])
498 cf_enable_openssl="no"
499 fi
500 unset cf_openssl_basedir
501else
502 dnl If --disable-openssl was specified
503 AC_MSG_RESULT(disabled)
504fi
505
506save_CPPFLAGS="$CPPFLAGS"
507CPPFLAGS="$CPPFLAGS $SSL_INCLUDES"
508save_LIBS="$LIBS"
509LIBS="$LIBS $SSL_LIBS"
510if test "$cf_enable_openssl" != no; then
511 dnl Check OpenSSL version (must be 0.9.6 or above!)
512 AC_MSG_CHECKING(for OpenSSL 0.9.6 or above)
513 AC_RUN_IFELSE(
514 AC_LANG_PROGRAM(
515 [#include <openssl/opensslv.h>
516 #include <stdlib.h>],
517 [[if ( OPENSSL_VERSION_NUMBER >= 0x00906000)
518 exit(0); else exit(1);]]),
519 cf_openssl_version_ok=yes,
520 cf_openssl_version_ok=no,
521 cf_openssl_version_ok=no)
522
523 if test "$cf_openssl_version_ok" = yes; then
524 AC_MSG_RESULT(found)
525
526 dnl Work around pmake/gmake conditional incompatibilities
527 AC_SUBST(ENCSPEED, encspeed)
528
529 dnl Do all the HAVE_LIBCRYPTO magic -- and check for ciphers
530 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
531 AC_CHECK_LIB(crypto, RSA_free)
532 SSL_LIBS="$SSL_LIBS -lcrypto"
533 SSL_SRCS_ENABLE='$(SSL_SRCS)'
534 else
535 AC_MSG_RESULT(no - OpenSSL support disabled)
536 fi
537fi
538
539CPPFLAGS="$save_CPPFLAGS"
540LIBS="$save_LIBS"
541
542dnl End OpenSSL detection
543
544
545dnl Specialized functions and libraries
546dnl ===================================
547
548AC_ARG_WITH(zlib-path,
549AC_HELP_STRING([--with-zlib-path=DIR],[Path to libz.so for ziplinks support.]),
550[LIBS="$LIBS -L$withval"],)
551
552AC_ARG_ENABLE(zlib,
553AC_HELP_STRING([--disable-zlib],[Disable ziplinks support]),
554[zlib=$enableval],[zlib=yes])
555
556if test "$zlib" = yes; then
557
558AC_CHECK_HEADER(zlib.h, [
559 AC_CHECK_LIB(z, zlibVersion,
560 [
561 AC_SUBST(ZLIB_LD, -lz)
562 AC_DEFINE(HAVE_LIBZ, 1, [Define to 1 if zlib (-lz) is available.])
563 ], zlib=no)
564], zlib=no)
565
566fi
567
cf1001a7
LS
568dnl Check for shared sqlite
569dnl ======================
a6ef3156
LS
570AC_ARG_WITH(shared-sqlite,
571AC_HELP_STRING([--with-shared-sqlite],[Use shared sqlite]),
572[shared_sqlite=$withval],[shared_sqlite=no])
497e30a0
LS
573
574if test "$shared_sqlite" = yes; then
a5471f24
LS
575 PKG_CHECK_MODULES(SQLITE, [sqlite3],
576 [
577 shared_sqlite=yes
cf1001a7 578 ], shared_sqlite=no)
497e30a0
LS
579fi
580
74ab6be0 581if test "$shared_sqlite" = no; then
cf1001a7 582 SQLITE_SRC="sqlite3.c"
74ab6be0
LS
583fi
584
a5471f24
LS
585AC_SUBST(SQLITE_LD, "$SQLITE_LIBS")
586AC_SUBST(SQLITE_INCLUDES, "$SQLITE_CFLAGS")
cf1001a7
LS
587AC_SUBST(SQLITE_SRC)
588
212380e3
AC
589dnl IO Loop Selection
590dnl =================
591
1b4cfad8
AC
592AC_ARG_ENABLE(ports, AC_HELP_STRING([--enable-ports],[Force solaris I/O ports subsystem usage.]),
593[ if test $enableval = yes; then
594 SELECT_TYPE_EXPLICIT="ports"
595 else
596 use_ports=no
597 fi
598],)
599
212380e3
AC
600AC_ARG_ENABLE(poll, AC_HELP_STRING([--enable-poll],[Force poll() usage.]),
601[ if test $enableval = yes; then
602 SELECT_TYPE_EXPLICIT="poll"
603 else
604 use_poll=no
605 fi
606],)
607
608AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select],[Force select() usage.]),
609[ if test $enableval = yes; then
610 SELECT_TYPE_EXPLICIT="select"
611 else
612 use_select=no
613 fi
614],)
615
616AC_ARG_ENABLE(kqueue, AC_HELP_STRING([--enable-kqueue],[Force kqueue() usage.]),
617[ if test $enableval = yes; then
618 SELECT_TYPE_EXPLICIT="kqueue"
619 else
620 use_kqueue=no
621 fi
622],)
623
212380e3
AC
624AC_ARG_ENABLE(epoll, AC_HELP_STRING([--enable-epoll],[Force sys_epoll usage (Linux only).]),
625[ if test $enableval = yes; then
626 SELECT_TYPE_EXPLICIT="epoll"
a34ec229 627 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
212380e3
AC
628 else
629 use_epoll=no
630 fi
631],)
632
633dnl **********************************************************************
634d4aad 634dnl Check for --with-confdir [deprecated, use --sysconfdir instead]
212380e3
AC
635dnl **********************************************************************
636
634d4aad
NPB
637AC_ARG_WITH([confdir],
638 [AC_HELP_STRING([--with-confdir=DIR],
639 [Directory to install config files [deprecated, use --sysconfdir instead].])],
640 [ sysconfdir=`echo $withval | sed 's/\/$//'` ],
641 [ confdir='${sysconfdir}' ])
642AC_DEFINE_DIR([ETC_DIR], [sysconfdir], [Prefix where config files are installed.])
212380e3
AC
643
644dnl **********************************************************************
645dnl Check for --with-logdir
646dnl **********************************************************************
647
648AC_MSG_CHECKING([whether to modify logdir])
649AC_ARG_WITH(logdir,
650AC_HELP_STRING([--with-logdir=DIR],
651 [Directory where to write logfiles.]),
652 [ logdir=`echo $withval | sed 's/\/$//'`
c74836dc
NPB
653 AC_MSG_RESULT(yes)],
654 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
655 [logdir='${localstatedir}/log/${PACKAGE_TARNAME}'],
656 [logdir='${prefix}/logs'])
657 AC_MSG_RESULT(no)])
658AC_DEFINE_DIR([LOG_DIR], [logdir], [Prefix where to write logfiles.])
659AC_SUBST_DIR([logdir])
212380e3
AC
660
661dnl **********************************************************************
662dnl Check for --with-helpdir
663dnl **********************************************************************
664
665AC_MSG_CHECKING([whether to modify helpdir])
666AC_ARG_WITH(helpdir,
667AC_HELP_STRING([--with-helpdir=DIR],
668 [Directory to install help files.]),
669 [ helpdir=`echo $withval | sed 's/\/$//'`
c74836dc
NPB
670 AC_MSG_RESULT(yes) ],
671 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
672 [helpdir='${datadir}/${PACKAGE_TARNAME}/help'],
673 [helpdir='${prefix}/help'])
674 AC_MSG_RESULT(no) ])
675AC_DEFINE_DIR([HELP_DIR], [helpdir], [Prefix where help files are installed.])
676AC_SUBST_DIR([helpdir])
212380e3
AC
677
678dnl **********************************************************************
679dnl Check for --with-moduledir
680dnl **********************************************************************
681
682AC_MSG_CHECKING([whether to modify moduledir])
683AC_ARG_WITH(moduledir,
c74836dc
NPB
684 [AC_HELP_STRING([--with-moduledir=DIR],
685 [Directory to install modules.])],
212380e3 686 [ moduledir=`echo $withval | sed 's/\/$//'`
c74836dc
NPB
687 AC_MSG_RESULT(yes)],
688 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
689 [moduledir='${pkglibdir}/modules'],
690 [moduledir='${prefix}/modules'])
212380e3 691 AC_MSG_RESULT(no)
c74836dc
NPB
692 ])
693AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.])
694AC_SUBST_DIR([moduledir])
695
696dnl Check for --with-rundir
697
698AC_MSG_CHECKING([whether or modify rundir])
699AC_ARG_WITH([rundir],
700 [AC_HELP_STRING([--with-rundir=DIR],
701 [Directory in which to store pidfile.])],
702 [AC_MSG_RESULT([yes])
703 rundir=`echo $withval | sed 's/\/$//'`],
704 [AC_MSG_RESULT([no])
705 AS_IF([test "x$enable_fhs_paths" = "xyes"],
706 [rundir='${prefix}/run'],
707 [rundir='${sysconfdir}'])])
708AC_SUBST([rundir])
709AC_DEFINE_DIR([PKGRUNDIR], [pkgrundir], [Directory to store pidfile in.])
710
711dnl Installed utility program prefixes (does not affect binaries
712dnl installed into pkglibexecdir)
713AC_MSG_CHECKING([for program prefix])
714AC_ARG_WITH([program-prefix],
715 [AS_HELP_STRING([--with-program-prefix=], [If set, programs installed into PATH will be installed with names prefixed by this prefix.])],
716 [test "x$with_program_prefix" = "xno" && with_program_prefix=],
717 [with_program_prefix=])
718AC_MSG_RESULT(["$with_program_prefix"])
719PROGRAM_PREFIX="$with_program_prefix"
720AC_SUBST([PROGRAM_PREFIX])
721AC_DEFINE_UNQUOTED([PROGRAM_PREFIX], ["$with_program_prefix"], [String with which all programs intended to be in PATH are prefixed.])
212380e3 722
b6d0720c
AC
723dnl **********************************************************************
724dnl Branding
725dnl **********************************************************************
726
727AC_MSG_CHECKING([whether custom branding is requested])
728AC_ARG_WITH(custom-branding,
729AC_HELP_STRING([--with-custom-branding=NAME],
730 [Custom branding name.]),
731 [BRANDING_NAME=$withval
732 AC_MSG_RESULT([yes])],
733 [BRANDING_NAME=$PACKAGE_NAME
734 AC_MSG_RESULT([no])]
735)
736
737AC_MSG_CHECKING([whether a custom version is requested])
738AC_ARG_WITH(custom-version,
739AC_HELP_STRING([--with-custom-version=NAME],
740 [Custom version branding.]),
741 [BRANDING_VERSION=$withval
742 AC_MSG_RESULT([yes])],
743 [BRANDING_VERSION=$PACKAGE_VERSION
744 AC_MSG_RESULT([no])]
745)
746
747AC_DEFINE_UNQUOTED(BRANDING_NAME, ["$BRANDING_NAME"], [Custom branding name.])
748AC_DEFINE_UNQUOTED(BRANDING_VERSION, ["$BRANDING_VERSION"], [Custom branding name.])
749
f5493691
AC
750if test "x$BRANDING_NAME" != "x$PACKAGE_NAME"; then
751 AC_DEFINE(CUSTOM_BRANDING, 1, [Define if custom branding is enabled.])
752fi
753
212380e3
AC
754if test ! -z "$SELECT_TYPE_EXPLICIT"; then
755 SELECT_TYPE="$SELECT_TYPE_EXPLICIT";
756 echo "Forcing $SELECT_TYPE to be enabled"
757else
758
1b4cfad8
AC
759if test ! "x$use_ports" = "xno"; then
760 AC_CHECK_FUNCS(port_getn, [haveports=yes], [haveports=no])
761 if test "x$haveports" = "xyes" ; then
762 SELECT_TYPE="ports"
763 fi
764fi
765
212380e3
AC
766if test ! "x$use_select" = "xno"; then
767 AC_CHECK_FUNCS(select, [haveselect=yes], [haveselect=no])
768 if test "x$haveselect" = "xyes" ; then
769 SELECT_TYPE="select"
770 fi
771fi
772
773if test ! "x$use_poll" = "xno"; then
774 AC_CHECK_FUNCS(poll, [havepoll=yes], [havepoll=no])
775 if test "x$havepoll" = "xyes" ; then
776 SELECT_TYPE="poll"
777 fi
778fi
779
212380e3
AC
780if test ! "x$use_kqueue" = "xno"; then
781 AC_CHECK_FUNCS(kevent, [havekqueue=yes], [havekqueue=no])
782 if test "x$havekqueue" = "xyes" ; then
783 SELECT_TYPE="kqueue"
784 fi
785fi
786
787if test ! "x$use_epoll" = "xno"; then
788 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
789 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
790 if test "x$haveepoll" = "xyes" ; then
791 AC_MSG_CHECKING(for epoll support in kernel)
792 AC_TRY_RUN(
793#include <stdint.h>
794#include <sys/param.h>
795#include <sys/types.h>
796#include <sys/epoll.h>
797#include <sys/syscall.h>
798#include <unistd.h>
799
800int
801main(int argc, char **argv)
802{
803 int epfd;
804
805 epfd = epoll_create(256);
33b310b3 806 return (epfd == -1 ? 1 : 0);
212380e3
AC
807}, [AC_MSG_RESULT(yes)
808 AC_DEFINE(HAVE_EPOLL, 1,
809 [Define if your system supports the epoll system calls])
810 SELECT_TYPE="epoll"],
811 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
812 fi
813 fi
814
815haveepollsyscall=no
816
817if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
818 if test "x$haveepoll" = "xno" ; then
819 AC_MSG_CHECKING(for epoll system call)
820 AC_TRY_RUN(
821#include <stdint.h>
822#include <sys/param.h>
823#include <sys/types.h>
824#include <sys/epoll.h>
825#include <sys/syscall.h>
826#include <unistd.h>
827
828int
829epoll_create(int size)
830{
831 return (syscall(__NR_epoll_create, size));
832}
833
834int
835main(int argc, char **argv)
836{
837 int epfd;
838
839 epfd = epoll_create(256);
840 exit (epfd == -1 ? 1 : 0);
841}, [AC_MSG_RESULT(yes)
842 AC_DEFINE(HAVE_EPOLL, 1,
843 [Define if your system supports the epoll system calls])
844 SELECT_TYPE="epoll"],
845 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
846 fi
847fi
848
849fi
850
851fi
852
853if test -z "$SELECT_TYPE"; then
854 AC_MSG_ERROR([Unable to find a usable IO interface],)
855fi
856
857echo "Using $SELECT_TYPE for select loop."
858
859AC_DEFINE_UNQUOTED(SELECT_TYPE, "$SELECT_TYPE", [This is the type of IO loop we are using])
860AC_SUBST(SELECT_TYPE)
861
862
863dnl Debug-related options
864dnl =====================
865
866AC_ARG_ENABLE(assert,
867AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
868[assert=$enableval], [assert=no])
869
870if test "$assert" = no; then
871 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
872elif test "$assert" = soft; then
873 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
874 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
875elif test "$assert" = yes; then
876 assert = "hard";
877fi
878
879AC_MSG_CHECKING(if you want IO Debugging hooks)
880AC_ARG_ENABLE(iodebug,
881AC_HELP_STRING([--enable-iodebug],[Enable IO Debugging hooks]),
882[iodebug=$enableval], [iodebug=no])
883
884if test "$iodebug" = yes; then
885 AC_DEFINE(USE_IODEBUG_HOOKS, 1, [Define this to enable IO Debug hooks.])
886 AC_MSG_RESULT(yes)
887else
888 AC_MSG_RESULT(no)
889fi
890
891
892AC_MSG_CHECKING(if you want to do a profile build)
893AC_ARG_ENABLE(profile,
894AC_HELP_STRING([--enable-profile],[Enable profiling]),
895[profile=$enableval], [profile=no])
896
897if test "$profile" = yes; then
898 if test "$ac_cv_c_compiler_gnu" = yes; then
899 IRC_CFLAGS="$IRC_CFLAGS -pg"
900 AC_MSG_RESULT([yes, adding -pg])
901 AC_DEFINE(CHARYBDIS_PROFILE, 1, [Define this if you are profiling.])
902 else
903 AC_MSG_RESULT([no, profile builds only work with gcc])
904 fi
905else
906 AC_MSG_RESULT(no)
907fi
908
909AC_ARG_ENABLE(balloc,
910AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
911[balloc=$enableval], [balloc=yes])
912
913if test "$balloc" = no; then
914 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
915fi
916
212380e3
AC
917AC_ARG_ENABLE(small-net,
918AC_HELP_STRING([--enable-small-net],[Enable small network support.]),
919[small_net=$enableval], [small_net=no])
920
921if test "$small_net" = yes; then
922dnl AC_DEFINE([HASHSIZE], 4096, [Max number of buckets in hash tables.])
923 AC_DEFINE([NICKNAMEHISTORYLENGTH], 1500, [Size of the WHOWAS array.])
924 AC_DEFINE([CHANNEL_HEAP_SIZE], 256, [Size of the channel heap.])
925 AC_DEFINE([BAN_HEAP_SIZE], 128, [Size of the ban heap.])
926 AC_DEFINE([CLIENT_HEAP_SIZE], 256, [Size of the client heap.])
927 AC_DEFINE([LCLIENT_HEAP_SIZE], 128, [Size of the local client heap.])
928 AC_DEFINE([PCLIENT_HEAP_SIZE], 32, [Size of the pre-client heap.])
929 AC_DEFINE([USER_HEAP_SIZE], 128, [Size of the user heap.])
930 AC_DEFINE([DNODE_HEAP_SIZE], 256, [Size of the dlink_node heap.])
931 AC_DEFINE([TOPIC_HEAP_SIZE], 256, [Size of the topic heap.])
932 AC_DEFINE([LINEBUF_HEAP_SIZE], 128, [Size of the linebuf heap.])
933 AC_DEFINE([MEMBER_HEAP_SIZE], 256, [Sizeof member heap.])
934 AC_DEFINE([ND_HEAP_SIZE], 128, [Size of the nick delay heap.])
935 AC_DEFINE([CONFITEM_HEAP_SIZE], 128, [Size of the confitem heap.])
936 AC_DEFINE([MONITOR_HEAP_SIZE], 128, [Size of the monitor heap.])
ce923338 937 AC_DEFINE([FD_HEAP_SIZE], 128, [Size of fd heap.])
bc5f6d5b 938 AC_DEFINE([AWAY_HEAP_SIZE], 128, [Size of away heap.])
212380e3
AC
939else
940dnl These settings are for a large network like efnet..they will use lots of memory
941dnl so enable small net unless you really need this much support
942 AC_DEFINE([NICKNAMEHISTORYLENGTH], 15000, [Size of the WHOWAS array.])
943 AC_DEFINE([CHANNEL_HEAP_SIZE], 8192, [Size of the channel heap.])
944 AC_DEFINE([BAN_HEAP_SIZE], 4096, [Size of the ban heap.])
945 AC_DEFINE([CLIENT_HEAP_SIZE], 8192, [Size of the client heap.])
946 AC_DEFINE([LCLIENT_HEAP_SIZE], 1024, [Size of the local client heap.])
947 AC_DEFINE([PCLIENT_HEAP_SIZE], 256, [Size of the pre-client heap.])
948 AC_DEFINE([USER_HEAP_SIZE], 8192, [Size of the user heap.])
949 AC_DEFINE([DNODE_HEAP_SIZE], 8192, [Size of the dlink_node heap.])
950 AC_DEFINE([TOPIC_HEAP_SIZE], 4096, [Size of the topic heap.])
951 AC_DEFINE([LINEBUF_HEAP_SIZE], 2048, [Size of the linebuf heap.])
952 AC_DEFINE([MEMBER_HEAP_SIZE], 32768, [Sizeof member heap.])
953 AC_DEFINE([ND_HEAP_SIZE], 512, [Size of the nick delay heap.])
954 AC_DEFINE([CONFITEM_HEAP_SIZE], 256, [Size of the confitem heap.])
955 AC_DEFINE([MONITOR_HEAP_SIZE], 1024, [Size of the monitor heap.])
ce923338 956 AC_DEFINE([FD_HEAP_SIZE], 1024, [Size of fd heap.])
bc5f6d5b 957 AC_DEFINE([AWAY_HEAP_SIZE], 512, [Size of away heap.])
212380e3
AC
958fi
959
960AC_ARG_WITH(nicklen,
b225bf93 961AC_HELP_STRING([--with-nicklen=LENGTH],[Set the upper-bound nick length to LENGTH (default 31, max 50)]),
212380e3 962[
f173c7d8
JT
963 if ! expr "$withval" + 0 >/dev/null 2>&1; then
964 AC_ERROR([NICKLEN must be a numeric value])
965 fi
ca8ff483 966 if test $withval -gt 50; then
212380e3
AC
967 NICKLEN=50
968 AC_MSG_WARN([NICKLEN has a hard limit of 50. Setting NICKLEN=50])
ca8ff483
JT
969 elif test $withval -lt 9; then
970 NICKLEN=9
971 AC_MSG_WARN([NICKLEN has a lower limit of 9. Setting NICKLEN=9])
212380e3
AC
972 else
973 NICKLEN="$withval"
974 fi
b225bf93 975], [NICKLEN=31])
212380e3
AC
976
977AC_ARG_WITH(topiclen,
978AC_HELP_STRING([--with-topiclen=NUMBER],[Set the max topic length to NUMBER (default 390, max 390)]),
979[
980 if test $withval -ge 390; then
981 TOPICLEN=390
982 AC_MSG_WARN([TOPICLEN has a hard limit of 390. Setting TOPICLEN=390])
983 else
984 TOPICLEN=$withval
985 fi
986], [TOPICLEN=390])
987
212380e3
AC
988AC_DEFINE_UNQUOTED(TOPICLEN, ${TOPICLEN}, [Maximum topic length (<=390)])
989AC_DEFINE_UNQUOTED(NICKLEN, (${NICKLEN}+1), [Nickname length])
212380e3 990
f13494df 991shared_modules="yes"
212380e3
AC
992dnl Some first-stage sanity checks.
993if test "$shared_modules" = yes; then
212380e3
AC
994 dnl TenDRA's cc is called tcc too.
995 if test "$CC" = tcc -a "$TenDRA" = "no"; then
996 AC_MSG_WARN([disabling shared modules: Tiny C Compiler can't create PIC])
997 shared_modules="no"
998 fi
999fi
1000
1001dnl Second stage: check for functions and headers.
1002if test "$shared_modules" = yes; then
1003 DYNLINK_C=dynlink.c
1004 AC_CHECK_HEADERS(dlfcn.h)
1005 AC_SEARCH_LIBS(shl_load, dld,
1006 [
1007 AC_DEFINE(HAVE_SHL_LOAD, 1, [Define if the shl_load function is available.])
1008 SUFFIX=".sl"
1009 MOD_TARGET=hpux_shared
1010 SEDOBJ="s/\.o/.sl/g"
1011 ],
1012 dnl !shl_load:
1013 [
1014 dnl standard dlopen
1015 AC_SEARCH_LIBS(dlopen, [dl c_r],
1016 [
1017 AC_DEFINE(HAVE_DLOPEN, 1, [Define if the dlopen function is available.])
1018 SUFFIX=".so"
1019 MOD_TARGET=shared_modules
1020 SEDOBJ="s/\.o/.so/g"
1021 if test "$AppleGCC" = yes; then
1022 AC_CHECK_HEADERS([mach-o/dyld.h])
1023 fi
1024 AC_CHECK_FUNC(dlsym, ,
1025 [
1026 AC_MSG_WARN([dlsym is not available, shared modules disabled])
1027 shared_modules=no
1028 ])
1029 AC_CHECK_FUNCS(dlfunc)
1030 ],
1031 [
1032 shared_modules=no
1033 ])
1034 ])
1035fi
1036
1037AC_DEFINE_UNQUOTED(SHARED_SUFFIX, "$SUFFIX", [Suffix for shared libraries on this platform.])
1038
1039dnl Third stage - wrangling the linker.
1040if test "$shared_modules" = yes; then
1041 # The GNU linker requires the -export-dynamic option to make
1042 # all symbols visible in the dynamic symbol table.
1043 hold_ldflags=$LDFLAGS
1044 AC_MSG_CHECKING(for the ld -export-dynamic flag)
1045 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic -Werror"
1046 AC_LINK_IFELSE(AC_LANG_PROGRAM([],[int i;]), found=yes, found=no)
1047 LDFLAGS=$hold_ldflags
1048
1049 if expr "`uname -s`" : ^IRIX >/dev/null 2>&1; then
1050 found="no, IRIX ld uses -B,dynamic"
1051 LDFLAGS="${LDFLAGS} -Wl,-B,dynamic"
1052 fi
1053
1054 if expr "`uname -s`" : ^AIX >/dev/null 2>&1; then
1055 found="no, AIX ld uses -G -brtl"
1056 LDFLAGS="${LDFLAGS} -Wl,-G,-brtl"
1057 fi
1058
1059 AC_MSG_RESULT($found)
1060
1061 if test "$found" = yes; then
1062 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
1063 fi
1064
1065 AC_MSG_CHECKING(for compiler option to produce PIC)
1066 dnl The order should be here to check for groups of compilers,
1067 dnl then for odd compilers, then if no PICFLAGS were set up,
1068 dnl check for GCC and set defaults, or else error. -jmallett
1069 if test "$SGS" = "yes"; then
1070 AC_MSG_RESULT([SVR4 SGS interfaces: -KPIC -DPIC -G])
1071 PICFLAGS="-KPIC -DPIC -G"
1072 fi
1073
1074 if test "$AppleGCC" = "yes"; then
1075 AC_MSG_RESULT([Darwin Mach-O bundles: -fno-common -bundle -flat_namespace -undefined suppress])
1076 PICFLAGS="-fno-common -bundle -flat_namespace -undefined suppress"
1077 fi
1078 dnl Please note, that on HPUX two different stages of module compilation occurs, since
1079 dnl while compiling modules, the compiler does not allow you to give arguments
1080 dnl to the linker. (I did not design this)
1081 dnl So we need -c in the first stage of module compilation.
1082 dnl In the second stage, we link the modules via ld -b.
1083 dnl Additionally, HPUX does not like -export-dynamic, it likes -E instead.
1084 dnl -TimeMr14C
1085 if test "$HPUX" = "yes" -a "$CC" != gcc; then
1086 AC_MSG_RESULT(HP-UX cc: +z -r -q -n)
1087 PICFLAGS="+z -r -q -n -c"
1088 AC_MSG_CHECKING([if +ESfic is required on this platform])
1089
1090 if expr "`$CC +ESfic 2>&1`" : ".*neither supported.*" >/dev/null; then
1091 AC_MSG_RESULT(no)
1092 else
1093 AC_MSG_RESULT(yes)
1094 PICFLAGS="$PICFLAGS +ESfic"
1095 fi
1096
1097 LDFLAGS="${LDFLAGS} -Wl,-E"
1098 fi
1099 if test "$Tru" = yes -a "$CC" != gcc; then
1100 AC_MSG_RESULT([Tru64: -shared -expect_unresolved '*'])
1101 PICFLAGS="-shared -expect_unresolved '*' "
1102 LDFLAGS="-call_shared"
1103 fi
1104 if test -z "$PICFLAGS"; then
1105 if test "$ac_cv_c_compiler_gnu" = "yes"; then
1106 AC_MSG_RESULT(gcc: -fPIC -DPIC -shared)
1107 PICFLAGS="-fPIC -DPIC -shared"
1108 else
1109 AC_MSG_RESULT(no)
1110 shared_modules=no
1111 fi
1112 fi
1113fi
1114
794816af
JT
1115# rpath, for finding libratbox.so at run time
1116hold_ldflags=$LDFLAGS
1117AC_MSG_CHECKING(for the ld -rpath flag)
1118LDFLAGS="${LDFLAGS} -Wl,-rpath=${libdir}"
1119AC_LINK_IFELSE(AC_LANG_PROGRAM([],[int i;]), found=yes, found=no)
1120LDFLAGS=$hold_ldflags
1121AC_MSG_RESULT($found)
1122if test "$found" = yes; then
1123 LDFLAGS="${LDFLAGS} -Wl,-rpath=\${libdir}"
1124fi
1125
212380e3
AC
1126# This must be down here, or it will mess up checks like the ones
1127# for -Wl,-export-dynamic
1128# -- jilles
97199fb3 1129CWARNS=""
212380e3
AC
1130AC_ARG_ENABLE(warnings,
1131AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
1132[
1133IRC_CFLAGS="$IRC_CFLAGS -O0"
1134CFLAGS="$IRC_CFLAGS"
1135
1136CHARYBDIS_C_GCC_TRY_FLAGS([-Wall], charybdis_cv_c_gcc_w_all)
1137CHARYBDIS_C_GCC_TRY_FLAGS([-Wpointer-arith], charybdis_cv_c_gcc_w_pointer_arith)
1138CHARYBDIS_C_GCC_TRY_FLAGS([-Wimplicit -Wnested-externs], charybdis_cv_c_gcc_w_implicit)
1139CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-align], charybdis_cv_c_gcc_w_cast_align)
1140CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-qual], charybdis_cv_c_gcc_w_cast_qual)
c0e90a8e
JT
1141CHARYBDIS_C_GCC_TRY_FLAGS([-Wwrite-strings], charybdis_cv_c_gcc_w_write_strings)
1142CHARYBDIS_C_GCC_TRY_FLAGS([-Werror-implicit-function-declaration], charybdis_cv_c_gcc_w_error_implicit_function_declaration)
212380e3
AC
1143CHARYBDIS_C_GCC_TRY_FLAGS([-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations], charybdis_cv_c_gcc_prototypes)
1144CHARYBDIS_C_GCC_TRY_FLAGS([-Wparenthesis], charybdis_cv_c_gcc_parenthesis)
1145CHARYBDIS_C_GCC_TRY_FLAGS([-W -Wno-unused], charybdis_cv_c_gcc_w)
1146CHARYBDIS_C_GCC_TRY_FLAGS([-Wextra], charybdis_cv_c_gcc_w_extra)
1147CHARYBDIS_C_GCC_TRY_FLAGS([-Wshadow], charybdis_cv_c_gcc_w_shadow)
1148CHARYBDIS_C_GCC_TRY_FLAGS([-Wmissing-noreturn], charybdis_cv_c_gcc_w_missing_noreturn)
1149CHARYBDIS_C_GCC_TRY_FLAGS([-Wundef], charybdis_cv_c_gcc_w_undef)
1150CHARYBDIS_C_GCC_TRY_FLAGS([-Wpacked], charybdis_cv_c_gcc_w_packed)
1151CHARYBDIS_C_GCC_TRY_FLAGS([-Wnested-externs], charybdis_cv_c_gcc_w_nested_externs)
212380e3
AC
1152CHARYBDIS_C_GCC_TRY_FLAGS([-Wunused-function -Wunused-label -Wunused-value -Wunused-variable], charybdis_cv_c_gcc_w_unused)
1153CHARYBDIS_C_GCC_TRY_FLAGS([-Wredundant-decls], charybdis_cv_c_gcc_w_redundant_decls)
1154CHARYBDIS_C_GCC_TRY_FLAGS([-Wfloat-equal], charybdis_cv_c_gcc_w_float_equal)
f9a9ffac 1155CHARYBDIS_C_GCC_TRY_FLAGS([-Wformat -Wformat-y2k -Wno-format-security], charybdis_cv_c_gcc_w_format)
212380e3
AC
1156
1157IRC_CFLAGS="$CFLAGS"
1158],[])
1159
1160if test "$shared_modules" = no; then
1161 DYNLINK_C=""
1162 MOD_TARGET="libmodules.a"
1163 MODULES_LIBS="../modules/libmodules.a"
1164 SEDOBJ=""
1165 AC_DEFINE(STATIC_MODULES, 1, [Define to 1 if dynamic modules can't be used.])
1166 AC_MSG_WARN([shared module support has been disabled!])
1167fi
1168
1169dnl Stage 5 - underscores in front of symbol names.
1170if test "$shared_modules" = yes; then
1171
1172 AC_CHECK_FUNC(nlist,,
1173 AC_CHECK_LIB(dl, nlist, nlist_lib="-ldl",
1174 AC_CHECK_LIB(elf, nlist, nlist_lib="-lelf",)
1175 )
1176 )
1177
1178 dnl We need to find out whether underscores are appended to symbol
1179 dnl names in executable files. First, though, we need to see
1180 dnl where nlist.h is hiding.
1181 AC_CHECK_HEADER(libelf/nlist.h, [ nlist_h="libelf/nlist.h" ], )
1182 AC_CHECK_HEADER(elf/nlist.h, [ nlist_h="elf/nlist.h" ], )
1183 AC_CHECK_HEADER(nlist.h, [ nlist_h="nlist.h" ], )
1184 if test x"$nlist_h" = "x"; then
1185 AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "", [String containing extra underscores prepended to symbols loaded from modules.])
1186 else
1187 AC_MSG_CHECKING(for extra underscores prepended to symbol names)
1188 AC_CACHE_VAL(symbol_underscores,
1189 [
1190cat << EOF > conftest.c
1191#include <$nlist_h>
1192#include <stdio.h>
1193#include <stdlib.h>
1194void _modinit(void);
1195int main(int argc, char *argv[[]]) {
1196 int i;
1197 struct nlist nl[[5]];
1198
1199 /* fill the names in this way, so it'll work almost everywhere */
1200 nl[[0]].n_name = "_modinit";
1201 nl[[1]].n_name = "__modinit";
1202 nl[[2]].n_name = "___modinit";
1203 nl[[3]].n_name = "____modinit";
1204 nl[[0]].n_value = nl[[1]].n_value = nl[[2]].n_value = nl[[3]].n_value = nl[[4]].n_name = NULL;
1205
1206 if(argc < 2 || (nlist(argv[[1]], nl)) == -1) exit(-1);
1207 for(i = 0; i < 4; i++) {
1208 if(nl[[i]].n_value != NULL)
1209 {
1210 int j;
1211 for(j = 0; j < i; j++)
1212 printf("_");
1213 exit(i);
1214 }
1215 }
1216 exit(-1);
1217}
1218void _modinit(void) { return; }
1219EOF
1220 $CC $CPPFLAGS $IRC_CFLAGS -o conftest conftest.c $nlist_lib >/dev/null 2>&1
1221 symbol_underscores=`./conftest conftest`
1222 AC_MSG_RESULT($symbol_underscores)
1223 $RM -f conftest conftest.c
1224 ])
1225 AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "${symbol_underscores}", [String containing extra underscores prepended to symbols loaded from modules.])
1226 fi
1227fi
1228
97199fb3
JT
1229IRC_CFLAGS="$IRC_CFLAGS $CWARNS"
1230
212380e3
AC
1231AC_SUBST(MODULES_LIBS)
1232AC_SUBST(MOD_TARGET)
1233
1234AC_SUBST(SSL_SRCS_ENABLE)
1235AC_SUBST(SSL_INCLUDES)
1236AC_SUBST(SSL_LIBS)
1237
1238AC_SUBST(LDFLAGS)
1239AC_SUBST(PICFLAGS)
1240AC_SUBST(IRC_CFLAGS)
1241AC_SUBST(SEDOBJ)
1242
1243
1244if test "$prefix" = "NONE"; then
1245 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$ac_default_prefix", [Prefix where the ircd is installed.])
1246
1247else
1248
1249dnl Don't get bitten by Cygwin's stupidity if the user specified
1250dnl a custom prefix with a trailing slash
1251
1252 prefix=`echo $prefix | sed 's/\/$//'`
1253 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$prefix", [Prefix where the ircd is installed.])
1254
1255fi
1256
1257AC_CONFIG_FILES( \
1258 Makefile \
734ce253 1259 bandb/Makefile \
d261b578 1260 ssld/Makefile \
212380e3 1261 extensions/Makefile \
212380e3
AC
1262 src/Makefile \
1263 modules/Makefile \
1264 tools/Makefile \
14048b96 1265 tools/genssl \
212380e3
AC
1266 doc/Makefile \
1267 help/Makefile \
1268)
14048b96 1269AC_CONFIG_COMMANDS([tools/genssl_chmod], [chmod 755 tools/genssl])
212380e3
AC
1270
1271AC_OUTPUT
1272
1273if test "$cf_openssl_version_ok" = yes; then
1274 openssl="yes"
1275else
1276 openssl="no"
1277fi
1278
1279if test "$shared_modules" = yes; then
1280 modules=shared
1281else
1282 modules=static
1283fi
1284
1285echo "
b6d0720c 1286Configuration of ${BRANDING_NAME}-${BRANDING_VERSION}:
212380e3
AC
1287 Install directory : $prefix
1288
1289 Ziplinks : $zlib
1290 OpenSSL : $openssl
212380e3
AC
1291 Socket Engine : $SELECT_TYPE
1292 Small network : $small_net
1293 Block allocator : $balloc
212380e3
AC
1294
1295 Nickname length : $NICKLEN
1296 Topic length : $TOPICLEN
1297
b6d0720c 1298Use (g)make to compile $BRANDING_NAME, then (g)make install to install it.
212380e3 1299"