2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2013 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,
27 [ngircd-ml@ngircd.barton.de], [ngircd], [http://ngircd.barton.de/])
29 AC_CONFIG_SRCDIR([src/ngircd/ngircd.c])
30 AC_CONFIG_HEADER([src/config.h])
33 AM_INIT_AUTOMAKE([-Wall 1.10 ]ng_color_tests)
35 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
37 # -- Templates for config.h --
39 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
40 AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
41 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
42 AH_TEMPLATE([ICONV], [Define if libiconv can be used, e.g. for CHARCONV])
43 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
44 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
45 AH_TEMPLATE([PAM], [Define if PAM should be used])
46 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
47 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
48 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
49 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
50 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
51 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
53 AH_TEMPLATE([HOST_OS], [Target operating system name])
54 AH_TEMPLATE([HOST_VENDOR], [Target system vendor])
55 AH_TEMPLATE([HOST_CPU], [Target CPU name])
62 # -- Helper programs --
64 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
72 # -- Compiler Features --
78 # -- Hard coded system and compiler dependencies/features/options ... --
80 AC_DEFUN([GCC_STACK_PROTECT_CC],[
82 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
83 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
84 ssp_old_cflags="$CFLAGS"
85 CFLAGS="$CFLAGS -fstack-protector-all"
86 AC_TRY_LINK(,,, ssp_cc=no)
88 CFLAGS="$ssp_old_cflags"
89 if test "X$ssp_cc" = "Xyes"; then
90 CFLAGS="$CFLAGS -fstack-protector"
91 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
95 if test "$GCC" = "yes"; then
96 # We are using the GNU C compiler. Good!
97 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
104 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
105 # (tested with HP/UX 11.11)
106 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
110 # Add additional CFLAGS, eventually specified on the command line:
111 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
113 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"' -DDOCDIR='\"\$(docdir)\"'"
121 # Required header files
123 fcntl.h netdb.h netinet/in.h stdlib.h string.h \
124 strings.h sys/socket.h sys/time.h unistd.h \
125 ],,AC_MSG_ERROR([required C header missing!]))
127 # Optional header files
128 AC_CHECK_HEADERS_ONCE([ \
129 arpa/inet.h inttypes.h malloc.h netinet/in_systm.h netinet/ip.h \
130 stdbool.h stddef.h stdint.h varargs.h \
135 AC_MSG_CHECKING(whether socklen_t exists)
137 #include <sys/types.h>
138 #include <sys/socket.h>
141 a = 2; b = 4; a += b;
143 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
157 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
158 [#include <arpa/inet.h>])
162 # memmove: A/UX libUTIL
163 AC_SEARCH_LIBS([memmove], [UTIL], [], [
164 AC_MSG_ERROR([unable to find the memmove() function])
166 # gethostbyname: Solaris libnsl
167 AC_SEARCH_LIBS([gethostbyname], [bind nsl network], [], [
168 AC_MSG_ERROR([unable to find the gethostbyname() function])
170 # bind: SVR4 libsocket
171 AC_SEARCH_LIBS([bind], [socket network], [], [
172 AC_MSG_ERROR([unable to find the bind() function])
182 alarm dup2 endpwent gethostbyaddr gethostbyname gethostname \
183 gettimeofday inet_ntoa memmove memset setsid socket strcasecmp \
184 strchr strcspn strerror strncasecmp strrchr strspn strstr \
186 AC_MSG_ERROR([required function missing!]))
189 AC_CHECK_FUNCS_ONCE([ \
190 gai_strerror getaddrinfo getnameinfo inet_aton sigaction sigprocmask \
191 snprintf vsnprintf strdup strndup strlcpy strlcat strtok_r waitpid])
193 # -- Configuration options --
199 AS_HELP_STRING([--without-syslog],
200 [disable syslog (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_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes], [
208 AC_MSG_ERROR([Can't enable syslog!])
212 [ AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes])
215 if test "$x_syslog_on" = "yes"; then
217 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
220 # use zlib compression?
224 AS_HELP_STRING([--without-zlib],
225 [disable zlib compression (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_LIB(z, deflate)
233 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
234 AC_MSG_ERROR([Can't enable zlib!])
238 [ AC_CHECK_LIB(z, deflate)
239 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
242 if test "$x_zlib_on" = "yes"; then
244 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
247 # detect which IO API to use:
252 AS_HELP_STRING([--without-select],
253 [disable select IO support (autodetected by default)]),
254 [ if test "$withval" != "no"; then
255 if test "$withval" != "yes"; then
256 CFLAGS="-I$withval/include $CFLAGS"
257 CPPFLAGS="-I$withval/include $CPPFLAGS"
258 LDFLAGS="-L$withval/lib $LDFLAGS"
260 AC_CHECK_FUNCS(select, x_io_select=yes,
261 AC_MSG_ERROR([Can't enable select IO support!])
266 AC_CHECK_FUNCS(select, x_io_select=yes)
271 AS_HELP_STRING([--without-poll],
272 [disable poll support (autodetected by default)]),
273 [ if test "$withval" != "no"; then
274 if test "$withval" != "yes"; then
275 CFLAGS="-I$withval/include $CFLAGS"
276 CPPFLAGS="-I$withval/include $CPPFLAGS"
277 LDFLAGS="-L$withval/lib $LDFLAGS"
279 AC_CHECK_FUNCS(poll, [
280 AC_CHECK_HEADERS(poll.h,
281 x_io_backend=poll\(\),
283 [Can't enable poll IO support!])
286 AC_MSG_ERROR([Can't enable poll IO support!])
291 AC_CHECK_FUNCS(poll, [
292 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
298 AS_HELP_STRING([--without-devpoll],
299 [disable /dev/poll IO support (autodetected by default)]),
300 [ if test "$withval" != "no"; then
301 if test "$withval" != "yes"; then
302 CFLAGS="-I$withval/include $CFLAGS"
303 CPPFLAGS="-I$withval/include $CPPFLAGS"
304 LDFLAGS="-L$withval/lib $LDFLAGS"
307 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
311 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
316 AS_HELP_STRING([--without-epoll],
317 [disable epoll IO support (autodetected by default)]),
318 [ if test "$withval" != "no"; then
319 if test "$withval" != "yes"; then
320 CFLAGS="-I$withval/include $CFLAGS"
321 CPPFLAGS="-I$withval/include $CPPFLAGS"
322 LDFLAGS="-L$withval/lib $LDFLAGS"
324 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
325 AC_MSG_ERROR([Can't enable epoll IO support!])
330 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
335 AS_HELP_STRING([--without-kqueue],
336 [disable kqueue IO support (autodetected by default)]),
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_FUNCS(kqueue, x_io_backend=kqueue\(\),
344 AC_MSG_ERROR([Can't enable kqueue IO support!])
349 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
353 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
354 # when epoll() and select() are available, we'll use both!
355 x_io_backend="epoll(), select()"
357 if test "$x_io_epoll" = "yes"; then
358 # we prefere epoll() if it is available
359 x_io_backend="epoll()"
361 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
362 # we'll use select, when available and no "better"
363 # interface has been detected ...
364 x_io_backend="select()"
369 if test "$x_io_backend" = "none"; then
370 AC_MSG_ERROR([No useable IO API activated/found!?])
376 AS_HELP_STRING([--with-openssl],
377 [enable SSL support using OpenSSL]),
378 [ if test "$withval" != "no"; then
379 if test "$withval" != "yes"; then
380 CFLAGS="-I$withval/include $CFLAGS"
381 CPPFLAGS="-I$withval/include $CPPFLAGS"
382 LDFLAGS="-L$withval/lib $LDFLAGS"
384 AC_CHECK_LIB(crypto, BIO_s_mem)
385 AC_CHECK_LIB(ssl, SSL_library_init)
386 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
387 AC_MSG_ERROR([Can't enable openssl])
394 AS_HELP_STRING([--with-gnutls],
395 [enable SSL support using gnutls]),
396 [ if test "$withval" != "no"; then
397 if test "$withval" != "yes"; then
398 CFLAGS="-I$withval/include $CFLAGS"
399 CPPFLAGS="-I$withval/include $CPPFLAGS"
400 LDFLAGS="-L$withval/lib $LDFLAGS"
402 AC_CHECK_LIB(gnutls, gnutls_global_init)
403 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
404 AC_MSG_ERROR([Can't enable gnutls])
411 if test "$x_ssl_gnutls" = "yes"; then
412 if test "$x_ssl_openssl" = "yes";then
413 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
417 if test "$x_ssl_openssl" = "yes"; then
424 AC_ARG_WITH(tcp-wrappers,
425 AS_HELP_STRING([--with-tcp-wrappers],
426 [enable TCP wrappers support]),
427 [ if test "$withval" != "no"; then
428 if test "$withval" != "yes"; then
429 CFLAGS="-I$withval/include $CFLAGS"
430 CPPFLAGS="-I$withval/include $CPPFLAGS"
431 LDFLAGS="-L$withval/lib $LDFLAGS"
433 AC_MSG_CHECKING(for hosts_access)
437 int allow_severity = 0;
438 int deny_severity = 0;
440 tcpd_warn("link test");
443 AC_DEFINE(TCPWRAP, 1)
447 AC_MSG_ERROR([Can't enable TCP wrappers!])
453 # do IDENT requests using libident?
457 AS_HELP_STRING([--with-ident],
458 [enable "IDENT" ("AUTH") protocol support]),
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(ident, ident_id)
466 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
467 AC_MSG_ERROR([Can't enable IDENT support!])
472 if test "$x_identauth_on" = "yes"; then
473 AC_DEFINE(IDENTAUTH, 1)
474 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
477 # compile in PAM support?
481 AS_HELP_STRING([--with-pam],
482 [enable user authentication using PAM]),
483 [ if test "$withval" != "no"; then
484 if test "$withval" != "yes"; then
485 CFLAGS="-I$withval/include $CFLAGS"
486 CPPFLAGS="-I$withval/include $CPPFLAGS"
487 LDFLAGS="-L$withval/lib $LDFLAGS"
489 AC_CHECK_LIB(pam, pam_authenticate)
490 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
491 AC_MSG_ERROR([Can't enable PAM support!])
496 if test "$x_pam_on" = "yes"; then
498 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
499 if test "$pam_ok" != "yes"; then
500 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
501 AC_MSG_ERROR([required C header missing!]))
505 # compile in IRC+ protocol support?
508 AC_ARG_ENABLE(ircplus,
509 AS_HELP_STRING([--disable-ircplus],
510 [disable IRC+ protocol]),
511 if test "$enableval" = "no"; then x_ircplus_on=no; fi
513 if test "$x_ircplus_on" = "yes"; then
514 AC_DEFINE(IRCPLUS, 1)
516 # Compile in iconv support?
517 # We only check for it when IRC+ is enabled, because the IRC+ command
518 # CHARCONV is the only function depending on it.
521 AS_HELP_STRING([--with-iconv],
522 [enable character conversion using libiconv]),
523 [ if test "$withval" != "no"; then
524 if test "$withval" != "yes"; then
525 CFLAGS="-I$withval/include $CFLAGS"
526 CPPFLAGS="-I$withval/include $CPPFLAGS"
527 LDFLAGS="-L$withval/lib $LDFLAGS"
529 AC_CHECK_LIB(iconv, iconv_open)
530 AC_CHECK_FUNCS(iconv_open, x_iconv_on=yes)
531 if test "$x_iconv_on" != "yes"; then
532 AC_CHECK_LIB(iconv, libiconv_open)
533 AC_CHECK_FUNCS(libiconv_open, x_iconv_on=yes)
535 if test "$x_iconv_on" != "yes"; then
536 AC_MSG_ERROR([Can't enable libiconv support!])
540 if test "$x_iconv_on" = "yes"; then
545 # enable support for IPv6?
548 AS_HELP_STRING([--enable-ipv6],
549 [enable IPv6 protocol support]),
550 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
552 if test "$x_ipv6_on" = "yes"; then
553 # getaddrinfo() and getnameinfo() are optional when not compiling
554 # with IPv6 support, but are required for IPv6 to work!
556 getaddrinfo getnameinfo \
557 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
558 AC_DEFINE(WANT_IPV6, 1)
561 # compile in IRC "sniffer"?
563 x_sniffer_on=no; x_debug_on=no
564 AC_ARG_ENABLE(sniffer,
565 AS_HELP_STRING([--enable-sniffer],
566 [enable IRC traffic sniffer (enables debug mode)]),
567 if test "$enableval" = "yes"; then
568 AC_DEFINE(SNIFFER, 1)
569 x_sniffer_on=yes; x_debug_on=yes
573 # enable additional debugging code?
576 AS_HELP_STRING([--enable-debug],
577 [show additional debug output]),
578 if test "$enableval" = "yes"; then x_debug_on=yes; fi
580 if test "$x_debug_on" = "yes"; then
582 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
583 AC_CHECK_FUNCS(mtrace)
586 # enable "strict RFC rules"?
589 AC_ARG_ENABLE(strict-rfc,
590 AS_HELP_STRING([--enable-strict-rfc],
591 [strict RFC conformance -- may break clients!]),
592 if test "$enableval" = "yes"; then
593 AC_DEFINE(STRICT_RFC, 1)
600 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu" )
601 AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor" )
602 AC_DEFINE_UNQUOTED(HOST_OS, "$host_os" )
604 # Add additional CFLAGS, eventually specified on the command line, but after
605 # running this configure script. Useful for "-Werror" for example.
606 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
608 # -- Generate files --
612 contrib/Debian/Makefile \
613 contrib/MacOSX/Makefile \
614 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
615 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
620 src/ipaddr/Makefile \
622 src/ngircd/Makefile \
623 src/portab/Makefile \
624 src/testsuite/Makefile \
630 type dpkg >/dev/null 2>&1
631 if test $? -eq 0; then
632 # Generate debian/ link if the dpkg command exists
633 # (read: if we are running on a debian compatible system)
634 echo "creating Debian-specific links ..."
635 test -f debian/rules || ln -s contrib/Debian debian
641 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
644 # Someone please show me a better way :) [borrowed by OpenSSH]
645 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
646 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
647 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
648 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
649 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
651 echo " Host: ${host}"
652 echo " Compiler: ${CC}"
653 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
654 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
655 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
656 test -n "$LIBS" && echo " Libraries: ${LIBS}"
658 echo " 'ngircd' binary: $S"
659 echo " Configuration file: $C"
660 echo " Manual pages: $M"
661 echo " Documentation: $D"
664 echo $ECHO_N " Syslog support: $ECHO_C"
665 test "$x_syslog_on" = "yes" \
666 && echo $ECHO_N "yes $ECHO_C" \
667 || echo $ECHO_N "no $ECHO_C"
668 echo $ECHO_N " Enable debug code: $ECHO_C"
669 test "$x_debug_on" = "yes" \
673 echo $ECHO_N " zlib compression: $ECHO_C"
674 test "$x_zlib_on" = "yes" \
675 && echo $ECHO_N "yes $ECHO_C" \
676 || echo $ECHO_N "no $ECHO_C"
677 echo $ECHO_N " IRC sniffer: $ECHO_C"
678 test "$x_sniffer_on" = "yes" \
682 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
683 test "$x_tcpwrap_on" = "yes" \
684 && echo $ECHO_N "yes $ECHO_C" \
685 || echo $ECHO_N "no $ECHO_C"
686 echo $ECHO_N " Strict RFC mode: $ECHO_C"
687 test "$x_strict_rfc_on" = "yes" \
691 echo $ECHO_N " IDENT support: $ECHO_C"
692 test "$x_identauth_on" = "yes" \
693 && echo $ECHO_N "yes $ECHO_C" \
694 || echo $ECHO_N "no $ECHO_C"
695 echo $ECHO_N " IRC+ protocol: $ECHO_C"
696 test "$x_ircplus_on" = "yes" \
700 echo $ECHO_N " IPv6 protocol: $ECHO_C"
701 test "$x_ipv6_on" = "yes" \
702 && echo $ECHO_N "yes $ECHO_C" \
703 || echo $ECHO_N "no $ECHO_C"
704 echo $ECHO_N " I/O backend: $ECHO_C"
707 echo $ECHO_N " PAM support: $ECHO_C"
708 test "$x_pam_on" = "yes" \
709 && echo $ECHO_N "yes $ECHO_C" \
710 || echo $ECHO_N "no $ECHO_C"
711 echo $ECHO_N " SSL support: $ECHO_C"
714 echo $ECHO_N " libiconv support: $ECHO_C"
719 define(_automake_regex_,[[^AUTOMAKE_OPTIONS = [a-z .\-]*/portab/ansi2knr]])
720 if ! grep "_automake_regex_" src/ngircd/Makefile.am >/dev/null 2>&1; then
722 echo "This GNU automake generated build system does not support \"de-ANSI-fication\","
723 echo "therefore don't use it to generate \"official\" distribution archives!"
724 echo "(Most probably you want to use GNU automake 1.11.x for this purpose ...)"