2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2012 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(git describe|sed -e 's/rel-//g'|sed -e 's/-/~/'|tr -d \\n))
14 # -- Initialisation --
17 AC_INIT([ngIRCd], VERSION_ID,
18 [ngircd-ml@ngircd.barton.de], [ngircd], [http://ngircd.barton.de/])
20 AC_CONFIG_SRCDIR([src/ngircd/ngircd.c])
21 AC_CONFIG_HEADER([src/config.h])
24 AM_INIT_AUTOMAKE([1.11])
26 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
28 # -- Templates for config.h --
30 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
31 AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
32 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
33 AH_TEMPLATE([ICONV], [Define if libiconv can be used, e.g. for CHARCONV])
34 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
35 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
36 AH_TEMPLATE([PAM], [Define if PAM should be used])
37 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
38 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
39 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
40 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
41 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
42 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
44 AH_TEMPLATE([HOST_OS], [Target operating system name])
45 AH_TEMPLATE([HOST_VENDOR], [Target system vendor])
46 AH_TEMPLATE([HOST_CPU], [Target CPU name])
53 # -- Helper programs --
61 # -- Compiler Features --
67 # -- Hard coded system and compiler dependencies/features/options ... --
69 AC_DEFUN([GCC_STACK_PROTECT_CC],[
71 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
72 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
73 ssp_old_cflags="$CFLAGS"
74 CFLAGS="$CFLAGS -fstack-protector-all"
75 AC_TRY_LINK(,,, ssp_cc=no)
77 CFLAGS="$ssp_old_cflags"
78 if test "X$ssp_cc" = "Xyes"; then
79 CFLAGS="$CFLAGS -fstack-protector"
80 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
84 if test "$GCC" = "yes"; then
85 # We are using the GNU C compiler. Good!
86 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
93 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
94 # (tested with HP/UX 11.11)
95 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
99 # Add additional CFLAGS, eventually specified on the command line:
100 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
102 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
110 # Required header files
112 fcntl.h netdb.h netinet/in.h netinet/in_systm.h stdlib.h string.h \
113 strings.h sys/socket.h sys/time.h unistd.h \
114 ],,AC_MSG_ERROR([required C header missing!]))
116 # Optional header files
117 AC_CHECK_HEADERS_ONCE([ \
118 arpa/inet.h inttypes.h malloc.h netinet/ip.h stdbool.h stddef.h \
124 AC_MSG_CHECKING(whether socklen_t exists)
126 #include <sys/types.h>
127 #include <sys/socket.h>
130 a = 2; b = 4; a += b;
132 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
146 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
147 [#include <arpa/inet.h>])
151 # memmove: A/UX libUTIL
152 AC_SEARCH_LIBS([memmove], [UTIL], [], [
153 AC_MSG_ERROR([unable to find the memmove() function])
155 # gethostbyname: Solaris libnsl
156 AC_SEARCH_LIBS([gethostbyname], [nsl], [], [
157 AC_MSG_ERROR([unable to find the gethostbyname() function])
159 # bind: SVR4 libsocket
160 AC_SEARCH_LIBS([bind], [socket], [], [
161 AC_MSG_ERROR([unable to find the bind() function])
171 alarm dup2 endpwent gethostbyaddr gethostbyname gethostname \
172 gettimeofday inet_ntoa memmove memset setsid socket strcasecmp \
173 strchr strcspn strerror strncasecmp strrchr strspn strstr \
175 AC_MSG_ERROR([required function missing!]))
178 AC_CHECK_FUNCS_ONCE([ \
179 gai_strerror getaddrinfo getnameinfo inet_aton sigaction sigprocmask \
180 snprintf vsnprintf strdup strlcpy strlcat strtok_r waitpid])
182 # -- Configuration options --
188 AS_HELP_STRING([--without-syslog],
189 [disable syslog (autodetected by default)]),
190 [ if test "$withval" != "no"; then
191 if test "$withval" != "yes"; then
192 CFLAGS="-I$withval/include $CFLAGS"
193 CPPFLAGS="-I$withval/include $CPPFLAGS"
194 LDFLAGS="-L$withval/lib $LDFLAGS"
196 AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes], [
197 AC_MSG_ERROR([Can't enable syslog!])
201 [ AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes])
204 if test "$x_syslog_on" = "yes"; then
206 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
209 # use zlib compression?
213 AS_HELP_STRING([--without-zlib],
214 [disable zlib compression (autodetected by default)]),
215 [ if test "$withval" != "no"; then
216 if test "$withval" != "yes"; then
217 CFLAGS="-I$withval/include $CFLAGS"
218 CPPFLAGS="-I$withval/include $CPPFLAGS"
219 LDFLAGS="-L$withval/lib $LDFLAGS"
221 AC_CHECK_LIB(z, deflate)
222 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
223 AC_MSG_ERROR([Can't enable zlib!])
227 [ AC_CHECK_LIB(z, deflate)
228 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
231 if test "$x_zlib_on" = "yes"; then
233 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
236 # detect which IO API to use:
241 AS_HELP_STRING([--without-select],
242 [disable select IO support (autodetected by default)]),
243 [ if test "$withval" != "no"; then
244 if test "$withval" != "yes"; then
245 CFLAGS="-I$withval/include $CFLAGS"
246 CPPFLAGS="-I$withval/include $CPPFLAGS"
247 LDFLAGS="-L$withval/lib $LDFLAGS"
249 AC_CHECK_FUNCS(select, x_io_select=yes,
250 AC_MSG_ERROR([Can't enable select IO support!])
255 AC_CHECK_FUNCS(select, x_io_select=yes)
260 AS_HELP_STRING([--without-poll],
261 [disable poll support (autodetected by default)]),
262 [ if test "$withval" != "no"; then
263 if test "$withval" != "yes"; then
264 CFLAGS="-I$withval/include $CFLAGS"
265 CPPFLAGS="-I$withval/include $CPPFLAGS"
266 LDFLAGS="-L$withval/lib $LDFLAGS"
268 AC_CHECK_FUNCS(poll, [
269 AC_CHECK_HEADERS(poll.h,
270 x_io_backend=poll\(\),
272 [Can't enable poll IO support!])
275 AC_MSG_ERROR([Can't enable poll IO support!])
280 AC_CHECK_FUNCS(poll, [
281 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
287 AS_HELP_STRING([--without-devpoll],
288 [disable /dev/poll IO support (autodetected by default)]),
289 [ if test "$withval" != "no"; then
290 if test "$withval" != "yes"; then
291 CFLAGS="-I$withval/include $CFLAGS"
292 CPPFLAGS="-I$withval/include $CPPFLAGS"
293 LDFLAGS="-L$withval/lib $LDFLAGS"
296 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
300 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
305 AS_HELP_STRING([--without-epoll],
306 [disable epoll IO support (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_FUNCS(epoll_create, x_io_epoll=yes,
314 AC_MSG_ERROR([Can't enable epoll IO support!])
319 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
324 AS_HELP_STRING([--without-kqueue],
325 [disable kqueue IO support (autodetected by default)]),
326 [ if test "$withval" != "no"; then
327 if test "$withval" != "yes"; then
328 CFLAGS="-I$withval/include $CFLAGS"
329 CPPFLAGS="-I$withval/include $CPPFLAGS"
330 LDFLAGS="-L$withval/lib $LDFLAGS"
332 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
333 AC_MSG_ERROR([Can't enable kqueue IO support!])
338 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
342 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
343 # when epoll() and select() are available, we'll use both!
344 x_io_backend="epoll(), select()"
346 if test "$x_io_epoll" = "yes"; then
347 # we prefere epoll() if it is available
348 x_io_backend="epoll()"
350 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
351 # we'll use select, when available and no "better"
352 # interface has been detected ...
353 x_io_backend="select()"
358 if test "$x_io_backend" = "none"; then
359 AC_MSG_ERROR([No useable IO API activated/found!?])
365 AS_HELP_STRING([--with-openssl],
366 [enable SSL support using OpenSSL]),
367 [ if test "$withval" != "no"; then
368 if test "$withval" != "yes"; then
369 CFLAGS="-I$withval/include $CFLAGS"
370 CPPFLAGS="-I$withval/include $CPPFLAGS"
371 LDFLAGS="-L$withval/lib $LDFLAGS"
373 AC_CHECK_LIB(crypto, BIO_s_mem)
374 AC_CHECK_LIB(ssl, SSL_library_init)
375 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
376 AC_MSG_ERROR([Can't enable openssl])
383 AS_HELP_STRING([--with-gnutls],
384 [enable SSL support using gnutls]),
385 [ if test "$withval" != "no"; then
386 if test "$withval" != "yes"; then
387 CFLAGS="-I$withval/include $CFLAGS"
388 CPPFLAGS="-I$withval/include $CPPFLAGS"
389 LDFLAGS="-L$withval/lib $LDFLAGS"
391 AC_CHECK_LIB(gnutls, gnutls_global_init)
392 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
393 AC_MSG_ERROR([Can't enable gnutls])
400 if test "$x_ssl_gnutls" = "yes"; then
401 if test "$x_ssl_openssl" = "yes";then
402 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
406 if test "$x_ssl_openssl" = "yes"; then
413 AC_ARG_WITH(tcp-wrappers,
414 AS_HELP_STRING([--with-tcp-wrappers],
415 [enable TCP wrappers support]),
416 [ if test "$withval" != "no"; then
417 if test "$withval" != "yes"; then
418 CFLAGS="-I$withval/include $CFLAGS"
419 CPPFLAGS="-I$withval/include $CPPFLAGS"
420 LDFLAGS="-L$withval/lib $LDFLAGS"
422 AC_MSG_CHECKING(for hosts_access)
426 int allow_severity = 0;
427 int deny_severity = 0;
429 tcpd_warn("link test");
432 AC_DEFINE(TCPWRAP, 1)
436 AC_MSG_ERROR([Can't enable TCP wrappers!])
442 # do IDENT requests using libident?
446 AS_HELP_STRING([--with-ident],
447 [enable "IDENT" ("AUTH") protocol support]),
448 [ if test "$withval" != "no"; then
449 if test "$withval" != "yes"; then
450 CFLAGS="-I$withval/include $CFLAGS"
451 CPPFLAGS="-I$withval/include $CPPFLAGS"
452 LDFLAGS="-L$withval/lib $LDFLAGS"
454 AC_CHECK_LIB(ident, ident_id)
455 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
456 AC_MSG_ERROR([Can't enable IDENT support!])
461 if test "$x_identauth_on" = "yes"; then
462 AC_DEFINE(IDENTAUTH, 1)
463 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
466 # compile in PAM support?
470 AS_HELP_STRING([--with-pam],
471 [enable user authentication using PAM]),
472 [ if test "$withval" != "no"; then
473 if test "$withval" != "yes"; then
474 CFLAGS="-I$withval/include $CFLAGS"
475 CPPFLAGS="-I$withval/include $CPPFLAGS"
476 LDFLAGS="-L$withval/lib $LDFLAGS"
478 AC_CHECK_LIB(pam, pam_authenticate)
479 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
480 AC_MSG_ERROR([Can't enable PAM support!])
485 if test "$x_pam_on" = "yes"; then
487 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
488 if test "$pam_ok" != "yes"; then
489 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
490 AC_MSG_ERROR([required C header missing!]))
494 # compile in IRC+ protocol support?
497 AC_ARG_ENABLE(ircplus,
498 AS_HELP_STRING([--disable-ircplus],
499 [disable IRC+ protocol]),
500 if test "$enableval" = "no"; then x_ircplus_on=no; fi
502 if test "$x_ircplus_on" = "yes"; then
503 AC_DEFINE(IRCPLUS, 1)
505 # Compile in iconv support?
506 # We only check for it when IRC+ is enabled, because the IRC+ command
507 # CHARCONV is the only function depending on it.
510 [ --with-iconv enable character conversation using libiconv],
511 [ if test "$withval" != "no"; then
512 if test "$withval" != "yes"; then
513 CFLAGS="-I$withval/include $CFLAGS"
514 CPPFLAGS="-I$withval/include $CPPFLAGS"
515 LDFLAGS="-L$withval/lib $LDFLAGS"
517 AC_CHECK_LIB(iconv, iconv_open)
518 AC_CHECK_FUNCS(iconv_open, x_iconv_on=yes,
519 AC_MSG_ERROR([Can't enable libiconv support!])
524 if test "$x_iconv_on" = "yes"; then
529 # enable support for IPv6?
532 AS_HELP_STRING([--enable-ipv6],
533 [enable IPv6 protocol support]),
534 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
536 if test "$x_ipv6_on" = "yes"; then
537 # getaddrinfo() and getnameinfo() are optional when not compiling
538 # with IPv6 support, but are required for IPv6 to work!
540 getaddrinfo getnameinfo \
541 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
542 AC_DEFINE(WANT_IPV6, 1)
545 # compile in IRC "sniffer"?
547 x_sniffer_on=no; x_debug_on=no
548 AC_ARG_ENABLE(sniffer,
549 AS_HELP_STRING([--enable-sniffer],
550 [enable IRC traffic sniffer (enables debug mode)]),
551 if test "$enableval" = "yes"; then
552 AC_DEFINE(SNIFFER, 1)
553 x_sniffer_on=yes; x_debug_on=yes
557 # enable additional debugging code?
560 AS_HELP_STRING([--enable-debug],
561 [show additional debug output]),
562 if test "$enableval" = "yes"; then x_debug_on=yes; fi
564 if test "$x_debug_on" = "yes"; then
566 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
567 AC_CHECK_FUNCS(mtrace)
570 # enable "strict RFC rules"?
573 AC_ARG_ENABLE(strict-rfc,
574 AS_HELP_STRING([--enable-strict-rfc],
575 [strict RFC conformance -- may break clients!]),
576 if test "$enableval" = "yes"; then
577 AC_DEFINE(STRICT_RFC, 1)
584 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu" )
585 AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor" )
586 AC_DEFINE_UNQUOTED(HOST_OS, "$host_os" )
588 # Add additional CFLAGS, eventually specified on the command line, but after
589 # running this configure script. Useful for "-Werror" for example.
590 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
592 # -- Generate files --
596 contrib/Anope/Makefile \
597 contrib/Debian/Makefile \
598 contrib/MacOSX/Makefile \
599 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
600 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
605 src/ipaddr/Makefile \
607 src/ngircd/Makefile \
608 src/portab/Makefile \
609 src/testsuite/Makefile \
615 type dpkg >/dev/null 2>&1
616 if test $? -eq 0; then
617 # Generate debian/ link if the dpkg command exists
618 # (read: if we are running on a debian compatible system)
619 echo "creating Debian-specific links ..."
620 test -f debian/rules || ln -s contrib/Debian debian
626 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
629 # Someone please show me a better way :) [borrowed by OpenSSH]
630 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
631 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
632 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
633 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
634 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
636 echo " Host: ${host}"
637 echo " Compiler: ${CC}"
638 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
639 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
640 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
641 test -n "$LIBS" && echo " Libraries: ${LIBS}"
643 echo " 'ngircd' binary: $S"
644 echo " Configuration file: $C"
645 echo " Manual pages: $M"
646 echo " Documentation: $D"
649 echo $ECHO_N " Syslog support: $ECHO_C"
650 test "$x_syslog_on" = "yes" \
651 && echo $ECHO_N "yes $ECHO_C" \
652 || echo $ECHO_N "no $ECHO_C"
653 echo $ECHO_N " Enable debug code: $ECHO_C"
654 test "$x_debug_on" = "yes" \
658 echo $ECHO_N " zlib compression: $ECHO_C"
659 test "$x_zlib_on" = "yes" \
660 && echo $ECHO_N "yes $ECHO_C" \
661 || echo $ECHO_N "no $ECHO_C"
662 echo $ECHO_N " IRC sniffer: $ECHO_C"
663 test "$x_sniffer_on" = "yes" \
667 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
668 test "$x_tcpwrap_on" = "yes" \
669 && echo $ECHO_N "yes $ECHO_C" \
670 || echo $ECHO_N "no $ECHO_C"
671 echo $ECHO_N " Strict RFC mode: $ECHO_C"
672 test "$x_strict_rfc_on" = "yes" \
676 echo $ECHO_N " IDENT support: $ECHO_C"
677 test "$x_identauth_on" = "yes" \
678 && echo $ECHO_N "yes $ECHO_C" \
679 || echo $ECHO_N "no $ECHO_C"
680 echo $ECHO_N " IRC+ protocol: $ECHO_C"
681 test "$x_ircplus_on" = "yes" \
685 echo $ECHO_N " IPv6 protocol: $ECHO_C"
686 test "$x_ipv6_on" = "yes" \
687 && echo $ECHO_N "yes $ECHO_C" \
688 || echo $ECHO_N "no $ECHO_C"
689 echo $ECHO_N " I/O backend: $ECHO_C"
690 echo "\"$x_io_backend\""
692 echo $ECHO_N " PAM support: $ECHO_C"
693 test "$x_pam_on" = "yes" \
694 && echo $ECHO_N "yes $ECHO_C" \
695 || echo $ECHO_N "no $ECHO_C"
696 echo $ECHO_N " SSL support: $ECHO_C"
699 echo $ECHO_N " libiconv support: $ECHO_C"