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)\"'"
110 # Required header files
112 fcntl.h inttypes.h netdb.h netinet/in.h netinet/in_systm.h stdlib.h \
113 string.h strings.h sys/socket.h sys/time.h unistd.h \
114 ],,AC_MSG_ERROR([required C header missing!]))
116 # Optional header files
118 arpa/inet.h malloc.h netinet/ip.h stdbool.h stddef.h stdint.h \
124 AC_MSG_CHECKING(whether socklen_t exists)
126 #include <sys/types.h>
127 #include <sys/socket.h>
130 a = 2; b = 4; a += b;
132 AC_DEFINE(HAVE_socklen_t) AC_MSG_RESULT(yes)
146 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
147 [#include <arpa/inet.h>])
152 AC_CHECK_LIB(UTIL,memmove)
153 # needed on solaris. GNU libc also has a libnsl, but we do not need it.
154 AC_SEARCH_LIBS(gethostbyname,nsl)
155 AC_CHECK_LIB(socket,bind)
166 alarm dup2 endpwent gethostbyaddr gethostbyname gethostname \
167 gettimeofday inet_ntoa memmove memset setsid socket strcasecmp \
168 strchr strcspn strerror strncasecmp strrchr strspn strstr \
170 AC_MSG_ERROR([required function missing!]))
174 gai_strerror getaddrinfo getnameinfo inet_aton sigaction sigprocmask \
175 snprintf vsnprintf strdup strlcpy strlcat strtok_r waitpid])
177 # -- Configuration options --
183 [ --without-syslog disable syslog (autodetected by default)],
184 [ if test "$withval" != "no"; then
185 if test "$withval" != "yes"; then
186 CFLAGS="-I$withval/include $CFLAGS"
187 CPPFLAGS="-I$withval/include $CPPFLAGS"
188 LDFLAGS="-L$withval/lib $LDFLAGS"
190 AC_CHECK_LIB(be, syslog)
191 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
192 AC_MSG_ERROR([Can't enable syslog!])
197 AC_CHECK_LIB(be, syslog)
198 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
201 if test "$x_syslog_on" = "yes"; then
203 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
206 # use zlib compression?
210 [ --without-zlib disable zlib compression (autodetected by default)],
211 [ if test "$withval" != "no"; then
212 if test "$withval" != "yes"; then
213 CFLAGS="-I$withval/include $CFLAGS"
214 CPPFLAGS="-I$withval/include $CPPFLAGS"
215 LDFLAGS="-L$withval/lib $LDFLAGS"
217 AC_CHECK_LIB(z, deflate)
218 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
219 AC_MSG_ERROR([Can't enable zlib!])
223 [ AC_CHECK_LIB(z, deflate)
224 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
227 if test "$x_zlib_on" = "yes"; then
229 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
232 # detect which IO API to use:
237 [ --without-select disable select IO support (autodetected by default)],
238 [ if test "$withval" != "no"; then
239 if test "$withval" != "yes"; then
240 CFLAGS="-I$withval/include $CFLAGS"
241 CPPFLAGS="-I$withval/include $CPPFLAGS"
242 LDFLAGS="-L$withval/lib $LDFLAGS"
244 AC_CHECK_FUNCS(select, x_io_select=yes,
245 AC_MSG_ERROR([Can't enable select IO support!])
250 AC_CHECK_FUNCS(select, x_io_select=yes)
255 [ --without-poll disable poll support (autodetected by default)],
256 [ if test "$withval" != "no"; then
257 if test "$withval" != "yes"; then
258 CFLAGS="-I$withval/include $CFLAGS"
259 CPPFLAGS="-I$withval/include $CPPFLAGS"
260 LDFLAGS="-L$withval/lib $LDFLAGS"
262 AC_CHECK_FUNCS(poll, [
263 AC_CHECK_HEADERS(poll.h,
264 x_io_backend=poll\(\),
266 [Can't enable poll IO support!])
269 AC_MSG_ERROR([Can't enable poll IO support!])
274 AC_CHECK_FUNCS(poll, [
275 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
281 [ --without-devpoll disable /dev/poll 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"
289 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
293 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
298 [ --without-epoll disable epoll IO support (autodetected by default)],
299 [ if test "$withval" != "no"; then
300 if test "$withval" != "yes"; then
301 CFLAGS="-I$withval/include $CFLAGS"
302 CPPFLAGS="-I$withval/include $CPPFLAGS"
303 LDFLAGS="-L$withval/lib $LDFLAGS"
305 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
306 AC_MSG_ERROR([Can't enable epoll IO support!])
311 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
316 [ --without-kqueue disable kqueue IO support (autodetected by default)],
317 [ if test "$withval" != "no"; then
318 if test "$withval" != "yes"; then
319 CFLAGS="-I$withval/include $CFLAGS"
320 CPPFLAGS="-I$withval/include $CPPFLAGS"
321 LDFLAGS="-L$withval/lib $LDFLAGS"
323 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
324 AC_MSG_ERROR([Can't enable kqueue IO support!])
329 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
333 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
334 # when epoll() and select() are available, we'll use both!
335 x_io_backend="epoll(), select()"
337 if test "$x_io_epoll" = "yes"; then
338 # we prefere epoll() if it is available
339 x_io_backend="epoll()"
341 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
342 # we'll use select, when available and no "better"
343 # interface has been detected ...
344 x_io_backend="select()"
349 if test "$x_io_backend" = "none"; then
350 AC_MSG_ERROR([No useable IO API activated/found!?])
356 [ --with-openssl enable SSL support using OpenSSL],
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(crypto, BIO_s_mem)
364 AC_CHECK_LIB(ssl, SSL_library_init)
365 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
366 AC_MSG_ERROR([Can't enable openssl])
373 [ --with-gnutls enable SSL support using gnutls],
374 [ if test "$withval" != "no"; then
375 if test "$withval" != "yes"; then
376 CFLAGS="-I$withval/include $CFLAGS"
377 CPPFLAGS="-I$withval/include $CPPFLAGS"
378 LDFLAGS="-L$withval/lib $LDFLAGS"
380 AC_CHECK_LIB(gnutls, gnutls_global_init)
381 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
382 AC_MSG_ERROR([Can't enable gnutls])
389 if test "$x_ssl_gnutls" = "yes"; then
390 if test "$x_ssl_openssl" = "yes";then
391 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
395 if test "$x_ssl_openssl" = "yes"; then
402 AC_ARG_WITH(tcp-wrappers,
403 [ --with-tcp-wrappers enable TCP wrappers support],
404 [ if test "$withval" != "no"; then
405 if test "$withval" != "yes"; then
406 CFLAGS="-I$withval/include $CFLAGS"
407 CPPFLAGS="-I$withval/include $CPPFLAGS"
408 LDFLAGS="-L$withval/lib $LDFLAGS"
410 AC_MSG_CHECKING(for hosts_access)
414 int allow_severity = 0;
415 int deny_severity = 0;
417 tcpd_warn("link test");
420 AC_DEFINE(TCPWRAP, 1)
424 AC_MSG_ERROR([Can't enable TCP wrappers!])
430 # do IDENT requests using libident?
434 [ --with-ident enable "IDENT" ("AUTH") protocol support],
435 [ if test "$withval" != "no"; then
436 if test "$withval" != "yes"; then
437 CFLAGS="-I$withval/include $CFLAGS"
438 CPPFLAGS="-I$withval/include $CPPFLAGS"
439 LDFLAGS="-L$withval/lib $LDFLAGS"
441 AC_CHECK_LIB(ident, ident_id)
442 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
443 AC_MSG_ERROR([Can't enable IDENT support!])
448 if test "$x_identauth_on" = "yes"; then
449 AC_DEFINE(IDENTAUTH, 1)
450 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
453 # compile in PAM support?
457 [ --with-pam enable user authentication using PAM],
458 [ if test "$withval" != "no"; then
459 if test "$withval" != "yes"; then
460 CFLAGS="-I$withval/include $CFLAGS"
461 CPPFLAGS="-I$withval/include $CPPFLAGS"
462 LDFLAGS="-L$withval/lib $LDFLAGS"
464 AC_CHECK_LIB(pam, pam_authenticate)
465 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
466 AC_MSG_ERROR([Can't enable PAM support!])
471 if test "$x_pam_on" = "yes"; then
473 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
474 if test "$pam_ok" != "yes"; then
475 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
476 AC_MSG_ERROR([required C header missing!]))
480 # compile in IRC+ protocol support?
483 AC_ARG_ENABLE(ircplus,
484 [ --disable-ircplus disable IRC+ protocol],
485 if test "$enableval" = "no"; then x_ircplus_on=no; fi
487 if test "$x_ircplus_on" = "yes"; then
488 AC_DEFINE(IRCPLUS, 1)
491 # enable support for IPv6?
494 [ --enable-ipv6 enable IPv6 protocol support],
495 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
497 if test "$x_ipv6_on" = "yes"; then
498 # getaddrinfo() and getnameinfo() are optional when not compiling
499 # with IPv6 support, but are required for IPv6 to work!
501 getaddrinfo getnameinfo \
502 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
503 AC_DEFINE(WANT_IPV6, 1)
506 # compile in IRC "sniffer"?
508 x_sniffer_on=no; x_debug_on=no
509 AC_ARG_ENABLE(sniffer,
510 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
511 if test "$enableval" = "yes"; then
512 AC_DEFINE(SNIFFER, 1)
513 x_sniffer_on=yes; x_debug_on=yes
517 # enable additional debugging code?
520 [ --enable-debug show additional debug output],
521 if test "$enableval" = "yes"; then x_debug_on=yes; fi
523 if test "$x_debug_on" = "yes"; then
525 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
526 AC_CHECK_FUNCS(mtrace)
529 # enable "strict RFC rules"?
532 AC_ARG_ENABLE(strict-rfc,
533 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
534 if test "$enableval" = "yes"; then
535 AC_DEFINE(STRICT_RFC, 1)
542 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
543 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
544 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
546 # Add additional CFLAGS, eventually specified on the command line, but after
547 # running this configure script. Useful for "-Werror" for example.
548 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
550 # -- Generate files --
554 contrib/Anope/Makefile \
555 contrib/Debian/Makefile \
556 contrib/MacOSX/Makefile \
557 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
558 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
563 src/ipaddr/Makefile \
565 src/ngircd/Makefile \
566 src/portab/Makefile \
567 src/testsuite/Makefile \
571 type dpkg >/dev/null 2>&1
572 if test $? -eq 0; then
573 # Generate debian/ link if the dpkg command exists
574 # (read: if we are running on a debian compatible system)
575 echo "creating Debian-specific links ..."
576 test -f debian/rules || ln -s contrib/Debian debian
582 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
585 # Someone please show me a better way :) [borrowed by OpenSSH]
586 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
587 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
588 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
589 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
590 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
592 echo " Target: ${target}"
593 test "$target" != "$host" && echo " Host: ${host}"
594 echo " Compiler: ${CC}"
595 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
596 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
597 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
598 test -n "$LIBS" && echo " Libraries: ${LIBS}"
600 echo " 'ngircd' binary: $S"
601 echo " Configuration file: $C"
602 echo " Manual pages: $M"
603 echo " Documentation: $D"
606 echo $ECHO_N " Syslog support: $ECHO_C"
607 test "$x_syslog_on" = "yes" \
608 && echo $ECHO_N "yes $ECHO_C" \
609 || echo $ECHO_N "no $ECHO_C"
610 echo $ECHO_N " Enable debug code: $ECHO_C"
611 test "$x_debug_on" = "yes" \
615 echo $ECHO_N " zlib compression: $ECHO_C"
616 test "$x_zlib_on" = "yes" \
617 && echo $ECHO_N "yes $ECHO_C" \
618 || echo $ECHO_N "no $ECHO_C"
619 echo $ECHO_N " IRC sniffer: $ECHO_C"
620 test "$x_sniffer_on" = "yes" \
624 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
625 test "$x_tcpwrap_on" = "yes" \
626 && echo $ECHO_N "yes $ECHO_C" \
627 || echo $ECHO_N "no $ECHO_C"
628 echo $ECHO_N " Strict RFC mode: $ECHO_C"
629 test "$x_strict_rfc_on" = "yes" \
633 echo $ECHO_N " IDENT support: $ECHO_C"
634 test "$x_identauth_on" = "yes" \
635 && echo $ECHO_N "yes $ECHO_C" \
636 || echo $ECHO_N "no $ECHO_C"
637 echo $ECHO_N " IRC+ protocol: $ECHO_C"
638 test "$x_ircplus_on" = "yes" \
642 echo $ECHO_N " IPv6 protocol: $ECHO_C"
643 test "$x_ipv6_on" = "yes" \
644 && echo $ECHO_N "yes $ECHO_C" \
645 || echo $ECHO_N "no $ECHO_C"
646 echo $ECHO_N " I/O backend: $ECHO_C"
647 echo "\"$x_io_backend\""
649 echo $ECHO_N " PAM support: $ECHO_C"
650 test "$x_pam_on" = "yes" \
651 && echo $ECHO_N "yes $ECHO_C" \
652 || echo $ECHO_N "no $ECHO_C"
653 echo $ECHO_N " SSL support: $ECHO_C"