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])
52 # -- Helper programs --
60 # -- Compiler Features --
66 # -- Hard coded system and compiler dependencies/features/options ... --
68 AC_DEFUN([GCC_STACK_PROTECT_CC],[
70 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
71 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
72 ssp_old_cflags="$CFLAGS"
73 CFLAGS="$CFLAGS -fstack-protector-all"
74 AC_TRY_LINK(,,, ssp_cc=no)
76 CFLAGS="$ssp_old_cflags"
77 if test "X$ssp_cc" = "Xyes"; then
78 CFLAGS="$CFLAGS -fstack-protector"
79 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
83 if test "$GCC" = "yes"; then
84 # We are using the GNU C compiler. Good!
85 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
92 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
93 # (tested with HP/UX 11.11)
94 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
98 # Add additional CFLAGS, eventually specified on the command line:
99 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
101 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
109 # Required header files
111 fcntl.h inttypes.h netdb.h netinet/in.h netinet/in_systm.h stdlib.h \
112 string.h strings.h sys/socket.h sys/time.h unistd.h \
113 ],,AC_MSG_ERROR([required C header missing!]))
115 # Optional header files
117 arpa/inet.h malloc.h netinet/ip.h stdbool.h stddef.h stdint.h \
123 AC_MSG_CHECKING(whether socklen_t exists)
125 #include <sys/types.h>
126 #include <sys/socket.h>
129 a = 2; b = 4; a += b;
131 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)
165 alarm dup2 endpwent gethostbyaddr gethostbyname gethostname \
166 gettimeofday inet_ntoa memmove memset setsid socket strcasecmp \
167 strchr strcspn strerror strncasecmp strrchr strspn strstr \
169 AC_MSG_ERROR([required function missing!]))
173 gai_strerror getaddrinfo getnameinfo inet_aton sigaction sigprocmask \
174 snprintf vsnprintf strdup strlcpy strlcat strtok_r waitpid])
176 # -- Configuration options --
182 [ --without-syslog disable syslog (autodetected by default)],
183 [ if test "$withval" != "no"; then
184 if test "$withval" != "yes"; then
185 CFLAGS="-I$withval/include $CFLAGS"
186 CPPFLAGS="-I$withval/include $CPPFLAGS"
187 LDFLAGS="-L$withval/lib $LDFLAGS"
189 AC_CHECK_LIB(be, syslog)
190 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
191 AC_MSG_ERROR([Can't enable syslog!])
196 AC_CHECK_LIB(be, syslog)
197 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
200 if test "$x_syslog_on" = "yes"; then
202 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
205 # use zlib compression?
209 [ --without-zlib disable zlib compression (autodetected by default)],
210 [ if test "$withval" != "no"; then
211 if test "$withval" != "yes"; then
212 CFLAGS="-I$withval/include $CFLAGS"
213 CPPFLAGS="-I$withval/include $CPPFLAGS"
214 LDFLAGS="-L$withval/lib $LDFLAGS"
216 AC_CHECK_LIB(z, deflate)
217 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
218 AC_MSG_ERROR([Can't enable zlib!])
222 [ AC_CHECK_LIB(z, deflate)
223 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
226 if test "$x_zlib_on" = "yes"; then
228 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
231 # detect which IO API to use:
236 [ --without-select disable select IO support (autodetected by default)],
237 [ if test "$withval" != "no"; then
238 if test "$withval" != "yes"; then
239 CFLAGS="-I$withval/include $CFLAGS"
240 CPPFLAGS="-I$withval/include $CPPFLAGS"
241 LDFLAGS="-L$withval/lib $LDFLAGS"
243 AC_CHECK_FUNCS(select, x_io_select=yes,
244 AC_MSG_ERROR([Can't enable select IO support!])
249 AC_CHECK_FUNCS(select, x_io_select=yes)
254 [ --without-poll disable poll support (autodetected by default)],
255 [ if test "$withval" != "no"; then
256 if test "$withval" != "yes"; then
257 CFLAGS="-I$withval/include $CFLAGS"
258 CPPFLAGS="-I$withval/include $CPPFLAGS"
259 LDFLAGS="-L$withval/lib $LDFLAGS"
261 AC_CHECK_FUNCS(poll, [
262 AC_CHECK_HEADERS(poll.h,
263 x_io_backend=poll\(\),
265 [Can't enable poll IO support!])
268 AC_MSG_ERROR([Can't enable poll IO support!])
273 AC_CHECK_FUNCS(poll, [
274 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
280 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
281 [ if test "$withval" != "no"; then
282 if test "$withval" != "yes"; then
283 CFLAGS="-I$withval/include $CFLAGS"
284 CPPFLAGS="-I$withval/include $CPPFLAGS"
285 LDFLAGS="-L$withval/lib $LDFLAGS"
288 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
292 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
297 [ --without-epoll disable epoll IO support (autodetected by default)],
298 [ if test "$withval" != "no"; then
299 if test "$withval" != "yes"; then
300 CFLAGS="-I$withval/include $CFLAGS"
301 CPPFLAGS="-I$withval/include $CPPFLAGS"
302 LDFLAGS="-L$withval/lib $LDFLAGS"
304 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
305 AC_MSG_ERROR([Can't enable epoll IO support!])
310 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
315 [ --without-kqueue disable kqueue IO support (autodetected by default)],
316 [ if test "$withval" != "no"; then
317 if test "$withval" != "yes"; then
318 CFLAGS="-I$withval/include $CFLAGS"
319 CPPFLAGS="-I$withval/include $CPPFLAGS"
320 LDFLAGS="-L$withval/lib $LDFLAGS"
322 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
323 AC_MSG_ERROR([Can't enable kqueue IO support!])
328 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
332 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
333 # when epoll() and select() are available, we'll use both!
334 x_io_backend="epoll(), select()"
336 if test "$x_io_epoll" = "yes"; then
337 # we prefere epoll() if it is available
338 x_io_backend="epoll()"
340 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
341 # we'll use select, when available and no "better"
342 # interface has been detected ...
343 x_io_backend="select()"
348 if test "$x_io_backend" = "none"; then
349 AC_MSG_ERROR([No useable IO API activated/found!?])
355 [ --with-openssl enable SSL support using OpenSSL],
356 [ if test "$withval" != "no"; then
357 if test "$withval" != "yes"; then
358 CFLAGS="-I$withval/include $CFLAGS"
359 CPPFLAGS="-I$withval/include $CPPFLAGS"
360 LDFLAGS="-L$withval/lib $LDFLAGS"
362 AC_CHECK_LIB(crypto, BIO_s_mem)
363 AC_CHECK_LIB(ssl, SSL_library_init)
364 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
365 AC_MSG_ERROR([Can't enable openssl])
372 [ --with-gnutls enable SSL support using gnutls],
373 [ if test "$withval" != "no"; then
374 if test "$withval" != "yes"; then
375 CFLAGS="-I$withval/include $CFLAGS"
376 CPPFLAGS="-I$withval/include $CPPFLAGS"
377 LDFLAGS="-L$withval/lib $LDFLAGS"
379 AC_CHECK_LIB(gnutls, gnutls_global_init)
380 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
381 AC_MSG_ERROR([Can't enable gnutls])
388 if test "$x_ssl_gnutls" = "yes"; then
389 if test "$x_ssl_openssl" = "yes";then
390 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
394 if test "$x_ssl_openssl" = "yes"; then
401 AC_ARG_WITH(tcp-wrappers,
402 [ --with-tcp-wrappers enable TCP wrappers support],
403 [ if test "$withval" != "no"; then
404 if test "$withval" != "yes"; then
405 CFLAGS="-I$withval/include $CFLAGS"
406 CPPFLAGS="-I$withval/include $CPPFLAGS"
407 LDFLAGS="-L$withval/lib $LDFLAGS"
409 AC_MSG_CHECKING(for hosts_access)
413 int allow_severity = 0;
414 int deny_severity = 0;
416 tcpd_warn("link test");
419 AC_DEFINE(TCPWRAP, 1)
423 AC_MSG_ERROR([Can't enable TCP wrappers!])
429 # do IDENT requests using libident?
433 [ --with-ident enable "IDENT" ("AUTH") protocol support],
434 [ if test "$withval" != "no"; then
435 if test "$withval" != "yes"; then
436 CFLAGS="-I$withval/include $CFLAGS"
437 CPPFLAGS="-I$withval/include $CPPFLAGS"
438 LDFLAGS="-L$withval/lib $LDFLAGS"
440 AC_CHECK_LIB(ident, ident_id)
441 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
442 AC_MSG_ERROR([Can't enable IDENT support!])
447 if test "$x_identauth_on" = "yes"; then
448 AC_DEFINE(IDENTAUTH, 1)
449 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
452 # compile in PAM support?
456 [ --with-pam enable user authentication using PAM],
457 [ if test "$withval" != "no"; then
458 if test "$withval" != "yes"; then
459 CFLAGS="-I$withval/include $CFLAGS"
460 CPPFLAGS="-I$withval/include $CPPFLAGS"
461 LDFLAGS="-L$withval/lib $LDFLAGS"
463 AC_CHECK_LIB(pam, pam_authenticate)
464 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
465 AC_MSG_ERROR([Can't enable PAM support!])
470 if test "$x_pam_on" = "yes"; then
472 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
473 if test "$pam_ok" != "yes"; then
474 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
475 AC_MSG_ERROR([required C header missing!]))
479 # compile in IRC+ protocol support?
482 AC_ARG_ENABLE(ircplus,
483 [ --disable-ircplus disable IRC+ protocol],
484 if test "$enableval" = "no"; then x_ircplus_on=no; fi
486 if test "$x_ircplus_on" = "yes"; then
487 AC_DEFINE(IRCPLUS, 1)
490 # enable support for IPv6?
493 [ --enable-ipv6 enable IPv6 protocol support],
494 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
496 if test "$x_ipv6_on" = "yes"; then
497 # getaddrinfo() and getnameinfo() are optional when not compiling
498 # with IPv6 support, but are required for IPv6 to work!
500 getaddrinfo getnameinfo \
501 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
502 AC_DEFINE(WANT_IPV6, 1)
505 # compile in IRC "sniffer"?
507 x_sniffer_on=no; x_debug_on=no
508 AC_ARG_ENABLE(sniffer,
509 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
510 if test "$enableval" = "yes"; then
511 AC_DEFINE(SNIFFER, 1)
512 x_sniffer_on=yes; x_debug_on=yes
516 # enable additional debugging code?
519 [ --enable-debug show additional debug output],
520 if test "$enableval" = "yes"; then x_debug_on=yes; fi
522 if test "$x_debug_on" = "yes"; then
524 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
525 AC_CHECK_FUNCS(mtrace)
528 # enable "strict RFC rules"?
531 AC_ARG_ENABLE(strict-rfc,
532 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
533 if test "$enableval" = "yes"; then
534 AC_DEFINE(STRICT_RFC, 1)
541 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
542 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
543 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
545 # Add additional CFLAGS, eventually specified on the command line, but after
546 # running this configure script. Useful for "-Werror" for example.
547 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
549 # -- Generate files --
553 contrib/Anope/Makefile \
554 contrib/Debian/Makefile \
555 contrib/MacOSX/Makefile \
556 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
557 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
562 src/ipaddr/Makefile \
564 src/ngircd/Makefile \
565 src/portab/Makefile \
566 src/testsuite/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 ${docdir}` ; 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 " IDENT support: $ECHO_C"
635 test "$x_identauth_on" = "yes" \
636 && echo $ECHO_N "yes $ECHO_C" \
637 || echo $ECHO_N "no $ECHO_C"
638 echo $ECHO_N " IRC+ protocol: $ECHO_C"
639 test "$x_ircplus_on" = "yes" \
643 echo $ECHO_N " IPv6 protocol: $ECHO_C"
644 test "$x_ipv6_on" = "yes" \
645 && echo $ECHO_N "yes $ECHO_C" \
646 || echo $ECHO_N "no $ECHO_C"
647 echo $ECHO_N " I/O backend: $ECHO_C"
648 echo "\"$x_io_backend\""
650 echo $ECHO_N " PAM support: $ECHO_C"
651 test "$x_pam_on" = "yes" \
652 && echo $ECHO_N "yes $ECHO_C" \
653 || echo $ECHO_N "no $ECHO_C"
654 echo $ECHO_N " SSL support: $ECHO_C"