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 define(VERSION_ID,esyscmd(git describe|sed -e 's/rel-//g'|sed -e 's/-/~/'|tr -d \\n))
14 # -- Initialisation --
17 AC_INIT(ngircd, VERSION_ID)
18 AC_CONFIG_SRCDIR(src/ngircd/ngircd.c)
21 AM_CONFIG_HEADER(src/config.h)
23 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
25 # -- Templates for config.h --
27 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
28 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
29 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
30 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
31 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
32 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
33 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
34 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
35 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
36 AH_TEMPLATE([ZEROCONF], [Define if support for Zeroconf should be included])
37 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
38 AH_TEMPLATE([PAM], [Define if PAM should be used])
39 AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
41 AH_TEMPLATE([TARGET_OS], [Target operating system name])
42 AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
43 AH_TEMPLATE([TARGET_CPU], [Target CPU name])
51 # -- Helper programs --
59 # -- Compiler Features --
65 # -- Hard coded system and compiler dependencies/features/options ... --
67 AC_DEFUN([GCC_STACK_PROTECT_CC],[
69 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
70 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
71 ssp_old_cflags="$CFLAGS"
72 CFLAGS="$CFLAGS -fstack-protector-all"
73 AC_TRY_LINK(,,, ssp_cc=no)
75 CFLAGS="$ssp_old_cflags"
76 if test "X$ssp_cc" = "Xyes"; then
77 CFLAGS="$CFLAGS -fstack-protector"
78 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
82 if test "$GCC" = "yes"; then
83 # We are using the GNU C compiler. Good!
84 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
91 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
92 # (tested with HP/UX 11.11)
93 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
97 # Add additional CFLAGS, eventually specified on the command line:
98 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
100 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
109 ctype.h errno.h fcntl.h netdb.h netinet/in.h netinet/in_systm.h \
110 stdlib.h string.h strings.h sys/socket.h sys/time.h unistd.h \
111 ],,AC_MSG_ERROR([required C header missing!]))
114 arpa/inet.h ctype.h malloc.h netinet/ip.h stdbool.h stddef.h varargs.h \
116 #ifdef HAVE_SYS_TYPES_H
117 #include <sys/types.h>
119 #ifdef HAVE_SYS_SOCKET_H
120 #include <sys/socket.h>
122 #ifdef HAVE_NETINET_IN_H
123 #include <netinet/in.h>
130 AC_MSG_CHECKING(whether socklen_t exists)
132 #include <sys/types.h>
133 #include <sys/socket.h>
136 a = 2; b = 4; a += b;
138 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
146 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
147 [#include <arpa/inet.h>])
152 AC_CHECK_LIB(UTIL,memmove)
153 # needed on solaris. GNU libc also has a libnsl, but we do not need it.
154 AC_SEARCH_LIBS(gethostbyname,nsl)
155 AC_CHECK_LIB(socket,bind)
163 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
164 setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
166 AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction sigprocmask snprintf \
167 vsnprintf strdup strlcpy strlcat strtok_r)
169 # -- Configuration options --
175 [ --without-syslog disable syslog (autodetected by default)],
176 [ if test "$withval" != "no"; then
177 if test "$withval" != "yes"; then
178 CFLAGS="-I$withval/include $CFLAGS"
179 CPPFLAGS="-I$withval/include $CPPFLAGS"
180 LDFLAGS="-L$withval/lib $LDFLAGS"
182 AC_CHECK_LIB(be, syslog)
183 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
184 AC_MSG_ERROR([Can't enable syslog!])
189 AC_CHECK_LIB(be, syslog)
190 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
193 if test "$x_syslog_on" = "yes"; then
195 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
198 # use zlib compression?
202 [ --without-zlib disable zlib compression (autodetected by default)],
203 [ if test "$withval" != "no"; then
204 if test "$withval" != "yes"; then
205 CFLAGS="-I$withval/include $CFLAGS"
206 CPPFLAGS="-I$withval/include $CPPFLAGS"
207 LDFLAGS="-L$withval/lib $LDFLAGS"
209 AC_CHECK_LIB(z, deflate)
210 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
211 AC_MSG_ERROR([Can't enable zlib!])
215 [ AC_CHECK_LIB(z, deflate)
216 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
219 if test "$x_zlib_on" = "yes"; then
221 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
224 # detect which IO API to use:
229 [ --without-select disable select IO support (autodetected by default)],
230 [ if test "$withval" != "no"; then
231 if test "$withval" != "yes"; then
232 CFLAGS="-I$withval/include $CFLAGS"
233 CPPFLAGS="-I$withval/include $CPPFLAGS"
234 LDFLAGS="-L$withval/lib $LDFLAGS"
236 AC_CHECK_FUNCS(select, x_io_select=yes,
237 AC_MSG_ERROR([Can't enable select IO support!])
242 AC_CHECK_FUNCS(select, x_io_select=yes)
247 [ --without-poll disable poll support (autodetected by default)],
248 [ if test "$withval" != "no"; then
249 if test "$withval" != "yes"; then
250 CFLAGS="-I$withval/include $CFLAGS"
251 CPPFLAGS="-I$withval/include $CPPFLAGS"
252 LDFLAGS="-L$withval/lib $LDFLAGS"
254 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
255 AC_MSG_ERROR([Can't enable poll IO support!])
260 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
265 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
266 [ if test "$withval" != "no"; then
267 if test "$withval" != "yes"; then
268 CFLAGS="-I$withval/include $CFLAGS"
269 CPPFLAGS="-I$withval/include $CPPFLAGS"
270 LDFLAGS="-L$withval/lib $LDFLAGS"
273 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
277 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
282 [ --without-epoll disable epoll IO support (autodetected by default)],
283 [ if test "$withval" != "no"; then
284 if test "$withval" != "yes"; then
285 CFLAGS="-I$withval/include $CFLAGS"
286 CPPFLAGS="-I$withval/include $CPPFLAGS"
287 LDFLAGS="-L$withval/lib $LDFLAGS"
289 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
290 AC_MSG_ERROR([Can't enable epoll IO support!])
295 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
300 [ --without-kqueue disable kqueue IO support (autodetected by default)],
301 [ if test "$withval" != "no"; then
302 if test "$withval" != "yes"; then
303 CFLAGS="-I$withval/include $CFLAGS"
304 CPPFLAGS="-I$withval/include $CPPFLAGS"
305 LDFLAGS="-L$withval/lib $LDFLAGS"
307 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
308 AC_MSG_ERROR([Can't enable kqueue IO support!])
313 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
317 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
318 # when epoll() and select() are available, we'll use both!
319 x_io_backend="epoll(), select()"
321 if test "$x_io_epoll" = "yes"; then
322 # we prefere epoll() if it is available
323 x_io_backend="epoll()"
325 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
326 # we'll use select, when available and no "better"
327 # interface has been detected ...
328 x_io_backend="select()"
333 if test "$x_io_backend" = "none"; then
334 AC_MSG_ERROR([No useabe IO API activated/found!?])
340 [ --with-openssl enable SSL support using OpenSSL],
341 [ if test "$withval" != "no"; then
342 if test "$withval" != "yes"; then
343 CFLAGS="-I$withval/include $CFLAGS"
344 CPPFLAGS="-I$withval/include $CPPFLAGS"
345 LDFLAGS="-L$withval/lib $LDFLAGS"
347 AC_CHECK_LIB(crypto, BIO_s_mem)
348 AC_CHECK_LIB(ssl, SSL_library_init)
349 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
350 AC_MSG_ERROR([Can't enable openssl])
357 [ --with-gnutls enable SSL support using gnutls],
358 [ if test "$withval" != "no"; then
359 if test "$withval" != "yes"; then
360 CFLAGS="-I$withval/include $CFLAGS"
361 CPPFLAGS="-I$withval/include $CPPFLAGS"
362 LDFLAGS="-L$withval/lib $LDFLAGS"
364 AC_CHECK_LIB(gnutls, gnutls_global_init)
365 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
366 AC_MSG_ERROR([Can't enable gnutls])
373 if test "$x_ssl_gnutls" = "yes"; then
374 if test "$x_ssl_openssl" = "yes";then
375 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
379 if test "$x_ssl_openssl" = "yes"; then
386 AC_ARG_WITH(tcp-wrappers,
387 [ --with-tcp-wrappers enable TCP wrappers support],
388 [ if test "$withval" != "no"; then
389 if test "$withval" != "yes"; then
390 CFLAGS="-I$withval/include $CFLAGS"
391 CPPFLAGS="-I$withval/include $CPPFLAGS"
392 LDFLAGS="-L$withval/lib $LDFLAGS"
394 AC_MSG_CHECKING(for hosts_access)
398 int allow_severity = 0;
399 int deny_severity = 0;
401 tcpd_warn("link test");
404 AC_DEFINE(TCPWRAP, 1)
408 AC_MSG_ERROR([Can't enable TCP wrappers!])
414 # include support for "zeroconf"?
417 AC_ARG_WITH(zeroconf,
418 [ --with-zeroconf enable support for "Zeroconf"],
419 [ if test "$withval" != "no"; then
420 if test "$withval" != "yes"; then
421 CFLAGS="-I$withval/include $CFLAGS"
422 CPPFLAGS="-I$withval/include $CPPFLAGS"
423 LDFLAGS="-L$withval/lib $LDFLAGS"
425 AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
427 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
428 AC_CHECK_LIB(howl, sw_discovery_init)
429 AC_CHECK_FUNCS(sw_discovery_init, \
430 x_zeroconf_on=howl, \
431 AC_MSG_ERROR([Can't enable Zeroconf!]))
436 if test "$x_zeroconf_on" = "osx"; then
437 AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
438 mach/port.h],,AC_MSG_ERROR([required C header missing!]))
439 AC_DEFINE(ZEROCONF, 1)
441 if test "$x_zeroconf_on" = "howl"; then
442 for dir in /usr/local/include /usr/local/include/howl* \
443 /usr/include /usr/include/howl* \
444 /usr/local/include/avahi* /usr/include/avahi*; do
445 test -d "$dir" || continue
446 AC_MSG_CHECKING([for Howl headers in $dir])
447 if test -f "$dir/rendezvous/rendezvous.h"; then
448 if test "$dir" != "/usr/local/include" -a \
449 "$dir" != "/usr/include"; then
450 CFLAGS="-I$dir $CFLAGS"
451 CPPFLAGS="-I$dir $CPPFLAGS"
459 AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
460 AC_MSG_ERROR([required C header missing!]))
461 AC_DEFINE(ZEROCONF, 1)
464 # do IDENT requests using libident?
468 [ --with-ident enable "IDENT" ("AUTH") protocol support],
469 [ if test "$withval" != "no"; then
470 if test "$withval" != "yes"; then
471 CFLAGS="-I$withval/include $CFLAGS"
472 CPPFLAGS="-I$withval/include $CPPFLAGS"
473 LDFLAGS="-L$withval/lib $LDFLAGS"
475 AC_CHECK_LIB(ident, ident_id)
476 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
477 AC_MSG_ERROR([Can't enable IDENT support!])
482 if test "$x_identauth_on" = "yes"; then
483 AC_DEFINE(IDENTAUTH, 1)
484 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
487 # compile in PAM support?
491 [ --with-pam enable user authentication using PAM],
492 [ if test "$withval" != "no"; then
493 if test "$withval" != "yes"; then
494 CFLAGS="-I$withval/include $CFLAGS"
495 CPPFLAGS="-I$withval/include $CPPFLAGS"
496 LDFLAGS="-L$withval/lib $LDFLAGS"
498 AC_CHECK_LIB(pam, pam_authenticate)
499 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
500 AC_MSG_ERROR([Can't enable PAM support!])
505 if test "$x_pam_on" = "yes"; then
507 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
508 if test "$pam_ok" != "yes"; then
509 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
510 AC_MSG_ERROR([required C header missing!]))
514 # compile in IRC+ protocol support?
517 AC_ARG_ENABLE(ircplus,
518 [ --disable-ircplus disable IRC+ protocol],
519 if test "$enableval" = "no"; then x_ircplus_on=no; fi
521 if test "$x_ircplus_on" = "yes"; then
522 AC_DEFINE(IRCPLUS, 1)
525 # enable support for IPv6?
528 [ --enable-ipv6 enable IPv6 protocol support],
529 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
531 if test "$x_ipv6_on" = "yes"; then
532 # getaddrinfo() and getnameinfo() are optional when not compiling
533 # with IPv6 support, but are required for IPv6 to work!
535 getaddrinfo getnameinfo \
536 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
537 AC_DEFINE(WANT_IPV6, 1)
540 # compile in IRC "sniffer"?
542 x_sniffer_on=no; x_debug_on=no
543 AC_ARG_ENABLE(sniffer,
544 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
545 if test "$enableval" = "yes"; then
546 AC_DEFINE(SNIFFER, 1)
547 x_sniffer_on=yes; x_debug_on=yes
551 # enable additional debugging code?
554 [ --enable-debug show additional debug output],
555 if test "$enableval" = "yes"; then x_debug_on=yes; fi
557 if test "$x_debug_on" = "yes"; then
559 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
560 AC_CHECK_FUNCS(mtrace)
563 # enable "strict RFC rules"?
566 AC_ARG_ENABLE(strict-rfc,
567 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
568 if test "$enableval" = "yes"; then
569 AC_DEFINE(STRICT_RFC, 1)
576 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
577 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
578 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
580 # Add additional CFLAGS, eventually specified on the command line, but after
581 # running this configure script. Useful for "-Werror" for example.
582 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
584 # -- Generate files --
591 src/portab/Makefile \
592 src/ipaddr/Makefile \
594 src/ngircd/Makefile \
595 src/testsuite/Makefile \
598 contrib/Debian/Makefile \
599 contrib/MacOSX/Makefile \
600 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
601 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
604 type dpkg >/dev/null 2>&1
605 if test $? -eq 0; then
606 # Generate debian/ link if the dpkg command exists
607 # (read: if we are running on a debian compatible system)
608 echo "creating Debian-specific links ..."
609 test -f debian/rules || ln -s contrib/Debian debian
615 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
618 # Someone please show me a better way :) [borrowed by OpenSSH]
619 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
620 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
621 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
622 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
623 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
625 echo " Target: ${target}"
626 test "$target" != "$host" && echo " Host: ${host}"
627 echo " Compiler: ${CC}"
628 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
629 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
630 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
631 test -n "$LIBS" && echo " Libraries: ${LIBS}"
633 echo " 'ngircd' binary: $S"
634 echo " Configuration file: $C"
635 echo " Manual pages: $M"
636 echo " Documentation: $D"
639 echo $ECHO_N " Syslog support: $ECHO_C"
640 test "$x_syslog_on" = "yes" \
641 && echo $ECHO_N "yes $ECHO_C" \
642 || echo $ECHO_N "no $ECHO_C"
643 echo $ECHO_N " Enable debug code: $ECHO_C"
644 test "$x_debug_on" = "yes" \
648 echo $ECHO_N " zlib compression: $ECHO_C"
649 test "$x_zlib_on" = "yes" \
650 && echo $ECHO_N "yes $ECHO_C" \
651 || echo $ECHO_N "no $ECHO_C"
652 echo $ECHO_N " IRC sniffer: $ECHO_C"
653 test "$x_sniffer_on" = "yes" \
657 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
658 test "$x_tcpwrap_on" = "yes" \
659 && echo $ECHO_N "yes $ECHO_C" \
660 || echo $ECHO_N "no $ECHO_C"
661 echo $ECHO_N " Strict RFC mode: $ECHO_C"
662 test "$x_strict_rfc_on" = "yes" \
666 echo $ECHO_N " Zeroconf support: $ECHO_C"
667 case "$x_zeroconf_on" in
669 echo $ECHO_N "Apple $ECHO_C"
672 echo $ECHO_N "Howl $ECHO_C"
675 echo $ECHO_N "no $ECHO_C"
678 echo $ECHO_N " IRC+ protocol: $ECHO_C"
679 test "$x_ircplus_on" = "yes" \
683 echo $ECHO_N " IDENT support: $ECHO_C"
684 test "$x_identauth_on" = "yes" \
685 && echo $ECHO_N "yes $ECHO_C" \
686 || echo $ECHO_N "no $ECHO_C"
687 echo $ECHO_N " I/O backend: $ECHO_C"
688 echo "\"$x_io_backend\""
690 echo $ECHO_N " IPv6 protocol: $ECHO_C"
691 test "$x_ipv6_on" = "yes" \
692 && echo $ECHO_N "yes $ECHO_C" \
693 || echo $ECHO_N "no $ECHO_C"
694 echo $ECHO_N " SSL support: $ECHO_C"
697 echo $ECHO_N " PAM support: $ECHO_C"
698 test "$x_pam_on" = "yes" \