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-dev)
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])
47 # -- Helper programs --
55 # -- Compiler Features --
61 # -- Hard coded system and compiler dependencies/features/options ... --
63 AC_DEFUN([GCC_STACK_PROTECT_CC],[
65 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
66 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
67 ssp_old_cflags="$CFLAGS"
68 CFLAGS="$CFLAGS -fstack-protector-all"
69 AC_TRY_LINK(,,, ssp_cc=no)
71 CFLAGS="$ssp_old_cflags"
72 if test "X$ssp_cc" = "Xyes"; then
73 CFLAGS="$CFLAGS -fstack-protector"
74 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
78 if test "$GCC" = "yes"; then
79 # We are using the GNU C compiler. Good!
80 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
87 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
88 # (tested with HP/UX 11.11)
89 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
93 # Add additional CFLAGS, eventually specified on the command line:
94 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
96 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
105 ctype.h errno.h fcntl.h netdb.h netinet/in.h netinet/in_systm.h \
106 stdlib.h string.h strings.h sys/socket.h sys/time.h unistd.h \
107 ],,AC_MSG_ERROR([required C header missing!]))
110 arpa/inet.h ctype.h malloc.h netinet/ip.h stdbool.h stddef.h varargs.h \
112 #ifdef HAVE_SYS_TYPES_H
113 #include <sys/types.h>
115 #ifdef HAVE_SYS_SOCKET_H
116 #include <sys/socket.h>
118 #ifdef HAVE_NETINET_IN_H
119 #include <netinet/in.h>
126 AC_MSG_CHECKING(whether socklen_t exists)
128 #include <sys/types.h>
129 #include <sys/socket.h>
132 a = 2; b = 4; a += b;
134 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
142 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
143 [#include <arpa/inet.h>])
148 AC_CHECK_LIB(UTIL,memmove)
149 # needed on solaris. GNU libc also has a libnsl, but we do not need it.
150 AC_SEARCH_LIBS(gethostbyname,nsl)
151 AC_CHECK_LIB(socket,bind)
159 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
160 setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
162 AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction sigprocmask snprintf \
163 vsnprintf strdup strlcpy strlcat strtok_r)
165 # -- Configuration options --
171 [ --without-syslog disable syslog (autodetected by default)],
172 [ if test "$withval" != "no"; then
173 if test "$withval" != "yes"; then
174 CFLAGS="-I$withval/include $CFLAGS"
175 CPPFLAGS="-I$withval/include $CPPFLAGS"
176 LDFLAGS="-L$withval/lib $LDFLAGS"
178 AC_CHECK_LIB(be, syslog)
179 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
180 AC_MSG_ERROR([Can't enable syslog!])
185 AC_CHECK_LIB(be, syslog)
186 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
189 if test "$x_syslog_on" = "yes"; then
191 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
194 # use zlib compression?
198 [ --without-zlib disable zlib compression (autodetected by default)],
199 [ if test "$withval" != "no"; then
200 if test "$withval" != "yes"; then
201 CFLAGS="-I$withval/include $CFLAGS"
202 CPPFLAGS="-I$withval/include $CPPFLAGS"
203 LDFLAGS="-L$withval/lib $LDFLAGS"
205 AC_CHECK_LIB(z, deflate)
206 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
207 AC_MSG_ERROR([Can't enable zlib!])
211 [ AC_CHECK_LIB(z, deflate)
212 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
215 if test "$x_zlib_on" = "yes"; then
217 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
220 # detect which IO API to use:
225 [ --without-select disable select IO support (autodetected by default)],
226 [ if test "$withval" != "no"; then
227 if test "$withval" != "yes"; then
228 CFLAGS="-I$withval/include $CFLAGS"
229 CPPFLAGS="-I$withval/include $CPPFLAGS"
230 LDFLAGS="-L$withval/lib $LDFLAGS"
232 AC_CHECK_FUNCS(select, x_io_select=yes,
233 AC_MSG_ERROR([Can't enable select IO support!])
238 AC_CHECK_FUNCS(select, x_io_select=yes)
243 [ --without-poll disable poll support (autodetected by default)],
244 [ if test "$withval" != "no"; then
245 if test "$withval" != "yes"; then
246 CFLAGS="-I$withval/include $CFLAGS"
247 CPPFLAGS="-I$withval/include $CPPFLAGS"
248 LDFLAGS="-L$withval/lib $LDFLAGS"
250 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
251 AC_MSG_ERROR([Can't enable poll IO support!])
256 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
261 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
262 [ if test "$withval" != "no"; then
263 if test "$withval" != "yes"; then
264 CFLAGS="-I$withval/include $CFLAGS"
265 CPPFLAGS="-I$withval/include $CPPFLAGS"
266 LDFLAGS="-L$withval/lib $LDFLAGS"
269 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
273 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
278 [ --without-epoll disable epoll IO support (autodetected by default)],
279 [ if test "$withval" != "no"; then
280 if test "$withval" != "yes"; then
281 CFLAGS="-I$withval/include $CFLAGS"
282 CPPFLAGS="-I$withval/include $CPPFLAGS"
283 LDFLAGS="-L$withval/lib $LDFLAGS"
285 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
286 AC_MSG_ERROR([Can't enable epoll IO support!])
291 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
296 [ --without-kqueue disable kqueue IO support (autodetected by default)],
297 [ if test "$withval" != "no"; then
298 if test "$withval" != "yes"; then
299 CFLAGS="-I$withval/include $CFLAGS"
300 CPPFLAGS="-I$withval/include $CPPFLAGS"
301 LDFLAGS="-L$withval/lib $LDFLAGS"
303 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
304 AC_MSG_ERROR([Can't enable kqueue IO support!])
309 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
313 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
314 # when epoll() and select() are available, we'll use both!
315 x_io_backend="epoll(), select()"
317 if test "$x_io_epoll" = "yes"; then
318 # we prefere epoll() if it is available
319 x_io_backend="epoll()"
321 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
322 # we'll use select, when available and no "better"
323 # interface has been detected ...
324 x_io_backend="select()"
329 if test "$x_io_backend" = "none"; then
330 AC_MSG_ERROR([No useabe IO API activated/found!?])
336 [ --with-openssl enable SSL support using OpenSSL],
337 [ if test "$withval" != "no"; then
338 if test "$withval" != "yes"; then
339 CFLAGS="-I$withval/include $CFLAGS"
340 CPPFLAGS="-I$withval/include $CPPFLAGS"
341 LDFLAGS="-L$withval/lib $LDFLAGS"
343 AC_CHECK_LIB(crypto, BIO_s_mem)
344 AC_CHECK_LIB(ssl, SSL_library_init)
345 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
346 AC_MSG_ERROR([Can't enable openssl])
353 [ --with-gnutls enable SSL support using gnutls],
354 [ if test "$withval" != "no"; then
355 if test "$withval" != "yes"; then
356 CFLAGS="-I$withval/include $CFLAGS"
357 CPPFLAGS="-I$withval/include $CPPFLAGS"
358 LDFLAGS="-L$withval/lib $LDFLAGS"
360 AC_CHECK_LIB(gnutls, gnutls_global_init)
361 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
362 AC_MSG_ERROR([Can't enable gnutls])
369 if test "$x_ssl_gnutls" = "yes"; then
370 if test "$x_ssl_openssl" = "yes";then
371 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
375 if test "$x_ssl_openssl" = "yes"; then
382 AC_ARG_WITH(tcp-wrappers,
383 [ --with-tcp-wrappers enable TCP wrappers support],
384 [ if test "$withval" != "no"; then
385 if test "$withval" != "yes"; then
386 CFLAGS="-I$withval/include $CFLAGS"
387 CPPFLAGS="-I$withval/include $CPPFLAGS"
388 LDFLAGS="-L$withval/lib $LDFLAGS"
390 AC_MSG_CHECKING(for hosts_access)
394 int allow_severity = 0;
395 int deny_severity = 0;
397 tcpd_warn("link test");
400 AC_DEFINE(TCPWRAP, 1)
404 AC_MSG_ERROR([Can't enable TCP wrappers!])
410 # include support for "zeroconf"?
413 AC_ARG_WITH(zeroconf,
414 [ --with-zeroconf enable support for "Zeroconf"],
415 [ if test "$withval" != "no"; then
416 if test "$withval" != "yes"; then
417 CFLAGS="-I$withval/include $CFLAGS"
418 CPPFLAGS="-I$withval/include $CPPFLAGS"
419 LDFLAGS="-L$withval/lib $LDFLAGS"
421 AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
423 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
424 AC_CHECK_LIB(howl, sw_discovery_init)
425 AC_CHECK_FUNCS(sw_discovery_init, \
426 x_zeroconf_on=howl, \
427 AC_MSG_ERROR([Can't enable Zeroconf!]))
432 if test "$x_zeroconf_on" = "osx"; then
433 AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
434 mach/port.h],,AC_MSG_ERROR([required C header missing!]))
435 AC_DEFINE(ZEROCONF, 1)
437 if test "$x_zeroconf_on" = "howl"; then
438 for dir in /usr/local/include /usr/local/include/howl* \
439 /usr/include /usr/include/howl* \
440 /usr/local/include/avahi* /usr/include/avahi*; do
441 test -d "$dir" || continue
442 AC_MSG_CHECKING([for Howl headers in $dir])
443 if test -f "$dir/rendezvous/rendezvous.h"; then
444 if test "$dir" != "/usr/local/include" -a \
445 "$dir" != "/usr/include"; then
446 CFLAGS="-I$dir $CFLAGS"
447 CPPFLAGS="-I$dir $CPPFLAGS"
455 AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
456 AC_MSG_ERROR([required C header missing!]))
457 AC_DEFINE(ZEROCONF, 1)
460 # do IDENT requests using libident?
464 [ --with-ident enable "IDENT" ("AUTH") protocol support],
465 [ if test "$withval" != "no"; then
466 if test "$withval" != "yes"; then
467 CFLAGS="-I$withval/include $CFLAGS"
468 CPPFLAGS="-I$withval/include $CPPFLAGS"
469 LDFLAGS="-L$withval/lib $LDFLAGS"
471 AC_CHECK_LIB(ident, ident_id)
472 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
473 AC_MSG_ERROR([Can't enable IDENT support!])
478 if test "$x_identauth_on" = "yes"; then
479 AC_DEFINE(IDENTAUTH, 1)
480 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
483 # compile in PAM support?
487 [ --with-pam enable user authentication using PAM],
488 [ if test "$withval" != "no"; then
489 if test "$withval" != "yes"; then
490 CFLAGS="-I$withval/include $CFLAGS"
491 CPPFLAGS="-I$withval/include $CPPFLAGS"
492 LDFLAGS="-L$withval/lib $LDFLAGS"
494 AC_CHECK_LIB(pam, pam_authenticate)
495 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
496 AC_MSG_ERROR([Can't enable PAM support!])
501 if test "$x_pam_on" = "yes"; then
503 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
504 if test "$pam_ok" != "yes"; then
505 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
506 AC_MSG_ERROR([required C header missing!]))
510 # compile in IRC+ protocol support?
513 AC_ARG_ENABLE(ircplus,
514 [ --disable-ircplus disable IRC+ protocol],
515 if test "$enableval" = "no"; then x_ircplus_on=no; fi
517 if test "$x_ircplus_on" = "yes"; then
518 AC_DEFINE(IRCPLUS, 1)
521 # enable support for IPv6?
524 [ --enable-ipv6 enable IPv6 protocol support],
525 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
527 if test "$x_ipv6_on" = "yes"; then
528 # getaddrinfo() and getnameinfo() are optional when not compiling
529 # with IPv6 support, but are required for IPv6 to work!
531 getaddrinfo getnameinfo \
532 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
533 AC_DEFINE(WANT_IPV6, 1)
536 # compile in IRC "sniffer"?
538 x_sniffer_on=no; x_debug_on=no
539 AC_ARG_ENABLE(sniffer,
540 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
541 if test "$enableval" = "yes"; then
542 AC_DEFINE(SNIFFER, 1)
543 x_sniffer_on=yes; x_debug_on=yes
547 # enable additional debugging code?
550 [ --enable-debug show additional debug output],
551 if test "$enableval" = "yes"; then x_debug_on=yes; fi
553 if test "$x_debug_on" = "yes"; then
555 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
556 AC_CHECK_FUNCS(mtrace)
559 # enable "strict RFC rules"?
562 AC_ARG_ENABLE(strict-rfc,
563 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
564 if test "$enableval" = "yes"; then
565 AC_DEFINE(STRICT_RFC, 1)
572 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
573 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
574 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
576 # Add additional CFLAGS, eventually specified on the command line, but after
577 # running this configure script. Useful for "-Werror" for example.
578 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
580 # -- Generate files --
587 src/portab/Makefile \
588 src/ipaddr/Makefile \
590 src/ngircd/Makefile \
591 src/testsuite/Makefile \
594 contrib/Debian/Makefile \
595 contrib/MacOSX/Makefile \
596 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
597 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
600 type dpkg >/dev/null 2>&1
601 if test $? -eq 0; then
602 # Generate debian/ link if the dpkg command exists
603 # (read: if we are running on a debian compatible system)
604 echo "creating Debian-specific links ..."
605 test -f debian/rules || ln -s contrib/Debian debian
611 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
614 # Someone please show me a better way :) [borrowed by OpenSSH]
615 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
616 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
617 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
618 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
619 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
621 echo " Target: ${target}"
622 test "$target" != "$host" && echo " Host: ${host}"
623 echo " Compiler: ${CC}"
624 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
625 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
626 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
627 test -n "$LIBS" && echo " Libraries: ${LIBS}"
629 echo " 'ngircd' binary: $S"
630 echo " Configuration file: $C"
631 echo " Manual pages: $M"
632 echo " Documentation: $D"
635 echo $ECHO_N " Syslog support: $ECHO_C"
636 test "$x_syslog_on" = "yes" \
637 && echo $ECHO_N "yes $ECHO_C" \
638 || echo $ECHO_N "no $ECHO_C"
639 echo $ECHO_N " Enable debug code: $ECHO_C"
640 test "$x_debug_on" = "yes" \
644 echo $ECHO_N " zlib compression: $ECHO_C"
645 test "$x_zlib_on" = "yes" \
646 && echo $ECHO_N "yes $ECHO_C" \
647 || echo $ECHO_N "no $ECHO_C"
648 echo $ECHO_N " IRC sniffer: $ECHO_C"
649 test "$x_sniffer_on" = "yes" \
653 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
654 test "$x_tcpwrap_on" = "yes" \
655 && echo $ECHO_N "yes $ECHO_C" \
656 || echo $ECHO_N "no $ECHO_C"
657 echo $ECHO_N " Strict RFC mode: $ECHO_C"
658 test "$x_strict_rfc_on" = "yes" \
662 echo $ECHO_N " Zeroconf support: $ECHO_C"
663 case "$x_zeroconf_on" in
665 echo $ECHO_N "Apple $ECHO_C"
668 echo $ECHO_N "Howl $ECHO_C"
671 echo $ECHO_N "no $ECHO_C"
674 echo $ECHO_N " IRC+ protocol: $ECHO_C"
675 test "$x_ircplus_on" = "yes" \
679 echo $ECHO_N " IDENT support: $ECHO_C"
680 test "$x_identauth_on" = "yes" \
681 && echo $ECHO_N "yes $ECHO_C" \
682 || echo $ECHO_N "no $ECHO_C"
683 echo $ECHO_N " I/O backend: $ECHO_C"
684 echo "\"$x_io_backend\""
686 echo $ECHO_N " IPv6 protocol: $ECHO_C"
687 test "$x_ipv6_on" = "yes" \
688 && echo $ECHO_N "yes $ECHO_C" \
689 || echo $ECHO_N "no $ECHO_C"
690 echo $ECHO_N " SSL support: $ECHO_C"
693 echo $ECHO_N " PAM support: $ECHO_C"
694 test "$x_pam_on" = "yes" \