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 m4_ifdef([AM_SILENT_RULES],
15 [m4_define([ng_color_tests], [color-tests])],
16 [m4_define([ng_color_tests], [])])
18 # -- Initialisation --
21 AC_INIT([ngIRCd], VERSION_ID,
22 [ngircd-ml@ngircd.barton.de], [ngircd], [http://ngircd.barton.de/])
24 AC_CONFIG_SRCDIR([src/ngircd/ngircd.c])
25 AC_CONFIG_HEADER([src/config.h])
28 AM_INIT_AUTOMAKE([-Wall 1.10 ]ng_color_tests)
30 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
32 # -- Templates for config.h --
34 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
35 AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
36 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
37 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
38 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
39 AH_TEMPLATE([PAM], [Define if PAM should be used])
40 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
41 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
42 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
43 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
44 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
45 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
47 AH_TEMPLATE([HOST_OS], [Target operating system name])
48 AH_TEMPLATE([HOST_VENDOR], [Target system vendor])
49 AH_TEMPLATE([HOST_CPU], [Target CPU name])
56 # -- Helper programs --
64 # -- Compiler Features --
70 # -- Hard coded system and compiler dependencies/features/options ... --
72 AC_DEFUN([GCC_STACK_PROTECT_CC],[
74 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
75 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
76 ssp_old_cflags="$CFLAGS"
77 CFLAGS="$CFLAGS -fstack-protector-all"
78 AC_TRY_LINK(,,, ssp_cc=no)
80 CFLAGS="$ssp_old_cflags"
81 if test "X$ssp_cc" = "Xyes"; then
82 CFLAGS="$CFLAGS -fstack-protector"
83 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
87 if test "$GCC" = "yes"; then
88 # We are using the GNU C compiler. Good!
89 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
96 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
97 # (tested with HP/UX 11.11)
98 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
102 # Add additional CFLAGS, eventually specified on the command line:
103 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
105 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
113 # Required header files
115 fcntl.h netdb.h netinet/in.h netinet/in_systm.h stdlib.h string.h \
116 strings.h sys/socket.h sys/time.h unistd.h \
117 ],,AC_MSG_ERROR([required C header missing!]))
119 # Optional header files
120 AC_CHECK_HEADERS_ONCE([ \
121 arpa/inet.h inttypes.h malloc.h netinet/ip.h stdbool.h stddef.h \
127 AC_MSG_CHECKING(whether socklen_t exists)
129 #include <sys/types.h>
130 #include <sys/socket.h>
133 a = 2; b = 4; a += b;
135 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
149 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
150 [#include <arpa/inet.h>])
154 # memmove: A/UX libUTIL
155 AC_SEARCH_LIBS([memmove], [UTIL], [], [
156 AC_MSG_ERROR([unable to find the memmove() function])
158 # gethostbyname: Solaris libnsl
159 AC_SEARCH_LIBS([gethostbyname], [nsl], [], [
160 AC_MSG_ERROR([unable to find the gethostbyname() function])
162 # bind: SVR4 libsocket
163 AC_SEARCH_LIBS([bind], [socket], [], [
164 AC_MSG_ERROR([unable to find the bind() function])
174 alarm dup2 endpwent gethostbyaddr gethostbyname gethostname \
175 gettimeofday inet_ntoa memmove memset setsid socket strcasecmp \
176 strchr strcspn strerror strncasecmp strrchr strspn strstr \
178 AC_MSG_ERROR([required function missing!]))
181 AC_CHECK_FUNCS_ONCE([ \
182 gai_strerror getaddrinfo getnameinfo inet_aton sigaction sigprocmask \
183 snprintf vsnprintf strdup strlcpy strlcat strtok_r waitpid])
185 # -- Configuration options --
191 AS_HELP_STRING([--without-syslog],
192 [disable syslog (autodetected by default)]),
193 [ if test "$withval" != "no"; then
194 if test "$withval" != "yes"; then
195 CFLAGS="-I$withval/include $CFLAGS"
196 CPPFLAGS="-I$withval/include $CPPFLAGS"
197 LDFLAGS="-L$withval/lib $LDFLAGS"
199 AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes], [
200 AC_MSG_ERROR([Can't enable syslog!])
204 [ AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes])
207 if test "$x_syslog_on" = "yes"; then
209 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
212 # use zlib compression?
216 AS_HELP_STRING([--without-zlib],
217 [disable zlib compression (autodetected by default)]),
218 [ if test "$withval" != "no"; then
219 if test "$withval" != "yes"; then
220 CFLAGS="-I$withval/include $CFLAGS"
221 CPPFLAGS="-I$withval/include $CPPFLAGS"
222 LDFLAGS="-L$withval/lib $LDFLAGS"
224 AC_CHECK_LIB(z, deflate)
225 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
226 AC_MSG_ERROR([Can't enable zlib!])
230 [ AC_CHECK_LIB(z, deflate)
231 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
234 if test "$x_zlib_on" = "yes"; then
236 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
239 # detect which IO API to use:
244 AS_HELP_STRING([--without-select],
245 [disable select IO support (autodetected by default)]),
246 [ if test "$withval" != "no"; then
247 if test "$withval" != "yes"; then
248 CFLAGS="-I$withval/include $CFLAGS"
249 CPPFLAGS="-I$withval/include $CPPFLAGS"
250 LDFLAGS="-L$withval/lib $LDFLAGS"
252 AC_CHECK_FUNCS(select, x_io_select=yes,
253 AC_MSG_ERROR([Can't enable select IO support!])
258 AC_CHECK_FUNCS(select, x_io_select=yes)
263 AS_HELP_STRING([--without-poll],
264 [disable poll support (autodetected by default)]),
265 [ if test "$withval" != "no"; then
266 if test "$withval" != "yes"; then
267 CFLAGS="-I$withval/include $CFLAGS"
268 CPPFLAGS="-I$withval/include $CPPFLAGS"
269 LDFLAGS="-L$withval/lib $LDFLAGS"
271 AC_CHECK_FUNCS(poll, [
272 AC_CHECK_HEADERS(poll.h,
273 x_io_backend=poll\(\),
275 [Can't enable poll IO support!])
278 AC_MSG_ERROR([Can't enable poll IO support!])
283 AC_CHECK_FUNCS(poll, [
284 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
290 AS_HELP_STRING([--without-devpoll],
291 [disable /dev/poll IO support (autodetected by default)]),
292 [ if test "$withval" != "no"; then
293 if test "$withval" != "yes"; then
294 CFLAGS="-I$withval/include $CFLAGS"
295 CPPFLAGS="-I$withval/include $CPPFLAGS"
296 LDFLAGS="-L$withval/lib $LDFLAGS"
299 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
303 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
308 AS_HELP_STRING([--without-epoll],
309 [disable epoll IO support (autodetected by default)]),
310 [ if test "$withval" != "no"; then
311 if test "$withval" != "yes"; then
312 CFLAGS="-I$withval/include $CFLAGS"
313 CPPFLAGS="-I$withval/include $CPPFLAGS"
314 LDFLAGS="-L$withval/lib $LDFLAGS"
316 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
317 AC_MSG_ERROR([Can't enable epoll IO support!])
322 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
327 AS_HELP_STRING([--without-kqueue],
328 [disable kqueue IO support (autodetected by default)]),
329 [ if test "$withval" != "no"; then
330 if test "$withval" != "yes"; then
331 CFLAGS="-I$withval/include $CFLAGS"
332 CPPFLAGS="-I$withval/include $CPPFLAGS"
333 LDFLAGS="-L$withval/lib $LDFLAGS"
335 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
336 AC_MSG_ERROR([Can't enable kqueue IO support!])
341 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
345 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
346 # when epoll() and select() are available, we'll use both!
347 x_io_backend="epoll(), select()"
349 if test "$x_io_epoll" = "yes"; then
350 # we prefere epoll() if it is available
351 x_io_backend="epoll()"
353 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
354 # we'll use select, when available and no "better"
355 # interface has been detected ...
356 x_io_backend="select()"
361 if test "$x_io_backend" = "none"; then
362 AC_MSG_ERROR([No useable IO API activated/found!?])
368 AS_HELP_STRING([--with-openssl],
369 [enable SSL support using OpenSSL]),
370 [ if test "$withval" != "no"; then
371 if test "$withval" != "yes"; then
372 CFLAGS="-I$withval/include $CFLAGS"
373 CPPFLAGS="-I$withval/include $CPPFLAGS"
374 LDFLAGS="-L$withval/lib $LDFLAGS"
376 AC_CHECK_LIB(crypto, BIO_s_mem)
377 AC_CHECK_LIB(ssl, SSL_library_init)
378 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
379 AC_MSG_ERROR([Can't enable openssl])
386 AS_HELP_STRING([--with-gnutls],
387 [enable SSL support using gnutls]),
388 [ if test "$withval" != "no"; then
389 if test "$withval" != "yes"; then
390 CFLAGS="-I$withval/include $CFLAGS"
391 CPPFLAGS="-I$withval/include $CPPFLAGS"
392 LDFLAGS="-L$withval/lib $LDFLAGS"
394 AC_CHECK_LIB(gnutls, gnutls_global_init)
395 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
396 AC_MSG_ERROR([Can't enable gnutls])
403 if test "$x_ssl_gnutls" = "yes"; then
404 if test "$x_ssl_openssl" = "yes";then
405 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
409 if test "$x_ssl_openssl" = "yes"; then
416 AC_ARG_WITH(tcp-wrappers,
417 AS_HELP_STRING([--with-tcp-wrappers],
418 [enable TCP wrappers support]),
419 [ if test "$withval" != "no"; then
420 if test "$withval" != "yes"; then
421 CFLAGS="-I$withval/include $CFLAGS"
422 CPPFLAGS="-I$withval/include $CPPFLAGS"
423 LDFLAGS="-L$withval/lib $LDFLAGS"
425 AC_MSG_CHECKING(for hosts_access)
429 int allow_severity = 0;
430 int deny_severity = 0;
432 tcpd_warn("link test");
435 AC_DEFINE(TCPWRAP, 1)
439 AC_MSG_ERROR([Can't enable TCP wrappers!])
445 # do IDENT requests using libident?
449 AS_HELP_STRING([--with-ident],
450 [enable "IDENT" ("AUTH") protocol support]),
451 [ if test "$withval" != "no"; then
452 if test "$withval" != "yes"; then
453 CFLAGS="-I$withval/include $CFLAGS"
454 CPPFLAGS="-I$withval/include $CPPFLAGS"
455 LDFLAGS="-L$withval/lib $LDFLAGS"
457 AC_CHECK_LIB(ident, ident_id)
458 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
459 AC_MSG_ERROR([Can't enable IDENT support!])
464 if test "$x_identauth_on" = "yes"; then
465 AC_DEFINE(IDENTAUTH, 1)
466 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
469 # compile in PAM support?
473 AS_HELP_STRING([--with-pam],
474 [enable user authentication using PAM]),
475 [ if test "$withval" != "no"; then
476 if test "$withval" != "yes"; then
477 CFLAGS="-I$withval/include $CFLAGS"
478 CPPFLAGS="-I$withval/include $CPPFLAGS"
479 LDFLAGS="-L$withval/lib $LDFLAGS"
481 AC_CHECK_LIB(pam, pam_authenticate)
482 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
483 AC_MSG_ERROR([Can't enable PAM support!])
488 if test "$x_pam_on" = "yes"; then
490 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
491 if test "$pam_ok" != "yes"; then
492 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
493 AC_MSG_ERROR([required C header missing!]))
497 # compile in IRC+ protocol support?
500 AC_ARG_ENABLE(ircplus,
501 AS_HELP_STRING([--disable-ircplus],
502 [disable IRC+ protocol]),
503 if test "$enableval" = "no"; then x_ircplus_on=no; fi
505 if test "$x_ircplus_on" = "yes"; then
506 AC_DEFINE(IRCPLUS, 1)
509 # enable support for IPv6?
512 AS_HELP_STRING([--enable-ipv6],
513 [enable IPv6 protocol support]),
514 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
516 if test "$x_ipv6_on" = "yes"; then
517 # getaddrinfo() and getnameinfo() are optional when not compiling
518 # with IPv6 support, but are required for IPv6 to work!
520 getaddrinfo getnameinfo \
521 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
522 AC_DEFINE(WANT_IPV6, 1)
525 # compile in IRC "sniffer"?
527 x_sniffer_on=no; x_debug_on=no
528 AC_ARG_ENABLE(sniffer,
529 AS_HELP_STRING([--enable-sniffer],
530 [enable IRC traffic sniffer (enables debug mode)]),
531 if test "$enableval" = "yes"; then
532 AC_DEFINE(SNIFFER, 1)
533 x_sniffer_on=yes; x_debug_on=yes
537 # enable additional debugging code?
540 AS_HELP_STRING([--enable-debug],
541 [show additional debug output]),
542 if test "$enableval" = "yes"; then x_debug_on=yes; fi
544 if test "$x_debug_on" = "yes"; then
546 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
547 AC_CHECK_FUNCS(mtrace)
550 # enable "strict RFC rules"?
553 AC_ARG_ENABLE(strict-rfc,
554 AS_HELP_STRING([--enable-strict-rfc],
555 [strict RFC conformance -- may break clients!]),
556 if test "$enableval" = "yes"; then
557 AC_DEFINE(STRICT_RFC, 1)
564 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu" )
565 AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor" )
566 AC_DEFINE_UNQUOTED(HOST_OS, "$host_os" )
568 # Add additional CFLAGS, eventually specified on the command line, but after
569 # running this configure script. Useful for "-Werror" for example.
570 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
572 # -- Generate files --
576 contrib/Anope/Makefile \
577 contrib/Debian/Makefile \
578 contrib/MacOSX/Makefile \
579 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
580 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
585 src/ipaddr/Makefile \
587 src/ngircd/Makefile \
588 src/portab/Makefile \
589 src/testsuite/Makefile \
595 type dpkg >/dev/null 2>&1
596 if test $? -eq 0; then
597 # Generate debian/ link if the dpkg command exists
598 # (read: if we are running on a debian compatible system)
599 echo "creating Debian-specific links ..."
600 test -f debian/rules || ln -s contrib/Debian debian
606 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
609 # Someone please show me a better way :) [borrowed by OpenSSH]
610 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
611 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
612 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
613 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
614 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
616 echo " Host: ${host}"
617 echo " Compiler: ${CC}"
618 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
619 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
620 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
621 test -n "$LIBS" && echo " Libraries: ${LIBS}"
623 echo " 'ngircd' binary: $S"
624 echo " Configuration file: $C"
625 echo " Manual pages: $M"
626 echo " Documentation: $D"
629 echo $ECHO_N " Syslog support: $ECHO_C"
630 test "$x_syslog_on" = "yes" \
631 && echo $ECHO_N "yes $ECHO_C" \
632 || echo $ECHO_N "no $ECHO_C"
633 echo $ECHO_N " Enable debug code: $ECHO_C"
634 test "$x_debug_on" = "yes" \
638 echo $ECHO_N " zlib compression: $ECHO_C"
639 test "$x_zlib_on" = "yes" \
640 && echo $ECHO_N "yes $ECHO_C" \
641 || echo $ECHO_N "no $ECHO_C"
642 echo $ECHO_N " IRC sniffer: $ECHO_C"
643 test "$x_sniffer_on" = "yes" \
647 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
648 test "$x_tcpwrap_on" = "yes" \
649 && echo $ECHO_N "yes $ECHO_C" \
650 || echo $ECHO_N "no $ECHO_C"
651 echo $ECHO_N " Strict RFC mode: $ECHO_C"
652 test "$x_strict_rfc_on" = "yes" \
656 echo $ECHO_N " IDENT support: $ECHO_C"
657 test "$x_identauth_on" = "yes" \
658 && echo $ECHO_N "yes $ECHO_C" \
659 || echo $ECHO_N "no $ECHO_C"
660 echo $ECHO_N " IRC+ protocol: $ECHO_C"
661 test "$x_ircplus_on" = "yes" \
665 echo $ECHO_N " IPv6 protocol: $ECHO_C"
666 test "$x_ipv6_on" = "yes" \
667 && echo $ECHO_N "yes $ECHO_C" \
668 || echo $ECHO_N "no $ECHO_C"
669 echo $ECHO_N " I/O backend: $ECHO_C"
670 echo "\"$x_io_backend\""
672 echo $ECHO_N " PAM support: $ECHO_C"
673 test "$x_pam_on" = "yes" \
674 && echo $ECHO_N "yes $ECHO_C" \
675 || echo $ECHO_N "no $ECHO_C"
676 echo $ECHO_N " SSL support: $ECHO_C"