2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2010 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 --
15 AC_INIT(ngircd, 17~rc1)
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])
36 AH_TEMPLATE([PAM], [Define if PAM should be used])
37 AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
39 AH_TEMPLATE([TARGET_OS], [Target operating system name])
40 AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
41 AH_TEMPLATE([TARGET_CPU], [Target CPU name])
48 # -- Helper programs --
56 # -- Compiler Features --
62 # -- Hard coded system and compiler dependencies/features/options ... --
64 AC_DEFUN([GCC_STACK_PROTECT_CC],[
66 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
67 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
68 ssp_old_cflags="$CFLAGS"
69 CFLAGS="$CFLAGS -fstack-protector-all"
70 AC_TRY_LINK(,,, ssp_cc=no)
72 CFLAGS="$ssp_old_cflags"
73 if test "X$ssp_cc" = "Xyes"; then
74 CFLAGS="$CFLAGS -fstack-protector"
75 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
79 if test "$GCC" = "yes"; then
80 # We are using the GNU C compiler. Good!
81 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
88 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
89 # (tested with HP/UX 11.11)
90 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
94 # Add additional CFLAGS, eventually specified on the command line:
95 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
97 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
106 ctype.h errno.h fcntl.h netdb.h netinet/in.h netinet/in_systm.h \
107 stdlib.h string.h strings.h sys/socket.h sys/time.h unistd.h \
108 ],,AC_MSG_ERROR([required C header missing!]))
111 arpa/inet.h ctype.h malloc.h netinet/ip.h stdbool.h stddef.h varargs.h \
113 #ifdef HAVE_SYS_TYPES_H
114 #include <sys/types.h>
116 #ifdef HAVE_SYS_SOCKET_H
117 #include <sys/socket.h>
119 #ifdef HAVE_NETINET_IN_H
120 #include <netinet/in.h>
127 AC_MSG_CHECKING(whether socklen_t exists)
129 #include <sys/types.h>
130 #include <sys/socket.h>
133 a = 2; b = 4; a += b;
135 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
143 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
144 [#include <arpa/inet.h>])
149 AC_CHECK_LIB(UTIL,memmove)
150 # needed on solaris. GNU libc also has a libnsl, but we do not need it.
151 AC_SEARCH_LIBS(gethostbyname,nsl)
152 AC_CHECK_LIB(socket,bind)
160 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
161 setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
163 AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction sigprocmask snprintf \
164 vsnprintf strdup strlcpy strlcat strtok_r)
166 # -- Configuration options --
172 [ --without-syslog disable syslog (autodetected by default)],
173 [ if test "$withval" != "no"; then
174 if test "$withval" != "yes"; then
175 CFLAGS="-I$withval/include $CFLAGS"
176 CPPFLAGS="-I$withval/include $CPPFLAGS"
177 LDFLAGS="-L$withval/lib $LDFLAGS"
179 AC_CHECK_LIB(be, syslog)
180 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
181 AC_MSG_ERROR([Can't enable syslog!])
186 AC_CHECK_LIB(be, syslog)
187 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
190 if test "$x_syslog_on" = "yes"; then
192 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
195 # use zlib compression?
199 [ --without-zlib disable zlib compression (autodetected by default)],
200 [ if test "$withval" != "no"; then
201 if test "$withval" != "yes"; then
202 CFLAGS="-I$withval/include $CFLAGS"
203 CPPFLAGS="-I$withval/include $CPPFLAGS"
204 LDFLAGS="-L$withval/lib $LDFLAGS"
206 AC_CHECK_LIB(z, deflate)
207 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
208 AC_MSG_ERROR([Can't enable zlib!])
212 [ AC_CHECK_LIB(z, deflate)
213 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
216 if test "$x_zlib_on" = "yes"; then
218 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
221 # detect which IO API to use:
226 [ --without-select disable select IO support (autodetected by default)],
227 [ if test "$withval" != "no"; then
228 if test "$withval" != "yes"; then
229 CFLAGS="-I$withval/include $CFLAGS"
230 CPPFLAGS="-I$withval/include $CPPFLAGS"
231 LDFLAGS="-L$withval/lib $LDFLAGS"
233 AC_CHECK_FUNCS(select, x_io_select=yes,
234 AC_MSG_ERROR([Can't enable select IO support!])
239 AC_CHECK_FUNCS(select, x_io_select=yes)
244 [ --without-poll disable poll support (autodetected by default)],
245 [ if test "$withval" != "no"; then
246 if test "$withval" != "yes"; then
247 CFLAGS="-I$withval/include $CFLAGS"
248 CPPFLAGS="-I$withval/include $CPPFLAGS"
249 LDFLAGS="-L$withval/lib $LDFLAGS"
251 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
252 AC_MSG_ERROR([Can't enable poll IO support!])
257 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
262 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
263 [ if test "$withval" != "no"; then
264 if test "$withval" != "yes"; then
265 CFLAGS="-I$withval/include $CFLAGS"
266 CPPFLAGS="-I$withval/include $CPPFLAGS"
267 LDFLAGS="-L$withval/lib $LDFLAGS"
270 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
274 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
279 [ --without-epoll disable epoll IO support (autodetected by default)],
280 [ if test "$withval" != "no"; then
281 if test "$withval" != "yes"; then
282 CFLAGS="-I$withval/include $CFLAGS"
283 CPPFLAGS="-I$withval/include $CPPFLAGS"
284 LDFLAGS="-L$withval/lib $LDFLAGS"
286 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
287 AC_MSG_ERROR([Can't enable epoll IO support!])
292 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
297 [ --without-kqueue disable kqueue IO support (autodetected by default)],
298 [ if test "$withval" != "no"; then
299 if test "$withval" != "yes"; then
300 CFLAGS="-I$withval/include $CFLAGS"
301 CPPFLAGS="-I$withval/include $CPPFLAGS"
302 LDFLAGS="-L$withval/lib $LDFLAGS"
304 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
305 AC_MSG_ERROR([Can't enable kqueue IO support!])
310 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
314 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
315 # when epoll() and select() are available, we'll use both!
316 x_io_backend="epoll(), select()"
318 if test "$x_io_epoll" = "yes"; then
319 # we prefere epoll() if it is available
320 x_io_backend="epoll()"
322 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
323 # we'll use select, when available and no "better"
324 # interface has been detected ...
325 x_io_backend="select()"
330 if test "$x_io_backend" = "none"; then
331 AC_MSG_ERROR([No useabe IO API activated/found!?])
337 [ --with-openssl enable SSL support using OpenSSL],
338 [ if test "$withval" != "no"; then
339 if test "$withval" != "yes"; then
340 CFLAGS="-I$withval/include $CFLAGS"
341 CPPFLAGS="-I$withval/include $CPPFLAGS"
342 LDFLAGS="-L$withval/lib $LDFLAGS"
344 AC_CHECK_LIB(crypto, BIO_s_mem)
345 AC_CHECK_LIB(ssl, SSL_library_init)
346 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
347 AC_MSG_ERROR([Can't enable openssl])
354 [ --with-gnutls enable SSL support using gnutls],
355 [ if test "$withval" != "no"; then
356 if test "$withval" != "yes"; then
357 CFLAGS="-I$withval/include $CFLAGS"
358 CPPFLAGS="-I$withval/include $CPPFLAGS"
359 LDFLAGS="-L$withval/lib $LDFLAGS"
361 AC_CHECK_LIB(gnutls, gnutls_global_init)
362 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
363 AC_MSG_ERROR([Can't enable gnutls])
370 if test "$x_ssl_gnutls" = "yes"; then
371 if test "$x_ssl_openssl" = "yes";then
372 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
376 if test "$x_ssl_openssl" = "yes"; then
383 AC_ARG_WITH(tcp-wrappers,
384 [ --with-tcp-wrappers enable TCP wrappers support],
385 [ if test "$withval" != "no"; then
386 if test "$withval" != "yes"; then
387 CFLAGS="-I$withval/include $CFLAGS"
388 CPPFLAGS="-I$withval/include $CPPFLAGS"
389 LDFLAGS="-L$withval/lib $LDFLAGS"
391 AC_MSG_CHECKING(for hosts_access)
395 int allow_severity = 0;
396 int deny_severity = 0;
398 tcpd_warn("link test");
401 AC_DEFINE(TCPWRAP, 1)
405 AC_MSG_ERROR([Can't enable TCP wrappers!])
411 # include support for "zeroconf"?
414 AC_ARG_WITH(zeroconf,
415 [ --with-zeroconf enable support for "Zeroconf"],
416 [ if test "$withval" != "no"; then
417 if test "$withval" != "yes"; then
418 CFLAGS="-I$withval/include $CFLAGS"
419 CPPFLAGS="-I$withval/include $CPPFLAGS"
420 LDFLAGS="-L$withval/lib $LDFLAGS"
422 AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
424 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
425 AC_CHECK_LIB(howl, sw_discovery_init)
426 AC_CHECK_FUNCS(sw_discovery_init, \
427 x_zeroconf_on=howl, \
428 AC_MSG_ERROR([Can't enable Zeroconf!]))
433 if test "$x_zeroconf_on" = "osx"; then
434 AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
435 mach/port.h],,AC_MSG_ERROR([required C header missing!]))
436 AC_DEFINE(ZEROCONF, 1)
438 if test "$x_zeroconf_on" = "howl"; then
439 for dir in /usr/local/include /usr/local/include/howl* \
440 /usr/include /usr/include/howl* \
441 /usr/local/include/avahi* /usr/include/avahi*; do
442 test -d "$dir" || continue
443 AC_MSG_CHECKING([for Howl headers in $dir])
444 if test -f "$dir/rendezvous/rendezvous.h"; then
445 if test "$dir" != "/usr/local/include" -a \
446 "$dir" != "/usr/include"; then
447 CFLAGS="-I$dir $CFLAGS"
448 CPPFLAGS="-I$dir $CPPFLAGS"
456 AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
457 AC_MSG_ERROR([required C header missing!]))
458 AC_DEFINE(ZEROCONF, 1)
461 # do IDENT requests using libident?
465 [ --with-ident enable "IDENT" ("AUTH") protocol support],
466 [ if test "$withval" != "no"; then
467 if test "$withval" != "yes"; then
468 CFLAGS="-I$withval/include $CFLAGS"
469 CPPFLAGS="-I$withval/include $CPPFLAGS"
470 LDFLAGS="-L$withval/lib $LDFLAGS"
472 AC_CHECK_LIB(ident, ident_id)
473 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
474 AC_MSG_ERROR([Can't enable IDENT support!])
479 if test "$x_identauth_on" = "yes"; then
480 AC_DEFINE(IDENTAUTH, 1)
481 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
484 # compile in PAM support?
488 [ --with-pam enable user authentication using PAM],
489 [ if test "$withval" != "no"; then
490 if test "$withval" != "yes"; then
491 CFLAGS="-I$withval/include $CFLAGS"
492 CPPFLAGS="-I$withval/include $CPPFLAGS"
493 LDFLAGS="-L$withval/lib $LDFLAGS"
495 AC_CHECK_LIB(pam, pam_authenticate)
496 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
497 AC_MSG_ERROR([Can't enable PAM support!])
502 if test "$x_pam_on" = "yes"; then
504 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
505 if test "$pam_ok" != "yes"; then
506 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
507 AC_MSG_ERROR([required C header missing!]))
511 # compile in IRC+ protocol support?
514 AC_ARG_ENABLE(ircplus,
515 [ --disable-ircplus disable IRC+ protocol],
516 if test "$enableval" = "no"; then x_ircplus_on=no; fi
518 if test "$x_ircplus_on" = "yes"; then
519 AC_DEFINE(IRCPLUS, 1)
522 # enable support for IPv6?
525 [ --enable-ipv6 enable IPv6 protocol support],
526 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
528 if test "$x_ipv6_on" = "yes"; then
529 # getaddrinfo() and getnameinfo() are optional when not compiling
530 # with IPv6 support, but are required for IPv6 to work!
532 getaddrinfo getnameinfo \
533 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
534 AC_DEFINE(WANT_IPV6, 1)
537 # compile in IRC "sniffer"?
539 x_sniffer_on=no; x_debug_on=no
540 AC_ARG_ENABLE(sniffer,
541 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
542 if test "$enableval" = "yes"; then
543 AC_DEFINE(SNIFFER, 1)
544 x_sniffer_on=yes; x_debug_on=yes
548 # enable additional debugging code?
551 [ --enable-debug show additional debug output],
552 if test "$enableval" = "yes"; then x_debug_on=yes; fi
554 if test "$x_debug_on" = "yes"; then
556 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
557 AC_CHECK_FUNCS(mtrace)
560 # enable "strict RFC rules"?
563 AC_ARG_ENABLE(strict-rfc,
564 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
565 if test "$enableval" = "yes"; then
566 AC_DEFINE(STRICT_RFC, 1)
573 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
574 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
575 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
577 # Add additional CFLAGS, eventually specified on the command line, but after
578 # running this configure script. Useful for "-Werror" for example.
579 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
581 # -- Generate files --
588 src/portab/Makefile \
589 src/ipaddr/Makefile \
591 src/ngircd/Makefile \
592 src/testsuite/Makefile \
595 contrib/Debian/Makefile \
596 contrib/MacOSX/Makefile \
597 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
598 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
601 type dpkg >/dev/null 2>&1
602 if test $? -eq 0; then
603 # Generate debian/ link if the dpkg command exists
604 # (read: if we are running on a debian compatible system)
605 echo "creating Debian-specific links ..."
606 test -f debian/rules || ln -s contrib/Debian debian
612 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
615 # Someone please show me a better way :) [borrowed by OpenSSH]
616 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
617 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
618 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
619 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
620 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
622 echo " Target: ${target}"
623 test "$target" != "$host" && echo " Host: ${host}"
624 echo " Compiler: ${CC}"
625 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
626 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
627 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
628 test -n "$LIBS" && echo " Libraries: ${LIBS}"
630 echo " 'ngircd' binary: $S"
631 echo " Configuration file: $C"
632 echo " Manual pages: $M"
633 echo " Documentation: $D"
636 echo $ECHO_N " Syslog support: $ECHO_C"
637 test "$x_syslog_on" = "yes" \
638 && echo $ECHO_N "yes $ECHO_C" \
639 || echo $ECHO_N "no $ECHO_C"
640 echo $ECHO_N " Enable debug code: $ECHO_C"
641 test "$x_debug_on" = "yes" \
645 echo $ECHO_N " zlib compression: $ECHO_C"
646 test "$x_zlib_on" = "yes" \
647 && echo $ECHO_N "yes $ECHO_C" \
648 || echo $ECHO_N "no $ECHO_C"
649 echo $ECHO_N " IRC sniffer: $ECHO_C"
650 test "$x_sniffer_on" = "yes" \
654 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
655 test "$x_tcpwrap_on" = "yes" \
656 && echo $ECHO_N "yes $ECHO_C" \
657 || echo $ECHO_N "no $ECHO_C"
658 echo $ECHO_N " Strict RFC mode: $ECHO_C"
659 test "$x_strict_rfc_on" = "yes" \
663 echo $ECHO_N " Zeroconf support: $ECHO_C"
664 case "$x_zeroconf_on" in
666 echo $ECHO_N "Apple $ECHO_C"
669 echo $ECHO_N "Howl $ECHO_C"
672 echo $ECHO_N "no $ECHO_C"
675 echo $ECHO_N " IRC+ protocol: $ECHO_C"
676 test "$x_ircplus_on" = "yes" \
680 echo $ECHO_N " IDENT support: $ECHO_C"
681 test "$x_identauth_on" = "yes" \
682 && echo $ECHO_N "yes $ECHO_C" \
683 || echo $ECHO_N "no $ECHO_C"
684 echo $ECHO_N " I/O backend: $ECHO_C"
685 echo "\"$x_io_backend\""
687 echo $ECHO_N " IPv6 protocol: $ECHO_C"
688 test "$x_ipv6_on" = "yes" \
689 && echo $ECHO_N "yes $ECHO_C" \
690 || echo $ECHO_N "no $ECHO_C"
691 echo $ECHO_N " SSL support: $ECHO_C"
694 echo $ECHO_N " PAM support: $ECHO_C"
695 test "$x_pam_on" = "yes" \