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 arc4random gai_strerror getaddrinfo getnameinfo inet_aton sigaction \
191 sigprocmask snprintf vsnprintf strdup strndup strlcpy strlcat strtok_r \
194 # -- Configuration options --
200 AS_HELP_STRING([--without-syslog],
201 [disable syslog (autodetected by default)]),
202 [ if test "$withval" != "no"; then
203 if test "$withval" != "yes"; then
204 CFLAGS="-I$withval/include $CFLAGS"
205 CPPFLAGS="-I$withval/include $CPPFLAGS"
206 LDFLAGS="-L$withval/lib $LDFLAGS"
208 AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes], [
209 AC_MSG_ERROR([Can't enable syslog!])
213 [ AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes])
216 if test "$x_syslog_on" = "yes"; then
218 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
221 # use zlib compression?
225 AS_HELP_STRING([--without-zlib],
226 [disable zlib compression (autodetected by default)]),
227 [ if test "$withval" != "no"; then
228 if test "$withval" != "yes"; then
229 CFLAGS="-I$withval/include $CFLAGS"
230 CPPFLAGS="-I$withval/include $CPPFLAGS"
231 LDFLAGS="-L$withval/lib $LDFLAGS"
233 AC_CHECK_LIB(z, deflate)
234 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
235 AC_MSG_ERROR([Can't enable zlib!])
239 [ AC_CHECK_LIB(z, deflate)
240 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
243 if test "$x_zlib_on" = "yes"; then
245 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
248 # detect which IO API to use:
253 AS_HELP_STRING([--without-select],
254 [disable select IO support (autodetected by default)]),
255 [ if test "$withval" != "no"; then
256 if test "$withval" != "yes"; then
257 CFLAGS="-I$withval/include $CFLAGS"
258 CPPFLAGS="-I$withval/include $CPPFLAGS"
259 LDFLAGS="-L$withval/lib $LDFLAGS"
261 AC_CHECK_FUNCS(select, x_io_select=yes,
262 AC_MSG_ERROR([Can't enable select IO support!])
267 AC_CHECK_FUNCS(select, x_io_select=yes)
272 AS_HELP_STRING([--without-poll],
273 [disable poll support (autodetected by default)]),
274 [ if test "$withval" != "no"; then
275 if test "$withval" != "yes"; then
276 CFLAGS="-I$withval/include $CFLAGS"
277 CPPFLAGS="-I$withval/include $CPPFLAGS"
278 LDFLAGS="-L$withval/lib $LDFLAGS"
280 AC_CHECK_FUNCS(poll, [
281 AC_CHECK_HEADERS(poll.h,
282 x_io_backend=poll\(\),
284 [Can't enable poll IO support!])
287 AC_MSG_ERROR([Can't enable poll IO support!])
292 AC_CHECK_FUNCS(poll, [
293 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
299 AS_HELP_STRING([--without-devpoll],
300 [disable /dev/poll 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"
308 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
312 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
317 AS_HELP_STRING([--without-epoll],
318 [disable epoll IO support (autodetected by default)]),
319 [ if test "$withval" != "no"; then
320 if test "$withval" != "yes"; then
321 CFLAGS="-I$withval/include $CFLAGS"
322 CPPFLAGS="-I$withval/include $CPPFLAGS"
323 LDFLAGS="-L$withval/lib $LDFLAGS"
325 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
326 AC_MSG_ERROR([Can't enable epoll IO support!])
331 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
336 AS_HELP_STRING([--without-kqueue],
337 [disable kqueue IO support (autodetected by default)]),
338 [ if test "$withval" != "no"; then
339 if test "$withval" != "yes"; then
340 CFLAGS="-I$withval/include $CFLAGS"
341 CPPFLAGS="-I$withval/include $CPPFLAGS"
342 LDFLAGS="-L$withval/lib $LDFLAGS"
344 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
345 AC_MSG_ERROR([Can't enable kqueue IO support!])
350 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
354 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
355 # when epoll() and select() are available, we'll use both!
356 x_io_backend="epoll(), select()"
358 if test "$x_io_epoll" = "yes"; then
359 # we prefere epoll() if it is available
360 x_io_backend="epoll()"
362 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
363 # we'll use select, when available and no "better"
364 # interface has been detected ...
365 x_io_backend="select()"
370 if test "$x_io_backend" = "none"; then
371 AC_MSG_ERROR([No useable IO API activated/found!?])
377 AS_HELP_STRING([--with-openssl],
378 [enable SSL support using OpenSSL]),
379 [ if test "$withval" != "no"; then
380 if test "$withval" != "yes"; then
381 CFLAGS="-I$withval/include $CFLAGS"
382 CPPFLAGS="-I$withval/include $CPPFLAGS"
383 LDFLAGS="-L$withval/lib $LDFLAGS"
385 AC_CHECK_LIB(crypto, BIO_s_mem)
386 AC_CHECK_LIB(ssl, SSL_library_init)
387 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
388 AC_MSG_ERROR([Can't enable openssl])
395 AS_HELP_STRING([--with-gnutls],
396 [enable SSL support using gnutls]),
397 [ if test "$withval" != "no"; then
398 if test "$withval" != "yes"; then
399 CFLAGS="-I$withval/include $CFLAGS"
400 CPPFLAGS="-I$withval/include $CPPFLAGS"
401 LDFLAGS="-L$withval/lib $LDFLAGS"
403 AC_CHECK_LIB(gnutls, gnutls_global_init)
404 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
405 AC_MSG_ERROR([Can't enable gnutls])
412 if test "$x_ssl_gnutls" = "yes"; then
413 if test "$x_ssl_openssl" = "yes";then
414 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
418 if test "$x_ssl_openssl" = "yes"; then
425 AC_ARG_WITH(tcp-wrappers,
426 AS_HELP_STRING([--with-tcp-wrappers],
427 [enable TCP wrappers support]),
428 [ if test "$withval" != "no"; then
429 if test "$withval" != "yes"; then
430 CFLAGS="-I$withval/include $CFLAGS"
431 CPPFLAGS="-I$withval/include $CPPFLAGS"
432 LDFLAGS="-L$withval/lib $LDFLAGS"
434 AC_MSG_CHECKING(for hosts_access)
438 int allow_severity = 0;
439 int deny_severity = 0;
441 tcpd_warn("link test");
444 AC_DEFINE(TCPWRAP, 1)
448 AC_MSG_ERROR([Can't enable TCP wrappers!])
454 # do IDENT requests using libident?
458 AS_HELP_STRING([--with-ident],
459 [enable "IDENT" ("AUTH") protocol support]),
460 [ if test "$withval" != "no"; then
461 if test "$withval" != "yes"; then
462 CFLAGS="-I$withval/include $CFLAGS"
463 CPPFLAGS="-I$withval/include $CPPFLAGS"
464 LDFLAGS="-L$withval/lib $LDFLAGS"
466 AC_CHECK_LIB(ident, ident_id)
467 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
468 AC_MSG_ERROR([Can't enable IDENT support!])
473 if test "$x_identauth_on" = "yes"; then
474 AC_DEFINE(IDENTAUTH, 1)
475 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
478 # compile in PAM support?
482 AS_HELP_STRING([--with-pam],
483 [enable user authentication using PAM]),
484 [ if test "$withval" != "no"; then
485 if test "$withval" != "yes"; then
486 CFLAGS="-I$withval/include $CFLAGS"
487 CPPFLAGS="-I$withval/include $CPPFLAGS"
488 LDFLAGS="-L$withval/lib $LDFLAGS"
490 AC_CHECK_LIB(pam, pam_authenticate)
491 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
492 AC_MSG_ERROR([Can't enable PAM support!])
497 if test "$x_pam_on" = "yes"; then
499 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
500 if test "$pam_ok" != "yes"; then
501 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
502 AC_MSG_ERROR([required C header missing!]))
506 # compile in IRC+ protocol support?
509 AC_ARG_ENABLE(ircplus,
510 AS_HELP_STRING([--disable-ircplus],
511 [disable IRC+ protocol]),
512 if test "$enableval" = "no"; then x_ircplus_on=no; fi
514 if test "$x_ircplus_on" = "yes"; then
515 AC_DEFINE(IRCPLUS, 1)
517 # Compile in iconv support?
518 # We only check for it when IRC+ is enabled, because the IRC+ command
519 # CHARCONV is the only function depending on it.
522 AS_HELP_STRING([--with-iconv],
523 [enable character conversion using libiconv]),
524 [ if test "$withval" != "no"; then
525 if test "$withval" != "yes"; then
526 CFLAGS="-I$withval/include $CFLAGS"
527 CPPFLAGS="-I$withval/include $CPPFLAGS"
528 LDFLAGS="-L$withval/lib $LDFLAGS"
530 AC_CHECK_LIB(iconv, iconv_open)
531 AC_CHECK_FUNCS(iconv_open, x_iconv_on=yes)
532 if test "$x_iconv_on" != "yes"; then
533 AC_CHECK_LIB(iconv, libiconv_open)
534 AC_CHECK_FUNCS(libiconv_open, x_iconv_on=yes)
536 if test "$x_iconv_on" != "yes"; then
537 AC_MSG_ERROR([Can't enable libiconv support!])
541 if test "$x_iconv_on" = "yes"; then
546 # enable support for IPv6?
549 AS_HELP_STRING([--enable-ipv6],
550 [enable IPv6 protocol support]),
551 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
553 if test "$x_ipv6_on" = "yes"; then
554 # getaddrinfo() and getnameinfo() are optional when not compiling
555 # with IPv6 support, but are required for IPv6 to work!
557 getaddrinfo getnameinfo \
558 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
559 AC_DEFINE(WANT_IPV6, 1)
562 # compile in IRC "sniffer"?
564 x_sniffer_on=no; x_debug_on=no
565 AC_ARG_ENABLE(sniffer,
566 AS_HELP_STRING([--enable-sniffer],
567 [enable IRC traffic sniffer (enables debug mode)]),
568 if test "$enableval" = "yes"; then
569 AC_DEFINE(SNIFFER, 1)
570 x_sniffer_on=yes; x_debug_on=yes
574 # enable additional debugging code?
577 AS_HELP_STRING([--enable-debug],
578 [show additional debug output]),
579 if test "$enableval" = "yes"; then x_debug_on=yes; fi
581 if test "$x_debug_on" = "yes"; then
583 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
584 AC_CHECK_FUNCS(mtrace)
587 # enable "strict RFC rules"?
590 AC_ARG_ENABLE(strict-rfc,
591 AS_HELP_STRING([--enable-strict-rfc],
592 [strict RFC conformance -- may break clients!]),
593 if test "$enableval" = "yes"; then
594 AC_DEFINE(STRICT_RFC, 1)
601 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu" )
602 AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor" )
603 AC_DEFINE_UNQUOTED(HOST_OS, "$host_os" )
605 # Add additional CFLAGS, eventually specified on the command line, but after
606 # running this configure script. Useful for "-Werror" for example.
607 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
609 # -- Generate files --
613 contrib/Debian/Makefile \
614 contrib/MacOSX/Makefile \
615 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
616 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
621 src/ipaddr/Makefile \
623 src/ngircd/Makefile \
624 src/portab/Makefile \
625 src/testsuite/Makefile \
631 type dpkg >/dev/null 2>&1
632 if test $? -eq 0; then
633 # Generate debian/ link if the dpkg command exists
634 # (read: if we are running on a debian compatible system)
635 echo "creating Debian-specific links ..."
636 test -f debian/rules || ln -s contrib/Debian debian
642 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
645 # Someone please show me a better way :) [borrowed by OpenSSH]
646 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
647 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
648 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
649 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
650 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
652 echo " Host: ${host}"
653 echo " Compiler: ${CC}"
654 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
655 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
656 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
657 test -n "$LIBS" && echo " Libraries: ${LIBS}"
659 echo " 'ngircd' binary: $S"
660 echo " Configuration file: $C"
661 echo " Manual pages: $M"
662 echo " Documentation: $D"
665 echo $ECHO_N " Syslog support: $ECHO_C"
666 test "$x_syslog_on" = "yes" \
667 && echo $ECHO_N "yes $ECHO_C" \
668 || echo $ECHO_N "no $ECHO_C"
669 echo $ECHO_N " Enable debug code: $ECHO_C"
670 test "$x_debug_on" = "yes" \
674 echo $ECHO_N " zlib compression: $ECHO_C"
675 test "$x_zlib_on" = "yes" \
676 && echo $ECHO_N "yes $ECHO_C" \
677 || echo $ECHO_N "no $ECHO_C"
678 echo $ECHO_N " IRC sniffer: $ECHO_C"
679 test "$x_sniffer_on" = "yes" \
683 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
684 test "$x_tcpwrap_on" = "yes" \
685 && echo $ECHO_N "yes $ECHO_C" \
686 || echo $ECHO_N "no $ECHO_C"
687 echo $ECHO_N " Strict RFC mode: $ECHO_C"
688 test "$x_strict_rfc_on" = "yes" \
692 echo $ECHO_N " IDENT support: $ECHO_C"
693 test "$x_identauth_on" = "yes" \
694 && echo $ECHO_N "yes $ECHO_C" \
695 || echo $ECHO_N "no $ECHO_C"
696 echo $ECHO_N " IRC+ protocol: $ECHO_C"
697 test "$x_ircplus_on" = "yes" \
701 echo $ECHO_N " IPv6 protocol: $ECHO_C"
702 test "$x_ipv6_on" = "yes" \
703 && echo $ECHO_N "yes $ECHO_C" \
704 || echo $ECHO_N "no $ECHO_C"
705 echo $ECHO_N " I/O backend: $ECHO_C"
708 echo $ECHO_N " PAM support: $ECHO_C"
709 test "$x_pam_on" = "yes" \
710 && echo $ECHO_N "yes $ECHO_C" \
711 || echo $ECHO_N "no $ECHO_C"
712 echo $ECHO_N " SSL support: $ECHO_C"
715 echo $ECHO_N " libiconv support: $ECHO_C"
720 define(_automake_regex_,[[^AUTOMAKE_OPTIONS = [a-z .\-]*/portab/ansi2knr]])
721 if ! grep "_automake_regex_" src/ngircd/Makefile.am >/dev/null 2>&1; then
723 echo "This GNU automake generated build system does not support \"de-ANSI-fication\","
724 echo "therefore don't use it to generate \"official\" distribution archives!"
725 echo "(Most probably you want to use GNU automake 1.11.x for this purpose ...)"