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])
49 # -- Helper programs --
57 # -- Compiler Features --
63 # -- Hard coded system and compiler dependencies/features/options ... --
65 AC_DEFUN([GCC_STACK_PROTECT_CC],[
67 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
68 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
69 ssp_old_cflags="$CFLAGS"
70 CFLAGS="$CFLAGS -fstack-protector-all"
71 AC_TRY_LINK(,,, ssp_cc=no)
73 CFLAGS="$ssp_old_cflags"
74 if test "X$ssp_cc" = "Xyes"; then
75 CFLAGS="$CFLAGS -fstack-protector"
76 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
80 if test "$GCC" = "yes"; then
81 # We are using the GNU C compiler. Good!
82 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
89 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
90 # (tested with HP/UX 11.11)
91 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
95 # Add additional CFLAGS, eventually specified on the command line:
96 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
98 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
107 ctype.h errno.h fcntl.h netdb.h netinet/in.h netinet/in_systm.h \
108 stdlib.h string.h strings.h sys/socket.h sys/time.h unistd.h \
109 ],,AC_MSG_ERROR([required C header missing!]))
112 arpa/inet.h ctype.h malloc.h netinet/ip.h stdbool.h stddef.h varargs.h \
114 #ifdef HAVE_SYS_TYPES_H
115 #include <sys/types.h>
117 #ifdef HAVE_SYS_SOCKET_H
118 #include <sys/socket.h>
120 #ifdef HAVE_NETINET_IN_H
121 #include <netinet/in.h>
128 AC_MSG_CHECKING(whether socklen_t exists)
130 #include <sys/types.h>
131 #include <sys/socket.h>
134 a = 2; b = 4; a += b;
136 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
144 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
145 [#include <arpa/inet.h>])
150 AC_CHECK_LIB(UTIL,memmove)
151 # needed on solaris. GNU libc also has a libnsl, but we do not need it.
152 AC_SEARCH_LIBS(gethostbyname,nsl)
153 AC_CHECK_LIB(socket,bind)
161 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
162 setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
164 AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction sigprocmask snprintf \
165 vsnprintf strdup strlcpy strlcat strtok_r)
167 # -- Configuration options --
173 [ --without-syslog disable syslog (autodetected by default)],
174 [ if test "$withval" != "no"; then
175 if test "$withval" != "yes"; then
176 CFLAGS="-I$withval/include $CFLAGS"
177 CPPFLAGS="-I$withval/include $CPPFLAGS"
178 LDFLAGS="-L$withval/lib $LDFLAGS"
180 AC_CHECK_LIB(be, syslog)
181 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
182 AC_MSG_ERROR([Can't enable syslog!])
187 AC_CHECK_LIB(be, syslog)
188 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
191 if test "$x_syslog_on" = "yes"; then
193 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
196 # use zlib compression?
200 [ --without-zlib disable zlib compression (autodetected by default)],
201 [ if test "$withval" != "no"; then
202 if test "$withval" != "yes"; then
203 CFLAGS="-I$withval/include $CFLAGS"
204 CPPFLAGS="-I$withval/include $CPPFLAGS"
205 LDFLAGS="-L$withval/lib $LDFLAGS"
207 AC_CHECK_LIB(z, deflate)
208 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
209 AC_MSG_ERROR([Can't enable zlib!])
213 [ AC_CHECK_LIB(z, deflate)
214 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
217 if test "$x_zlib_on" = "yes"; then
219 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
222 # detect which IO API to use:
227 [ --without-select disable select IO support (autodetected by default)],
228 [ if test "$withval" != "no"; then
229 if test "$withval" != "yes"; then
230 CFLAGS="-I$withval/include $CFLAGS"
231 CPPFLAGS="-I$withval/include $CPPFLAGS"
232 LDFLAGS="-L$withval/lib $LDFLAGS"
234 AC_CHECK_FUNCS(select, x_io_select=yes,
235 AC_MSG_ERROR([Can't enable select IO support!])
240 AC_CHECK_FUNCS(select, x_io_select=yes)
245 [ --without-poll disable poll support (autodetected by default)],
246 [ if test "$withval" != "no"; then
247 if test "$withval" != "yes"; then
248 CFLAGS="-I$withval/include $CFLAGS"
249 CPPFLAGS="-I$withval/include $CPPFLAGS"
250 LDFLAGS="-L$withval/lib $LDFLAGS"
252 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
253 AC_MSG_ERROR([Can't enable poll IO support!])
258 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
263 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
264 [ if test "$withval" != "no"; then
265 if test "$withval" != "yes"; then
266 CFLAGS="-I$withval/include $CFLAGS"
267 CPPFLAGS="-I$withval/include $CPPFLAGS"
268 LDFLAGS="-L$withval/lib $LDFLAGS"
271 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
275 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
280 [ --without-epoll disable epoll IO support (autodetected by default)],
281 [ if test "$withval" != "no"; then
282 if test "$withval" != "yes"; then
283 CFLAGS="-I$withval/include $CFLAGS"
284 CPPFLAGS="-I$withval/include $CPPFLAGS"
285 LDFLAGS="-L$withval/lib $LDFLAGS"
287 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
288 AC_MSG_ERROR([Can't enable epoll IO support!])
293 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
298 [ --without-kqueue disable kqueue IO support (autodetected by default)],
299 [ if test "$withval" != "no"; then
300 if test "$withval" != "yes"; then
301 CFLAGS="-I$withval/include $CFLAGS"
302 CPPFLAGS="-I$withval/include $CPPFLAGS"
303 LDFLAGS="-L$withval/lib $LDFLAGS"
305 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
306 AC_MSG_ERROR([Can't enable kqueue IO support!])
311 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
315 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
316 # when epoll() and select() are available, we'll use both!
317 x_io_backend="epoll(), select()"
319 if test "$x_io_epoll" = "yes"; then
320 # we prefere epoll() if it is available
321 x_io_backend="epoll()"
323 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
324 # we'll use select, when available and no "better"
325 # interface has been detected ...
326 x_io_backend="select()"
331 if test "$x_io_backend" = "none"; then
332 AC_MSG_ERROR([No useabe IO API activated/found!?])
338 [ --with-openssl enable SSL support using OpenSSL],
339 [ if test "$withval" != "no"; then
340 if test "$withval" != "yes"; then
341 CFLAGS="-I$withval/include $CFLAGS"
342 CPPFLAGS="-I$withval/include $CPPFLAGS"
343 LDFLAGS="-L$withval/lib $LDFLAGS"
345 AC_CHECK_LIB(crypto, BIO_s_mem)
346 AC_CHECK_LIB(ssl, SSL_library_init)
347 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
348 AC_MSG_ERROR([Can't enable openssl])
355 [ --with-gnutls enable SSL support using gnutls],
356 [ if test "$withval" != "no"; then
357 if test "$withval" != "yes"; then
358 CFLAGS="-I$withval/include $CFLAGS"
359 CPPFLAGS="-I$withval/include $CPPFLAGS"
360 LDFLAGS="-L$withval/lib $LDFLAGS"
362 AC_CHECK_LIB(gnutls, gnutls_global_init)
363 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
364 AC_MSG_ERROR([Can't enable gnutls])
371 if test "$x_ssl_gnutls" = "yes"; then
372 if test "$x_ssl_openssl" = "yes";then
373 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
377 if test "$x_ssl_openssl" = "yes"; then
384 AC_ARG_WITH(tcp-wrappers,
385 [ --with-tcp-wrappers enable TCP wrappers support],
386 [ if test "$withval" != "no"; then
387 if test "$withval" != "yes"; then
388 CFLAGS="-I$withval/include $CFLAGS"
389 CPPFLAGS="-I$withval/include $CPPFLAGS"
390 LDFLAGS="-L$withval/lib $LDFLAGS"
392 AC_MSG_CHECKING(for hosts_access)
396 int allow_severity = 0;
397 int deny_severity = 0;
399 tcpd_warn("link test");
402 AC_DEFINE(TCPWRAP, 1)
406 AC_MSG_ERROR([Can't enable TCP wrappers!])
412 # include support for "zeroconf"?
415 AC_ARG_WITH(zeroconf,
416 [ --with-zeroconf enable support for "Zeroconf"],
417 [ if test "$withval" != "no"; then
418 if test "$withval" != "yes"; then
419 CFLAGS="-I$withval/include $CFLAGS"
420 CPPFLAGS="-I$withval/include $CPPFLAGS"
421 LDFLAGS="-L$withval/lib $LDFLAGS"
423 AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
425 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
426 AC_CHECK_LIB(howl, sw_discovery_init)
427 AC_CHECK_FUNCS(sw_discovery_init, \
428 x_zeroconf_on=howl, \
429 AC_MSG_ERROR([Can't enable Zeroconf!]))
434 if test "$x_zeroconf_on" = "osx"; then
435 AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
436 mach/port.h],,AC_MSG_ERROR([required C header missing!]))
437 AC_DEFINE(ZEROCONF, 1)
439 if test "$x_zeroconf_on" = "howl"; then
440 for dir in /usr/local/include /usr/local/include/howl* \
441 /usr/include /usr/include/howl* \
442 /usr/local/include/avahi* /usr/include/avahi*; do
443 test -d "$dir" || continue
444 AC_MSG_CHECKING([for Howl headers in $dir])
445 if test -f "$dir/rendezvous/rendezvous.h"; then
446 if test "$dir" != "/usr/local/include" -a \
447 "$dir" != "/usr/include"; then
448 CFLAGS="-I$dir $CFLAGS"
449 CPPFLAGS="-I$dir $CPPFLAGS"
457 AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
458 AC_MSG_ERROR([required C header missing!]))
459 AC_DEFINE(ZEROCONF, 1)
462 # do IDENT requests using libident?
466 [ --with-ident enable "IDENT" ("AUTH") protocol support],
467 [ if test "$withval" != "no"; then
468 if test "$withval" != "yes"; then
469 CFLAGS="-I$withval/include $CFLAGS"
470 CPPFLAGS="-I$withval/include $CPPFLAGS"
471 LDFLAGS="-L$withval/lib $LDFLAGS"
473 AC_CHECK_LIB(ident, ident_id)
474 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
475 AC_MSG_ERROR([Can't enable IDENT support!])
480 if test "$x_identauth_on" = "yes"; then
481 AC_DEFINE(IDENTAUTH, 1)
482 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
485 # compile in PAM support?
489 [ --with-pam enable user authentication using PAM],
490 [ if test "$withval" != "no"; then
491 if test "$withval" != "yes"; then
492 CFLAGS="-I$withval/include $CFLAGS"
493 CPPFLAGS="-I$withval/include $CPPFLAGS"
494 LDFLAGS="-L$withval/lib $LDFLAGS"
496 AC_CHECK_LIB(pam, pam_authenticate)
497 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
498 AC_MSG_ERROR([Can't enable PAM support!])
503 if test "$x_pam_on" = "yes"; then
505 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
506 if test "$pam_ok" != "yes"; then
507 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
508 AC_MSG_ERROR([required C header missing!]))
512 # compile in IRC+ protocol support?
515 AC_ARG_ENABLE(ircplus,
516 [ --disable-ircplus disable IRC+ protocol],
517 if test "$enableval" = "no"; then x_ircplus_on=no; fi
519 if test "$x_ircplus_on" = "yes"; then
520 AC_DEFINE(IRCPLUS, 1)
523 # enable support for IPv6?
526 [ --enable-ipv6 enable IPv6 protocol support],
527 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
529 if test "$x_ipv6_on" = "yes"; then
530 # getaddrinfo() and getnameinfo() are optional when not compiling
531 # with IPv6 support, but are required for IPv6 to work!
533 getaddrinfo getnameinfo \
534 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
535 AC_DEFINE(WANT_IPV6, 1)
538 # compile in IRC "sniffer"?
540 x_sniffer_on=no; x_debug_on=no
541 AC_ARG_ENABLE(sniffer,
542 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
543 if test "$enableval" = "yes"; then
544 AC_DEFINE(SNIFFER, 1)
545 x_sniffer_on=yes; x_debug_on=yes
549 # enable additional debugging code?
552 [ --enable-debug show additional debug output],
553 if test "$enableval" = "yes"; then x_debug_on=yes; fi
555 if test "$x_debug_on" = "yes"; then
557 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
558 AC_CHECK_FUNCS(mtrace)
561 # enable "strict RFC rules"?
564 AC_ARG_ENABLE(strict-rfc,
565 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
566 if test "$enableval" = "yes"; then
567 AC_DEFINE(STRICT_RFC, 1)
574 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
575 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
576 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
578 # Add additional CFLAGS, eventually specified on the command line, but after
579 # running this configure script. Useful for "-Werror" for example.
580 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
582 # -- Generate files --
589 src/portab/Makefile \
590 src/ipaddr/Makefile \
592 src/ngircd/Makefile \
593 src/testsuite/Makefile \
596 contrib/Debian/Makefile \
597 contrib/MacOSX/Makefile \
598 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
599 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
602 type dpkg >/dev/null 2>&1
603 if test $? -eq 0; then
604 # Generate debian/ link if the dpkg command exists
605 # (read: if we are running on a debian compatible system)
606 echo "creating Debian-specific links ..."
607 test -f debian/rules || ln -s contrib/Debian debian
613 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
616 # Someone please show me a better way :) [borrowed by OpenSSH]
617 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
618 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
619 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
620 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
621 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
623 echo " Target: ${target}"
624 test "$target" != "$host" && echo " Host: ${host}"
625 echo " Compiler: ${CC}"
626 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
627 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
628 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
629 test -n "$LIBS" && echo " Libraries: ${LIBS}"
631 echo " 'ngircd' binary: $S"
632 echo " Configuration file: $C"
633 echo " Manual pages: $M"
634 echo " Documentation: $D"
637 echo $ECHO_N " Syslog support: $ECHO_C"
638 test "$x_syslog_on" = "yes" \
639 && echo $ECHO_N "yes $ECHO_C" \
640 || echo $ECHO_N "no $ECHO_C"
641 echo $ECHO_N " Enable debug code: $ECHO_C"
642 test "$x_debug_on" = "yes" \
646 echo $ECHO_N " zlib compression: $ECHO_C"
647 test "$x_zlib_on" = "yes" \
648 && echo $ECHO_N "yes $ECHO_C" \
649 || echo $ECHO_N "no $ECHO_C"
650 echo $ECHO_N " IRC sniffer: $ECHO_C"
651 test "$x_sniffer_on" = "yes" \
655 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
656 test "$x_tcpwrap_on" = "yes" \
657 && echo $ECHO_N "yes $ECHO_C" \
658 || echo $ECHO_N "no $ECHO_C"
659 echo $ECHO_N " Strict RFC mode: $ECHO_C"
660 test "$x_strict_rfc_on" = "yes" \
664 echo $ECHO_N " Zeroconf support: $ECHO_C"
665 case "$x_zeroconf_on" in
667 echo $ECHO_N "Apple $ECHO_C"
670 echo $ECHO_N "Howl $ECHO_C"
673 echo $ECHO_N "no $ECHO_C"
676 echo $ECHO_N " IRC+ protocol: $ECHO_C"
677 test "$x_ircplus_on" = "yes" \
681 echo $ECHO_N " IDENT support: $ECHO_C"
682 test "$x_identauth_on" = "yes" \
683 && echo $ECHO_N "yes $ECHO_C" \
684 || echo $ECHO_N "no $ECHO_C"
685 echo $ECHO_N " I/O backend: $ECHO_C"
686 echo "\"$x_io_backend\""
688 echo $ECHO_N " IPv6 protocol: $ECHO_C"
689 test "$x_ipv6_on" = "yes" \
690 && echo $ECHO_N "yes $ECHO_C" \
691 || echo $ECHO_N "no $ECHO_C"
692 echo $ECHO_N " SSL support: $ECHO_C"
695 echo $ECHO_N " PAM support: $ECHO_C"
696 test "$x_pam_on" = "yes" \