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, 15~rc1)
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 stdlib.h string.h \
105 strings.h sys/socket.h sys/time.h unistd.h \
106 ],,AC_MSG_ERROR([required C header missing!]))
108 AC_CHECK_HEADERS([arpa/inet.h ctype.h malloc.h stdbool.h stddef.h varargs.h])
112 AC_MSG_CHECKING(whether socklen_t exists)
114 #include <sys/types.h>
115 #include <sys/socket.h>
118 a = 2; b = 4; a += b;
120 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
128 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
129 [#include <arpa/inet.h>])
133 AC_CHECK_LIB(UTIL,memmove)
134 AC_CHECK_LIB(socket,bind)
135 AC_CHECK_LIB(nsl,gethostent)
143 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
144 setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
146 AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction snprintf \
147 vsnprintf strdup strlcpy strlcat strtok_r)
149 # -- Configuration options --
155 [ --without-syslog disable syslog (autodetected by default)],
156 [ if test "$withval" != "no"; then
157 if test "$withval" != "yes"; then
158 CFLAGS="-I$withval/include $CFLAGS"
159 CPPFLAGS="-I$withval/include $CPPFLAGS"
160 LDFLAGS="-L$withval/lib $LDFLAGS"
162 AC_CHECK_LIB(be, syslog)
163 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
164 AC_MSG_ERROR([Can't enable syslog!])
169 AC_CHECK_LIB(be, syslog)
170 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
173 if test "$x_syslog_on" = "yes"; then
175 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
178 # use zlib compression?
182 [ --without-zlib disable zlib compression (autodetected by default)],
183 [ if test "$withval" != "no"; then
184 if test "$withval" != "yes"; then
185 CFLAGS="-I$withval/include $CFLAGS"
186 CPPFLAGS="-I$withval/include $CPPFLAGS"
187 LDFLAGS="-L$withval/lib $LDFLAGS"
189 AC_CHECK_LIB(z, deflate)
190 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
191 AC_MSG_ERROR([Can't enable zlib!])
195 [ AC_CHECK_LIB(z, deflate)
196 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
199 if test "$x_zlib_on" = "yes"; then
201 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
204 # detect which IO API to use:
209 [ --without-select disable select IO support (autodetected by default)],
210 [ if test "$withval" != "no"; then
211 if test "$withval" != "yes"; then
212 CFLAGS="-I$withval/include $CFLAGS"
213 CPPFLAGS="-I$withval/include $CPPFLAGS"
214 LDFLAGS="-L$withval/lib $LDFLAGS"
216 AC_CHECK_FUNCS(select, x_io_select=yes,
217 AC_MSG_ERROR([Can't enable select IO support!])
222 AC_CHECK_FUNCS(select, x_io_select=yes)
227 [ --without-poll disable poll support (autodetected by default)],
228 [ if test "$withval" != "no"; then
229 if test "$withval" != "yes"; then
230 CFLAGS="-I$withval/include $CFLAGS"
231 CPPFLAGS="-I$withval/include $CPPFLAGS"
232 LDFLAGS="-L$withval/lib $LDFLAGS"
234 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
235 AC_MSG_ERROR([Can't enable poll IO support!])
240 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
245 [ --without-devpoll disable /dev/poll 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"
253 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
257 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
262 [ --without-epoll disable epoll IO support (autodetected by default)],
263 [ if test "$withval" != "no"; then
264 if test "$withval" != "yes"; then
265 CFLAGS="-I$withval/include $CFLAGS"
266 CPPFLAGS="-I$withval/include $CPPFLAGS"
267 LDFLAGS="-L$withval/lib $LDFLAGS"
269 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
270 AC_MSG_ERROR([Can't enable epoll IO support!])
275 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
280 [ --without-kqueue disable kqueue IO support (autodetected by default)],
281 [ if test "$withval" != "no"; then
282 if test "$withval" != "yes"; then
283 CFLAGS="-I$withval/include $CFLAGS"
284 CPPFLAGS="-I$withval/include $CPPFLAGS"
285 LDFLAGS="-L$withval/lib $LDFLAGS"
287 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
288 AC_MSG_ERROR([Can't enable kqueue IO support!])
293 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
297 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
298 # when epoll() and select() are available, we'll use both!
299 x_io_backend="epoll(), select()"
301 if test "$x_io_epoll" = "yes"; then
302 # we prefere epoll() if it is available
303 x_io_backend="epoll()"
305 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
306 # we'll use select, when available and no "better"
307 # interface has been detected ...
308 x_io_backend="select()"
313 if test "$x_io_backend" = "none"; then
314 AC_MSG_ERROR([No useabe IO API activated/found!?])
320 [ --with-openssl enable SSL support using OpenSSL],
321 [ if test "$withval" != "no"; then
322 if test "$withval" != "yes"; then
323 CFLAGS="-I$withval/include $CFLAGS"
324 CPPFLAGS="-I$withval/include $CPPFLAGS"
325 LDFLAGS="-L$withval/lib $LDFLAGS"
327 AC_CHECK_LIB(crypto, BIO_s_mem)
328 AC_CHECK_LIB(ssl, SSL_library_init)
329 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
330 AC_MSG_ERROR([Can't enable openssl])
337 [ --with-gnutls enable SSL support using gnutls],
338 [ if test "$withval" != "no"; then
339 if test "$withval" != "yes"; then
340 CFLAGS="-I$withval/include $CFLAGS"
341 CPPFLAGS="-I$withval/include $CPPFLAGS"
342 LDFLAGS="-L$withval/lib $LDFLAGS"
344 AC_CHECK_LIB(gnutls, gnutls_global_init)
345 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
346 AC_MSG_ERROR([Can't enable gnutls])
353 if test "$x_ssl_gnutls" = "yes"; then
354 if test "$x_ssl_openssl" = "yes";then
355 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
359 if test "$x_ssl_openssl" = "yes"; then
366 AC_ARG_WITH(tcp-wrappers,
367 [ --with-tcp-wrappers enable TCP wrappers support],
368 [ if test "$withval" != "no"; then
369 if test "$withval" != "yes"; then
370 CFLAGS="-I$withval/include $CFLAGS"
371 CPPFLAGS="-I$withval/include $CPPFLAGS"
372 LDFLAGS="-L$withval/lib $LDFLAGS"
374 AC_MSG_CHECKING(for hosts_access)
378 int allow_severity = 0;
379 int deny_severity = 0;
381 tcpd_warn("link test");
384 AC_DEFINE(TCPWRAP, 1)
388 AC_MSG_ERROR([Can't enable TCP wrappers!])
394 # include support for "zeroconf"?
397 AC_ARG_WITH(zeroconf,
398 [ --with-zeroconf enable support for "Zeroconf"],
399 [ if test "$withval" != "no"; then
400 if test "$withval" != "yes"; then
401 CFLAGS="-I$withval/include $CFLAGS"
402 CPPFLAGS="-I$withval/include $CPPFLAGS"
403 LDFLAGS="-L$withval/lib $LDFLAGS"
405 AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
407 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
408 AC_CHECK_LIB(howl, sw_discovery_init)
409 AC_CHECK_FUNCS(sw_discovery_init, \
410 x_zeroconf_on=howl, \
411 AC_MSG_ERROR([Can't enable Zeroconf!]))
416 if test "$x_zeroconf_on" = "osx"; then
417 AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
418 mach/port.h],,AC_MSG_ERROR([required C header missing!]))
419 AC_DEFINE(ZEROCONF, 1)
421 if test "$x_zeroconf_on" = "howl"; then
422 for dir in /usr/local/include /usr/local/include/howl* \
423 /usr/include /usr/include/howl* \
424 /usr/local/include/avahi* /usr/include/avahi*; do
425 test -d "$dir" || continue
426 AC_MSG_CHECKING([for Howl headers in $dir])
427 if test -f "$dir/rendezvous/rendezvous.h"; then
428 if test "$dir" != "/usr/local/include" -a \
429 "$dir" != "/usr/include"; then
430 CFLAGS="-I$dir $CFLAGS"
431 CPPFLAGS="-I$dir $CPPFLAGS"
439 AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
440 AC_MSG_ERROR([required C header missing!]))
441 AC_DEFINE(ZEROCONF, 1)
444 # do IDENT requests using libident?
448 [ --with-ident enable "IDENT" ("AUTH") protocol support],
449 [ if test "$withval" != "no"; then
450 if test "$withval" != "yes"; then
451 CFLAGS="-I$withval/include $CFLAGS"
452 CPPFLAGS="-I$withval/include $CPPFLAGS"
453 LDFLAGS="-L$withval/lib $LDFLAGS"
455 AC_CHECK_LIB(ident, ident_id)
456 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
457 AC_MSG_ERROR([Can't enable IDENT support!])
462 if test "$x_identauth_on" = "yes"; then
463 AC_DEFINE(IDENTAUTH, 1)
464 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
467 # compile in IRC+ protocol support?
470 AC_ARG_ENABLE(ircplus,
471 [ --disable-ircplus disable IRC+ protocol],
472 if test "$enableval" = "no"; then x_ircplus_on=no; fi
474 if test "$x_ircplus_on" = "yes"; then
475 AC_DEFINE(IRCPLUS, 1)
478 # enable support for IPv6?
481 [ --enable-ipv6 enable IPv6 protocol support],
482 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
484 if test "$x_ipv6_on" = "yes"; then
485 # getaddrinfo() and getnameinfo() are optional when not compiling
486 # with IPv6 support, but are required for IPv6 to work!
488 getaddrinfo getnameinfo \
489 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
490 AC_DEFINE(WANT_IPV6, 1)
493 # compile in IRC "sniffer"?
495 x_sniffer_on=no; x_debug_on=no
496 AC_ARG_ENABLE(sniffer,
497 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
498 if test "$enableval" = "yes"; then
499 AC_DEFINE(SNIFFER, 1)
500 x_sniffer_on=yes; x_debug_on=yes
504 # enable additional debugging code?
507 [ --enable-debug show additional debug output],
508 if test "$enableval" = "yes"; then x_debug_on=yes; fi
510 if test "$x_debug_on" = "yes"; then
512 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
513 AC_CHECK_FUNCS(mtrace)
516 # enable "strict RFC rules"?
519 AC_ARG_ENABLE(strict-rfc,
520 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
521 if test "$enableval" = "yes"; then
522 AC_DEFINE(STRICT_RFC, 1)
529 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
530 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
531 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
533 # Add additional CFLAGS, eventually specified on the command line, but after
534 # running this configure script. Useful for "-Werror" for example.
535 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
537 # -- Generate files --
544 src/portab/Makefile \
545 src/ipaddr/Makefile \
547 src/ngircd/Makefile \
548 src/testsuite/Makefile \
551 contrib/Debian/Makefile \
552 contrib/MacOSX/Makefile \
553 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
554 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
557 type dpkg >/dev/null 2>&1
558 if test $? -eq 0; then
559 # Generate debian/ link if the dpkg command exists
560 # (read: if we are running on a debian compatible system)
561 echo "creating Debian-specific links ..."
562 test -f debian/rules || ln -s contrib/Debian debian
568 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
571 # Someone please show me a better way :) [borrowed by OpenSSH]
572 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
573 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
574 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
575 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
576 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
578 echo " Target: ${target}"
579 test "$target" != "$host" && echo " Host: ${host}"
580 echo " Compiler: ${CC}"
581 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
582 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
583 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
584 test -n "$LIBS" && echo " Libraries: ${LIBS}"
586 echo " 'ngircd' binary: $S"
587 echo " Configuration file: $C"
588 echo " Manual pages: $M"
589 echo " Documentation: $D"
592 echo $ECHO_N " Syslog support: $ECHO_C"
593 test "$x_syslog_on" = "yes" \
594 && echo $ECHO_N "yes $ECHO_C" \
595 || echo $ECHO_N "no $ECHO_C"
596 echo $ECHO_N " Enable debug code: $ECHO_C"
597 test "$x_debug_on" = "yes" \
601 echo $ECHO_N " zlib compression: $ECHO_C"
602 test "$x_zlib_on" = "yes" \
603 && echo $ECHO_N "yes $ECHO_C" \
604 || echo $ECHO_N "no $ECHO_C"
605 echo $ECHO_N " IRC sniffer: $ECHO_C"
606 test "$x_sniffer_on" = "yes" \
610 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
611 test "$x_tcpwrap_on" = "yes" \
612 && echo $ECHO_N "yes $ECHO_C" \
613 || echo $ECHO_N "no $ECHO_C"
614 echo $ECHO_N " Strict RFC mode: $ECHO_C"
615 test "$x_strict_rfc_on" = "yes" \
619 echo $ECHO_N " Zeroconf support: $ECHO_C"
620 case "$x_zeroconf_on" in
622 echo $ECHO_N "Apple $ECHO_C"
625 echo $ECHO_N "Howl $ECHO_C"
628 echo $ECHO_N "no $ECHO_C"
631 echo $ECHO_N " IRC+ protocol: $ECHO_C"
632 test "$x_ircplus_on" = "yes" \
636 echo $ECHO_N " IDENT support: $ECHO_C"
637 test "$x_identauth_on" = "yes" \
638 && echo $ECHO_N "yes $ECHO_C" \
639 || echo $ECHO_N "no $ECHO_C"
640 echo $ECHO_N " I/O backend: $ECHO_C"
641 echo "\"$x_io_backend\""
643 echo $ECHO_N " IPv6 protocol: $ECHO_C"
644 echo $ECHO_N "$x_ipv6_on $ECHO_C"
646 echo $ECHO_N " SSL support: $ECHO_C"