2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2008 Alexander Barton <alex@barton.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 # Please read the file COPYING, README and AUTHORS for more information.
12 # -- Initialisation --
16 AC_CONFIG_SRCDIR(src/ngircd/ngircd.c)
19 AM_CONFIG_HEADER(src/config.h)
21 # -- Templates for config.h --
23 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
24 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
25 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
26 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
27 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
28 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
29 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
30 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
31 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
32 AH_TEMPLATE([ZEROCONF], [Define if support for Zeroconf should be included])
33 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
35 AH_TEMPLATE([TARGET_OS], [Target operating system name])
36 AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
37 AH_TEMPLATE([TARGET_CPU], [Target CPU name])
43 # -- Helper programs --
51 # -- Compiler Features --
57 # -- Hard coded system and compiler dependencies/features/options ... --
59 AC_DEFUN([GCC_STACK_PROTECT_CC],[
61 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
62 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
63 ssp_old_cflags="$CFLAGS"
64 CFLAGS="$CFLAGS -fstack-protector-all"
65 AC_TRY_LINK(,,, ssp_cc=no)
67 CFLAGS="$ssp_old_cflags"
68 if test "X$ssp_cc" = "Xyes"; then
69 CFLAGS="$CFLAGS -fstack-protector"
70 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
75 if test "$GCC" = "yes"; then
76 # We are using the GNU C compiler. Good!
77 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
84 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
85 # (tested with HP/UX 11.11)
86 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
90 # Add additional CFLAGS, eventually specified on the command line:
91 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
93 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
102 ctype.h errno.h fcntl.h netdb.h netinet/in.h stdlib.h string.h \
103 strings.h sys/socket.h sys/time.h unistd.h \
104 ],,AC_MSG_ERROR([required C header missing!]))
106 AC_CHECK_HEADERS([arpa/inet.h ctype.h malloc.h stdbool.h stddef.h varargs.h])
110 AC_MSG_CHECKING(whether socklen_t exists)
112 #include <sys/types.h>
113 #include <sys/socket.h>
116 a = 2; b = 4; a += b;
118 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
129 AC_CHECK_LIB(UTIL,memmove)
130 AC_CHECK_LIB(socket,bind)
131 AC_CHECK_LIB(nsl,gethostent)
139 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
140 setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
142 AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strdup strlcpy strlcat strtok_r)
144 # -- Configuration options --
150 [ --without-syslog disable syslog (autodetected by default)],
151 [ if test "$withval" != "no"; then
152 if test "$withval" != "yes"; then
153 CFLAGS="-I$withval/include $CFLAGS"
154 CPPFLAGS="-I$withval/include $CPPFLAGS"
155 LDFLAGS="-L$withval/lib $LDFLAGS"
157 AC_CHECK_LIB(be, syslog)
158 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
159 AC_MSG_ERROR([Can't enable syslog!])
164 AC_CHECK_LIB(be, syslog)
165 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
168 if test "$x_syslog_on" = "yes"; then
170 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
173 # use zlib compression?
177 [ --without-zlib disable zlib compression (autodetected by default)],
178 [ if test "$withval" != "no"; then
179 if test "$withval" != "yes"; then
180 CFLAGS="-I$withval/include $CFLAGS"
181 CPPFLAGS="-I$withval/include $CPPFLAGS"
182 LDFLAGS="-L$withval/lib $LDFLAGS"
184 AC_CHECK_LIB(z, deflate)
185 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
186 AC_MSG_ERROR([Can't enable zlib!])
190 [ AC_CHECK_LIB(z, deflate)
191 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
194 if test "$x_zlib_on" = "yes"; then
196 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
199 # detect which IO API to use:
204 [ --without-select disable select IO support (autodetected by default)],
205 [ if test "$withval" != "no"; then
206 if test "$withval" != "yes"; then
207 CFLAGS="-I$withval/include $CFLAGS"
208 CPPFLAGS="-I$withval/include $CPPFLAGS"
209 LDFLAGS="-L$withval/lib $LDFLAGS"
211 AC_CHECK_FUNCS(select, x_io_select=yes,
212 AC_MSG_ERROR([Can't enable select IO support!])
217 AC_CHECK_FUNCS(select, x_io_select=yes)
222 [ --without-poll disable poll support (autodetected by default)],
223 [ if test "$withval" != "no"; then
224 if test "$withval" != "yes"; then
225 CFLAGS="-I$withval/include $CFLAGS"
226 CPPFLAGS="-I$withval/include $CPPFLAGS"
227 LDFLAGS="-L$withval/lib $LDFLAGS"
229 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
230 AC_MSG_ERROR([Can't enable poll IO support!])
235 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
240 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
241 [ if test "$withval" != "no"; then
242 if test "$withval" != "yes"; then
243 CFLAGS="-I$withval/include $CFLAGS"
244 CPPFLAGS="-I$withval/include $CPPFLAGS"
245 LDFLAGS="-L$withval/lib $LDFLAGS"
248 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
252 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
257 [ --without-epoll disable epoll IO support (autodetected by default)],
258 [ if test "$withval" != "no"; then
259 if test "$withval" != "yes"; then
260 CFLAGS="-I$withval/include $CFLAGS"
261 CPPFLAGS="-I$withval/include $CPPFLAGS"
262 LDFLAGS="-L$withval/lib $LDFLAGS"
264 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
265 AC_MSG_ERROR([Can't enable epoll IO support!])
270 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
275 [ --without-kqueue disable kqueue IO support (autodetected by default)],
276 [ if test "$withval" != "no"; then
277 if test "$withval" != "yes"; then
278 CFLAGS="-I$withval/include $CFLAGS"
279 CPPFLAGS="-I$withval/include $CPPFLAGS"
280 LDFLAGS="-L$withval/lib $LDFLAGS"
282 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
283 AC_MSG_ERROR([Can't enable kqueue IO support!])
288 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
292 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
293 # when epoll() and select() are available, we'll use both!
294 x_io_backend="epoll(), select()"
296 if test "$x_io_epoll" = "yes"; then
297 # we prefere epoll() if it is available
298 x_io_backend="epoll()"
300 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
301 # we'll use select, when available and no "better"
302 # interface has been detected ...
303 x_io_backend="select()"
308 if test "$x_io_backend" = "none"; then
309 AC_MSG_ERROR([No useabe IO API activated/found!?])
315 [ --with-openssl enable SSL support using OpenSSL],
316 [ if test "$withval" = "yes"; then
317 if test "$withval" != "yes"; then
318 CFLAGS="-I$withval/include $CFLAGS"
319 CPPFLAGS="-I$withval/include $CPPFLAGS"
320 LDFLAGS="-L$withval/lib $LDFLAGS"
322 AC_CHECK_LIB(crypto, BIO_s_mem)
323 AC_CHECK_LIB(ssl, SSL_library_init)
324 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
325 AC_MSG_ERROR([Can't enable openssl])
332 [ --with-gnutls enable SSL support using gnutls],
333 [ if test "$withval" = "yes"; then
334 if test "$withval" != "yes"; then
335 CFLAGS="-I$withval/include $CFLAGS"
336 CPPFLAGS="-I$withval/include $CPPFLAGS"
337 LDFLAGS="-L$withval/lib $LDFLAGS"
339 AC_CHECK_LIB(gnutls, gnutls_global_init)
340 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
341 AC_MSG_ERROR([Can't enable gnutls])
348 if test "$x_ssl_gnutls" = "yes"; then
349 if test "$x_ssl_openssl" = "yes";then
350 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
354 if test "$x_ssl_openssl" = "yes"; then
361 AC_ARG_WITH(tcp-wrappers,
362 [ --with-tcp-wrappers enable TCP wrappers support],
363 [ if test "$withval" != "no"; then
364 if test "$withval" != "yes"; then
365 CFLAGS="-I$withval/include $CFLAGS"
366 CPPFLAGS="-I$withval/include $CPPFLAGS"
367 LDFLAGS="-L$withval/lib $LDFLAGS"
369 AC_MSG_CHECKING(for hosts_access)
373 int allow_severity = 0;
374 int deny_severity = 0;
376 tcpd_warn("link test");
379 AC_DEFINE(TCPWRAP, 1)
383 AC_MSG_ERROR([Can't enable TCP wrappers!])
389 # include support for "zeroconf"?
392 AC_ARG_WITH(zeroconf,
393 [ --with-zeroconf enable support for "Zeroconf"],
394 [ if test "$withval" != "no"; then
395 if test "$withval" != "yes"; then
396 CFLAGS="-I$withval/include $CFLAGS"
397 CPPFLAGS="-I$withval/include $CPPFLAGS"
398 LDFLAGS="-L$withval/lib $LDFLAGS"
400 AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
402 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
403 AC_CHECK_LIB(howl, sw_discovery_init)
404 AC_CHECK_FUNCS(sw_discovery_init, \
405 x_zeroconf_on=howl, \
406 AC_MSG_ERROR([Can't enable Zeroconf!]))
411 if test "$x_zeroconf_on" = "osx"; then
412 AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
413 mach/port.h],,AC_MSG_ERROR([required C header missing!]))
414 AC_DEFINE(ZEROCONF, 1)
416 if test "$x_zeroconf_on" = "howl"; then
417 for dir in /usr/local/include /usr/local/include/howl* \
418 /usr/include /usr/include/howl* \
419 /usr/local/include/avahi* /usr/include/avahi*; do
420 test -d "$dir" || continue
421 AC_MSG_CHECKING([for Howl headers in $dir])
422 if test -f "$dir/rendezvous/rendezvous.h"; then
423 if test "$dir" != "/usr/local/include" -a \
424 "$dir" != "/usr/include"; then
425 CFLAGS="-I$dir $CFLAGS"
426 CPPFLAGS="-I$dir $CPPFLAGS"
434 AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
435 AC_MSG_ERROR([required C header missing!]))
436 AC_DEFINE(ZEROCONF, 1)
439 # do IDENT requests using libident?
443 [ --with-ident enable "IDENT" ("AUTH") protocol support],
444 [ if test "$withval" != "no"; then
445 if test "$withval" != "yes"; then
446 CFLAGS="-I$withval/include $CFLAGS"
447 CPPFLAGS="-I$withval/include $CPPFLAGS"
448 LDFLAGS="-L$withval/lib $LDFLAGS"
450 AC_CHECK_LIB(ident, ident_id)
451 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
452 AC_MSG_ERROR([Can't enable IDENT support!])
457 if test "$x_identauth_on" = "yes"; then
458 AC_DEFINE(IDENTAUTH, 1)
459 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
462 # compile in IRC+ protocol support?
465 AC_ARG_ENABLE(ircplus,
466 [ --disable-ircplus disable IRC+ protocol],
467 if test "$enableval" = "no"; then x_ircplus_on=no; fi
469 if test "$x_ircplus_on" = "yes"; then
470 AC_DEFINE(IRCPLUS, 1)
473 # enable support for IPv6?
476 [ --enable-ipv6 enable IPv6 protocol support],
477 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
479 if test "$x_ipv6_on" = "yes"; then
481 getaddrinfo getnameinfo \
482 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
483 AC_DEFINE(WANT_IPV6, 1)
486 # compile in IRC "sniffer"?
488 x_sniffer_on=no; x_debug_on=no
489 AC_ARG_ENABLE(sniffer,
490 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
491 if test "$enableval" = "yes"; then
492 AC_DEFINE(SNIFFER, 1)
493 x_sniffer_on=yes; x_debug_on=yes
497 # enable additional debugging code?
500 [ --enable-debug show additional debug output],
501 if test "$enableval" = "yes"; then x_debug_on=yes; fi
503 if test "$x_debug_on" = "yes"; then
505 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
506 AC_CHECK_FUNCS(mtrace)
509 # enable "strict RFC rules"?
512 AC_ARG_ENABLE(strict-rfc,
513 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
514 if test "$enableval" = "yes"; then
515 AC_DEFINE(STRICT_RFC, 1)
522 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
523 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
524 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
526 # Add additional CFLAGS, eventually specified on the command line, but after
527 # running this configure script. Useful for "-Werror" for example.
528 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
530 # -- Generate files --
537 src/portab/Makefile \
538 src/ipaddr/Makefile \
540 src/ngircd/Makefile \
541 src/testsuite/Makefile \
544 contrib/Debian/Makefile \
545 contrib/MacOSX/Makefile \
546 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
547 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
550 type dpkg >/dev/null 2>&1
551 if test $? -eq 0; then
552 # Generate debian/ link if the dpkg command exists
553 # (read: if we are running on a debian compatible system)
554 echo "creating Debian-specific links ..."
555 test -f debian/rules || ln -s contrib/Debian debian
561 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
564 # Someone please show me a better way :) [borrowed by OpenSSH]
565 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
566 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
567 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
568 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
569 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
571 echo " Target: ${target}"
572 test "$target" != "$host" && echo " Host: ${host}"
573 echo " Compiler: ${CC}"
574 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
575 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
576 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
577 test -n "$LIBS" && echo " Libraries: ${LIBS}"
579 echo " 'ngircd' binary: $S"
580 echo " Configuration file: $C"
581 echo " Manual pages: $M"
582 echo " Documentation: $D"
585 echo $ECHO_N " Syslog support: $ECHO_C"
586 test "$x_syslog_on" = "yes" \
587 && echo $ECHO_N "yes $ECHO_C" \
588 || echo $ECHO_N "no $ECHO_C"
589 echo $ECHO_N " Enable debug code: $ECHO_C"
590 test "$x_debug_on" = "yes" \
594 echo $ECHO_N " zlib compression: $ECHO_C"
595 test "$x_zlib_on" = "yes" \
596 && echo $ECHO_N "yes $ECHO_C" \
597 || echo $ECHO_N "no $ECHO_C"
598 echo $ECHO_N " IRC sniffer: $ECHO_C"
599 test "$x_sniffer_on" = "yes" \
603 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
604 test "$x_tcpwrap_on" = "yes" \
605 && echo $ECHO_N "yes $ECHO_C" \
606 || echo $ECHO_N "no $ECHO_C"
607 echo $ECHO_N " Strict RFC mode: $ECHO_C"
608 test "$x_strict_rfc_on" = "yes" \
612 echo $ECHO_N " Zeroconf support: $ECHO_C"
613 case "$x_zeroconf_on" in
615 echo $ECHO_N "Apple $ECHO_C"
618 echo $ECHO_N "Howl $ECHO_C"
621 echo $ECHO_N "no $ECHO_C"
624 echo $ECHO_N " IRC+ protocol: $ECHO_C"
625 test "$x_ircplus_on" = "yes" \
629 echo $ECHO_N " IDENT support: $ECHO_C"
630 test "$x_identauth_on" = "yes" \
631 && echo $ECHO_N "yes $ECHO_C" \
632 || echo $ECHO_N "no $ECHO_C"
633 echo $ECHO_N " I/O backend: $ECHO_C"
634 echo "\"$x_io_backend\""
636 echo $ECHO_N " IPv6 protocol: $ECHO_C"
637 echo $ECHO_N "$x_ipv6_on $ECHO_C"
639 echo $ECHO_N " SSL support: $ECHO_C"