2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2010 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 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],,AC_MSG_ERROR([required function missing!]))
165 AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton sigaction sigprocmask snprintf \
166 vsnprintf strdup strlcpy strlcat strtok_r)
168 # -- Configuration options --
174 [ --without-syslog disable syslog (autodetected by default)],
175 [ if test "$withval" != "no"; then
176 if test "$withval" != "yes"; then
177 CFLAGS="-I$withval/include $CFLAGS"
178 CPPFLAGS="-I$withval/include $CPPFLAGS"
179 LDFLAGS="-L$withval/lib $LDFLAGS"
181 AC_CHECK_LIB(be, syslog)
182 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
183 AC_MSG_ERROR([Can't enable syslog!])
188 AC_CHECK_LIB(be, syslog)
189 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
192 if test "$x_syslog_on" = "yes"; then
194 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
197 # use zlib compression?
201 [ --without-zlib disable zlib compression (autodetected by default)],
202 [ if test "$withval" != "no"; then
203 if test "$withval" != "yes"; then
204 CFLAGS="-I$withval/include $CFLAGS"
205 CPPFLAGS="-I$withval/include $CPPFLAGS"
206 LDFLAGS="-L$withval/lib $LDFLAGS"
208 AC_CHECK_LIB(z, deflate)
209 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
210 AC_MSG_ERROR([Can't enable zlib!])
214 [ AC_CHECK_LIB(z, deflate)
215 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
218 if test "$x_zlib_on" = "yes"; then
220 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
223 # detect which IO API to use:
228 [ --without-select disable select IO 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(select, x_io_select=yes,
236 AC_MSG_ERROR([Can't enable select IO support!])
241 AC_CHECK_FUNCS(select, x_io_select=yes)
246 [ --without-poll disable poll 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"
253 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\),
254 AC_MSG_ERROR([Can't enable poll IO support!])
259 AC_CHECK_FUNCS(poll, x_io_backend=poll\(\))
264 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
265 [ if test "$withval" != "no"; then
266 if test "$withval" != "yes"; then
267 CFLAGS="-I$withval/include $CFLAGS"
268 CPPFLAGS="-I$withval/include $CPPFLAGS"
269 LDFLAGS="-L$withval/lib $LDFLAGS"
272 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
276 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
281 [ --without-epoll disable epoll 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(epoll_create, x_io_epoll=yes,
289 AC_MSG_ERROR([Can't enable epoll IO support!])
294 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
299 [ --without-kqueue disable kqueue IO support (autodetected by default)],
300 [ if test "$withval" != "no"; then
301 if test "$withval" != "yes"; then
302 CFLAGS="-I$withval/include $CFLAGS"
303 CPPFLAGS="-I$withval/include $CPPFLAGS"
304 LDFLAGS="-L$withval/lib $LDFLAGS"
306 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
307 AC_MSG_ERROR([Can't enable kqueue IO support!])
312 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
316 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
317 # when epoll() and select() are available, we'll use both!
318 x_io_backend="epoll(), select()"
320 if test "$x_io_epoll" = "yes"; then
321 # we prefere epoll() if it is available
322 x_io_backend="epoll()"
324 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
325 # we'll use select, when available and no "better"
326 # interface has been detected ...
327 x_io_backend="select()"
332 if test "$x_io_backend" = "none"; then
333 AC_MSG_ERROR([No useabe IO API activated/found!?])
339 [ --with-openssl enable SSL support using OpenSSL],
340 [ if test "$withval" != "no"; then
341 if test "$withval" != "yes"; then
342 CFLAGS="-I$withval/include $CFLAGS"
343 CPPFLAGS="-I$withval/include $CPPFLAGS"
344 LDFLAGS="-L$withval/lib $LDFLAGS"
346 AC_CHECK_LIB(crypto, BIO_s_mem)
347 AC_CHECK_LIB(ssl, SSL_library_init)
348 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
349 AC_MSG_ERROR([Can't enable openssl])
356 [ --with-gnutls enable SSL support using gnutls],
357 [ if test "$withval" != "no"; then
358 if test "$withval" != "yes"; then
359 CFLAGS="-I$withval/include $CFLAGS"
360 CPPFLAGS="-I$withval/include $CPPFLAGS"
361 LDFLAGS="-L$withval/lib $LDFLAGS"
363 AC_CHECK_LIB(gnutls, gnutls_global_init)
364 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
365 AC_MSG_ERROR([Can't enable gnutls])
372 if test "$x_ssl_gnutls" = "yes"; then
373 if test "$x_ssl_openssl" = "yes";then
374 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
378 if test "$x_ssl_openssl" = "yes"; then
385 AC_ARG_WITH(tcp-wrappers,
386 [ --with-tcp-wrappers enable TCP wrappers support],
387 [ if test "$withval" != "no"; then
388 if test "$withval" != "yes"; then
389 CFLAGS="-I$withval/include $CFLAGS"
390 CPPFLAGS="-I$withval/include $CPPFLAGS"
391 LDFLAGS="-L$withval/lib $LDFLAGS"
393 AC_MSG_CHECKING(for hosts_access)
397 int allow_severity = 0;
398 int deny_severity = 0;
400 tcpd_warn("link test");
403 AC_DEFINE(TCPWRAP, 1)
407 AC_MSG_ERROR([Can't enable TCP wrappers!])
413 # do IDENT requests using libident?
417 [ --with-ident enable "IDENT" ("AUTH") protocol support],
418 [ if test "$withval" != "no"; then
419 if test "$withval" != "yes"; then
420 CFLAGS="-I$withval/include $CFLAGS"
421 CPPFLAGS="-I$withval/include $CPPFLAGS"
422 LDFLAGS="-L$withval/lib $LDFLAGS"
424 AC_CHECK_LIB(ident, ident_id)
425 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
426 AC_MSG_ERROR([Can't enable IDENT support!])
431 if test "$x_identauth_on" = "yes"; then
432 AC_DEFINE(IDENTAUTH, 1)
433 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
436 # compile in PAM support?
440 [ --with-pam enable user authentication using PAM],
441 [ if test "$withval" != "no"; then
442 if test "$withval" != "yes"; then
443 CFLAGS="-I$withval/include $CFLAGS"
444 CPPFLAGS="-I$withval/include $CPPFLAGS"
445 LDFLAGS="-L$withval/lib $LDFLAGS"
447 AC_CHECK_LIB(pam, pam_authenticate)
448 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
449 AC_MSG_ERROR([Can't enable PAM support!])
454 if test "$x_pam_on" = "yes"; then
456 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
457 if test "$pam_ok" != "yes"; then
458 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
459 AC_MSG_ERROR([required C header missing!]))
463 # compile in IRC+ protocol support?
466 AC_ARG_ENABLE(ircplus,
467 [ --disable-ircplus disable IRC+ protocol],
468 if test "$enableval" = "no"; then x_ircplus_on=no; fi
470 if test "$x_ircplus_on" = "yes"; then
471 AC_DEFINE(IRCPLUS, 1)
474 # enable support for IPv6?
477 [ --enable-ipv6 enable IPv6 protocol support],
478 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
480 if test "$x_ipv6_on" = "yes"; then
481 # getaddrinfo() and getnameinfo() are optional when not compiling
482 # with IPv6 support, but are required for IPv6 to work!
484 getaddrinfo getnameinfo \
485 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
486 AC_DEFINE(WANT_IPV6, 1)
489 # compile in IRC "sniffer"?
491 x_sniffer_on=no; x_debug_on=no
492 AC_ARG_ENABLE(sniffer,
493 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
494 if test "$enableval" = "yes"; then
495 AC_DEFINE(SNIFFER, 1)
496 x_sniffer_on=yes; x_debug_on=yes
500 # enable additional debugging code?
503 [ --enable-debug show additional debug output],
504 if test "$enableval" = "yes"; then x_debug_on=yes; fi
506 if test "$x_debug_on" = "yes"; then
508 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
509 AC_CHECK_FUNCS(mtrace)
512 # enable "strict RFC rules"?
515 AC_ARG_ENABLE(strict-rfc,
516 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
517 if test "$enableval" = "yes"; then
518 AC_DEFINE(STRICT_RFC, 1)
525 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
526 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
527 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
529 # Add additional CFLAGS, eventually specified on the command line, but after
530 # running this configure script. Useful for "-Werror" for example.
531 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
533 # -- Generate files --
540 src/portab/Makefile \
541 src/ipaddr/Makefile \
543 src/ngircd/Makefile \
544 src/testsuite/Makefile \
547 contrib/Debian/Makefile \
548 contrib/MacOSX/Makefile \
549 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
550 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
553 type dpkg >/dev/null 2>&1
554 if test $? -eq 0; then
555 # Generate debian/ link if the dpkg command exists
556 # (read: if we are running on a debian compatible system)
557 echo "creating Debian-specific links ..."
558 test -f debian/rules || ln -s contrib/Debian debian
564 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
567 # Someone please show me a better way :) [borrowed by OpenSSH]
568 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
569 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
570 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
571 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
572 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
574 echo " Target: ${target}"
575 test "$target" != "$host" && echo " Host: ${host}"
576 echo " Compiler: ${CC}"
577 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
578 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
579 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
580 test -n "$LIBS" && echo " Libraries: ${LIBS}"
582 echo " 'ngircd' binary: $S"
583 echo " Configuration file: $C"
584 echo " Manual pages: $M"
585 echo " Documentation: $D"
588 echo $ECHO_N " Syslog support: $ECHO_C"
589 test "$x_syslog_on" = "yes" \
590 && echo $ECHO_N "yes $ECHO_C" \
591 || echo $ECHO_N "no $ECHO_C"
592 echo $ECHO_N " Enable debug code: $ECHO_C"
593 test "$x_debug_on" = "yes" \
597 echo $ECHO_N " zlib compression: $ECHO_C"
598 test "$x_zlib_on" = "yes" \
599 && echo $ECHO_N "yes $ECHO_C" \
600 || echo $ECHO_N "no $ECHO_C"
601 echo $ECHO_N " IRC sniffer: $ECHO_C"
602 test "$x_sniffer_on" = "yes" \
606 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
607 test "$x_tcpwrap_on" = "yes" \
608 && echo $ECHO_N "yes $ECHO_C" \
609 || echo $ECHO_N "no $ECHO_C"
610 echo $ECHO_N " Strict RFC mode: $ECHO_C"
611 test "$x_strict_rfc_on" = "yes" \
615 echo $ECHO_N " IDENT support: $ECHO_C"
616 test "$x_identauth_on" = "yes" \
617 && echo $ECHO_N "yes $ECHO_C" \
618 || echo $ECHO_N "no $ECHO_C"
619 echo $ECHO_N " IRC+ protocol: $ECHO_C"
620 test "$x_ircplus_on" = "yes" \
624 echo $ECHO_N " IPv6 protocol: $ECHO_C"
625 test "$x_ipv6_on" = "yes" \
626 && echo $ECHO_N "yes $ECHO_C" \
627 || echo $ECHO_N "no $ECHO_C"
628 echo $ECHO_N " I/O backend: $ECHO_C"
629 echo "\"$x_io_backend\""
631 echo $ECHO_N " PAM support: $ECHO_C"
632 test "$x_pam_on" = "yes" \
633 && echo $ECHO_N "yes $ECHO_C" \
634 || echo $ECHO_N "no $ECHO_C"
635 echo $ECHO_N " SSL support: $ECHO_C"