2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2014 Alexander Barton (alex@barton.de) and Contributors
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([
13 V=`git describe 2>/dev/null | sed -e 's/rel-//g' | sed -e 's/-/~/'`;
14 [ -z "$V" -a -r configure ] \
15 && V=`grep "PACKAGE_STRING=" configure | cut -d"'" -f2 | cut -d' ' -f2`
16 ( [ -n "$V" ] && echo "$V" || echo "??" ) | tr -d '\n';
19 m4_ifdef([AM_SILENT_RULES],
20 [m4_define([ng_color_tests], [color-tests])],
21 [m4_define([ng_color_tests], [])])
23 # -- Initialisation --
26 AC_INIT([ngIRCd],[VERSION_ID],[ngircd-ml@ngircd.barton.de],[ngircd],[http://ngircd.barton.de/])
28 AC_CONFIG_SRCDIR([src/ngircd/ngircd.c])
29 AC_CONFIG_HEADER([src/config.h])
32 AM_INIT_AUTOMAKE([-Wall 1.10 ]ng_color_tests)
34 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
36 # -- Templates for config.h --
38 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
39 AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
40 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
41 AH_TEMPLATE([ICONV], [Define if libiconv can be used, e.g. for CHARCONV])
42 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
43 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
44 AH_TEMPLATE([PAM], [Define if PAM should be used])
45 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
46 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
47 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
48 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
49 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
50 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
52 AH_TEMPLATE([HOST_OS], [Target operating system name])
53 AH_TEMPLATE([HOST_VENDOR], [Target system vendor])
54 AH_TEMPLATE([HOST_CPU], [Target CPU name])
61 # -- Helper programs --
63 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
72 # -- Compiler Features --
78 # -- Function Definitions --
80 AC_DEFUN([GCC_STACK_PROTECT_CC],[
82 # Use -fstack-protector-all for the test to enfoce the use of the
84 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
85 ssp_old_cflags="$CFLAGS"
86 CFLAGS="$CFLAGS -fstack-protector-all"
87 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],[],[ssp_cc=no])
89 CFLAGS="$ssp_old_cflags"
90 if test "X$ssp_cc" = "Xyes"; then
91 CFLAGS="$CFLAGS -fstack-protector"
92 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
96 AC_DEFUN([WORKING_GETADDRINFO],[
97 AC_CHECK_FUNCS([getaddrinfo],[
98 AC_MSG_CHECKING([whether getaddrinfo() works])
99 AC_RUN_IFELSE([AC_LANG_SOURCE([[
101 #include <sys/types.h>
102 #include <sys/socket.h>
105 main(int argc, char **argv)
107 struct addrinfo hints, *ai;
108 memset(&hints, 0, sizeof(hints));
109 hints.ai_flags = AI_PASSIVE;
110 hints.ai_socktype = SOCK_STREAM;
111 hints.ai_family = PF_UNSPEC;
112 if(getaddrinfo(NULL, "0", &hints, &ai) != 0)
117 AC_DEFINE([HAVE_WORKING_GETADDRINFO], 1, [getaddrinfo(0)])
127 # -- Hard coded system and compiler dependencies/features/options ... --
129 if test "$GCC" = "yes"; then
130 # We are using the GNU C compiler. Good!
131 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
138 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
139 # (tested with HP/UX 11.11)
140 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
144 # Add additional CFLAGS, eventually specified on the command line:
145 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
147 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"' -DDOCDIR='\"\$(docdir)\"'"
155 # Required header files
167 ],,AC_MSG_ERROR([required C header missing!]))
169 # Optional header files
170 AC_CHECK_HEADERS_ONCE([ \
184 AC_MSG_CHECKING(whether socklen_t exists)
185 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
186 #include <sys/types.h>
187 #include <sys/socket.h>
190 a = 2; b = 4; a += b;
192 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
205 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
206 [#include <arpa/inet.h>])
210 # memmove: A/UX libUTIL; but we can use our own implementation.
211 AC_SEARCH_LIBS([memmove], [UTIL])
212 # gethostbyname: Solaris libnsl
213 AC_SEARCH_LIBS([gethostbyname], [bind nsl network], [], [
214 AC_MSG_ERROR([unable to find the gethostbyname() function])
216 # bind: SVR4 libsocket
217 AC_SEARCH_LIBS([bind], [socket network], [], [
218 AC_MSG_ERROR([unable to find the bind() function])
248 AC_MSG_ERROR([required function missing!]))
251 AC_CHECK_FUNCS_ONCE([
274 # -- Configuration options --
280 AS_HELP_STRING([--without-syslog],
281 [disable syslog (autodetected by default)]),
282 [ if test "$withval" != "no"; then
283 if test "$withval" != "yes"; then
284 CFLAGS="-I$withval/include $CFLAGS"
285 CPPFLAGS="-I$withval/include $CPPFLAGS"
286 LDFLAGS="-L$withval/lib $LDFLAGS"
288 AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes], [
289 AC_MSG_ERROR([Can't enable syslog!])
293 [ AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes])
296 if test "$x_syslog_on" = "yes"; then
298 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
301 # use zlib compression?
305 AS_HELP_STRING([--without-zlib],
306 [disable zlib compression (autodetected by default)]),
307 [ if test "$withval" != "no"; then
308 if test "$withval" != "yes"; then
309 CFLAGS="-I$withval/include $CFLAGS"
310 CPPFLAGS="-I$withval/include $CPPFLAGS"
311 LDFLAGS="-L$withval/lib $LDFLAGS"
313 AC_CHECK_LIB(z, deflate)
314 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
315 AC_MSG_ERROR([Can't enable zlib!])
319 [ AC_CHECK_LIB(z, deflate)
320 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
323 if test "$x_zlib_on" = "yes"; then
325 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
328 # detect which IO API to use:
333 AS_HELP_STRING([--without-select],
334 [disable select IO support (autodetected by default)]),
335 [ if test "$withval" != "no"; 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_FUNCS(select, x_io_select=yes,
342 AC_MSG_ERROR([Can't enable select IO support!])
347 AC_CHECK_FUNCS(select, x_io_select=yes)
352 AS_HELP_STRING([--without-poll],
353 [disable poll support (autodetected by default)]),
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_FUNCS(poll, [
361 AC_CHECK_HEADERS(poll.h,
362 x_io_backend=poll\(\),
364 [Can't enable poll IO support!])
367 AC_MSG_ERROR([Can't enable poll IO support!])
372 AC_CHECK_FUNCS(poll, [
373 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
379 AS_HELP_STRING([--without-devpoll],
380 [disable /dev/poll IO support (autodetected by default)]),
381 [ if test "$withval" != "no"; then
382 if test "$withval" != "yes"; then
383 CFLAGS="-I$withval/include $CFLAGS"
384 CPPFLAGS="-I$withval/include $CPPFLAGS"
385 LDFLAGS="-L$withval/lib $LDFLAGS"
388 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
392 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
397 AS_HELP_STRING([--without-epoll],
398 [disable epoll IO support (autodetected by default)]),
399 [ if test "$withval" != "no"; then
400 if test "$withval" != "yes"; then
401 CFLAGS="-I$withval/include $CFLAGS"
402 CPPFLAGS="-I$withval/include $CPPFLAGS"
403 LDFLAGS="-L$withval/lib $LDFLAGS"
405 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
406 AC_MSG_ERROR([Can't enable epoll IO support!])
411 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
416 AS_HELP_STRING([--without-kqueue],
417 [disable kqueue IO support (autodetected by default)]),
418 [ if test "$withval" != "no"; then
419 if test "$withval" != "yes"; then
420 CFLAGS="-I$withval/include $CFLAGS"
421 CPPFLAGS="-I$withval/include $CPPFLAGS"
422 LDFLAGS="-L$withval/lib $LDFLAGS"
424 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
425 AC_MSG_ERROR([Can't enable kqueue IO support!])
430 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
434 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
435 # when epoll() and select() are available, we'll use both!
436 x_io_backend="epoll(), select()"
438 if test "$x_io_epoll" = "yes"; then
439 # we prefere epoll() if it is available
440 x_io_backend="epoll()"
442 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
443 # we'll use select, when available and no "better"
444 # interface has been detected ...
445 x_io_backend="select()"
450 if test "$x_io_backend" = "none"; then
451 AC_MSG_ERROR([No useable IO API activated/found!?])
457 AS_HELP_STRING([--with-openssl],
458 [enable SSL support using OpenSSL]),
459 [ if test "$withval" != "no"; then
460 if test "$withval" != "yes"; then
461 CFLAGS="-I$withval/include $CFLAGS"
462 CPPFLAGS="-I$withval/include $CPPFLAGS"
463 LDFLAGS="-L$withval/lib $LDFLAGS"
465 AC_CHECK_LIB(crypto, BIO_s_mem)
466 AC_CHECK_LIB(ssl, SSL_new)
467 AC_CHECK_FUNCS(SSL_new, x_ssl_openssl=yes,
468 AC_MSG_ERROR([Can't enable openssl])
475 AS_HELP_STRING([--with-gnutls],
476 [enable SSL support using gnutls]),
477 [ if test "$withval" != "no"; then
478 if test "$withval" != "yes"; then
479 CFLAGS="-I$withval/include $CFLAGS"
480 CPPFLAGS="-I$withval/include $CPPFLAGS"
481 LDFLAGS="-L$withval/lib $LDFLAGS"
483 AC_CHECK_LIB(gnutls, gnutls_global_init)
484 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
485 AC_MSG_ERROR([Can't enable gnutls])
492 if test "$x_ssl_gnutls" = "yes"; then
493 if test "$x_ssl_openssl" = "yes";then
494 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
498 if test "$x_ssl_openssl" = "yes"; then
505 AC_ARG_WITH(tcp-wrappers,
506 AS_HELP_STRING([--with-tcp-wrappers],
507 [enable TCP wrappers support]),
508 [ if test "$withval" != "no"; then
509 if test "$withval" != "yes"; then
510 CFLAGS="-I$withval/include $CFLAGS"
511 CPPFLAGS="-I$withval/include $CPPFLAGS"
512 LDFLAGS="-L$withval/lib $LDFLAGS"
514 AC_MSG_CHECKING(for hosts_access)
517 LIBS_END="-lwrap $LIBS_END"
518 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
519 #include <sys/types.h>
520 #include <sys/socket.h>
522 int allow_severity = 0;
523 int deny_severity = 0;
525 tcpd_warn("link test");
528 AC_DEFINE(TCPWRAP, 1)
532 AC_MSG_ERROR([Can't enable TCP wrappers!])
539 # do IDENT requests using libident?
543 AS_HELP_STRING([--with-ident],
544 [enable "IDENT" ("AUTH") protocol support]),
545 [ if test "$withval" != "no"; then
546 if test "$withval" != "yes"; then
547 CFLAGS="-I$withval/include $CFLAGS"
548 CPPFLAGS="-I$withval/include $CPPFLAGS"
549 LDFLAGS="-L$withval/lib $LDFLAGS"
551 AC_CHECK_LIB(ident, ident_id)
552 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
553 AC_MSG_ERROR([Can't enable IDENT support!])
558 if test "$x_identauth_on" = "yes"; then
559 AC_DEFINE(IDENTAUTH, 1)
560 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
563 # compile in PAM support?
567 AS_HELP_STRING([--with-pam],
568 [enable user authentication using PAM]),
569 [ if test "$withval" != "no"; then
570 if test "$withval" != "yes"; then
571 CFLAGS="-I$withval/include $CFLAGS"
572 CPPFLAGS="-I$withval/include $CPPFLAGS"
573 LDFLAGS="-L$withval/lib $LDFLAGS"
575 AC_CHECK_LIB(pam, pam_authenticate)
576 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
577 AC_MSG_ERROR([Can't enable PAM support!])
582 if test "$x_pam_on" = "yes"; then
584 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
585 if test "$pam_ok" != "yes"; then
586 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
587 AC_MSG_ERROR([required C header missing!]))
591 # compile in IRC+ protocol support?
594 AC_ARG_ENABLE(ircplus,
595 AS_HELP_STRING([--disable-ircplus],
596 [disable IRC+ protocol]),
597 if test "$enableval" = "no"; then x_ircplus_on=no; fi
599 if test "$x_ircplus_on" = "yes"; then
600 AC_DEFINE(IRCPLUS, 1)
602 # Compile in iconv support?
603 # We only check for it when IRC+ is enabled, because the IRC+ command
604 # CHARCONV is the only function depending on it.
607 AS_HELP_STRING([--with-iconv],
608 [enable character conversion using libiconv]),
609 [ if test "$withval" != "no"; then
610 if test "$withval" != "yes"; then
611 CFLAGS="-I$withval/include $CFLAGS"
612 CPPFLAGS="-I$withval/include $CPPFLAGS"
613 LDFLAGS="-L$withval/lib $LDFLAGS"
615 AC_CHECK_LIB(iconv, iconv_open)
616 AC_CHECK_FUNCS(iconv_open, x_iconv_on=yes)
617 if test "$x_iconv_on" != "yes"; then
618 AC_CHECK_LIB(iconv, libiconv_open)
619 AC_CHECK_FUNCS(libiconv_open, x_iconv_on=yes)
621 if test "$x_iconv_on" != "yes"; then
622 AC_MSG_ERROR([Can't enable libiconv support!])
626 if test "$x_iconv_on" = "yes"; then
631 # enable support for IPv6?
634 AS_HELP_STRING([--enable-ipv6],
635 [enable IPv6 protocol support]),
636 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
638 if test "$x_ipv6_on" = "yes"; then
639 # getaddrinfo() and getnameinfo() are optional when not compiling
640 # with IPv6 support, but are required for IPv6 to work!
642 getaddrinfo getnameinfo \
643 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
644 AC_DEFINE(WANT_IPV6, 1)
647 # compile in IRC "sniffer"?
649 x_sniffer_on=no; x_debug_on=no
650 AC_ARG_ENABLE(sniffer,
651 AS_HELP_STRING([--enable-sniffer],
652 [enable IRC traffic sniffer (enables debug mode)]),
653 if test "$enableval" = "yes"; then
654 AC_DEFINE(SNIFFER, 1)
655 x_sniffer_on=yes; x_debug_on=yes
659 # enable additional debugging code?
662 AS_HELP_STRING([--enable-debug],
663 [show additional debug output]),
664 if test "$enableval" = "yes"; then x_debug_on=yes; fi
666 if test "$x_debug_on" = "yes"; then
668 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
669 AC_CHECK_FUNCS(mtrace)
672 # enable "strict RFC rules"?
675 AC_ARG_ENABLE(strict-rfc,
676 AS_HELP_STRING([--enable-strict-rfc],
677 [strict RFC conformance -- may break clients!]),
678 if test "$enableval" = "yes"; then
679 AC_DEFINE(STRICT_RFC, 1)
686 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu" )
687 AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor" )
688 AC_DEFINE_UNQUOTED(HOST_OS, "$host_os" )
690 # Add additional CFLAGS, LDFLAGS and LIBS which were specified on the command
691 # line or by some tests from above, but after running this script. Useful for
692 # adding "-Werror", for example:
693 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
694 test -n "$LDFLAGS_END" && LDFLAGS="$LDFLAGS $LDFLAGS_END"
695 test -n "$LIBS_END" && LIBS="$LIBS $LIBS_END"
697 # -- Generate files --
701 contrib/Debian/Makefile \
702 contrib/MacOSX/Makefile \
703 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
704 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
709 src/ipaddr/Makefile \
711 src/ngircd/Makefile \
712 src/portab/Makefile \
713 src/testsuite/Makefile \
719 type dpkg >/dev/null 2>&1
720 if test $? -eq 0; then
721 # Generate debian/ link if the dpkg command exists
722 # (read: if we are running on a debian compatible system)
723 echo "creating Debian-specific links ..."
724 if test ! -f debian/rules -a -f contrib/Debian/rules; then
725 ln -s contrib/Debian debian
732 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
735 # Someone please show me a better way :) [borrowed by OpenSSH]
736 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
737 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
738 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
739 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
740 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
742 echo " Host: ${host}"
743 echo " Compiler: ${CC}"
744 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
745 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
746 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
747 test -n "$LIBS" && echo " Libraries: ${LIBS}"
749 echo " 'ngircd' binary: $S"
750 echo " Configuration file: $C"
751 echo " Manual pages: $M"
752 echo " Documentation: $D"
755 echo $ECHO_N " Syslog support: $ECHO_C"
756 test "$x_syslog_on" = "yes" \
757 && echo $ECHO_N "yes $ECHO_C" \
758 || echo $ECHO_N "no $ECHO_C"
759 echo $ECHO_N " Enable debug code: $ECHO_C"
760 test "$x_debug_on" = "yes" \
764 echo $ECHO_N " zlib compression: $ECHO_C"
765 test "$x_zlib_on" = "yes" \
766 && echo $ECHO_N "yes $ECHO_C" \
767 || echo $ECHO_N "no $ECHO_C"
768 echo $ECHO_N " IRC sniffer: $ECHO_C"
769 test "$x_sniffer_on" = "yes" \
773 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
774 test "$x_tcpwrap_on" = "yes" \
775 && echo $ECHO_N "yes $ECHO_C" \
776 || echo $ECHO_N "no $ECHO_C"
777 echo $ECHO_N " Strict RFC mode: $ECHO_C"
778 test "$x_strict_rfc_on" = "yes" \
782 echo $ECHO_N " IDENT support: $ECHO_C"
783 test "$x_identauth_on" = "yes" \
784 && echo $ECHO_N "yes $ECHO_C" \
785 || echo $ECHO_N "no $ECHO_C"
786 echo $ECHO_N " IRC+ protocol: $ECHO_C"
787 test "$x_ircplus_on" = "yes" \
791 echo $ECHO_N " IPv6 protocol: $ECHO_C"
792 test "$x_ipv6_on" = "yes" \
793 && echo $ECHO_N "yes $ECHO_C" \
794 || echo $ECHO_N "no $ECHO_C"
795 echo $ECHO_N " I/O backend: $ECHO_C"
798 echo $ECHO_N " PAM support: $ECHO_C"
799 test "$x_pam_on" = "yes" \
800 && echo $ECHO_N "yes $ECHO_C" \
801 || echo $ECHO_N "no $ECHO_C"
802 echo $ECHO_N " SSL support: $ECHO_C"
805 echo $ECHO_N " libiconv support: $ECHO_C"
810 define(_automake_regex_,[[^AUTOMAKE_OPTIONS = [a-z .\-]*/portab/ansi2knr]])
811 if ! grep "_automake_regex_" src/ngircd/Makefile.am >/dev/null 2>&1; then
813 echo "This GNU automake generated build system does not support \"de-ANSI-fication\","
814 echo "therefore don't use it to generate \"official\" distribution archives!"
815 echo "(Most probably you want to use GNU automake 1.11.x for this purpose ...)"