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 --
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!]))
109 arpa/inet.h ctype.h malloc.h netinet/ip.h stdbool.h stddef.h varargs.h])
113 AC_MSG_CHECKING(whether socklen_t exists)
115 #include <sys/types.h>
116 #include <sys/socket.h>
119 a = 2; b = 4; a += b;
121 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
129 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
130 [#include <arpa/inet.h>])
134 AC_CHECK_LIB(UTIL,memmove)
135 AC_CHECK_LIB(socket,bind)
136 AC_CHECK_LIB(nsl,gethostent)
144 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
145 setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
147 AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction snprintf \
148 vsnprintf strdup strlcpy strlcat strtok_r)
150 # -- Configuration options --
156 [ --without-syslog disable syslog (autodetected by default)],
157 [ if test "$withval" != "no"; then
158 if test "$withval" != "yes"; then
159 CFLAGS="-I$withval/include $CFLAGS"
160 CPPFLAGS="-I$withval/include $CPPFLAGS"
161 LDFLAGS="-L$withval/lib $LDFLAGS"
163 AC_CHECK_LIB(be, syslog)
164 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
165 AC_MSG_ERROR([Can't enable syslog!])
170 AC_CHECK_LIB(be, syslog)
171 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
174 if test "$x_syslog_on" = "yes"; then
176 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
179 # use zlib compression?
183 [ --without-zlib disable zlib compression (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(z, deflate)
191 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
192 AC_MSG_ERROR([Can't enable zlib!])
196 [ AC_CHECK_LIB(z, deflate)
197 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
200 if test "$x_zlib_on" = "yes"; then
202 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
205 # detect which IO API to use:
210 [ --without-select disable select IO support (autodetected by default)],
211 [ if test "$withval" != "no"; then
212 if test "$withval" != "yes"; then
213 CFLAGS="-I$withval/include $CFLAGS"
214 CPPFLAGS="-I$withval/include $CPPFLAGS"
215 LDFLAGS="-L$withval/lib $LDFLAGS"
217 AC_CHECK_FUNCS(select, x_io_select=yes,
218 AC_MSG_ERROR([Can't enable select IO support!])
223 AC_CHECK_FUNCS(select, x_io_select=yes)
228 [ --without-poll disable poll support (autodetected by default)],
229 [ if test "$withval" != "no"; then
230 if test "$withval" != "yes"; then
231 CFLAGS="-I$withval/include $CFLAGS"
232 CPPFLAGS="-I$withval/include $CPPFLAGS"
233 LDFLAGS="-L$withval/lib $LDFLAGS"
235 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
236 AC_MSG_ERROR([Can't enable poll IO support!])
241 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
246 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
247 [ if test "$withval" != "no"; then
248 if test "$withval" != "yes"; then
249 CFLAGS="-I$withval/include $CFLAGS"
250 CPPFLAGS="-I$withval/include $CPPFLAGS"
251 LDFLAGS="-L$withval/lib $LDFLAGS"
254 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
258 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
263 [ --without-epoll disable epoll IO support (autodetected by default)],
264 [ if test "$withval" != "no"; then
265 if test "$withval" != "yes"; then
266 CFLAGS="-I$withval/include $CFLAGS"
267 CPPFLAGS="-I$withval/include $CPPFLAGS"
268 LDFLAGS="-L$withval/lib $LDFLAGS"
270 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
271 AC_MSG_ERROR([Can't enable epoll IO support!])
276 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
281 [ --without-kqueue disable kqueue IO support (autodetected by default)],
282 [ if test "$withval" != "no"; then
283 if test "$withval" != "yes"; then
284 CFLAGS="-I$withval/include $CFLAGS"
285 CPPFLAGS="-I$withval/include $CPPFLAGS"
286 LDFLAGS="-L$withval/lib $LDFLAGS"
288 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
289 AC_MSG_ERROR([Can't enable kqueue IO support!])
294 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
298 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
299 # when epoll() and select() are available, we'll use both!
300 x_io_backend="epoll(), select()"
302 if test "$x_io_epoll" = "yes"; then
303 # we prefere epoll() if it is available
304 x_io_backend="epoll()"
306 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
307 # we'll use select, when available and no "better"
308 # interface has been detected ...
309 x_io_backend="select()"
314 if test "$x_io_backend" = "none"; then
315 AC_MSG_ERROR([No useabe IO API activated/found!?])
321 [ --with-openssl enable SSL support using OpenSSL],
322 [ if test "$withval" != "no"; then
323 if test "$withval" != "yes"; then
324 CFLAGS="-I$withval/include $CFLAGS"
325 CPPFLAGS="-I$withval/include $CPPFLAGS"
326 LDFLAGS="-L$withval/lib $LDFLAGS"
328 AC_CHECK_LIB(crypto, BIO_s_mem)
329 AC_CHECK_LIB(ssl, SSL_library_init)
330 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
331 AC_MSG_ERROR([Can't enable openssl])
338 [ --with-gnutls enable SSL support using gnutls],
339 [ if test "$withval" != "no"; then
340 if test "$withval" != "yes"; then
341 CFLAGS="-I$withval/include $CFLAGS"
342 CPPFLAGS="-I$withval/include $CPPFLAGS"
343 LDFLAGS="-L$withval/lib $LDFLAGS"
345 AC_CHECK_LIB(gnutls, gnutls_global_init)
346 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
347 AC_MSG_ERROR([Can't enable gnutls])
354 if test "$x_ssl_gnutls" = "yes"; then
355 if test "$x_ssl_openssl" = "yes";then
356 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
360 if test "$x_ssl_openssl" = "yes"; then
367 AC_ARG_WITH(tcp-wrappers,
368 [ --with-tcp-wrappers enable TCP wrappers support],
369 [ if test "$withval" != "no"; then
370 if test "$withval" != "yes"; then
371 CFLAGS="-I$withval/include $CFLAGS"
372 CPPFLAGS="-I$withval/include $CPPFLAGS"
373 LDFLAGS="-L$withval/lib $LDFLAGS"
375 AC_MSG_CHECKING(for hosts_access)
379 int allow_severity = 0;
380 int deny_severity = 0;
382 tcpd_warn("link test");
385 AC_DEFINE(TCPWRAP, 1)
389 AC_MSG_ERROR([Can't enable TCP wrappers!])
395 # include support for "zeroconf"?
398 AC_ARG_WITH(zeroconf,
399 [ --with-zeroconf enable support for "Zeroconf"],
400 [ if test "$withval" != "no"; then
401 if test "$withval" != "yes"; then
402 CFLAGS="-I$withval/include $CFLAGS"
403 CPPFLAGS="-I$withval/include $CPPFLAGS"
404 LDFLAGS="-L$withval/lib $LDFLAGS"
406 AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
408 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
409 AC_CHECK_LIB(howl, sw_discovery_init)
410 AC_CHECK_FUNCS(sw_discovery_init, \
411 x_zeroconf_on=howl, \
412 AC_MSG_ERROR([Can't enable Zeroconf!]))
417 if test "$x_zeroconf_on" = "osx"; then
418 AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
419 mach/port.h],,AC_MSG_ERROR([required C header missing!]))
420 AC_DEFINE(ZEROCONF, 1)
422 if test "$x_zeroconf_on" = "howl"; then
423 for dir in /usr/local/include /usr/local/include/howl* \
424 /usr/include /usr/include/howl* \
425 /usr/local/include/avahi* /usr/include/avahi*; do
426 test -d "$dir" || continue
427 AC_MSG_CHECKING([for Howl headers in $dir])
428 if test -f "$dir/rendezvous/rendezvous.h"; then
429 if test "$dir" != "/usr/local/include" -a \
430 "$dir" != "/usr/include"; then
431 CFLAGS="-I$dir $CFLAGS"
432 CPPFLAGS="-I$dir $CPPFLAGS"
440 AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
441 AC_MSG_ERROR([required C header missing!]))
442 AC_DEFINE(ZEROCONF, 1)
445 # do IDENT requests using libident?
449 [ --with-ident enable "IDENT" ("AUTH") protocol support],
450 [ if test "$withval" != "no"; then
451 if test "$withval" != "yes"; then
452 CFLAGS="-I$withval/include $CFLAGS"
453 CPPFLAGS="-I$withval/include $CPPFLAGS"
454 LDFLAGS="-L$withval/lib $LDFLAGS"
456 AC_CHECK_LIB(ident, ident_id)
457 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
458 AC_MSG_ERROR([Can't enable IDENT support!])
463 if test "$x_identauth_on" = "yes"; then
464 AC_DEFINE(IDENTAUTH, 1)
465 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
468 # compile in IRC+ protocol support?
471 AC_ARG_ENABLE(ircplus,
472 [ --disable-ircplus disable IRC+ protocol],
473 if test "$enableval" = "no"; then x_ircplus_on=no; fi
475 if test "$x_ircplus_on" = "yes"; then
476 AC_DEFINE(IRCPLUS, 1)
479 # enable support for IPv6?
482 [ --enable-ipv6 enable IPv6 protocol support],
483 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
485 if test "$x_ipv6_on" = "yes"; then
486 # getaddrinfo() and getnameinfo() are optional when not compiling
487 # with IPv6 support, but are required for IPv6 to work!
489 getaddrinfo getnameinfo \
490 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
491 AC_DEFINE(WANT_IPV6, 1)
494 # compile in IRC "sniffer"?
496 x_sniffer_on=no; x_debug_on=no
497 AC_ARG_ENABLE(sniffer,
498 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
499 if test "$enableval" = "yes"; then
500 AC_DEFINE(SNIFFER, 1)
501 x_sniffer_on=yes; x_debug_on=yes
505 # enable additional debugging code?
508 [ --enable-debug show additional debug output],
509 if test "$enableval" = "yes"; then x_debug_on=yes; fi
511 if test "$x_debug_on" = "yes"; then
513 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
514 AC_CHECK_FUNCS(mtrace)
517 # enable "strict RFC rules"?
520 AC_ARG_ENABLE(strict-rfc,
521 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
522 if test "$enableval" = "yes"; then
523 AC_DEFINE(STRICT_RFC, 1)
530 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
531 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
532 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
534 # Add additional CFLAGS, eventually specified on the command line, but after
535 # running this configure script. Useful for "-Werror" for example.
536 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
538 # -- Generate files --
545 src/portab/Makefile \
546 src/ipaddr/Makefile \
548 src/ngircd/Makefile \
549 src/testsuite/Makefile \
552 contrib/Debian/Makefile \
553 contrib/MacOSX/Makefile \
554 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
555 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
558 type dpkg >/dev/null 2>&1
559 if test $? -eq 0; then
560 # Generate debian/ link if the dpkg command exists
561 # (read: if we are running on a debian compatible system)
562 echo "creating Debian-specific links ..."
563 test -f debian/rules || ln -s contrib/Debian debian
569 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
572 # Someone please show me a better way :) [borrowed by OpenSSH]
573 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
574 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
575 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
576 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
577 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
579 echo " Target: ${target}"
580 test "$target" != "$host" && echo " Host: ${host}"
581 echo " Compiler: ${CC}"
582 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
583 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
584 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
585 test -n "$LIBS" && echo " Libraries: ${LIBS}"
587 echo " 'ngircd' binary: $S"
588 echo " Configuration file: $C"
589 echo " Manual pages: $M"
590 echo " Documentation: $D"
593 echo $ECHO_N " Syslog support: $ECHO_C"
594 test "$x_syslog_on" = "yes" \
595 && echo $ECHO_N "yes $ECHO_C" \
596 || echo $ECHO_N "no $ECHO_C"
597 echo $ECHO_N " Enable debug code: $ECHO_C"
598 test "$x_debug_on" = "yes" \
602 echo $ECHO_N " zlib compression: $ECHO_C"
603 test "$x_zlib_on" = "yes" \
604 && echo $ECHO_N "yes $ECHO_C" \
605 || echo $ECHO_N "no $ECHO_C"
606 echo $ECHO_N " IRC sniffer: $ECHO_C"
607 test "$x_sniffer_on" = "yes" \
611 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
612 test "$x_tcpwrap_on" = "yes" \
613 && echo $ECHO_N "yes $ECHO_C" \
614 || echo $ECHO_N "no $ECHO_C"
615 echo $ECHO_N " Strict RFC mode: $ECHO_C"
616 test "$x_strict_rfc_on" = "yes" \
620 echo $ECHO_N " Zeroconf support: $ECHO_C"
621 case "$x_zeroconf_on" in
623 echo $ECHO_N "Apple $ECHO_C"
626 echo $ECHO_N "Howl $ECHO_C"
629 echo $ECHO_N "no $ECHO_C"
632 echo $ECHO_N " IRC+ protocol: $ECHO_C"
633 test "$x_ircplus_on" = "yes" \
637 echo $ECHO_N " IDENT support: $ECHO_C"
638 test "$x_identauth_on" = "yes" \
639 && echo $ECHO_N "yes $ECHO_C" \
640 || echo $ECHO_N "no $ECHO_C"
641 echo $ECHO_N " I/O backend: $ECHO_C"
642 echo "\"$x_io_backend\""
644 echo $ECHO_N " IPv6 protocol: $ECHO_C"
645 echo $ECHO_N "$x_ipv6_on $ECHO_C"
647 echo $ECHO_N " SSL support: $ECHO_C"