2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors
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 define(VERSION_ID,esyscmd(git describe|sed -e 's/rel-//g'|sed -e 's/-/~/'|tr -d \\n))
14 # -- Initialisation --
17 AC_INIT(ngircd, VERSION_ID)
18 AC_CONFIG_SRCDIR(src/ngircd/ngircd.c)
21 AM_CONFIG_HEADER(src/config.h)
23 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
25 # -- Templates for config.h --
27 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
28 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
29 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
30 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
31 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
32 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
33 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
34 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
35 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
36 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
37 AH_TEMPLATE([PAM], [Define if PAM should be used])
38 AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
40 AH_TEMPLATE([TARGET_OS], [Target operating system name])
41 AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
42 AH_TEMPLATE([TARGET_CPU], [Target CPU name])
50 # -- Helper programs --
58 # -- Compiler Features --
64 # -- Hard coded system and compiler dependencies/features/options ... --
66 AC_DEFUN([GCC_STACK_PROTECT_CC],[
68 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
69 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
70 ssp_old_cflags="$CFLAGS"
71 CFLAGS="$CFLAGS -fstack-protector-all"
72 AC_TRY_LINK(,,, ssp_cc=no)
74 CFLAGS="$ssp_old_cflags"
75 if test "X$ssp_cc" = "Xyes"; then
76 CFLAGS="$CFLAGS -fstack-protector"
77 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
81 if test "$GCC" = "yes"; then
82 # We are using the GNU C compiler. Good!
83 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
90 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
91 # (tested with HP/UX 11.11)
92 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
96 # Add additional CFLAGS, eventually specified on the command line:
97 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
99 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
108 ctype.h errno.h fcntl.h netdb.h netinet/in.h netinet/in_systm.h \
109 stdlib.h string.h strings.h sys/socket.h sys/time.h unistd.h \
110 ],,AC_MSG_ERROR([required C header missing!]))
113 arpa/inet.h ctype.h malloc.h netinet/ip.h stdbool.h stddef.h varargs.h \
115 #ifdef HAVE_SYS_TYPES_H
116 #include <sys/types.h>
118 #ifdef HAVE_SYS_SOCKET_H
119 #include <sys/socket.h>
121 #ifdef HAVE_NETINET_IN_H
122 #include <netinet/in.h>
129 AC_MSG_CHECKING(whether socklen_t exists)
131 #include <sys/types.h>
132 #include <sys/socket.h>
135 a = 2; b = 4; a += b;
137 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
145 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
146 [#include <arpa/inet.h>])
151 AC_CHECK_LIB(UTIL,memmove)
152 # needed on solaris. GNU libc also has a libnsl, but we do not need it.
153 AC_SEARCH_LIBS(gethostbyname,nsl)
154 AC_CHECK_LIB(socket,bind)
162 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
163 setsid setsockopt socket strcasecmp waitpid],,
164 AC_MSG_ERROR([required function missing!]))
167 gai_strerror getaddrinfo getnameinfo inet_aton sigaction \
168 sigprocmask snprintf vsnprintf strdup strlcpy strlcat strtok_r])
170 # -- Configuration options --
176 [ --without-syslog disable syslog (autodetected by default)],
177 [ if test "$withval" != "no"; then
178 if test "$withval" != "yes"; then
179 CFLAGS="-I$withval/include $CFLAGS"
180 CPPFLAGS="-I$withval/include $CPPFLAGS"
181 LDFLAGS="-L$withval/lib $LDFLAGS"
183 AC_CHECK_LIB(be, syslog)
184 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
185 AC_MSG_ERROR([Can't enable syslog!])
190 AC_CHECK_LIB(be, syslog)
191 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
194 if test "$x_syslog_on" = "yes"; then
196 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
199 # use zlib compression?
203 [ --without-zlib disable zlib compression (autodetected by default)],
204 [ if test "$withval" != "no"; then
205 if test "$withval" != "yes"; then
206 CFLAGS="-I$withval/include $CFLAGS"
207 CPPFLAGS="-I$withval/include $CPPFLAGS"
208 LDFLAGS="-L$withval/lib $LDFLAGS"
210 AC_CHECK_LIB(z, deflate)
211 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
212 AC_MSG_ERROR([Can't enable zlib!])
216 [ AC_CHECK_LIB(z, deflate)
217 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
220 if test "$x_zlib_on" = "yes"; then
222 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
225 # detect which IO API to use:
230 [ --without-select disable select IO 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(select, x_io_select=yes,
238 AC_MSG_ERROR([Can't enable select IO support!])
243 AC_CHECK_FUNCS(select, x_io_select=yes)
248 [ --without-poll disable poll 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"
255 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
256 AC_MSG_ERROR([Can't enable poll IO support!])
261 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
266 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
267 [ if test "$withval" != "no"; then
268 if test "$withval" != "yes"; then
269 CFLAGS="-I$withval/include $CFLAGS"
270 CPPFLAGS="-I$withval/include $CPPFLAGS"
271 LDFLAGS="-L$withval/lib $LDFLAGS"
274 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
278 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
283 [ --without-epoll disable epoll 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(epoll_create, x_io_epoll=yes,
291 AC_MSG_ERROR([Can't enable epoll IO support!])
296 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
301 [ --without-kqueue disable kqueue IO support (autodetected by default)],
302 [ if test "$withval" != "no"; then
303 if test "$withval" != "yes"; then
304 CFLAGS="-I$withval/include $CFLAGS"
305 CPPFLAGS="-I$withval/include $CPPFLAGS"
306 LDFLAGS="-L$withval/lib $LDFLAGS"
308 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
309 AC_MSG_ERROR([Can't enable kqueue IO support!])
314 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
318 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
319 # when epoll() and select() are available, we'll use both!
320 x_io_backend="epoll(), select()"
322 if test "$x_io_epoll" = "yes"; then
323 # we prefere epoll() if it is available
324 x_io_backend="epoll()"
326 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
327 # we'll use select, when available and no "better"
328 # interface has been detected ...
329 x_io_backend="select()"
334 if test "$x_io_backend" = "none"; then
335 AC_MSG_ERROR([No useabe IO API activated/found!?])
341 [ --with-openssl enable SSL support using OpenSSL],
342 [ if test "$withval" != "no"; then
343 if test "$withval" != "yes"; then
344 CFLAGS="-I$withval/include $CFLAGS"
345 CPPFLAGS="-I$withval/include $CPPFLAGS"
346 LDFLAGS="-L$withval/lib $LDFLAGS"
348 AC_CHECK_LIB(crypto, BIO_s_mem)
349 AC_CHECK_LIB(ssl, SSL_library_init)
350 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
351 AC_MSG_ERROR([Can't enable openssl])
358 [ --with-gnutls enable SSL support using gnutls],
359 [ if test "$withval" != "no"; then
360 if test "$withval" != "yes"; then
361 CFLAGS="-I$withval/include $CFLAGS"
362 CPPFLAGS="-I$withval/include $CPPFLAGS"
363 LDFLAGS="-L$withval/lib $LDFLAGS"
365 AC_CHECK_LIB(gnutls, gnutls_global_init)
366 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
367 AC_MSG_ERROR([Can't enable gnutls])
374 if test "$x_ssl_gnutls" = "yes"; then
375 if test "$x_ssl_openssl" = "yes";then
376 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
380 if test "$x_ssl_openssl" = "yes"; then
387 AC_ARG_WITH(tcp-wrappers,
388 [ --with-tcp-wrappers enable TCP wrappers support],
389 [ if test "$withval" != "no"; then
390 if test "$withval" != "yes"; then
391 CFLAGS="-I$withval/include $CFLAGS"
392 CPPFLAGS="-I$withval/include $CPPFLAGS"
393 LDFLAGS="-L$withval/lib $LDFLAGS"
395 AC_MSG_CHECKING(for hosts_access)
399 int allow_severity = 0;
400 int deny_severity = 0;
402 tcpd_warn("link test");
405 AC_DEFINE(TCPWRAP, 1)
409 AC_MSG_ERROR([Can't enable TCP wrappers!])
415 # do IDENT requests using libident?
419 [ --with-ident enable "IDENT" ("AUTH") protocol support],
420 [ if test "$withval" != "no"; then
421 if test "$withval" != "yes"; then
422 CFLAGS="-I$withval/include $CFLAGS"
423 CPPFLAGS="-I$withval/include $CPPFLAGS"
424 LDFLAGS="-L$withval/lib $LDFLAGS"
426 AC_CHECK_LIB(ident, ident_id)
427 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
428 AC_MSG_ERROR([Can't enable IDENT support!])
433 if test "$x_identauth_on" = "yes"; then
434 AC_DEFINE(IDENTAUTH, 1)
435 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
438 # compile in PAM support?
442 [ --with-pam enable user authentication using PAM],
443 [ if test "$withval" != "no"; then
444 if test "$withval" != "yes"; then
445 CFLAGS="-I$withval/include $CFLAGS"
446 CPPFLAGS="-I$withval/include $CPPFLAGS"
447 LDFLAGS="-L$withval/lib $LDFLAGS"
449 AC_CHECK_LIB(pam, pam_authenticate)
450 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
451 AC_MSG_ERROR([Can't enable PAM support!])
456 if test "$x_pam_on" = "yes"; then
458 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
459 if test "$pam_ok" != "yes"; then
460 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
461 AC_MSG_ERROR([required C header missing!]))
465 # compile in IRC+ protocol support?
468 AC_ARG_ENABLE(ircplus,
469 [ --disable-ircplus disable IRC+ protocol],
470 if test "$enableval" = "no"; then x_ircplus_on=no; fi
472 if test "$x_ircplus_on" = "yes"; then
473 AC_DEFINE(IRCPLUS, 1)
476 # enable support for IPv6?
479 [ --enable-ipv6 enable IPv6 protocol support],
480 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
482 if test "$x_ipv6_on" = "yes"; then
483 # getaddrinfo() and getnameinfo() are optional when not compiling
484 # with IPv6 support, but are required for IPv6 to work!
486 getaddrinfo getnameinfo \
487 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
488 AC_DEFINE(WANT_IPV6, 1)
491 # compile in IRC "sniffer"?
493 x_sniffer_on=no; x_debug_on=no
494 AC_ARG_ENABLE(sniffer,
495 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
496 if test "$enableval" = "yes"; then
497 AC_DEFINE(SNIFFER, 1)
498 x_sniffer_on=yes; x_debug_on=yes
502 # enable additional debugging code?
505 [ --enable-debug show additional debug output],
506 if test "$enableval" = "yes"; then x_debug_on=yes; fi
508 if test "$x_debug_on" = "yes"; then
510 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
511 AC_CHECK_FUNCS(mtrace)
514 # enable "strict RFC rules"?
517 AC_ARG_ENABLE(strict-rfc,
518 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
519 if test "$enableval" = "yes"; then
520 AC_DEFINE(STRICT_RFC, 1)
527 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
528 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
529 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
531 # Add additional CFLAGS, eventually specified on the command line, but after
532 # running this configure script. Useful for "-Werror" for example.
533 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
535 # -- Generate files --
542 src/portab/Makefile \
543 src/ipaddr/Makefile \
545 src/ngircd/Makefile \
546 src/testsuite/Makefile \
549 contrib/Anope/Makefile \
550 contrib/Debian/Makefile \
551 contrib/MacOSX/Makefile \
552 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
553 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
556 type dpkg >/dev/null 2>&1
557 if test $? -eq 0; then
558 # Generate debian/ link if the dpkg command exists
559 # (read: if we are running on a debian compatible system)
560 echo "creating Debian-specific links ..."
561 test -f debian/rules || ln -s contrib/Debian debian
567 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
570 # Someone please show me a better way :) [borrowed by OpenSSH]
571 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
572 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
573 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
574 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
575 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
577 echo " Target: ${target}"
578 test "$target" != "$host" && echo " Host: ${host}"
579 echo " Compiler: ${CC}"
580 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
581 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
582 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
583 test -n "$LIBS" && echo " Libraries: ${LIBS}"
585 echo " 'ngircd' binary: $S"
586 echo " Configuration file: $C"
587 echo " Manual pages: $M"
588 echo " Documentation: $D"
591 echo $ECHO_N " Syslog support: $ECHO_C"
592 test "$x_syslog_on" = "yes" \
593 && echo $ECHO_N "yes $ECHO_C" \
594 || echo $ECHO_N "no $ECHO_C"
595 echo $ECHO_N " Enable debug code: $ECHO_C"
596 test "$x_debug_on" = "yes" \
600 echo $ECHO_N " zlib compression: $ECHO_C"
601 test "$x_zlib_on" = "yes" \
602 && echo $ECHO_N "yes $ECHO_C" \
603 || echo $ECHO_N "no $ECHO_C"
604 echo $ECHO_N " IRC sniffer: $ECHO_C"
605 test "$x_sniffer_on" = "yes" \
609 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
610 test "$x_tcpwrap_on" = "yes" \
611 && echo $ECHO_N "yes $ECHO_C" \
612 || echo $ECHO_N "no $ECHO_C"
613 echo $ECHO_N " Strict RFC mode: $ECHO_C"
614 test "$x_strict_rfc_on" = "yes" \
618 echo $ECHO_N " IDENT support: $ECHO_C"
619 test "$x_identauth_on" = "yes" \
620 && echo $ECHO_N "yes $ECHO_C" \
621 || echo $ECHO_N "no $ECHO_C"
622 echo $ECHO_N " IRC+ protocol: $ECHO_C"
623 test "$x_ircplus_on" = "yes" \
627 echo $ECHO_N " IPv6 protocol: $ECHO_C"
628 test "$x_ipv6_on" = "yes" \
629 && echo $ECHO_N "yes $ECHO_C" \
630 || echo $ECHO_N "no $ECHO_C"
631 echo $ECHO_N " I/O backend: $ECHO_C"
632 echo "\"$x_io_backend\""
634 echo $ECHO_N " PAM support: $ECHO_C"
635 test "$x_pam_on" = "yes" \
636 && echo $ECHO_N "yes $ECHO_C" \
637 || echo $ECHO_N "no $ECHO_C"
638 echo $ECHO_N " SSL support: $ECHO_C"