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 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
23 # -- Templates for config.h --
25 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
26 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
27 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
28 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
29 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
30 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
31 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
32 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
33 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
34 AH_TEMPLATE([ZEROCONF], [Define if support for Zeroconf should be included])
35 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
37 AH_TEMPLATE([TARGET_OS], [Target operating system name])
38 AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
39 AH_TEMPLATE([TARGET_CPU], [Target CPU name])
45 # -- Helper programs --
53 # -- Compiler Features --
59 # -- Hard coded system and compiler dependencies/features/options ... --
61 AC_DEFUN([GCC_STACK_PROTECT_CC],[
63 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
64 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
65 ssp_old_cflags="$CFLAGS"
66 CFLAGS="$CFLAGS -fstack-protector-all"
67 AC_TRY_LINK(,,, ssp_cc=no)
69 CFLAGS="$ssp_old_cflags"
70 if test "X$ssp_cc" = "Xyes"; then
71 CFLAGS="$CFLAGS -fstack-protector"
72 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
77 if test "$GCC" = "yes"; then
78 # We are using the GNU C compiler. Good!
79 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
86 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
87 # (tested with HP/UX 11.11)
88 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
92 # Add additional CFLAGS, eventually specified on the command line:
93 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
95 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
104 ctype.h errno.h fcntl.h netdb.h netinet/in.h stdlib.h string.h \
105 strings.h sys/socket.h sys/time.h unistd.h \
106 ],,AC_MSG_ERROR([required C header missing!]))
108 AC_CHECK_HEADERS([arpa/inet.h ctype.h malloc.h stdbool.h stddef.h varargs.h])
112 AC_MSG_CHECKING(whether socklen_t exists)
114 #include <sys/types.h>
115 #include <sys/socket.h>
118 a = 2; b = 4; a += b;
120 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
131 AC_CHECK_LIB(UTIL,memmove)
132 AC_CHECK_LIB(socket,bind)
133 AC_CHECK_LIB(nsl,gethostent)
141 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
142 setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
144 AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strdup strlcpy strlcat strtok_r)
146 # -- Configuration options --
152 [ --without-syslog disable syslog (autodetected by default)],
153 [ if test "$withval" != "no"; then
154 if test "$withval" != "yes"; then
155 CFLAGS="-I$withval/include $CFLAGS"
156 CPPFLAGS="-I$withval/include $CPPFLAGS"
157 LDFLAGS="-L$withval/lib $LDFLAGS"
159 AC_CHECK_LIB(be, syslog)
160 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
161 AC_MSG_ERROR([Can't enable syslog!])
166 AC_CHECK_LIB(be, syslog)
167 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
170 if test "$x_syslog_on" = "yes"; then
172 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
175 # use zlib compression?
179 [ --without-zlib disable zlib compression (autodetected by default)],
180 [ if test "$withval" != "no"; then
181 if test "$withval" != "yes"; then
182 CFLAGS="-I$withval/include $CFLAGS"
183 CPPFLAGS="-I$withval/include $CPPFLAGS"
184 LDFLAGS="-L$withval/lib $LDFLAGS"
186 AC_CHECK_LIB(z, deflate)
187 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
188 AC_MSG_ERROR([Can't enable zlib!])
192 [ AC_CHECK_LIB(z, deflate)
193 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
196 if test "$x_zlib_on" = "yes"; then
198 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
201 # detect which IO API to use:
206 [ --without-select disable select IO support (autodetected by default)],
207 [ if test "$withval" != "no"; then
208 if test "$withval" != "yes"; then
209 CFLAGS="-I$withval/include $CFLAGS"
210 CPPFLAGS="-I$withval/include $CPPFLAGS"
211 LDFLAGS="-L$withval/lib $LDFLAGS"
213 AC_CHECK_FUNCS(select, x_io_select=yes,
214 AC_MSG_ERROR([Can't enable select IO support!])
219 AC_CHECK_FUNCS(select, x_io_select=yes)
224 [ --without-poll disable poll support (autodetected by default)],
225 [ if test "$withval" != "no"; then
226 if test "$withval" != "yes"; then
227 CFLAGS="-I$withval/include $CFLAGS"
228 CPPFLAGS="-I$withval/include $CPPFLAGS"
229 LDFLAGS="-L$withval/lib $LDFLAGS"
231 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
232 AC_MSG_ERROR([Can't enable poll IO support!])
237 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
242 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
243 [ if test "$withval" != "no"; then
244 if test "$withval" != "yes"; then
245 CFLAGS="-I$withval/include $CFLAGS"
246 CPPFLAGS="-I$withval/include $CPPFLAGS"
247 LDFLAGS="-L$withval/lib $LDFLAGS"
250 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
254 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
259 [ --without-epoll disable epoll IO support (autodetected by default)],
260 [ if test "$withval" != "no"; then
261 if test "$withval" != "yes"; then
262 CFLAGS="-I$withval/include $CFLAGS"
263 CPPFLAGS="-I$withval/include $CPPFLAGS"
264 LDFLAGS="-L$withval/lib $LDFLAGS"
266 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
267 AC_MSG_ERROR([Can't enable epoll IO support!])
272 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
277 [ --without-kqueue disable kqueue IO support (autodetected by default)],
278 [ if test "$withval" != "no"; then
279 if test "$withval" != "yes"; then
280 CFLAGS="-I$withval/include $CFLAGS"
281 CPPFLAGS="-I$withval/include $CPPFLAGS"
282 LDFLAGS="-L$withval/lib $LDFLAGS"
284 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
285 AC_MSG_ERROR([Can't enable kqueue IO support!])
290 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
294 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
295 # when epoll() and select() are available, we'll use both!
296 x_io_backend="epoll(), select()"
298 if test "$x_io_epoll" = "yes"; then
299 # we prefere epoll() if it is available
300 x_io_backend="epoll()"
302 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
303 # we'll use select, when available and no "better"
304 # interface has been detected ...
305 x_io_backend="select()"
310 if test "$x_io_backend" = "none"; then
311 AC_MSG_ERROR([No useabe IO API activated/found!?])
317 [ --with-openssl enable SSL support using OpenSSL],
318 [ if test "$withval" = "yes"; then
319 if test "$withval" != "yes"; then
320 CFLAGS="-I$withval/include $CFLAGS"
321 CPPFLAGS="-I$withval/include $CPPFLAGS"
322 LDFLAGS="-L$withval/lib $LDFLAGS"
324 AC_CHECK_LIB(crypto, BIO_s_mem)
325 AC_CHECK_LIB(ssl, SSL_library_init)
326 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
327 AC_MSG_ERROR([Can't enable openssl])
334 [ --with-gnutls enable SSL support using gnutls],
335 [ if test "$withval" = "yes"; then
336 if test "$withval" != "yes"; then
337 CFLAGS="-I$withval/include $CFLAGS"
338 CPPFLAGS="-I$withval/include $CPPFLAGS"
339 LDFLAGS="-L$withval/lib $LDFLAGS"
341 AC_CHECK_LIB(gnutls, gnutls_global_init)
342 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
343 AC_MSG_ERROR([Can't enable gnutls])
350 if test "$x_ssl_gnutls" = "yes"; then
351 if test "$x_ssl_openssl" = "yes";then
352 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
356 if test "$x_ssl_openssl" = "yes"; then
363 AC_ARG_WITH(tcp-wrappers,
364 [ --with-tcp-wrappers enable TCP wrappers support],
365 [ if test "$withval" != "no"; then
366 if test "$withval" != "yes"; then
367 CFLAGS="-I$withval/include $CFLAGS"
368 CPPFLAGS="-I$withval/include $CPPFLAGS"
369 LDFLAGS="-L$withval/lib $LDFLAGS"
371 AC_MSG_CHECKING(for hosts_access)
375 int allow_severity = 0;
376 int deny_severity = 0;
378 tcpd_warn("link test");
381 AC_DEFINE(TCPWRAP, 1)
385 AC_MSG_ERROR([Can't enable TCP wrappers!])
391 # include support for "zeroconf"?
394 AC_ARG_WITH(zeroconf,
395 [ --with-zeroconf enable support for "Zeroconf"],
396 [ if test "$withval" != "no"; then
397 if test "$withval" != "yes"; then
398 CFLAGS="-I$withval/include $CFLAGS"
399 CPPFLAGS="-I$withval/include $CPPFLAGS"
400 LDFLAGS="-L$withval/lib $LDFLAGS"
402 AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
404 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
405 AC_CHECK_LIB(howl, sw_discovery_init)
406 AC_CHECK_FUNCS(sw_discovery_init, \
407 x_zeroconf_on=howl, \
408 AC_MSG_ERROR([Can't enable Zeroconf!]))
413 if test "$x_zeroconf_on" = "osx"; then
414 AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
415 mach/port.h],,AC_MSG_ERROR([required C header missing!]))
416 AC_DEFINE(ZEROCONF, 1)
418 if test "$x_zeroconf_on" = "howl"; then
419 for dir in /usr/local/include /usr/local/include/howl* \
420 /usr/include /usr/include/howl* \
421 /usr/local/include/avahi* /usr/include/avahi*; do
422 test -d "$dir" || continue
423 AC_MSG_CHECKING([for Howl headers in $dir])
424 if test -f "$dir/rendezvous/rendezvous.h"; then
425 if test "$dir" != "/usr/local/include" -a \
426 "$dir" != "/usr/include"; then
427 CFLAGS="-I$dir $CFLAGS"
428 CPPFLAGS="-I$dir $CPPFLAGS"
436 AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
437 AC_MSG_ERROR([required C header missing!]))
438 AC_DEFINE(ZEROCONF, 1)
441 # do IDENT requests using libident?
445 [ --with-ident enable "IDENT" ("AUTH") protocol support],
446 [ if test "$withval" != "no"; then
447 if test "$withval" != "yes"; then
448 CFLAGS="-I$withval/include $CFLAGS"
449 CPPFLAGS="-I$withval/include $CPPFLAGS"
450 LDFLAGS="-L$withval/lib $LDFLAGS"
452 AC_CHECK_LIB(ident, ident_id)
453 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
454 AC_MSG_ERROR([Can't enable IDENT support!])
459 if test "$x_identauth_on" = "yes"; then
460 AC_DEFINE(IDENTAUTH, 1)
461 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
464 # compile in IRC+ protocol support?
467 AC_ARG_ENABLE(ircplus,
468 [ --disable-ircplus disable IRC+ protocol],
469 if test "$enableval" = "no"; then x_ircplus_on=no; fi
471 if test "$x_ircplus_on" = "yes"; then
472 AC_DEFINE(IRCPLUS, 1)
475 # enable support for IPv6?
478 [ --enable-ipv6 enable IPv6 protocol support],
479 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
481 if test "$x_ipv6_on" = "yes"; then
483 getaddrinfo getnameinfo \
484 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
485 AC_DEFINE(WANT_IPV6, 1)
488 # compile in IRC "sniffer"?
490 x_sniffer_on=no; x_debug_on=no
491 AC_ARG_ENABLE(sniffer,
492 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
493 if test "$enableval" = "yes"; then
494 AC_DEFINE(SNIFFER, 1)
495 x_sniffer_on=yes; x_debug_on=yes
499 # enable additional debugging code?
502 [ --enable-debug show additional debug output],
503 if test "$enableval" = "yes"; then x_debug_on=yes; fi
505 if test "$x_debug_on" = "yes"; then
507 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
508 AC_CHECK_FUNCS(mtrace)
511 # enable "strict RFC rules"?
514 AC_ARG_ENABLE(strict-rfc,
515 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
516 if test "$enableval" = "yes"; then
517 AC_DEFINE(STRICT_RFC, 1)
524 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
525 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
526 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
528 # Add additional CFLAGS, eventually specified on the command line, but after
529 # running this configure script. Useful for "-Werror" for example.
530 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
532 # -- Generate files --
539 src/portab/Makefile \
540 src/ipaddr/Makefile \
542 src/ngircd/Makefile \
543 src/testsuite/Makefile \
546 contrib/Debian/Makefile \
547 contrib/MacOSX/Makefile \
548 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
549 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
552 type dpkg >/dev/null 2>&1
553 if test $? -eq 0; then
554 # Generate debian/ link if the dpkg command exists
555 # (read: if we are running on a debian compatible system)
556 echo "creating Debian-specific links ..."
557 test -f debian/rules || ln -s contrib/Debian debian
563 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
566 # Someone please show me a better way :) [borrowed by OpenSSH]
567 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
568 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
569 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
570 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
571 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
573 echo " Target: ${target}"
574 test "$target" != "$host" && echo " Host: ${host}"
575 echo " Compiler: ${CC}"
576 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
577 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
578 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
579 test -n "$LIBS" && echo " Libraries: ${LIBS}"
581 echo " 'ngircd' binary: $S"
582 echo " Configuration file: $C"
583 echo " Manual pages: $M"
584 echo " Documentation: $D"
587 echo $ECHO_N " Syslog support: $ECHO_C"
588 test "$x_syslog_on" = "yes" \
589 && echo $ECHO_N "yes $ECHO_C" \
590 || echo $ECHO_N "no $ECHO_C"
591 echo $ECHO_N " Enable debug code: $ECHO_C"
592 test "$x_debug_on" = "yes" \
596 echo $ECHO_N " zlib compression: $ECHO_C"
597 test "$x_zlib_on" = "yes" \
598 && echo $ECHO_N "yes $ECHO_C" \
599 || echo $ECHO_N "no $ECHO_C"
600 echo $ECHO_N " IRC sniffer: $ECHO_C"
601 test "$x_sniffer_on" = "yes" \
605 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
606 test "$x_tcpwrap_on" = "yes" \
607 && echo $ECHO_N "yes $ECHO_C" \
608 || echo $ECHO_N "no $ECHO_C"
609 echo $ECHO_N " Strict RFC mode: $ECHO_C"
610 test "$x_strict_rfc_on" = "yes" \
614 echo $ECHO_N " Zeroconf support: $ECHO_C"
615 case "$x_zeroconf_on" in
617 echo $ECHO_N "Apple $ECHO_C"
620 echo $ECHO_N "Howl $ECHO_C"
623 echo $ECHO_N "no $ECHO_C"
626 echo $ECHO_N " IRC+ protocol: $ECHO_C"
627 test "$x_ircplus_on" = "yes" \
631 echo $ECHO_N " IDENT support: $ECHO_C"
632 test "$x_identauth_on" = "yes" \
633 && echo $ECHO_N "yes $ECHO_C" \
634 || echo $ECHO_N "no $ECHO_C"
635 echo $ECHO_N " I/O backend: $ECHO_C"
636 echo "\"$x_io_backend\""
638 echo $ECHO_N " IPv6 protocol: $ECHO_C"
639 echo $ECHO_N "$x_ipv6_on $ECHO_C"
641 echo $ECHO_N " SSL support: $ECHO_C"