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 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 #ifdef HAVE_SYS_TYPES_H
112 #include <sys/types.h>
114 #ifdef HAVE_SYS_SOCKET_H
115 #include <sys/socket.h>
117 #ifdef HAVE_NETINET_IN_H
118 #include <netinet/in.h>
125 AC_MSG_CHECKING(whether socklen_t exists)
127 #include <sys/types.h>
128 #include <sys/socket.h>
131 a = 2; b = 4; a += b;
133 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
141 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
142 [#include <arpa/inet.h>])
147 AC_CHECK_LIB(UTIL,memmove)
148 # needed on solaris. GNU libc also has a libnsl, but we do not need it.
149 AC_SEARCH_LIBS(gethostbyname,nsl)
150 AC_CHECK_LIB(socket,bind)
158 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
159 setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
161 AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction snprintf \
162 vsnprintf strdup strlcpy strlcat strtok_r)
164 # -- Configuration options --
170 [ --without-syslog disable syslog (autodetected by default)],
171 [ if test "$withval" != "no"; then
172 if test "$withval" != "yes"; then
173 CFLAGS="-I$withval/include $CFLAGS"
174 CPPFLAGS="-I$withval/include $CPPFLAGS"
175 LDFLAGS="-L$withval/lib $LDFLAGS"
177 AC_CHECK_LIB(be, syslog)
178 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
179 AC_MSG_ERROR([Can't enable syslog!])
184 AC_CHECK_LIB(be, syslog)
185 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
188 if test "$x_syslog_on" = "yes"; then
190 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
193 # use zlib compression?
197 [ --without-zlib disable zlib compression (autodetected by default)],
198 [ if test "$withval" != "no"; then
199 if test "$withval" != "yes"; then
200 CFLAGS="-I$withval/include $CFLAGS"
201 CPPFLAGS="-I$withval/include $CPPFLAGS"
202 LDFLAGS="-L$withval/lib $LDFLAGS"
204 AC_CHECK_LIB(z, deflate)
205 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
206 AC_MSG_ERROR([Can't enable zlib!])
210 [ AC_CHECK_LIB(z, deflate)
211 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
214 if test "$x_zlib_on" = "yes"; then
216 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
219 # detect which IO API to use:
224 [ --without-select disable select IO support (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_FUNCS(select, x_io_select=yes,
232 AC_MSG_ERROR([Can't enable select IO support!])
237 AC_CHECK_FUNCS(select, x_io_select=yes)
242 [ --without-poll disable poll support (autodetected by default)],
243 [ if test "$withval" != "no"; then
244 if test "$withval" != "yes"; then
245 CFLAGS="-I$withval/include $CFLAGS"
246 CPPFLAGS="-I$withval/include $CPPFLAGS"
247 LDFLAGS="-L$withval/lib $LDFLAGS"
249 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
250 AC_MSG_ERROR([Can't enable poll IO support!])
255 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
260 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
261 [ if test "$withval" != "no"; then
262 if test "$withval" != "yes"; then
263 CFLAGS="-I$withval/include $CFLAGS"
264 CPPFLAGS="-I$withval/include $CPPFLAGS"
265 LDFLAGS="-L$withval/lib $LDFLAGS"
268 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
272 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
277 [ --without-epoll disable epoll IO support (autodetected by default)],
278 [ if test "$withval" != "no"; then
279 if test "$withval" != "yes"; then
280 CFLAGS="-I$withval/include $CFLAGS"
281 CPPFLAGS="-I$withval/include $CPPFLAGS"
282 LDFLAGS="-L$withval/lib $LDFLAGS"
284 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
285 AC_MSG_ERROR([Can't enable epoll IO support!])
290 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
295 [ --without-kqueue disable kqueue IO support (autodetected by default)],
296 [ if test "$withval" != "no"; then
297 if test "$withval" != "yes"; then
298 CFLAGS="-I$withval/include $CFLAGS"
299 CPPFLAGS="-I$withval/include $CPPFLAGS"
300 LDFLAGS="-L$withval/lib $LDFLAGS"
302 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
303 AC_MSG_ERROR([Can't enable kqueue IO support!])
308 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
312 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
313 # when epoll() and select() are available, we'll use both!
314 x_io_backend="epoll(), select()"
316 if test "$x_io_epoll" = "yes"; then
317 # we prefere epoll() if it is available
318 x_io_backend="epoll()"
320 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
321 # we'll use select, when available and no "better"
322 # interface has been detected ...
323 x_io_backend="select()"
328 if test "$x_io_backend" = "none"; then
329 AC_MSG_ERROR([No useabe IO API activated/found!?])
335 [ --with-openssl enable SSL support using OpenSSL],
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_LIB(crypto, BIO_s_mem)
343 AC_CHECK_LIB(ssl, SSL_library_init)
344 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
345 AC_MSG_ERROR([Can't enable openssl])
352 [ --with-gnutls enable SSL support using gnutls],
353 [ if test "$withval" != "no"; then
354 if test "$withval" != "yes"; then
355 CFLAGS="-I$withval/include $CFLAGS"
356 CPPFLAGS="-I$withval/include $CPPFLAGS"
357 LDFLAGS="-L$withval/lib $LDFLAGS"
359 AC_CHECK_LIB(gnutls, gnutls_global_init)
360 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
361 AC_MSG_ERROR([Can't enable gnutls])
368 if test "$x_ssl_gnutls" = "yes"; then
369 if test "$x_ssl_openssl" = "yes";then
370 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
374 if test "$x_ssl_openssl" = "yes"; then
381 AC_ARG_WITH(tcp-wrappers,
382 [ --with-tcp-wrappers enable TCP wrappers support],
383 [ if test "$withval" != "no"; then
384 if test "$withval" != "yes"; then
385 CFLAGS="-I$withval/include $CFLAGS"
386 CPPFLAGS="-I$withval/include $CPPFLAGS"
387 LDFLAGS="-L$withval/lib $LDFLAGS"
389 AC_MSG_CHECKING(for hosts_access)
393 int allow_severity = 0;
394 int deny_severity = 0;
396 tcpd_warn("link test");
399 AC_DEFINE(TCPWRAP, 1)
403 AC_MSG_ERROR([Can't enable TCP wrappers!])
409 # include support for "zeroconf"?
412 AC_ARG_WITH(zeroconf,
413 [ --with-zeroconf enable support for "Zeroconf"],
414 [ if test "$withval" != "no"; then
415 if test "$withval" != "yes"; then
416 CFLAGS="-I$withval/include $CFLAGS"
417 CPPFLAGS="-I$withval/include $CPPFLAGS"
418 LDFLAGS="-L$withval/lib $LDFLAGS"
420 AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
422 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
423 AC_CHECK_LIB(howl, sw_discovery_init)
424 AC_CHECK_FUNCS(sw_discovery_init, \
425 x_zeroconf_on=howl, \
426 AC_MSG_ERROR([Can't enable Zeroconf!]))
431 if test "$x_zeroconf_on" = "osx"; then
432 AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
433 mach/port.h],,AC_MSG_ERROR([required C header missing!]))
434 AC_DEFINE(ZEROCONF, 1)
436 if test "$x_zeroconf_on" = "howl"; then
437 for dir in /usr/local/include /usr/local/include/howl* \
438 /usr/include /usr/include/howl* \
439 /usr/local/include/avahi* /usr/include/avahi*; do
440 test -d "$dir" || continue
441 AC_MSG_CHECKING([for Howl headers in $dir])
442 if test -f "$dir/rendezvous/rendezvous.h"; then
443 if test "$dir" != "/usr/local/include" -a \
444 "$dir" != "/usr/include"; then
445 CFLAGS="-I$dir $CFLAGS"
446 CPPFLAGS="-I$dir $CPPFLAGS"
454 AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
455 AC_MSG_ERROR([required C header missing!]))
456 AC_DEFINE(ZEROCONF, 1)
459 # do IDENT requests using libident?
463 [ --with-ident enable "IDENT" ("AUTH") protocol support],
464 [ if test "$withval" != "no"; then
465 if test "$withval" != "yes"; then
466 CFLAGS="-I$withval/include $CFLAGS"
467 CPPFLAGS="-I$withval/include $CPPFLAGS"
468 LDFLAGS="-L$withval/lib $LDFLAGS"
470 AC_CHECK_LIB(ident, ident_id)
471 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
472 AC_MSG_ERROR([Can't enable IDENT support!])
477 if test "$x_identauth_on" = "yes"; then
478 AC_DEFINE(IDENTAUTH, 1)
479 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
482 # compile in IRC+ protocol support?
485 AC_ARG_ENABLE(ircplus,
486 [ --disable-ircplus disable IRC+ protocol],
487 if test "$enableval" = "no"; then x_ircplus_on=no; fi
489 if test "$x_ircplus_on" = "yes"; then
490 AC_DEFINE(IRCPLUS, 1)
493 # enable support for IPv6?
496 [ --enable-ipv6 enable IPv6 protocol support],
497 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
499 if test "$x_ipv6_on" = "yes"; then
500 # getaddrinfo() and getnameinfo() are optional when not compiling
501 # with IPv6 support, but are required for IPv6 to work!
503 getaddrinfo getnameinfo \
504 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
505 AC_DEFINE(WANT_IPV6, 1)
508 # compile in IRC "sniffer"?
510 x_sniffer_on=no; x_debug_on=no
511 AC_ARG_ENABLE(sniffer,
512 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
513 if test "$enableval" = "yes"; then
514 AC_DEFINE(SNIFFER, 1)
515 x_sniffer_on=yes; x_debug_on=yes
519 # enable additional debugging code?
522 [ --enable-debug show additional debug output],
523 if test "$enableval" = "yes"; then x_debug_on=yes; fi
525 if test "$x_debug_on" = "yes"; then
527 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
528 AC_CHECK_FUNCS(mtrace)
531 # enable "strict RFC rules"?
534 AC_ARG_ENABLE(strict-rfc,
535 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
536 if test "$enableval" = "yes"; then
537 AC_DEFINE(STRICT_RFC, 1)
544 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
545 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
546 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
548 # Add additional CFLAGS, eventually specified on the command line, but after
549 # running this configure script. Useful for "-Werror" for example.
550 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
552 # -- Generate files --
559 src/portab/Makefile \
560 src/ipaddr/Makefile \
562 src/ngircd/Makefile \
563 src/testsuite/Makefile \
566 contrib/Debian/Makefile \
567 contrib/MacOSX/Makefile \
568 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
569 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
572 type dpkg >/dev/null 2>&1
573 if test $? -eq 0; then
574 # Generate debian/ link if the dpkg command exists
575 # (read: if we are running on a debian compatible system)
576 echo "creating Debian-specific links ..."
577 test -f debian/rules || ln -s contrib/Debian debian
583 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
586 # Someone please show me a better way :) [borrowed by OpenSSH]
587 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
588 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
589 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
590 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
591 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
593 echo " Target: ${target}"
594 test "$target" != "$host" && echo " Host: ${host}"
595 echo " Compiler: ${CC}"
596 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
597 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
598 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
599 test -n "$LIBS" && echo " Libraries: ${LIBS}"
601 echo " 'ngircd' binary: $S"
602 echo " Configuration file: $C"
603 echo " Manual pages: $M"
604 echo " Documentation: $D"
607 echo $ECHO_N " Syslog support: $ECHO_C"
608 test "$x_syslog_on" = "yes" \
609 && echo $ECHO_N "yes $ECHO_C" \
610 || echo $ECHO_N "no $ECHO_C"
611 echo $ECHO_N " Enable debug code: $ECHO_C"
612 test "$x_debug_on" = "yes" \
616 echo $ECHO_N " zlib compression: $ECHO_C"
617 test "$x_zlib_on" = "yes" \
618 && echo $ECHO_N "yes $ECHO_C" \
619 || echo $ECHO_N "no $ECHO_C"
620 echo $ECHO_N " IRC sniffer: $ECHO_C"
621 test "$x_sniffer_on" = "yes" \
625 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
626 test "$x_tcpwrap_on" = "yes" \
627 && echo $ECHO_N "yes $ECHO_C" \
628 || echo $ECHO_N "no $ECHO_C"
629 echo $ECHO_N " Strict RFC mode: $ECHO_C"
630 test "$x_strict_rfc_on" = "yes" \
634 echo $ECHO_N " Zeroconf support: $ECHO_C"
635 case "$x_zeroconf_on" in
637 echo $ECHO_N "Apple $ECHO_C"
640 echo $ECHO_N "Howl $ECHO_C"
643 echo $ECHO_N "no $ECHO_C"
646 echo $ECHO_N " IRC+ protocol: $ECHO_C"
647 test "$x_ircplus_on" = "yes" \
651 echo $ECHO_N " IDENT support: $ECHO_C"
652 test "$x_identauth_on" = "yes" \
653 && echo $ECHO_N "yes $ECHO_C" \
654 || echo $ECHO_N "no $ECHO_C"
655 echo $ECHO_N " I/O backend: $ECHO_C"
656 echo "\"$x_io_backend\""
658 echo $ECHO_N " IPv6 protocol: $ECHO_C"
659 echo $ECHO_N "$x_ipv6_on $ECHO_C"
661 echo $ECHO_N " SSL support: $ECHO_C"