2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2012 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 [ngircd-ml@ngircd.barton.de], [ngircd], [http://ngircd.barton.de/])
20 AC_CONFIG_SRCDIR([src/ngircd/ngircd.c])
21 AC_CONFIG_HEADER([src/config.h])
24 AM_INIT_AUTOMAKE([1.11])
26 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
28 # -- Templates for config.h --
30 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
31 AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
32 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
33 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
34 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
35 AH_TEMPLATE([PAM], [Define if PAM should be used])
36 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
37 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
38 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
39 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
40 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
41 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
43 AH_TEMPLATE([TARGET_OS], [Target operating system name])
44 AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
45 AH_TEMPLATE([TARGET_CPU], [Target CPU name])
53 # -- Helper programs --
61 # -- Compiler Features --
67 # -- Hard coded system and compiler dependencies/features/options ... --
69 AC_DEFUN([GCC_STACK_PROTECT_CC],[
71 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
72 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
73 ssp_old_cflags="$CFLAGS"
74 CFLAGS="$CFLAGS -fstack-protector-all"
75 AC_TRY_LINK(,,, ssp_cc=no)
77 CFLAGS="$ssp_old_cflags"
78 if test "X$ssp_cc" = "Xyes"; then
79 CFLAGS="$CFLAGS -fstack-protector"
80 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
84 if test "$GCC" = "yes"; then
85 # We are using the GNU C compiler. Good!
86 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
93 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
94 # (tested with HP/UX 11.11)
95 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
99 # Add additional CFLAGS, eventually specified on the command line:
100 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
102 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
111 ctype.h errno.h fcntl.h netdb.h netinet/in.h netinet/in_systm.h \
112 stdlib.h string.h strings.h sys/socket.h sys/time.h unistd.h \
113 ],,AC_MSG_ERROR([required C header missing!]))
116 arpa/inet.h ctype.h malloc.h netinet/ip.h stdbool.h stddef.h varargs.h \
118 #ifdef HAVE_SYS_TYPES_H
119 #include <sys/types.h>
121 #ifdef HAVE_SYS_SOCKET_H
122 #include <sys/socket.h>
124 #ifdef HAVE_NETINET_IN_H
125 #include <netinet/in.h>
132 AC_MSG_CHECKING(whether socklen_t exists)
134 #include <sys/types.h>
135 #include <sys/socket.h>
138 a = 2; b = 4; a += b;
140 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
148 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
149 [#include <arpa/inet.h>])
154 AC_CHECK_LIB(UTIL,memmove)
155 # needed on solaris. GNU libc also has a libnsl, but we do not need it.
156 AC_SEARCH_LIBS(gethostbyname,nsl)
157 AC_CHECK_LIB(socket,bind)
165 bind gethostbyaddr gethostbyname gethostname inet_ntoa \
166 setsid setsockopt socket strcasecmp waitpid],,
167 AC_MSG_ERROR([required function missing!]))
170 gai_strerror getaddrinfo getnameinfo inet_aton sigaction \
171 sigprocmask snprintf vsnprintf strdup strlcpy strlcat strtok_r])
173 # -- Configuration options --
179 [ --without-syslog disable syslog (autodetected by default)],
180 [ if test "$withval" != "no"; then
181 if test "$withval" != "yes"; then
182 CFLAGS="-I$withval/include $CFLAGS"
183 CPPFLAGS="-I$withval/include $CPPFLAGS"
184 LDFLAGS="-L$withval/lib $LDFLAGS"
186 AC_CHECK_LIB(be, syslog)
187 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
188 AC_MSG_ERROR([Can't enable syslog!])
193 AC_CHECK_LIB(be, syslog)
194 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
197 if test "$x_syslog_on" = "yes"; then
199 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
202 # use zlib compression?
206 [ --without-zlib disable zlib compression (autodetected by default)],
207 [ if test "$withval" != "no"; then
208 if test "$withval" != "yes"; then
209 CFLAGS="-I$withval/include $CFLAGS"
210 CPPFLAGS="-I$withval/include $CPPFLAGS"
211 LDFLAGS="-L$withval/lib $LDFLAGS"
213 AC_CHECK_LIB(z, deflate)
214 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
215 AC_MSG_ERROR([Can't enable zlib!])
219 [ AC_CHECK_LIB(z, deflate)
220 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
223 if test "$x_zlib_on" = "yes"; then
225 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
228 # detect which IO API to use:
233 [ --without-select disable select IO support (autodetected by default)],
234 [ if test "$withval" != "no"; then
235 if test "$withval" != "yes"; then
236 CFLAGS="-I$withval/include $CFLAGS"
237 CPPFLAGS="-I$withval/include $CPPFLAGS"
238 LDFLAGS="-L$withval/lib $LDFLAGS"
240 AC_CHECK_FUNCS(select, x_io_select=yes,
241 AC_MSG_ERROR([Can't enable select IO support!])
246 AC_CHECK_FUNCS(select, x_io_select=yes)
251 [ --without-poll disable poll support (autodetected by default)],
252 [ if test "$withval" != "no"; then
253 if test "$withval" != "yes"; then
254 CFLAGS="-I$withval/include $CFLAGS"
255 CPPFLAGS="-I$withval/include $CPPFLAGS"
256 LDFLAGS="-L$withval/lib $LDFLAGS"
258 AC_CHECK_FUNCS(poll, [
259 AC_CHECK_HEADERS(poll.h,
260 x_io_backend=poll\(\),
262 [Can't enable poll IO support!])
265 AC_MSG_ERROR([Can't enable poll IO support!])
270 AC_CHECK_FUNCS(poll, [
271 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
277 [ --without-devpoll disable /dev/poll 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"
285 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
289 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
294 [ --without-epoll disable epoll IO support (autodetected by default)],
295 [ if test "$withval" != "no"; then
296 if test "$withval" != "yes"; then
297 CFLAGS="-I$withval/include $CFLAGS"
298 CPPFLAGS="-I$withval/include $CPPFLAGS"
299 LDFLAGS="-L$withval/lib $LDFLAGS"
301 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
302 AC_MSG_ERROR([Can't enable epoll IO support!])
307 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
312 [ --without-kqueue disable kqueue IO support (autodetected by default)],
313 [ if test "$withval" != "no"; then
314 if test "$withval" != "yes"; then
315 CFLAGS="-I$withval/include $CFLAGS"
316 CPPFLAGS="-I$withval/include $CPPFLAGS"
317 LDFLAGS="-L$withval/lib $LDFLAGS"
319 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
320 AC_MSG_ERROR([Can't enable kqueue IO support!])
325 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
329 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
330 # when epoll() and select() are available, we'll use both!
331 x_io_backend="epoll(), select()"
333 if test "$x_io_epoll" = "yes"; then
334 # we prefere epoll() if it is available
335 x_io_backend="epoll()"
337 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
338 # we'll use select, when available and no "better"
339 # interface has been detected ...
340 x_io_backend="select()"
345 if test "$x_io_backend" = "none"; then
346 AC_MSG_ERROR([No useable IO API activated/found!?])
352 [ --with-openssl enable SSL support using OpenSSL],
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(crypto, BIO_s_mem)
360 AC_CHECK_LIB(ssl, SSL_library_init)
361 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
362 AC_MSG_ERROR([Can't enable openssl])
369 [ --with-gnutls enable SSL support using gnutls],
370 [ if test "$withval" != "no"; then
371 if test "$withval" != "yes"; then
372 CFLAGS="-I$withval/include $CFLAGS"
373 CPPFLAGS="-I$withval/include $CPPFLAGS"
374 LDFLAGS="-L$withval/lib $LDFLAGS"
376 AC_CHECK_LIB(gnutls, gnutls_global_init)
377 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
378 AC_MSG_ERROR([Can't enable gnutls])
385 if test "$x_ssl_gnutls" = "yes"; then
386 if test "$x_ssl_openssl" = "yes";then
387 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
391 if test "$x_ssl_openssl" = "yes"; then
398 AC_ARG_WITH(tcp-wrappers,
399 [ --with-tcp-wrappers enable TCP wrappers support],
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_MSG_CHECKING(for hosts_access)
410 int allow_severity = 0;
411 int deny_severity = 0;
413 tcpd_warn("link test");
416 AC_DEFINE(TCPWRAP, 1)
420 AC_MSG_ERROR([Can't enable TCP wrappers!])
426 # do IDENT requests using libident?
430 [ --with-ident enable "IDENT" ("AUTH") protocol support],
431 [ if test "$withval" != "no"; then
432 if test "$withval" != "yes"; then
433 CFLAGS="-I$withval/include $CFLAGS"
434 CPPFLAGS="-I$withval/include $CPPFLAGS"
435 LDFLAGS="-L$withval/lib $LDFLAGS"
437 AC_CHECK_LIB(ident, ident_id)
438 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
439 AC_MSG_ERROR([Can't enable IDENT support!])
444 if test "$x_identauth_on" = "yes"; then
445 AC_DEFINE(IDENTAUTH, 1)
446 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
449 # compile in PAM support?
453 [ --with-pam enable user authentication using PAM],
454 [ if test "$withval" != "no"; then
455 if test "$withval" != "yes"; then
456 CFLAGS="-I$withval/include $CFLAGS"
457 CPPFLAGS="-I$withval/include $CPPFLAGS"
458 LDFLAGS="-L$withval/lib $LDFLAGS"
460 AC_CHECK_LIB(pam, pam_authenticate)
461 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
462 AC_MSG_ERROR([Can't enable PAM support!])
467 if test "$x_pam_on" = "yes"; then
469 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
470 if test "$pam_ok" != "yes"; then
471 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
472 AC_MSG_ERROR([required C header missing!]))
476 # compile in IRC+ protocol support?
479 AC_ARG_ENABLE(ircplus,
480 [ --disable-ircplus disable IRC+ protocol],
481 if test "$enableval" = "no"; then x_ircplus_on=no; fi
483 if test "$x_ircplus_on" = "yes"; then
484 AC_DEFINE(IRCPLUS, 1)
487 # enable support for IPv6?
490 [ --enable-ipv6 enable IPv6 protocol support],
491 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
493 if test "$x_ipv6_on" = "yes"; then
494 # getaddrinfo() and getnameinfo() are optional when not compiling
495 # with IPv6 support, but are required for IPv6 to work!
497 getaddrinfo getnameinfo \
498 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
499 AC_DEFINE(WANT_IPV6, 1)
502 # compile in IRC "sniffer"?
504 x_sniffer_on=no; x_debug_on=no
505 AC_ARG_ENABLE(sniffer,
506 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
507 if test "$enableval" = "yes"; then
508 AC_DEFINE(SNIFFER, 1)
509 x_sniffer_on=yes; x_debug_on=yes
513 # enable additional debugging code?
516 [ --enable-debug show additional debug output],
517 if test "$enableval" = "yes"; then x_debug_on=yes; fi
519 if test "$x_debug_on" = "yes"; then
521 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
522 AC_CHECK_FUNCS(mtrace)
525 # enable "strict RFC rules"?
528 AC_ARG_ENABLE(strict-rfc,
529 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
530 if test "$enableval" = "yes"; then
531 AC_DEFINE(STRICT_RFC, 1)
538 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
539 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
540 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
542 # Add additional CFLAGS, eventually specified on the command line, but after
543 # running this configure script. Useful for "-Werror" for example.
544 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
546 # -- Generate files --
550 contrib/Anope/Makefile \
551 contrib/Debian/Makefile \
552 contrib/MacOSX/Makefile \
553 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
554 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
559 src/ipaddr/Makefile \
561 src/ngircd/Makefile \
562 src/portab/Makefile \
563 src/testsuite/Makefile \
567 type dpkg >/dev/null 2>&1
568 if test $? -eq 0; then
569 # Generate debian/ link if the dpkg command exists
570 # (read: if we are running on a debian compatible system)
571 echo "creating Debian-specific links ..."
572 test -f debian/rules || ln -s contrib/Debian debian
578 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
581 # Someone please show me a better way :) [borrowed by OpenSSH]
582 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
583 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
584 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
585 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
586 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
588 echo " Target: ${target}"
589 test "$target" != "$host" && echo " Host: ${host}"
590 echo " Compiler: ${CC}"
591 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
592 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
593 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
594 test -n "$LIBS" && echo " Libraries: ${LIBS}"
596 echo " 'ngircd' binary: $S"
597 echo " Configuration file: $C"
598 echo " Manual pages: $M"
599 echo " Documentation: $D"
602 echo $ECHO_N " Syslog support: $ECHO_C"
603 test "$x_syslog_on" = "yes" \
604 && echo $ECHO_N "yes $ECHO_C" \
605 || echo $ECHO_N "no $ECHO_C"
606 echo $ECHO_N " Enable debug code: $ECHO_C"
607 test "$x_debug_on" = "yes" \
611 echo $ECHO_N " zlib compression: $ECHO_C"
612 test "$x_zlib_on" = "yes" \
613 && echo $ECHO_N "yes $ECHO_C" \
614 || echo $ECHO_N "no $ECHO_C"
615 echo $ECHO_N " IRC sniffer: $ECHO_C"
616 test "$x_sniffer_on" = "yes" \
620 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
621 test "$x_tcpwrap_on" = "yes" \
622 && echo $ECHO_N "yes $ECHO_C" \
623 || echo $ECHO_N "no $ECHO_C"
624 echo $ECHO_N " Strict RFC mode: $ECHO_C"
625 test "$x_strict_rfc_on" = "yes" \
629 echo $ECHO_N " IDENT support: $ECHO_C"
630 test "$x_identauth_on" = "yes" \
631 && echo $ECHO_N "yes $ECHO_C" \
632 || echo $ECHO_N "no $ECHO_C"
633 echo $ECHO_N " IRC+ protocol: $ECHO_C"
634 test "$x_ircplus_on" = "yes" \
638 echo $ECHO_N " IPv6 protocol: $ECHO_C"
639 test "$x_ipv6_on" = "yes" \
640 && echo $ECHO_N "yes $ECHO_C" \
641 || echo $ECHO_N "no $ECHO_C"
642 echo $ECHO_N " I/O backend: $ECHO_C"
643 echo "\"$x_io_backend\""
645 echo $ECHO_N " PAM support: $ECHO_C"
646 test "$x_pam_on" = "yes" \
647 && echo $ECHO_N "yes $ECHO_C" \
648 || echo $ECHO_N "no $ECHO_C"
649 echo $ECHO_N " SSL support: $ECHO_C"