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([
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([IDENTAUTH], [Define if the server should do IDENT requests])
43 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
44 AH_TEMPLATE([PAM], [Define if PAM should be used])
45 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
46 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
47 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
48 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
49 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
50 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
52 AH_TEMPLATE([HOST_OS], [Target operating system name])
53 AH_TEMPLATE([HOST_VENDOR], [Target system vendor])
54 AH_TEMPLATE([HOST_CPU], [Target CPU name])
61 # -- Helper programs --
63 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
71 # -- Compiler Features --
77 # -- Hard coded system and compiler dependencies/features/options ... --
79 AC_DEFUN([GCC_STACK_PROTECT_CC],[
81 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
82 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
83 ssp_old_cflags="$CFLAGS"
84 CFLAGS="$CFLAGS -fstack-protector-all"
85 AC_TRY_LINK(,,, ssp_cc=no)
87 CFLAGS="$ssp_old_cflags"
88 if test "X$ssp_cc" = "Xyes"; then
89 CFLAGS="$CFLAGS -fstack-protector"
90 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
94 if test "$GCC" = "yes"; then
95 # We are using the GNU C compiler. Good!
96 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
103 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
104 # (tested with HP/UX 11.11)
105 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
109 # Add additional CFLAGS, eventually specified on the command line:
110 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
112 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
120 # Required header files
122 fcntl.h netdb.h netinet/in.h netinet/in_systm.h stdlib.h string.h \
123 strings.h sys/socket.h sys/time.h unistd.h \
124 ],,AC_MSG_ERROR([required C header missing!]))
126 # Optional header files
127 AC_CHECK_HEADERS_ONCE([ \
128 arpa/inet.h inttypes.h malloc.h netinet/ip.h stdbool.h stddef.h \
134 AC_MSG_CHECKING(whether socklen_t exists)
136 #include <sys/types.h>
137 #include <sys/socket.h>
140 a = 2; b = 4; a += b;
142 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
156 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
157 [#include <arpa/inet.h>])
161 # memmove: A/UX libUTIL
162 AC_SEARCH_LIBS([memmove], [UTIL], [], [
163 AC_MSG_ERROR([unable to find the memmove() function])
165 # gethostbyname: Solaris libnsl
166 AC_SEARCH_LIBS([gethostbyname], [nsl], [], [
167 AC_MSG_ERROR([unable to find the gethostbyname() function])
169 # bind: SVR4 libsocket
170 AC_SEARCH_LIBS([bind], [socket], [], [
171 AC_MSG_ERROR([unable to find the bind() function])
181 alarm dup2 endpwent gethostbyaddr gethostbyname gethostname \
182 gettimeofday inet_ntoa memmove memset setsid socket strcasecmp \
183 strchr strcspn strerror strncasecmp strrchr strspn strstr \
185 AC_MSG_ERROR([required function missing!]))
188 AC_CHECK_FUNCS_ONCE([ \
189 gai_strerror getaddrinfo getnameinfo inet_aton sigaction sigprocmask \
190 snprintf vsnprintf strdup strlcpy strlcat strtok_r waitpid])
192 # -- Configuration options --
198 AS_HELP_STRING([--without-syslog],
199 [disable syslog (autodetected by default)]),
200 [ if test "$withval" != "no"; then
201 if test "$withval" != "yes"; then
202 CFLAGS="-I$withval/include $CFLAGS"
203 CPPFLAGS="-I$withval/include $CPPFLAGS"
204 LDFLAGS="-L$withval/lib $LDFLAGS"
206 AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes], [
207 AC_MSG_ERROR([Can't enable syslog!])
211 [ AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes])
214 if test "$x_syslog_on" = "yes"; then
216 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
219 # use zlib compression?
223 AS_HELP_STRING([--without-zlib],
224 [disable zlib compression (autodetected by default)]),
225 [ if test "$withval" != "no"; then
226 if test "$withval" != "yes"; then
227 CFLAGS="-I$withval/include $CFLAGS"
228 CPPFLAGS="-I$withval/include $CPPFLAGS"
229 LDFLAGS="-L$withval/lib $LDFLAGS"
231 AC_CHECK_LIB(z, deflate)
232 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
233 AC_MSG_ERROR([Can't enable zlib!])
237 [ AC_CHECK_LIB(z, deflate)
238 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
241 if test "$x_zlib_on" = "yes"; then
243 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
246 # detect which IO API to use:
251 AS_HELP_STRING([--without-select],
252 [disable select IO support (autodetected by default)]),
253 [ if test "$withval" != "no"; then
254 if test "$withval" != "yes"; then
255 CFLAGS="-I$withval/include $CFLAGS"
256 CPPFLAGS="-I$withval/include $CPPFLAGS"
257 LDFLAGS="-L$withval/lib $LDFLAGS"
259 AC_CHECK_FUNCS(select, x_io_select=yes,
260 AC_MSG_ERROR([Can't enable select IO support!])
265 AC_CHECK_FUNCS(select, x_io_select=yes)
270 AS_HELP_STRING([--without-poll],
271 [disable poll support (autodetected by default)]),
272 [ if test "$withval" != "no"; then
273 if test "$withval" != "yes"; then
274 CFLAGS="-I$withval/include $CFLAGS"
275 CPPFLAGS="-I$withval/include $CPPFLAGS"
276 LDFLAGS="-L$withval/lib $LDFLAGS"
278 AC_CHECK_FUNCS(poll, [
279 AC_CHECK_HEADERS(poll.h,
280 x_io_backend=poll\(\),
282 [Can't enable poll IO support!])
285 AC_MSG_ERROR([Can't enable poll IO support!])
290 AC_CHECK_FUNCS(poll, [
291 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
297 AS_HELP_STRING([--without-devpoll],
298 [disable /dev/poll IO support (autodetected by default)]),
299 [ if test "$withval" != "no"; then
300 if test "$withval" != "yes"; then
301 CFLAGS="-I$withval/include $CFLAGS"
302 CPPFLAGS="-I$withval/include $CPPFLAGS"
303 LDFLAGS="-L$withval/lib $LDFLAGS"
306 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
310 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
315 AS_HELP_STRING([--without-epoll],
316 [disable epoll IO support (autodetected by default)]),
317 [ if test "$withval" != "no"; then
318 if test "$withval" != "yes"; then
319 CFLAGS="-I$withval/include $CFLAGS"
320 CPPFLAGS="-I$withval/include $CPPFLAGS"
321 LDFLAGS="-L$withval/lib $LDFLAGS"
323 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
324 AC_MSG_ERROR([Can't enable epoll IO support!])
329 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
334 AS_HELP_STRING([--without-kqueue],
335 [disable kqueue IO support (autodetected by default)]),
336 [ if test "$withval" != "no"; then
337 if test "$withval" != "yes"; then
338 CFLAGS="-I$withval/include $CFLAGS"
339 CPPFLAGS="-I$withval/include $CPPFLAGS"
340 LDFLAGS="-L$withval/lib $LDFLAGS"
342 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
343 AC_MSG_ERROR([Can't enable kqueue IO support!])
348 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
352 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
353 # when epoll() and select() are available, we'll use both!
354 x_io_backend="epoll(), select()"
356 if test "$x_io_epoll" = "yes"; then
357 # we prefere epoll() if it is available
358 x_io_backend="epoll()"
360 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
361 # we'll use select, when available and no "better"
362 # interface has been detected ...
363 x_io_backend="select()"
368 if test "$x_io_backend" = "none"; then
369 AC_MSG_ERROR([No useable IO API activated/found!?])
375 AS_HELP_STRING([--with-openssl],
376 [enable SSL support using OpenSSL]),
377 [ if test "$withval" != "no"; then
378 if test "$withval" != "yes"; then
379 CFLAGS="-I$withval/include $CFLAGS"
380 CPPFLAGS="-I$withval/include $CPPFLAGS"
381 LDFLAGS="-L$withval/lib $LDFLAGS"
383 AC_CHECK_LIB(crypto, BIO_s_mem)
384 AC_CHECK_LIB(ssl, SSL_library_init)
385 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
386 AC_MSG_ERROR([Can't enable openssl])
393 AS_HELP_STRING([--with-gnutls],
394 [enable SSL support using gnutls]),
395 [ if test "$withval" != "no"; then
396 if test "$withval" != "yes"; then
397 CFLAGS="-I$withval/include $CFLAGS"
398 CPPFLAGS="-I$withval/include $CPPFLAGS"
399 LDFLAGS="-L$withval/lib $LDFLAGS"
401 AC_CHECK_LIB(gnutls, gnutls_global_init)
402 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
403 AC_MSG_ERROR([Can't enable gnutls])
410 if test "$x_ssl_gnutls" = "yes"; then
411 if test "$x_ssl_openssl" = "yes";then
412 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
416 if test "$x_ssl_openssl" = "yes"; then
423 AC_ARG_WITH(tcp-wrappers,
424 AS_HELP_STRING([--with-tcp-wrappers],
425 [enable TCP wrappers support]),
426 [ if test "$withval" != "no"; then
427 if test "$withval" != "yes"; then
428 CFLAGS="-I$withval/include $CFLAGS"
429 CPPFLAGS="-I$withval/include $CPPFLAGS"
430 LDFLAGS="-L$withval/lib $LDFLAGS"
432 AC_MSG_CHECKING(for hosts_access)
436 int allow_severity = 0;
437 int deny_severity = 0;
439 tcpd_warn("link test");
442 AC_DEFINE(TCPWRAP, 1)
446 AC_MSG_ERROR([Can't enable TCP wrappers!])
452 # do IDENT requests using libident?
456 AS_HELP_STRING([--with-ident],
457 [enable "IDENT" ("AUTH") protocol support]),
458 [ if test "$withval" != "no"; then
459 if test "$withval" != "yes"; then
460 CFLAGS="-I$withval/include $CFLAGS"
461 CPPFLAGS="-I$withval/include $CPPFLAGS"
462 LDFLAGS="-L$withval/lib $LDFLAGS"
464 AC_CHECK_LIB(ident, ident_id)
465 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
466 AC_MSG_ERROR([Can't enable IDENT support!])
471 if test "$x_identauth_on" = "yes"; then
472 AC_DEFINE(IDENTAUTH, 1)
473 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
476 # compile in PAM support?
480 AS_HELP_STRING([--with-pam],
481 [enable user authentication using PAM]),
482 [ if test "$withval" != "no"; then
483 if test "$withval" != "yes"; then
484 CFLAGS="-I$withval/include $CFLAGS"
485 CPPFLAGS="-I$withval/include $CPPFLAGS"
486 LDFLAGS="-L$withval/lib $LDFLAGS"
488 AC_CHECK_LIB(pam, pam_authenticate)
489 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
490 AC_MSG_ERROR([Can't enable PAM support!])
495 if test "$x_pam_on" = "yes"; then
497 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
498 if test "$pam_ok" != "yes"; then
499 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
500 AC_MSG_ERROR([required C header missing!]))
504 # compile in IRC+ protocol support?
507 AC_ARG_ENABLE(ircplus,
508 AS_HELP_STRING([--disable-ircplus],
509 [disable IRC+ protocol]),
510 if test "$enableval" = "no"; then x_ircplus_on=no; fi
512 if test "$x_ircplus_on" = "yes"; then
513 AC_DEFINE(IRCPLUS, 1)
516 # enable support for IPv6?
519 AS_HELP_STRING([--enable-ipv6],
520 [enable IPv6 protocol support]),
521 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
523 if test "$x_ipv6_on" = "yes"; then
524 # getaddrinfo() and getnameinfo() are optional when not compiling
525 # with IPv6 support, but are required for IPv6 to work!
527 getaddrinfo getnameinfo \
528 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
529 AC_DEFINE(WANT_IPV6, 1)
532 # compile in IRC "sniffer"?
534 x_sniffer_on=no; x_debug_on=no
535 AC_ARG_ENABLE(sniffer,
536 AS_HELP_STRING([--enable-sniffer],
537 [enable IRC traffic sniffer (enables debug mode)]),
538 if test "$enableval" = "yes"; then
539 AC_DEFINE(SNIFFER, 1)
540 x_sniffer_on=yes; x_debug_on=yes
544 # enable additional debugging code?
547 AS_HELP_STRING([--enable-debug],
548 [show additional debug output]),
549 if test "$enableval" = "yes"; then x_debug_on=yes; fi
551 if test "$x_debug_on" = "yes"; then
553 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
554 AC_CHECK_FUNCS(mtrace)
557 # enable "strict RFC rules"?
560 AC_ARG_ENABLE(strict-rfc,
561 AS_HELP_STRING([--enable-strict-rfc],
562 [strict RFC conformance -- may break clients!]),
563 if test "$enableval" = "yes"; then
564 AC_DEFINE(STRICT_RFC, 1)
571 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu" )
572 AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor" )
573 AC_DEFINE_UNQUOTED(HOST_OS, "$host_os" )
575 # Add additional CFLAGS, eventually specified on the command line, but after
576 # running this configure script. Useful for "-Werror" for example.
577 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
579 # -- Generate files --
583 contrib/Anope/Makefile \
584 contrib/Debian/Makefile \
585 contrib/MacOSX/Makefile \
586 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
587 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
592 src/ipaddr/Makefile \
594 src/ngircd/Makefile \
595 src/portab/Makefile \
596 src/testsuite/Makefile \
602 type dpkg >/dev/null 2>&1
603 if test $? -eq 0; then
604 # Generate debian/ link if the dpkg command exists
605 # (read: if we are running on a debian compatible system)
606 echo "creating Debian-specific links ..."
607 test -f debian/rules || ln -s contrib/Debian debian
613 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
616 # Someone please show me a better way :) [borrowed by OpenSSH]
617 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
618 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
619 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
620 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
621 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
623 echo " Host: ${host}"
624 echo " Compiler: ${CC}"
625 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
626 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
627 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
628 test -n "$LIBS" && echo " Libraries: ${LIBS}"
630 echo " 'ngircd' binary: $S"
631 echo " Configuration file: $C"
632 echo " Manual pages: $M"
633 echo " Documentation: $D"
636 echo $ECHO_N " Syslog support: $ECHO_C"
637 test "$x_syslog_on" = "yes" \
638 && echo $ECHO_N "yes $ECHO_C" \
639 || echo $ECHO_N "no $ECHO_C"
640 echo $ECHO_N " Enable debug code: $ECHO_C"
641 test "$x_debug_on" = "yes" \
645 echo $ECHO_N " zlib compression: $ECHO_C"
646 test "$x_zlib_on" = "yes" \
647 && echo $ECHO_N "yes $ECHO_C" \
648 || echo $ECHO_N "no $ECHO_C"
649 echo $ECHO_N " IRC sniffer: $ECHO_C"
650 test "$x_sniffer_on" = "yes" \
654 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
655 test "$x_tcpwrap_on" = "yes" \
656 && echo $ECHO_N "yes $ECHO_C" \
657 || echo $ECHO_N "no $ECHO_C"
658 echo $ECHO_N " Strict RFC mode: $ECHO_C"
659 test "$x_strict_rfc_on" = "yes" \
663 echo $ECHO_N " IDENT support: $ECHO_C"
664 test "$x_identauth_on" = "yes" \
665 && echo $ECHO_N "yes $ECHO_C" \
666 || echo $ECHO_N "no $ECHO_C"
667 echo $ECHO_N " IRC+ protocol: $ECHO_C"
668 test "$x_ircplus_on" = "yes" \
672 echo $ECHO_N " IPv6 protocol: $ECHO_C"
673 test "$x_ipv6_on" = "yes" \
674 && echo $ECHO_N "yes $ECHO_C" \
675 || echo $ECHO_N "no $ECHO_C"
676 echo $ECHO_N " I/O backend: $ECHO_C"
677 echo "\"$x_io_backend\""
679 echo $ECHO_N " PAM support: $ECHO_C"
680 test "$x_pam_on" = "yes" \
681 && echo $ECHO_N "yes $ECHO_C" \
682 || echo $ECHO_N "no $ECHO_C"
683 echo $ECHO_N " SSL support: $ECHO_C"
688 if ! grep "^AUTOMAKE_OPTIONS = ../portab/ansi2knr" src/ngircd/Makefile.am >/dev/null 2>&1; then
690 echo "This GNU automake generated build system does not support \"de-ANSI-fication\","
691 echo "therefore don't use it to generate \"official\" distribution archives!"
692 echo "(Most probably you want to use GNU automake 1.11.x for this purpose ...)"