2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2009 Alexander Barton <alex@barton.de>
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 # -- Initialisation --
15 AC_INIT(ngircd, 16~rc2)
16 AC_CONFIG_SRCDIR(src/ngircd/ngircd.c)
19 AM_CONFIG_HEADER(src/config.h)
21 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
23 # -- Templates for config.h --
25 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
26 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
27 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
28 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
29 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
30 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
31 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
32 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
33 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
34 AH_TEMPLATE([ZEROCONF], [Define if support for Zeroconf should be included])
35 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
36 AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
38 AH_TEMPLATE([TARGET_OS], [Target operating system name])
39 AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
40 AH_TEMPLATE([TARGET_CPU], [Target CPU name])
46 # -- Helper programs --
54 # -- Compiler Features --
60 # -- Hard coded system and compiler dependencies/features/options ... --
62 AC_DEFUN([GCC_STACK_PROTECT_CC],[
64 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
65 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
66 ssp_old_cflags="$CFLAGS"
67 CFLAGS="$CFLAGS -fstack-protector-all"
68 AC_TRY_LINK(,,, ssp_cc=no)
70 CFLAGS="$ssp_old_cflags"
71 if test "X$ssp_cc" = "Xyes"; then
72 CFLAGS="$CFLAGS -fstack-protector"
73 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
77 if test "$GCC" = "yes"; then
78 # We are using the GNU C compiler. Good!
79 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
86 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
87 # (tested with HP/UX 11.11)
88 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
92 # Add additional CFLAGS, eventually specified on the command line:
93 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
95 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
104 ctype.h errno.h fcntl.h netdb.h netinet/in.h netinet/in_systm.h \
105 stdlib.h string.h strings.h sys/socket.h sys/time.h unistd.h \
106 ],,AC_MSG_ERROR([required C header missing!]))
109 arpa/inet.h ctype.h malloc.h netinet/ip.h stdbool.h stddef.h varargs.h \
111 #include <netinet/in.h>
112 #ifdef HAVE_NETINET_IN_SYSTM_H
113 #include <netinet/in_systm.h>
120 AC_MSG_CHECKING(whether socklen_t exists)
122 #include <sys/types.h>
123 #include <sys/socket.h>
126 a = 2; b = 4; a += b;
128 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
136 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
137 [#include <arpa/inet.h>])
142 AC_CHECK_LIB(UTIL,memmove)
143 # needed on solaris. GNU libc also has a libnsl, but we do not need it.
144 AC_SEARCH_LIBS(gethostbyname,nsl)
145 AC_CHECK_LIB(socket,bind)
153 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
154 setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
156 AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction snprintf \
157 vsnprintf strdup strlcpy strlcat strtok_r)
159 # -- Configuration options --
165 [ --without-syslog disable syslog (autodetected by default)],
166 [ if test "$withval" != "no"; then
167 if test "$withval" != "yes"; then
168 CFLAGS="-I$withval/include $CFLAGS"
169 CPPFLAGS="-I$withval/include $CPPFLAGS"
170 LDFLAGS="-L$withval/lib $LDFLAGS"
172 AC_CHECK_LIB(be, syslog)
173 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
174 AC_MSG_ERROR([Can't enable syslog!])
179 AC_CHECK_LIB(be, syslog)
180 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
183 if test "$x_syslog_on" = "yes"; then
185 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
188 # use zlib compression?
192 [ --without-zlib disable zlib compression (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_CHECK_LIB(z, deflate)
200 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
201 AC_MSG_ERROR([Can't enable zlib!])
205 [ AC_CHECK_LIB(z, deflate)
206 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
209 if test "$x_zlib_on" = "yes"; then
211 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
214 # detect which IO API to use:
219 [ --without-select disable select IO support (autodetected by default)],
220 [ if test "$withval" != "no"; then
221 if test "$withval" != "yes"; then
222 CFLAGS="-I$withval/include $CFLAGS"
223 CPPFLAGS="-I$withval/include $CPPFLAGS"
224 LDFLAGS="-L$withval/lib $LDFLAGS"
226 AC_CHECK_FUNCS(select, x_io_select=yes,
227 AC_MSG_ERROR([Can't enable select IO support!])
232 AC_CHECK_FUNCS(select, x_io_select=yes)
237 [ --without-poll disable poll support (autodetected by default)],
238 [ if test "$withval" != "no"; then
239 if test "$withval" != "yes"; then
240 CFLAGS="-I$withval/include $CFLAGS"
241 CPPFLAGS="-I$withval/include $CPPFLAGS"
242 LDFLAGS="-L$withval/lib $LDFLAGS"
244 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
245 AC_MSG_ERROR([Can't enable poll IO support!])
250 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
255 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
256 [ if test "$withval" != "no"; then
257 if test "$withval" != "yes"; then
258 CFLAGS="-I$withval/include $CFLAGS"
259 CPPFLAGS="-I$withval/include $CPPFLAGS"
260 LDFLAGS="-L$withval/lib $LDFLAGS"
263 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
267 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
272 [ --without-epoll disable epoll IO support (autodetected by default)],
273 [ if test "$withval" != "no"; then
274 if test "$withval" != "yes"; then
275 CFLAGS="-I$withval/include $CFLAGS"
276 CPPFLAGS="-I$withval/include $CPPFLAGS"
277 LDFLAGS="-L$withval/lib $LDFLAGS"
279 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
280 AC_MSG_ERROR([Can't enable epoll IO support!])
285 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
290 [ --without-kqueue disable kqueue IO support (autodetected by default)],
291 [ if test "$withval" != "no"; then
292 if test "$withval" != "yes"; then
293 CFLAGS="-I$withval/include $CFLAGS"
294 CPPFLAGS="-I$withval/include $CPPFLAGS"
295 LDFLAGS="-L$withval/lib $LDFLAGS"
297 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
298 AC_MSG_ERROR([Can't enable kqueue IO support!])
303 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
307 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
308 # when epoll() and select() are available, we'll use both!
309 x_io_backend="epoll(), select()"
311 if test "$x_io_epoll" = "yes"; then
312 # we prefere epoll() if it is available
313 x_io_backend="epoll()"
315 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
316 # we'll use select, when available and no "better"
317 # interface has been detected ...
318 x_io_backend="select()"
323 if test "$x_io_backend" = "none"; then
324 AC_MSG_ERROR([No useabe IO API activated/found!?])
330 [ --with-openssl enable SSL support using OpenSSL],
331 [ if test "$withval" != "no"; then
332 if test "$withval" != "yes"; then
333 CFLAGS="-I$withval/include $CFLAGS"
334 CPPFLAGS="-I$withval/include $CPPFLAGS"
335 LDFLAGS="-L$withval/lib $LDFLAGS"
337 AC_CHECK_LIB(crypto, BIO_s_mem)
338 AC_CHECK_LIB(ssl, SSL_library_init)
339 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
340 AC_MSG_ERROR([Can't enable openssl])
347 [ --with-gnutls enable SSL support using gnutls],
348 [ if test "$withval" != "no"; then
349 if test "$withval" != "yes"; then
350 CFLAGS="-I$withval/include $CFLAGS"
351 CPPFLAGS="-I$withval/include $CPPFLAGS"
352 LDFLAGS="-L$withval/lib $LDFLAGS"
354 AC_CHECK_LIB(gnutls, gnutls_global_init)
355 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
356 AC_MSG_ERROR([Can't enable gnutls])
363 if test "$x_ssl_gnutls" = "yes"; then
364 if test "$x_ssl_openssl" = "yes";then
365 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
369 if test "$x_ssl_openssl" = "yes"; then
376 AC_ARG_WITH(tcp-wrappers,
377 [ --with-tcp-wrappers enable TCP wrappers support],
378 [ if test "$withval" != "no"; then
379 if test "$withval" != "yes"; then
380 CFLAGS="-I$withval/include $CFLAGS"
381 CPPFLAGS="-I$withval/include $CPPFLAGS"
382 LDFLAGS="-L$withval/lib $LDFLAGS"
384 AC_MSG_CHECKING(for hosts_access)
388 int allow_severity = 0;
389 int deny_severity = 0;
391 tcpd_warn("link test");
394 AC_DEFINE(TCPWRAP, 1)
398 AC_MSG_ERROR([Can't enable TCP wrappers!])
404 # include support for "zeroconf"?
407 AC_ARG_WITH(zeroconf,
408 [ --with-zeroconf enable support for "Zeroconf"],
409 [ if test "$withval" != "no"; then
410 if test "$withval" != "yes"; then
411 CFLAGS="-I$withval/include $CFLAGS"
412 CPPFLAGS="-I$withval/include $CPPFLAGS"
413 LDFLAGS="-L$withval/lib $LDFLAGS"
415 AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
417 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
418 AC_CHECK_LIB(howl, sw_discovery_init)
419 AC_CHECK_FUNCS(sw_discovery_init, \
420 x_zeroconf_on=howl, \
421 AC_MSG_ERROR([Can't enable Zeroconf!]))
426 if test "$x_zeroconf_on" = "osx"; then
427 AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
428 mach/port.h],,AC_MSG_ERROR([required C header missing!]))
429 AC_DEFINE(ZEROCONF, 1)
431 if test "$x_zeroconf_on" = "howl"; then
432 for dir in /usr/local/include /usr/local/include/howl* \
433 /usr/include /usr/include/howl* \
434 /usr/local/include/avahi* /usr/include/avahi*; do
435 test -d "$dir" || continue
436 AC_MSG_CHECKING([for Howl headers in $dir])
437 if test -f "$dir/rendezvous/rendezvous.h"; then
438 if test "$dir" != "/usr/local/include" -a \
439 "$dir" != "/usr/include"; then
440 CFLAGS="-I$dir $CFLAGS"
441 CPPFLAGS="-I$dir $CPPFLAGS"
449 AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
450 AC_MSG_ERROR([required C header missing!]))
451 AC_DEFINE(ZEROCONF, 1)
454 # do IDENT requests using libident?
458 [ --with-ident enable "IDENT" ("AUTH") protocol support],
459 [ if test "$withval" != "no"; then
460 if test "$withval" != "yes"; then
461 CFLAGS="-I$withval/include $CFLAGS"
462 CPPFLAGS="-I$withval/include $CPPFLAGS"
463 LDFLAGS="-L$withval/lib $LDFLAGS"
465 AC_CHECK_LIB(ident, ident_id)
466 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
467 AC_MSG_ERROR([Can't enable IDENT support!])
472 if test "$x_identauth_on" = "yes"; then
473 AC_DEFINE(IDENTAUTH, 1)
474 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
477 # compile in IRC+ protocol support?
480 AC_ARG_ENABLE(ircplus,
481 [ --disable-ircplus disable IRC+ protocol],
482 if test "$enableval" = "no"; then x_ircplus_on=no; fi
484 if test "$x_ircplus_on" = "yes"; then
485 AC_DEFINE(IRCPLUS, 1)
488 # enable support for IPv6?
491 [ --enable-ipv6 enable IPv6 protocol support],
492 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
494 if test "$x_ipv6_on" = "yes"; then
495 # getaddrinfo() and getnameinfo() are optional when not compiling
496 # with IPv6 support, but are required for IPv6 to work!
498 getaddrinfo getnameinfo \
499 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
500 AC_DEFINE(WANT_IPV6, 1)
503 # compile in IRC "sniffer"?
505 x_sniffer_on=no; x_debug_on=no
506 AC_ARG_ENABLE(sniffer,
507 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
508 if test "$enableval" = "yes"; then
509 AC_DEFINE(SNIFFER, 1)
510 x_sniffer_on=yes; x_debug_on=yes
514 # enable additional debugging code?
517 [ --enable-debug show additional debug output],
518 if test "$enableval" = "yes"; then x_debug_on=yes; fi
520 if test "$x_debug_on" = "yes"; then
522 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
523 AC_CHECK_FUNCS(mtrace)
526 # enable "strict RFC rules"?
529 AC_ARG_ENABLE(strict-rfc,
530 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
531 if test "$enableval" = "yes"; then
532 AC_DEFINE(STRICT_RFC, 1)
539 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
540 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
541 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
543 # Add additional CFLAGS, eventually specified on the command line, but after
544 # running this configure script. Useful for "-Werror" for example.
545 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
547 # -- Generate files --
554 src/portab/Makefile \
555 src/ipaddr/Makefile \
557 src/ngircd/Makefile \
558 src/testsuite/Makefile \
561 contrib/Debian/Makefile \
562 contrib/MacOSX/Makefile \
563 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
564 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
567 type dpkg >/dev/null 2>&1
568 if test $? -eq 0; then
569 # Generate debian/ link if the dpkg command exists
570 # (read: if we are running on a debian compatible system)
571 echo "creating Debian-specific links ..."
572 test -f debian/rules || ln -s contrib/Debian debian
578 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
581 # Someone please show me a better way :) [borrowed by OpenSSH]
582 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
583 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
584 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
585 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
586 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
588 echo " Target: ${target}"
589 test "$target" != "$host" && echo " Host: ${host}"
590 echo " Compiler: ${CC}"
591 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
592 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
593 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
594 test -n "$LIBS" && echo " Libraries: ${LIBS}"
596 echo " 'ngircd' binary: $S"
597 echo " Configuration file: $C"
598 echo " Manual pages: $M"
599 echo " Documentation: $D"
602 echo $ECHO_N " Syslog support: $ECHO_C"
603 test "$x_syslog_on" = "yes" \
604 && echo $ECHO_N "yes $ECHO_C" \
605 || echo $ECHO_N "no $ECHO_C"
606 echo $ECHO_N " Enable debug code: $ECHO_C"
607 test "$x_debug_on" = "yes" \
611 echo $ECHO_N " zlib compression: $ECHO_C"
612 test "$x_zlib_on" = "yes" \
613 && echo $ECHO_N "yes $ECHO_C" \
614 || echo $ECHO_N "no $ECHO_C"
615 echo $ECHO_N " IRC sniffer: $ECHO_C"
616 test "$x_sniffer_on" = "yes" \
620 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
621 test "$x_tcpwrap_on" = "yes" \
622 && echo $ECHO_N "yes $ECHO_C" \
623 || echo $ECHO_N "no $ECHO_C"
624 echo $ECHO_N " Strict RFC mode: $ECHO_C"
625 test "$x_strict_rfc_on" = "yes" \
629 echo $ECHO_N " Zeroconf support: $ECHO_C"
630 case "$x_zeroconf_on" in
632 echo $ECHO_N "Apple $ECHO_C"
635 echo $ECHO_N "Howl $ECHO_C"
638 echo $ECHO_N "no $ECHO_C"
641 echo $ECHO_N " IRC+ protocol: $ECHO_C"
642 test "$x_ircplus_on" = "yes" \
646 echo $ECHO_N " IDENT support: $ECHO_C"
647 test "$x_identauth_on" = "yes" \
648 && echo $ECHO_N "yes $ECHO_C" \
649 || echo $ECHO_N "no $ECHO_C"
650 echo $ECHO_N " I/O backend: $ECHO_C"
651 echo "\"$x_io_backend\""
653 echo $ECHO_N " IPv6 protocol: $ECHO_C"
654 echo $ECHO_N "$x_ipv6_on $ECHO_C"
656 echo $ECHO_N " SSL support: $ECHO_C"