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([IDENTAUTH], [Define if the server should do IDENT requests])
34 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
35 AH_TEMPLATE([PAM], [Define if PAM should be used])
36 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
37 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
38 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
39 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
40 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
41 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
43 AH_TEMPLATE([HOST_OS], [Target operating system name])
44 AH_TEMPLATE([HOST_VENDOR], [Target system vendor])
45 AH_TEMPLATE([HOST_CPU], [Target CPU name])
52 # -- Helper programs --
60 # -- Compiler Features --
66 # -- Hard coded system and compiler dependencies/features/options ... --
68 AC_DEFUN([GCC_STACK_PROTECT_CC],[
70 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
71 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
72 ssp_old_cflags="$CFLAGS"
73 CFLAGS="$CFLAGS -fstack-protector-all"
74 AC_TRY_LINK(,,, ssp_cc=no)
76 CFLAGS="$ssp_old_cflags"
77 if test "X$ssp_cc" = "Xyes"; then
78 CFLAGS="$CFLAGS -fstack-protector"
79 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
83 if test "$GCC" = "yes"; then
84 # We are using the GNU C compiler. Good!
85 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
92 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
93 # (tested with HP/UX 11.11)
94 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
98 # Add additional CFLAGS, eventually specified on the command line:
99 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
101 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
109 # Required header files
111 fcntl.h netdb.h netinet/in.h netinet/in_systm.h stdlib.h string.h \
112 strings.h sys/socket.h sys/time.h unistd.h \
113 ],,AC_MSG_ERROR([required C header missing!]))
115 # Optional header files
117 arpa/inet.h inttypes.h malloc.h netinet/ip.h stdbool.h stddef.h \
123 AC_MSG_CHECKING(whether socklen_t exists)
125 #include <sys/types.h>
126 #include <sys/socket.h>
129 a = 2; b = 4; a += b;
131 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
145 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
146 [#include <arpa/inet.h>])
151 AC_CHECK_LIB(UTIL,memmove)
152 # needed on solaris. GNU libc also has a libnsl, but we do not need it.
153 AC_SEARCH_LIBS(gethostbyname,nsl)
154 AC_CHECK_LIB(socket,bind)
165 alarm dup2 endpwent gethostbyaddr gethostbyname gethostname \
166 gettimeofday inet_ntoa memmove memset setsid socket strcasecmp \
167 strchr strcspn strerror strncasecmp strrchr strspn strstr \
169 AC_MSG_ERROR([required function missing!]))
173 gai_strerror getaddrinfo getnameinfo inet_aton sigaction sigprocmask \
174 snprintf vsnprintf strdup strlcpy strlcat strtok_r waitpid])
176 # -- Configuration options --
182 AS_HELP_STRING([--without-syslog],
183 [disable syslog (autodetected by default)]),
184 [ if test "$withval" != "no"; then
185 if test "$withval" != "yes"; then
186 CFLAGS="-I$withval/include $CFLAGS"
187 CPPFLAGS="-I$withval/include $CPPFLAGS"
188 LDFLAGS="-L$withval/lib $LDFLAGS"
190 AC_CHECK_LIB(be, syslog)
191 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
192 AC_MSG_ERROR([Can't enable syslog!])
197 AC_CHECK_LIB(be, syslog)
198 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
201 if test "$x_syslog_on" = "yes"; then
203 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
206 # use zlib compression?
210 AS_HELP_STRING([--without-zlib],
211 [disable zlib compression (autodetected by default)]),
212 [ if test "$withval" != "no"; then
213 if test "$withval" != "yes"; then
214 CFLAGS="-I$withval/include $CFLAGS"
215 CPPFLAGS="-I$withval/include $CPPFLAGS"
216 LDFLAGS="-L$withval/lib $LDFLAGS"
218 AC_CHECK_LIB(z, deflate)
219 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
220 AC_MSG_ERROR([Can't enable zlib!])
224 [ AC_CHECK_LIB(z, deflate)
225 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
228 if test "$x_zlib_on" = "yes"; then
230 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
233 # detect which IO API to use:
238 AS_HELP_STRING([--without-select],
239 [disable select IO support (autodetected by default)]),
240 [ if test "$withval" != "no"; then
241 if test "$withval" != "yes"; then
242 CFLAGS="-I$withval/include $CFLAGS"
243 CPPFLAGS="-I$withval/include $CPPFLAGS"
244 LDFLAGS="-L$withval/lib $LDFLAGS"
246 AC_CHECK_FUNCS(select, x_io_select=yes,
247 AC_MSG_ERROR([Can't enable select IO support!])
252 AC_CHECK_FUNCS(select, x_io_select=yes)
257 AS_HELP_STRING([--without-poll],
258 [disable poll support (autodetected by default)]),
259 [ if test "$withval" != "no"; then
260 if test "$withval" != "yes"; then
261 CFLAGS="-I$withval/include $CFLAGS"
262 CPPFLAGS="-I$withval/include $CPPFLAGS"
263 LDFLAGS="-L$withval/lib $LDFLAGS"
265 AC_CHECK_FUNCS(poll, [
266 AC_CHECK_HEADERS(poll.h,
267 x_io_backend=poll\(\),
269 [Can't enable poll IO support!])
272 AC_MSG_ERROR([Can't enable poll IO support!])
277 AC_CHECK_FUNCS(poll, [
278 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
284 AS_HELP_STRING([--without-devpoll],
285 [disable /dev/poll IO support (autodetected by default)]),
286 [ if test "$withval" != "no"; then
287 if test "$withval" != "yes"; then
288 CFLAGS="-I$withval/include $CFLAGS"
289 CPPFLAGS="-I$withval/include $CPPFLAGS"
290 LDFLAGS="-L$withval/lib $LDFLAGS"
293 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
297 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
302 AS_HELP_STRING([--without-epoll],
303 [disable epoll 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"
310 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
311 AC_MSG_ERROR([Can't enable epoll IO support!])
316 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
321 AS_HELP_STRING([--without-kqueue],
322 [disable kqueue IO support (autodetected by default)]),
323 [ if test "$withval" != "no"; then
324 if test "$withval" != "yes"; then
325 CFLAGS="-I$withval/include $CFLAGS"
326 CPPFLAGS="-I$withval/include $CPPFLAGS"
327 LDFLAGS="-L$withval/lib $LDFLAGS"
329 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
330 AC_MSG_ERROR([Can't enable kqueue IO support!])
335 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
339 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
340 # when epoll() and select() are available, we'll use both!
341 x_io_backend="epoll(), select()"
343 if test "$x_io_epoll" = "yes"; then
344 # we prefere epoll() if it is available
345 x_io_backend="epoll()"
347 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
348 # we'll use select, when available and no "better"
349 # interface has been detected ...
350 x_io_backend="select()"
355 if test "$x_io_backend" = "none"; then
356 AC_MSG_ERROR([No useable IO API activated/found!?])
362 AS_HELP_STRING([--with-openssl],
363 [enable SSL support using OpenSSL]),
364 [ if test "$withval" != "no"; then
365 if test "$withval" != "yes"; then
366 CFLAGS="-I$withval/include $CFLAGS"
367 CPPFLAGS="-I$withval/include $CPPFLAGS"
368 LDFLAGS="-L$withval/lib $LDFLAGS"
370 AC_CHECK_LIB(crypto, BIO_s_mem)
371 AC_CHECK_LIB(ssl, SSL_library_init)
372 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
373 AC_MSG_ERROR([Can't enable openssl])
380 AS_HELP_STRING([--with-gnutls],
381 [enable SSL support using gnutls]),
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(gnutls, gnutls_global_init)
389 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
390 AC_MSG_ERROR([Can't enable gnutls])
397 if test "$x_ssl_gnutls" = "yes"; then
398 if test "$x_ssl_openssl" = "yes";then
399 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
403 if test "$x_ssl_openssl" = "yes"; then
410 AC_ARG_WITH(tcp-wrappers,
411 AS_HELP_STRING([--with-tcp-wrappers],
412 [enable TCP wrappers support]),
413 [ if test "$withval" != "no"; then
414 if test "$withval" != "yes"; then
415 CFLAGS="-I$withval/include $CFLAGS"
416 CPPFLAGS="-I$withval/include $CPPFLAGS"
417 LDFLAGS="-L$withval/lib $LDFLAGS"
419 AC_MSG_CHECKING(for hosts_access)
423 int allow_severity = 0;
424 int deny_severity = 0;
426 tcpd_warn("link test");
429 AC_DEFINE(TCPWRAP, 1)
433 AC_MSG_ERROR([Can't enable TCP wrappers!])
439 # do IDENT requests using libident?
443 AS_HELP_STRING([--with-ident],
444 [enable "IDENT" ("AUTH") protocol support]),
445 [ if test "$withval" != "no"; then
446 if test "$withval" != "yes"; then
447 CFLAGS="-I$withval/include $CFLAGS"
448 CPPFLAGS="-I$withval/include $CPPFLAGS"
449 LDFLAGS="-L$withval/lib $LDFLAGS"
451 AC_CHECK_LIB(ident, ident_id)
452 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
453 AC_MSG_ERROR([Can't enable IDENT support!])
458 if test "$x_identauth_on" = "yes"; then
459 AC_DEFINE(IDENTAUTH, 1)
460 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
463 # compile in PAM support?
467 AS_HELP_STRING([--with-pam],
468 [enable user authentication using PAM]),
469 [ if test "$withval" != "no"; then
470 if test "$withval" != "yes"; then
471 CFLAGS="-I$withval/include $CFLAGS"
472 CPPFLAGS="-I$withval/include $CPPFLAGS"
473 LDFLAGS="-L$withval/lib $LDFLAGS"
475 AC_CHECK_LIB(pam, pam_authenticate)
476 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
477 AC_MSG_ERROR([Can't enable PAM support!])
482 if test "$x_pam_on" = "yes"; then
484 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
485 if test "$pam_ok" != "yes"; then
486 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
487 AC_MSG_ERROR([required C header missing!]))
491 # compile in IRC+ protocol support?
494 AC_ARG_ENABLE(ircplus,
495 AS_HELP_STRING([--disable-ircplus],
496 [disable IRC+ protocol]),
497 if test "$enableval" = "no"; then x_ircplus_on=no; fi
499 if test "$x_ircplus_on" = "yes"; then
500 AC_DEFINE(IRCPLUS, 1)
503 # enable support for IPv6?
506 AS_HELP_STRING([--enable-ipv6],
507 [enable IPv6 protocol support]),
508 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
510 if test "$x_ipv6_on" = "yes"; then
511 # getaddrinfo() and getnameinfo() are optional when not compiling
512 # with IPv6 support, but are required for IPv6 to work!
514 getaddrinfo getnameinfo \
515 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
516 AC_DEFINE(WANT_IPV6, 1)
519 # compile in IRC "sniffer"?
521 x_sniffer_on=no; x_debug_on=no
522 AC_ARG_ENABLE(sniffer,
523 AS_HELP_STRING([--enable-sniffer],
524 [enable IRC traffic sniffer (enables debug mode)]),
525 if test "$enableval" = "yes"; then
526 AC_DEFINE(SNIFFER, 1)
527 x_sniffer_on=yes; x_debug_on=yes
531 # enable additional debugging code?
534 AS_HELP_STRING([--enable-debug],
535 [show additional debug output]),
536 if test "$enableval" = "yes"; then x_debug_on=yes; fi
538 if test "$x_debug_on" = "yes"; then
540 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
541 AC_CHECK_FUNCS(mtrace)
544 # enable "strict RFC rules"?
547 AC_ARG_ENABLE(strict-rfc,
548 AS_HELP_STRING([--enable-strict-rfc],
549 [strict RFC conformance -- may break clients!]),
550 if test "$enableval" = "yes"; then
551 AC_DEFINE(STRICT_RFC, 1)
558 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu" )
559 AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor" )
560 AC_DEFINE_UNQUOTED(HOST_OS, "$host_os" )
562 # Add additional CFLAGS, eventually specified on the command line, but after
563 # running this configure script. Useful for "-Werror" for example.
564 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
566 # -- Generate files --
570 contrib/Anope/Makefile \
571 contrib/Debian/Makefile \
572 contrib/MacOSX/Makefile \
573 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
574 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
579 src/ipaddr/Makefile \
581 src/ngircd/Makefile \
582 src/portab/Makefile \
583 src/testsuite/Makefile \
589 type dpkg >/dev/null 2>&1
590 if test $? -eq 0; then
591 # Generate debian/ link if the dpkg command exists
592 # (read: if we are running on a debian compatible system)
593 echo "creating Debian-specific links ..."
594 test -f debian/rules || ln -s contrib/Debian debian
600 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
603 # Someone please show me a better way :) [borrowed by OpenSSH]
604 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
605 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
606 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
607 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
608 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
610 echo " Host: ${host}"
611 echo " Compiler: ${CC}"
612 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
613 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
614 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
615 test -n "$LIBS" && echo " Libraries: ${LIBS}"
617 echo " 'ngircd' binary: $S"
618 echo " Configuration file: $C"
619 echo " Manual pages: $M"
620 echo " Documentation: $D"
623 echo $ECHO_N " Syslog support: $ECHO_C"
624 test "$x_syslog_on" = "yes" \
625 && echo $ECHO_N "yes $ECHO_C" \
626 || echo $ECHO_N "no $ECHO_C"
627 echo $ECHO_N " Enable debug code: $ECHO_C"
628 test "$x_debug_on" = "yes" \
632 echo $ECHO_N " zlib compression: $ECHO_C"
633 test "$x_zlib_on" = "yes" \
634 && echo $ECHO_N "yes $ECHO_C" \
635 || echo $ECHO_N "no $ECHO_C"
636 echo $ECHO_N " IRC sniffer: $ECHO_C"
637 test "$x_sniffer_on" = "yes" \
641 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
642 test "$x_tcpwrap_on" = "yes" \
643 && echo $ECHO_N "yes $ECHO_C" \
644 || echo $ECHO_N "no $ECHO_C"
645 echo $ECHO_N " Strict RFC mode: $ECHO_C"
646 test "$x_strict_rfc_on" = "yes" \
650 echo $ECHO_N " IDENT support: $ECHO_C"
651 test "$x_identauth_on" = "yes" \
652 && echo $ECHO_N "yes $ECHO_C" \
653 || echo $ECHO_N "no $ECHO_C"
654 echo $ECHO_N " IRC+ protocol: $ECHO_C"
655 test "$x_ircplus_on" = "yes" \
659 echo $ECHO_N " IPv6 protocol: $ECHO_C"
660 test "$x_ipv6_on" = "yes" \
661 && echo $ECHO_N "yes $ECHO_C" \
662 || echo $ECHO_N "no $ECHO_C"
663 echo $ECHO_N " I/O backend: $ECHO_C"
664 echo "\"$x_io_backend\""
666 echo $ECHO_N " PAM support: $ECHO_C"
667 test "$x_pam_on" = "yes" \
668 && echo $ECHO_N "yes $ECHO_C" \
669 || echo $ECHO_N "no $ECHO_C"
670 echo $ECHO_N " SSL support: $ECHO_C"