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~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!]))
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>])
135 AC_CHECK_LIB(UTIL,memmove)
136 # needed on solaris. GNU libc also has a libnsl, but we do not need it.
137 AC_SEARCH_LIBS(gethostbyname,nsl)
138 AC_CHECK_LIB(socket,bind)
146 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
147 setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
149 AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction snprintf \
150 vsnprintf strdup strlcpy strlcat strtok_r)
152 # -- Configuration options --
158 [ --without-syslog disable syslog (autodetected by default)],
159 [ if test "$withval" != "no"; then
160 if test "$withval" != "yes"; then
161 CFLAGS="-I$withval/include $CFLAGS"
162 CPPFLAGS="-I$withval/include $CPPFLAGS"
163 LDFLAGS="-L$withval/lib $LDFLAGS"
165 AC_CHECK_LIB(be, syslog)
166 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
167 AC_MSG_ERROR([Can't enable syslog!])
172 AC_CHECK_LIB(be, syslog)
173 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
176 if test "$x_syslog_on" = "yes"; then
178 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
181 # use zlib compression?
185 [ --without-zlib disable zlib compression (autodetected by default)],
186 [ if test "$withval" != "no"; then
187 if test "$withval" != "yes"; then
188 CFLAGS="-I$withval/include $CFLAGS"
189 CPPFLAGS="-I$withval/include $CPPFLAGS"
190 LDFLAGS="-L$withval/lib $LDFLAGS"
192 AC_CHECK_LIB(z, deflate)
193 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
194 AC_MSG_ERROR([Can't enable zlib!])
198 [ AC_CHECK_LIB(z, deflate)
199 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
202 if test "$x_zlib_on" = "yes"; then
204 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
207 # detect which IO API to use:
212 [ --without-select disable select IO support (autodetected by default)],
213 [ if test "$withval" != "no"; then
214 if test "$withval" != "yes"; then
215 CFLAGS="-I$withval/include $CFLAGS"
216 CPPFLAGS="-I$withval/include $CPPFLAGS"
217 LDFLAGS="-L$withval/lib $LDFLAGS"
219 AC_CHECK_FUNCS(select, x_io_select=yes,
220 AC_MSG_ERROR([Can't enable select IO support!])
225 AC_CHECK_FUNCS(select, x_io_select=yes)
230 [ --without-poll disable poll support (autodetected by default)],
231 [ if test "$withval" != "no"; then
232 if test "$withval" != "yes"; then
233 CFLAGS="-I$withval/include $CFLAGS"
234 CPPFLAGS="-I$withval/include $CPPFLAGS"
235 LDFLAGS="-L$withval/lib $LDFLAGS"
237 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
238 AC_MSG_ERROR([Can't enable poll IO support!])
243 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
248 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
249 [ if test "$withval" != "no"; then
250 if test "$withval" != "yes"; then
251 CFLAGS="-I$withval/include $CFLAGS"
252 CPPFLAGS="-I$withval/include $CPPFLAGS"
253 LDFLAGS="-L$withval/lib $LDFLAGS"
256 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
260 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
265 [ --without-epoll disable epoll IO support (autodetected by default)],
266 [ if test "$withval" != "no"; then
267 if test "$withval" != "yes"; then
268 CFLAGS="-I$withval/include $CFLAGS"
269 CPPFLAGS="-I$withval/include $CPPFLAGS"
270 LDFLAGS="-L$withval/lib $LDFLAGS"
272 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
273 AC_MSG_ERROR([Can't enable epoll IO support!])
278 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
283 [ --without-kqueue disable kqueue IO support (autodetected by default)],
284 [ if test "$withval" != "no"; then
285 if test "$withval" != "yes"; then
286 CFLAGS="-I$withval/include $CFLAGS"
287 CPPFLAGS="-I$withval/include $CPPFLAGS"
288 LDFLAGS="-L$withval/lib $LDFLAGS"
290 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
291 AC_MSG_ERROR([Can't enable kqueue IO support!])
296 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
300 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
301 # when epoll() and select() are available, we'll use both!
302 x_io_backend="epoll(), select()"
304 if test "$x_io_epoll" = "yes"; then
305 # we prefere epoll() if it is available
306 x_io_backend="epoll()"
308 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
309 # we'll use select, when available and no "better"
310 # interface has been detected ...
311 x_io_backend="select()"
316 if test "$x_io_backend" = "none"; then
317 AC_MSG_ERROR([No useabe IO API activated/found!?])
323 [ --with-openssl enable SSL support using OpenSSL],
324 [ if test "$withval" != "no"; then
325 if test "$withval" != "yes"; then
326 CFLAGS="-I$withval/include $CFLAGS"
327 CPPFLAGS="-I$withval/include $CPPFLAGS"
328 LDFLAGS="-L$withval/lib $LDFLAGS"
330 AC_CHECK_LIB(crypto, BIO_s_mem)
331 AC_CHECK_LIB(ssl, SSL_library_init)
332 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
333 AC_MSG_ERROR([Can't enable openssl])
340 [ --with-gnutls enable SSL support using gnutls],
341 [ if test "$withval" != "no"; then
342 if test "$withval" != "yes"; then
343 CFLAGS="-I$withval/include $CFLAGS"
344 CPPFLAGS="-I$withval/include $CPPFLAGS"
345 LDFLAGS="-L$withval/lib $LDFLAGS"
347 AC_CHECK_LIB(gnutls, gnutls_global_init)
348 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
349 AC_MSG_ERROR([Can't enable gnutls])
356 if test "$x_ssl_gnutls" = "yes"; then
357 if test "$x_ssl_openssl" = "yes";then
358 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
362 if test "$x_ssl_openssl" = "yes"; then
369 AC_ARG_WITH(tcp-wrappers,
370 [ --with-tcp-wrappers enable TCP wrappers support],
371 [ if test "$withval" != "no"; then
372 if test "$withval" != "yes"; then
373 CFLAGS="-I$withval/include $CFLAGS"
374 CPPFLAGS="-I$withval/include $CPPFLAGS"
375 LDFLAGS="-L$withval/lib $LDFLAGS"
377 AC_MSG_CHECKING(for hosts_access)
381 int allow_severity = 0;
382 int deny_severity = 0;
384 tcpd_warn("link test");
387 AC_DEFINE(TCPWRAP, 1)
391 AC_MSG_ERROR([Can't enable TCP wrappers!])
397 # include support for "zeroconf"?
400 AC_ARG_WITH(zeroconf,
401 [ --with-zeroconf enable support for "Zeroconf"],
402 [ if test "$withval" != "no"; then
403 if test "$withval" != "yes"; then
404 CFLAGS="-I$withval/include $CFLAGS"
405 CPPFLAGS="-I$withval/include $CPPFLAGS"
406 LDFLAGS="-L$withval/lib $LDFLAGS"
408 AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx,
410 AC_CHECK_LIB(pthread, pthread_mutexattr_init)
411 AC_CHECK_LIB(howl, sw_discovery_init)
412 AC_CHECK_FUNCS(sw_discovery_init, \
413 x_zeroconf_on=howl, \
414 AC_MSG_ERROR([Can't enable Zeroconf!]))
419 if test "$x_zeroconf_on" = "osx"; then
420 AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \
421 mach/port.h],,AC_MSG_ERROR([required C header missing!]))
422 AC_DEFINE(ZEROCONF, 1)
424 if test "$x_zeroconf_on" = "howl"; then
425 for dir in /usr/local/include /usr/local/include/howl* \
426 /usr/include /usr/include/howl* \
427 /usr/local/include/avahi* /usr/include/avahi*; do
428 test -d "$dir" || continue
429 AC_MSG_CHECKING([for Howl headers in $dir])
430 if test -f "$dir/rendezvous/rendezvous.h"; then
431 if test "$dir" != "/usr/local/include" -a \
432 "$dir" != "/usr/include"; then
433 CFLAGS="-I$dir $CFLAGS"
434 CPPFLAGS="-I$dir $CPPFLAGS"
442 AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \
443 AC_MSG_ERROR([required C header missing!]))
444 AC_DEFINE(ZEROCONF, 1)
447 # do IDENT requests using libident?
451 [ --with-ident enable "IDENT" ("AUTH") protocol support],
452 [ if test "$withval" != "no"; then
453 if test "$withval" != "yes"; then
454 CFLAGS="-I$withval/include $CFLAGS"
455 CPPFLAGS="-I$withval/include $CPPFLAGS"
456 LDFLAGS="-L$withval/lib $LDFLAGS"
458 AC_CHECK_LIB(ident, ident_id)
459 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
460 AC_MSG_ERROR([Can't enable IDENT support!])
465 if test "$x_identauth_on" = "yes"; then
466 AC_DEFINE(IDENTAUTH, 1)
467 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
470 # compile in IRC+ protocol support?
473 AC_ARG_ENABLE(ircplus,
474 [ --disable-ircplus disable IRC+ protocol],
475 if test "$enableval" = "no"; then x_ircplus_on=no; fi
477 if test "$x_ircplus_on" = "yes"; then
478 AC_DEFINE(IRCPLUS, 1)
481 # enable support for IPv6?
484 [ --enable-ipv6 enable IPv6 protocol support],
485 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
487 if test "$x_ipv6_on" = "yes"; then
488 # getaddrinfo() and getnameinfo() are optional when not compiling
489 # with IPv6 support, but are required for IPv6 to work!
491 getaddrinfo getnameinfo \
492 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
493 AC_DEFINE(WANT_IPV6, 1)
496 # compile in IRC "sniffer"?
498 x_sniffer_on=no; x_debug_on=no
499 AC_ARG_ENABLE(sniffer,
500 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
501 if test "$enableval" = "yes"; then
502 AC_DEFINE(SNIFFER, 1)
503 x_sniffer_on=yes; x_debug_on=yes
507 # enable additional debugging code?
510 [ --enable-debug show additional debug output],
511 if test "$enableval" = "yes"; then x_debug_on=yes; fi
513 if test "$x_debug_on" = "yes"; then
515 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
516 AC_CHECK_FUNCS(mtrace)
519 # enable "strict RFC rules"?
522 AC_ARG_ENABLE(strict-rfc,
523 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
524 if test "$enableval" = "yes"; then
525 AC_DEFINE(STRICT_RFC, 1)
532 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
533 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
534 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
536 # Add additional CFLAGS, eventually specified on the command line, but after
537 # running this configure script. Useful for "-Werror" for example.
538 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
540 # -- Generate files --
547 src/portab/Makefile \
548 src/ipaddr/Makefile \
550 src/ngircd/Makefile \
551 src/testsuite/Makefile \
554 contrib/Debian/Makefile \
555 contrib/MacOSX/Makefile \
556 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
557 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
560 type dpkg >/dev/null 2>&1
561 if test $? -eq 0; then
562 # Generate debian/ link if the dpkg command exists
563 # (read: if we are running on a debian compatible system)
564 echo "creating Debian-specific links ..."
565 test -f debian/rules || ln -s contrib/Debian debian
571 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
574 # Someone please show me a better way :) [borrowed by OpenSSH]
575 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
576 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
577 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
578 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
579 D=`eval echo ${datadir}/doc/${PACKAGE}` ; D=`eval echo ${D}`
581 echo " Target: ${target}"
582 test "$target" != "$host" && echo " Host: ${host}"
583 echo " Compiler: ${CC}"
584 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
585 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
586 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
587 test -n "$LIBS" && echo " Libraries: ${LIBS}"
589 echo " 'ngircd' binary: $S"
590 echo " Configuration file: $C"
591 echo " Manual pages: $M"
592 echo " Documentation: $D"
595 echo $ECHO_N " Syslog support: $ECHO_C"
596 test "$x_syslog_on" = "yes" \
597 && echo $ECHO_N "yes $ECHO_C" \
598 || echo $ECHO_N "no $ECHO_C"
599 echo $ECHO_N " Enable debug code: $ECHO_C"
600 test "$x_debug_on" = "yes" \
604 echo $ECHO_N " zlib compression: $ECHO_C"
605 test "$x_zlib_on" = "yes" \
606 && echo $ECHO_N "yes $ECHO_C" \
607 || echo $ECHO_N "no $ECHO_C"
608 echo $ECHO_N " IRC sniffer: $ECHO_C"
609 test "$x_sniffer_on" = "yes" \
613 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
614 test "$x_tcpwrap_on" = "yes" \
615 && echo $ECHO_N "yes $ECHO_C" \
616 || echo $ECHO_N "no $ECHO_C"
617 echo $ECHO_N " Strict RFC mode: $ECHO_C"
618 test "$x_strict_rfc_on" = "yes" \
622 echo $ECHO_N " Zeroconf support: $ECHO_C"
623 case "$x_zeroconf_on" in
625 echo $ECHO_N "Apple $ECHO_C"
628 echo $ECHO_N "Howl $ECHO_C"
631 echo $ECHO_N "no $ECHO_C"
634 echo $ECHO_N " IRC+ protocol: $ECHO_C"
635 test "$x_ircplus_on" = "yes" \
639 echo $ECHO_N " IDENT support: $ECHO_C"
640 test "$x_identauth_on" = "yes" \
641 && echo $ECHO_N "yes $ECHO_C" \
642 || echo $ECHO_N "no $ECHO_C"
643 echo $ECHO_N " I/O backend: $ECHO_C"
644 echo "\"$x_io_backend\""
646 echo $ECHO_N " IPv6 protocol: $ECHO_C"
647 echo $ECHO_N "$x_ipv6_on $ECHO_C"
649 echo $ECHO_N " SSL support: $ECHO_C"