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 # -- 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_TRY_LINK(,,, 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 # -- Hard coded system and compiler dependencies/features/options ... --
98 if test "$GCC" = "yes"; then
99 # We are using the GNU C compiler. Good!
100 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
107 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
108 # (tested with HP/UX 11.11)
109 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
113 # Add additional CFLAGS, eventually specified on the command line:
114 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
116 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"' -DDOCDIR='\"\$(docdir)\"'"
124 # Required header files
126 fcntl.h netdb.h netinet/in.h stdlib.h string.h \
127 strings.h sys/socket.h sys/time.h unistd.h \
128 ],,AC_MSG_ERROR([required C header missing!]))
130 # Optional header files
131 AC_CHECK_HEADERS_ONCE([ \
132 arpa/inet.h inttypes.h malloc.h netinet/in_systm.h netinet/ip.h \
133 stdbool.h stddef.h stdint.h varargs.h \
138 AC_MSG_CHECKING(whether socklen_t exists)
140 #include <sys/types.h>
141 #include <sys/socket.h>
144 a = 2; b = 4; a += b;
146 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
160 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
161 [#include <arpa/inet.h>])
165 # memmove: A/UX libUTIL
166 AC_SEARCH_LIBS([memmove], [UTIL], [], [
167 AC_MSG_ERROR([unable to find the memmove() function])
169 # gethostbyname: Solaris libnsl
170 AC_SEARCH_LIBS([gethostbyname], [bind nsl network], [], [
171 AC_MSG_ERROR([unable to find the gethostbyname() function])
173 # bind: SVR4 libsocket
174 AC_SEARCH_LIBS([bind], [socket network], [], [
175 AC_MSG_ERROR([unable to find the bind() function])
185 alarm dup2 endpwent gethostbyaddr gethostbyname gethostname \
186 gettimeofday inet_ntoa memmove memset setsid socket strcasecmp \
187 strchr strcspn strerror strncasecmp strrchr strspn strstr \
189 AC_MSG_ERROR([required function missing!]))
192 AC_CHECK_FUNCS_ONCE([ \
193 arc4random arc4random_stir gai_strerror getaddrinfo getnameinfo inet_aton
194 sigaction sigprocmask snprintf vsnprintf strdup strndup strlcpy strlcat \
195 strtok_r unsetenv waitpid])
197 # -- Configuration options --
203 AS_HELP_STRING([--without-syslog],
204 [disable syslog (autodetected by default)]),
205 [ if test "$withval" != "no"; then
206 if test "$withval" != "yes"; then
207 CFLAGS="-I$withval/include $CFLAGS"
208 CPPFLAGS="-I$withval/include $CPPFLAGS"
209 LDFLAGS="-L$withval/lib $LDFLAGS"
211 AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes], [
212 AC_MSG_ERROR([Can't enable syslog!])
216 [ AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes])
219 if test "$x_syslog_on" = "yes"; then
221 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
224 # use zlib compression?
228 AS_HELP_STRING([--without-zlib],
229 [disable zlib compression (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_LIB(z, deflate)
237 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
238 AC_MSG_ERROR([Can't enable zlib!])
242 [ AC_CHECK_LIB(z, deflate)
243 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
246 if test "$x_zlib_on" = "yes"; then
248 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
251 # detect which IO API to use:
256 AS_HELP_STRING([--without-select],
257 [disable select IO support (autodetected by default)]),
258 [ if test "$withval" != "no"; then
259 if test "$withval" != "yes"; then
260 CFLAGS="-I$withval/include $CFLAGS"
261 CPPFLAGS="-I$withval/include $CPPFLAGS"
262 LDFLAGS="-L$withval/lib $LDFLAGS"
264 AC_CHECK_FUNCS(select, x_io_select=yes,
265 AC_MSG_ERROR([Can't enable select IO support!])
270 AC_CHECK_FUNCS(select, x_io_select=yes)
275 AS_HELP_STRING([--without-poll],
276 [disable poll support (autodetected by default)]),
277 [ if test "$withval" != "no"; then
278 if test "$withval" != "yes"; then
279 CFLAGS="-I$withval/include $CFLAGS"
280 CPPFLAGS="-I$withval/include $CPPFLAGS"
281 LDFLAGS="-L$withval/lib $LDFLAGS"
283 AC_CHECK_FUNCS(poll, [
284 AC_CHECK_HEADERS(poll.h,
285 x_io_backend=poll\(\),
287 [Can't enable poll IO support!])
290 AC_MSG_ERROR([Can't enable poll IO support!])
295 AC_CHECK_FUNCS(poll, [
296 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
302 AS_HELP_STRING([--without-devpoll],
303 [disable /dev/poll IO support (autodetected by default)]),
304 [ if test "$withval" != "no"; then
305 if test "$withval" != "yes"; then
306 CFLAGS="-I$withval/include $CFLAGS"
307 CPPFLAGS="-I$withval/include $CPPFLAGS"
308 LDFLAGS="-L$withval/lib $LDFLAGS"
311 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
315 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
320 AS_HELP_STRING([--without-epoll],
321 [disable epoll IO support (autodetected by default)]),
322 [ if test "$withval" != "no"; then
323 if test "$withval" != "yes"; then
324 CFLAGS="-I$withval/include $CFLAGS"
325 CPPFLAGS="-I$withval/include $CPPFLAGS"
326 LDFLAGS="-L$withval/lib $LDFLAGS"
328 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
329 AC_MSG_ERROR([Can't enable epoll IO support!])
334 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
339 AS_HELP_STRING([--without-kqueue],
340 [disable kqueue IO support (autodetected by default)]),
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_FUNCS(kqueue, x_io_backend=kqueue\(\),
348 AC_MSG_ERROR([Can't enable kqueue IO support!])
353 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
357 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
358 # when epoll() and select() are available, we'll use both!
359 x_io_backend="epoll(), select()"
361 if test "$x_io_epoll" = "yes"; then
362 # we prefere epoll() if it is available
363 x_io_backend="epoll()"
365 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
366 # we'll use select, when available and no "better"
367 # interface has been detected ...
368 x_io_backend="select()"
373 if test "$x_io_backend" = "none"; then
374 AC_MSG_ERROR([No useable IO API activated/found!?])
380 AS_HELP_STRING([--with-openssl],
381 [enable SSL support using OpenSSL]),
382 [ if test "$withval" != "no"; then
383 if test "$withval" != "yes"; then
384 CFLAGS="-I$withval/include $CFLAGS"
385 CPPFLAGS="-I$withval/include $CPPFLAGS"
386 LDFLAGS="-L$withval/lib $LDFLAGS"
388 AC_CHECK_LIB(crypto, BIO_s_mem)
389 AC_CHECK_LIB(ssl, SSL_library_init)
390 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
391 AC_MSG_ERROR([Can't enable openssl])
398 AS_HELP_STRING([--with-gnutls],
399 [enable SSL support using gnutls]),
400 [ if test "$withval" != "no"; then
401 if test "$withval" != "yes"; then
402 CFLAGS="-I$withval/include $CFLAGS"
403 CPPFLAGS="-I$withval/include $CPPFLAGS"
404 LDFLAGS="-L$withval/lib $LDFLAGS"
406 AC_CHECK_LIB(gnutls, gnutls_global_init)
407 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
408 AC_MSG_ERROR([Can't enable gnutls])
415 if test "$x_ssl_gnutls" = "yes"; then
416 if test "$x_ssl_openssl" = "yes";then
417 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
421 if test "$x_ssl_openssl" = "yes"; then
428 AC_ARG_WITH(tcp-wrappers,
429 AS_HELP_STRING([--with-tcp-wrappers],
430 [enable TCP wrappers support]),
431 [ if test "$withval" != "no"; then
432 if test "$withval" != "yes"; then
433 CFLAGS="-I$withval/include $CFLAGS"
434 CPPFLAGS="-I$withval/include $CPPFLAGS"
435 LDFLAGS="-L$withval/lib $LDFLAGS"
437 AC_MSG_CHECKING(for hosts_access)
441 int allow_severity = 0;
442 int deny_severity = 0;
444 tcpd_warn("link test");
447 AC_DEFINE(TCPWRAP, 1)
451 AC_MSG_ERROR([Can't enable TCP wrappers!])
457 # do IDENT requests using libident?
461 AS_HELP_STRING([--with-ident],
462 [enable "IDENT" ("AUTH") protocol support]),
463 [ if test "$withval" != "no"; then
464 if test "$withval" != "yes"; then
465 CFLAGS="-I$withval/include $CFLAGS"
466 CPPFLAGS="-I$withval/include $CPPFLAGS"
467 LDFLAGS="-L$withval/lib $LDFLAGS"
469 AC_CHECK_LIB(ident, ident_id)
470 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
471 AC_MSG_ERROR([Can't enable IDENT support!])
476 if test "$x_identauth_on" = "yes"; then
477 AC_DEFINE(IDENTAUTH, 1)
478 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
481 # compile in PAM support?
485 AS_HELP_STRING([--with-pam],
486 [enable user authentication using PAM]),
487 [ if test "$withval" != "no"; then
488 if test "$withval" != "yes"; then
489 CFLAGS="-I$withval/include $CFLAGS"
490 CPPFLAGS="-I$withval/include $CPPFLAGS"
491 LDFLAGS="-L$withval/lib $LDFLAGS"
493 AC_CHECK_LIB(pam, pam_authenticate)
494 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
495 AC_MSG_ERROR([Can't enable PAM support!])
500 if test "$x_pam_on" = "yes"; then
502 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
503 if test "$pam_ok" != "yes"; then
504 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
505 AC_MSG_ERROR([required C header missing!]))
509 # compile in IRC+ protocol support?
512 AC_ARG_ENABLE(ircplus,
513 AS_HELP_STRING([--disable-ircplus],
514 [disable IRC+ protocol]),
515 if test "$enableval" = "no"; then x_ircplus_on=no; fi
517 if test "$x_ircplus_on" = "yes"; then
518 AC_DEFINE(IRCPLUS, 1)
520 # Compile in iconv support?
521 # We only check for it when IRC+ is enabled, because the IRC+ command
522 # CHARCONV is the only function depending on it.
525 AS_HELP_STRING([--with-iconv],
526 [enable character conversion using libiconv]),
527 [ if test "$withval" != "no"; then
528 if test "$withval" != "yes"; then
529 CFLAGS="-I$withval/include $CFLAGS"
530 CPPFLAGS="-I$withval/include $CPPFLAGS"
531 LDFLAGS="-L$withval/lib $LDFLAGS"
533 AC_CHECK_LIB(iconv, iconv_open)
534 AC_CHECK_FUNCS(iconv_open, x_iconv_on=yes)
535 if test "$x_iconv_on" != "yes"; then
536 AC_CHECK_LIB(iconv, libiconv_open)
537 AC_CHECK_FUNCS(libiconv_open, x_iconv_on=yes)
539 if test "$x_iconv_on" != "yes"; then
540 AC_MSG_ERROR([Can't enable libiconv support!])
544 if test "$x_iconv_on" = "yes"; then
549 # enable support for IPv6?
552 AS_HELP_STRING([--enable-ipv6],
553 [enable IPv6 protocol support]),
554 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
556 if test "$x_ipv6_on" = "yes"; then
557 # getaddrinfo() and getnameinfo() are optional when not compiling
558 # with IPv6 support, but are required for IPv6 to work!
560 getaddrinfo getnameinfo \
561 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
562 AC_DEFINE(WANT_IPV6, 1)
565 # compile in IRC "sniffer"?
567 x_sniffer_on=no; x_debug_on=no
568 AC_ARG_ENABLE(sniffer,
569 AS_HELP_STRING([--enable-sniffer],
570 [enable IRC traffic sniffer (enables debug mode)]),
571 if test "$enableval" = "yes"; then
572 AC_DEFINE(SNIFFER, 1)
573 x_sniffer_on=yes; x_debug_on=yes
577 # enable additional debugging code?
580 AS_HELP_STRING([--enable-debug],
581 [show additional debug output]),
582 if test "$enableval" = "yes"; then x_debug_on=yes; fi
584 if test "$x_debug_on" = "yes"; then
586 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
587 AC_CHECK_FUNCS(mtrace)
590 # enable "strict RFC rules"?
593 AC_ARG_ENABLE(strict-rfc,
594 AS_HELP_STRING([--enable-strict-rfc],
595 [strict RFC conformance -- may break clients!]),
596 if test "$enableval" = "yes"; then
597 AC_DEFINE(STRICT_RFC, 1)
604 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu" )
605 AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor" )
606 AC_DEFINE_UNQUOTED(HOST_OS, "$host_os" )
608 # Add additional CFLAGS, eventually specified on the command line, but after
609 # running this configure script. Useful for "-Werror" for example.
610 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
612 # -- Generate files --
616 contrib/Debian/Makefile \
617 contrib/MacOSX/Makefile \
618 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
619 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
624 src/ipaddr/Makefile \
626 src/ngircd/Makefile \
627 src/portab/Makefile \
628 src/testsuite/Makefile \
634 type dpkg >/dev/null 2>&1
635 if test $? -eq 0; then
636 # Generate debian/ link if the dpkg command exists
637 # (read: if we are running on a debian compatible system)
638 echo "creating Debian-specific links ..."
639 test -f debian/rules || ln -s contrib/Debian debian
645 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
648 # Someone please show me a better way :) [borrowed by OpenSSH]
649 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
650 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
651 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
652 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
653 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
655 echo " Host: ${host}"
656 echo " Compiler: ${CC}"
657 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
658 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
659 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
660 test -n "$LIBS" && echo " Libraries: ${LIBS}"
662 echo " 'ngircd' binary: $S"
663 echo " Configuration file: $C"
664 echo " Manual pages: $M"
665 echo " Documentation: $D"
668 echo $ECHO_N " Syslog support: $ECHO_C"
669 test "$x_syslog_on" = "yes" \
670 && echo $ECHO_N "yes $ECHO_C" \
671 || echo $ECHO_N "no $ECHO_C"
672 echo $ECHO_N " Enable debug code: $ECHO_C"
673 test "$x_debug_on" = "yes" \
677 echo $ECHO_N " zlib compression: $ECHO_C"
678 test "$x_zlib_on" = "yes" \
679 && echo $ECHO_N "yes $ECHO_C" \
680 || echo $ECHO_N "no $ECHO_C"
681 echo $ECHO_N " IRC sniffer: $ECHO_C"
682 test "$x_sniffer_on" = "yes" \
686 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
687 test "$x_tcpwrap_on" = "yes" \
688 && echo $ECHO_N "yes $ECHO_C" \
689 || echo $ECHO_N "no $ECHO_C"
690 echo $ECHO_N " Strict RFC mode: $ECHO_C"
691 test "$x_strict_rfc_on" = "yes" \
695 echo $ECHO_N " IDENT support: $ECHO_C"
696 test "$x_identauth_on" = "yes" \
697 && echo $ECHO_N "yes $ECHO_C" \
698 || echo $ECHO_N "no $ECHO_C"
699 echo $ECHO_N " IRC+ protocol: $ECHO_C"
700 test "$x_ircplus_on" = "yes" \
704 echo $ECHO_N " IPv6 protocol: $ECHO_C"
705 test "$x_ipv6_on" = "yes" \
706 && echo $ECHO_N "yes $ECHO_C" \
707 || echo $ECHO_N "no $ECHO_C"
708 echo $ECHO_N " I/O backend: $ECHO_C"
711 echo $ECHO_N " PAM support: $ECHO_C"
712 test "$x_pam_on" = "yes" \
713 && echo $ECHO_N "yes $ECHO_C" \
714 || echo $ECHO_N "no $ECHO_C"
715 echo $ECHO_N " SSL support: $ECHO_C"
718 echo $ECHO_N " libiconv support: $ECHO_C"
723 define(_automake_regex_,[[^AUTOMAKE_OPTIONS = [a-z .\-]*/portab/ansi2knr]])
724 if ! grep "_automake_regex_" src/ngircd/Makefile.am >/dev/null 2>&1; then
726 echo "This GNU automake generated build system does not support \"de-ANSI-fication\","
727 echo "therefore don't use it to generate \"official\" distribution archives!"
728 echo "(Most probably you want to use GNU automake 1.11.x for this purpose ...)"