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([
13 V=`git describe 2>/dev/null | sed -e 's/rel-//g' | sed -e 's/-/~/'`;
14 [ -z "$V" -a -r configure ] \
15 && V=`grep "PACKAGE_STRING=" configure | cut -d"'" -f2 | cut -d' ' -f2`
16 ( [ -n "$V" ] && echo "$V" || echo "??" ) | tr -d '\n';
19 m4_ifdef([AM_SILENT_RULES],
20 [m4_define([ng_color_tests], [color-tests])],
21 [m4_define([ng_color_tests], [])])
23 # -- Initialisation --
26 AC_INIT([ngIRCd], VERSION_ID,
27 [ngircd-ml@ngircd.barton.de], [ngircd], [http://ngircd.barton.de/])
29 AC_CONFIG_SRCDIR([src/ngircd/ngircd.c])
30 AC_CONFIG_HEADER([src/config.h])
33 AM_INIT_AUTOMAKE([-Wall 1.10 ]ng_color_tests)
35 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
37 # -- Templates for config.h --
39 AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
40 AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
41 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
42 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
43 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
44 AH_TEMPLATE([PAM], [Define if PAM should be used])
45 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
46 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
47 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
48 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
49 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
50 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
52 AH_TEMPLATE([HOST_OS], [Target operating system name])
53 AH_TEMPLATE([HOST_VENDOR], [Target system vendor])
54 AH_TEMPLATE([HOST_CPU], [Target CPU name])
61 # -- Helper programs --
69 # -- Compiler Features --
75 # -- Hard coded system and compiler dependencies/features/options ... --
77 AC_DEFUN([GCC_STACK_PROTECT_CC],[
79 # we use -fstack-protector-all for the test to enfoce the use of the guard variable
80 AC_MSG_CHECKING([whether ${CC} accepts -fstack-protector])
81 ssp_old_cflags="$CFLAGS"
82 CFLAGS="$CFLAGS -fstack-protector-all"
83 AC_TRY_LINK(,,, ssp_cc=no)
85 CFLAGS="$ssp_old_cflags"
86 if test "X$ssp_cc" = "Xyes"; then
87 CFLAGS="$CFLAGS -fstack-protector"
88 AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
92 if test "$GCC" = "yes"; then
93 # We are using the GNU C compiler. Good!
94 CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
101 # This is HP/UX, we need to define _XOPEN_SOURCE_EXTENDED
102 # (tested with HP/UX 11.11)
103 CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED"
107 # Add additional CFLAGS, eventually specified on the command line:
108 test -n "$CFLAGS_ADD" && CFLAGS="$CFLAGS $CFLAGS_ADD"
110 CFLAGS="$CFLAGS -DSYSCONFDIR='\"\$(sysconfdir)\"'"
118 # Required header files
120 fcntl.h netdb.h netinet/in.h netinet/in_systm.h stdlib.h string.h \
121 strings.h sys/socket.h sys/time.h unistd.h \
122 ],,AC_MSG_ERROR([required C header missing!]))
124 # Optional header files
125 AC_CHECK_HEADERS_ONCE([ \
126 arpa/inet.h inttypes.h malloc.h netinet/ip.h stdbool.h stddef.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)
154 AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
155 [#include <arpa/inet.h>])
159 # memmove: A/UX libUTIL
160 AC_SEARCH_LIBS([memmove], [UTIL], [], [
161 AC_MSG_ERROR([unable to find the memmove() function])
163 # gethostbyname: Solaris libnsl
164 AC_SEARCH_LIBS([gethostbyname], [nsl], [], [
165 AC_MSG_ERROR([unable to find the gethostbyname() function])
167 # bind: SVR4 libsocket
168 AC_SEARCH_LIBS([bind], [socket], [], [
169 AC_MSG_ERROR([unable to find the bind() function])
179 alarm dup2 endpwent gethostbyaddr gethostbyname gethostname \
180 gettimeofday inet_ntoa memmove memset setsid socket strcasecmp \
181 strchr strcspn strerror strncasecmp strrchr strspn strstr \
183 AC_MSG_ERROR([required function missing!]))
186 AC_CHECK_FUNCS_ONCE([ \
187 gai_strerror getaddrinfo getnameinfo inet_aton sigaction sigprocmask \
188 snprintf vsnprintf strdup strlcpy strlcat strtok_r waitpid])
190 # -- Configuration options --
196 AS_HELP_STRING([--without-syslog],
197 [disable syslog (autodetected by default)]),
198 [ if test "$withval" != "no"; then
199 if test "$withval" != "yes"; then
200 CFLAGS="-I$withval/include $CFLAGS"
201 CPPFLAGS="-I$withval/include $CPPFLAGS"
202 LDFLAGS="-L$withval/lib $LDFLAGS"
204 AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes], [
205 AC_MSG_ERROR([Can't enable syslog!])
209 [ AC_SEARCH_LIBS([syslog], [be], [x_syslog_on=yes])
212 if test "$x_syslog_on" = "yes"; then
214 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
217 # use zlib compression?
221 AS_HELP_STRING([--without-zlib],
222 [disable zlib compression (autodetected by default)]),
223 [ if test "$withval" != "no"; then
224 if test "$withval" != "yes"; then
225 CFLAGS="-I$withval/include $CFLAGS"
226 CPPFLAGS="-I$withval/include $CPPFLAGS"
227 LDFLAGS="-L$withval/lib $LDFLAGS"
229 AC_CHECK_LIB(z, deflate)
230 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
231 AC_MSG_ERROR([Can't enable zlib!])
235 [ AC_CHECK_LIB(z, deflate)
236 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
239 if test "$x_zlib_on" = "yes"; then
241 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
244 # detect which IO API to use:
249 AS_HELP_STRING([--without-select],
250 [disable select IO support (autodetected by default)]),
251 [ if test "$withval" != "no"; then
252 if test "$withval" != "yes"; then
253 CFLAGS="-I$withval/include $CFLAGS"
254 CPPFLAGS="-I$withval/include $CPPFLAGS"
255 LDFLAGS="-L$withval/lib $LDFLAGS"
257 AC_CHECK_FUNCS(select, x_io_select=yes,
258 AC_MSG_ERROR([Can't enable select IO support!])
263 AC_CHECK_FUNCS(select, x_io_select=yes)
268 AS_HELP_STRING([--without-poll],
269 [disable poll support (autodetected by default)]),
270 [ if test "$withval" != "no"; then
271 if test "$withval" != "yes"; then
272 CFLAGS="-I$withval/include $CFLAGS"
273 CPPFLAGS="-I$withval/include $CPPFLAGS"
274 LDFLAGS="-L$withval/lib $LDFLAGS"
276 AC_CHECK_FUNCS(poll, [
277 AC_CHECK_HEADERS(poll.h,
278 x_io_backend=poll\(\),
280 [Can't enable poll IO support!])
283 AC_MSG_ERROR([Can't enable poll IO support!])
288 AC_CHECK_FUNCS(poll, [
289 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
295 AS_HELP_STRING([--without-devpoll],
296 [disable /dev/poll IO support (autodetected by default)]),
297 [ if test "$withval" != "no"; then
298 if test "$withval" != "yes"; then
299 CFLAGS="-I$withval/include $CFLAGS"
300 CPPFLAGS="-I$withval/include $CPPFLAGS"
301 LDFLAGS="-L$withval/lib $LDFLAGS"
304 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
308 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
313 AS_HELP_STRING([--without-epoll],
314 [disable epoll IO support (autodetected by default)]),
315 [ if test "$withval" != "no"; then
316 if test "$withval" != "yes"; then
317 CFLAGS="-I$withval/include $CFLAGS"
318 CPPFLAGS="-I$withval/include $CPPFLAGS"
319 LDFLAGS="-L$withval/lib $LDFLAGS"
321 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
322 AC_MSG_ERROR([Can't enable epoll IO support!])
327 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
332 AS_HELP_STRING([--without-kqueue],
333 [disable kqueue IO support (autodetected by default)]),
334 [ if test "$withval" != "no"; then
335 if test "$withval" != "yes"; then
336 CFLAGS="-I$withval/include $CFLAGS"
337 CPPFLAGS="-I$withval/include $CPPFLAGS"
338 LDFLAGS="-L$withval/lib $LDFLAGS"
340 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
341 AC_MSG_ERROR([Can't enable kqueue IO support!])
346 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
350 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
351 # when epoll() and select() are available, we'll use both!
352 x_io_backend="epoll(), select()"
354 if test "$x_io_epoll" = "yes"; then
355 # we prefere epoll() if it is available
356 x_io_backend="epoll()"
358 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
359 # we'll use select, when available and no "better"
360 # interface has been detected ...
361 x_io_backend="select()"
366 if test "$x_io_backend" = "none"; then
367 AC_MSG_ERROR([No useable IO API activated/found!?])
373 AS_HELP_STRING([--with-openssl],
374 [enable SSL support using OpenSSL]),
375 [ if test "$withval" != "no"; then
376 if test "$withval" != "yes"; then
377 CFLAGS="-I$withval/include $CFLAGS"
378 CPPFLAGS="-I$withval/include $CPPFLAGS"
379 LDFLAGS="-L$withval/lib $LDFLAGS"
381 AC_CHECK_LIB(crypto, BIO_s_mem)
382 AC_CHECK_LIB(ssl, SSL_library_init)
383 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
384 AC_MSG_ERROR([Can't enable openssl])
391 AS_HELP_STRING([--with-gnutls],
392 [enable SSL support using gnutls]),
393 [ if test "$withval" != "no"; then
394 if test "$withval" != "yes"; then
395 CFLAGS="-I$withval/include $CFLAGS"
396 CPPFLAGS="-I$withval/include $CPPFLAGS"
397 LDFLAGS="-L$withval/lib $LDFLAGS"
399 AC_CHECK_LIB(gnutls, gnutls_global_init)
400 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
401 AC_MSG_ERROR([Can't enable gnutls])
408 if test "$x_ssl_gnutls" = "yes"; then
409 if test "$x_ssl_openssl" = "yes";then
410 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
414 if test "$x_ssl_openssl" = "yes"; then
421 AC_ARG_WITH(tcp-wrappers,
422 AS_HELP_STRING([--with-tcp-wrappers],
423 [enable TCP wrappers support]),
424 [ if test "$withval" != "no"; then
425 if test "$withval" != "yes"; then
426 CFLAGS="-I$withval/include $CFLAGS"
427 CPPFLAGS="-I$withval/include $CPPFLAGS"
428 LDFLAGS="-L$withval/lib $LDFLAGS"
430 AC_MSG_CHECKING(for hosts_access)
434 int allow_severity = 0;
435 int deny_severity = 0;
437 tcpd_warn("link test");
440 AC_DEFINE(TCPWRAP, 1)
444 AC_MSG_ERROR([Can't enable TCP wrappers!])
450 # do IDENT requests using libident?
454 AS_HELP_STRING([--with-ident],
455 [enable "IDENT" ("AUTH") protocol support]),
456 [ if test "$withval" != "no"; then
457 if test "$withval" != "yes"; then
458 CFLAGS="-I$withval/include $CFLAGS"
459 CPPFLAGS="-I$withval/include $CPPFLAGS"
460 LDFLAGS="-L$withval/lib $LDFLAGS"
462 AC_CHECK_LIB(ident, ident_id)
463 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
464 AC_MSG_ERROR([Can't enable IDENT support!])
469 if test "$x_identauth_on" = "yes"; then
470 AC_DEFINE(IDENTAUTH, 1)
471 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
474 # compile in PAM support?
478 AS_HELP_STRING([--with-pam],
479 [enable user authentication using PAM]),
480 [ if test "$withval" != "no"; then
481 if test "$withval" != "yes"; then
482 CFLAGS="-I$withval/include $CFLAGS"
483 CPPFLAGS="-I$withval/include $CPPFLAGS"
484 LDFLAGS="-L$withval/lib $LDFLAGS"
486 AC_CHECK_LIB(pam, pam_authenticate)
487 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
488 AC_MSG_ERROR([Can't enable PAM support!])
493 if test "$x_pam_on" = "yes"; then
495 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
496 if test "$pam_ok" != "yes"; then
497 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
498 AC_MSG_ERROR([required C header missing!]))
502 # compile in IRC+ protocol support?
505 AC_ARG_ENABLE(ircplus,
506 AS_HELP_STRING([--disable-ircplus],
507 [disable IRC+ protocol]),
508 if test "$enableval" = "no"; then x_ircplus_on=no; fi
510 if test "$x_ircplus_on" = "yes"; then
511 AC_DEFINE(IRCPLUS, 1)
514 # enable support for IPv6?
517 AS_HELP_STRING([--enable-ipv6],
518 [enable IPv6 protocol support]),
519 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
521 if test "$x_ipv6_on" = "yes"; then
522 # getaddrinfo() and getnameinfo() are optional when not compiling
523 # with IPv6 support, but are required for IPv6 to work!
525 getaddrinfo getnameinfo \
526 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
527 AC_DEFINE(WANT_IPV6, 1)
530 # compile in IRC "sniffer"?
532 x_sniffer_on=no; x_debug_on=no
533 AC_ARG_ENABLE(sniffer,
534 AS_HELP_STRING([--enable-sniffer],
535 [enable IRC traffic sniffer (enables debug mode)]),
536 if test "$enableval" = "yes"; then
537 AC_DEFINE(SNIFFER, 1)
538 x_sniffer_on=yes; x_debug_on=yes
542 # enable additional debugging code?
545 AS_HELP_STRING([--enable-debug],
546 [show additional debug output]),
547 if test "$enableval" = "yes"; then x_debug_on=yes; fi
549 if test "$x_debug_on" = "yes"; then
551 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
552 AC_CHECK_FUNCS(mtrace)
555 # enable "strict RFC rules"?
558 AC_ARG_ENABLE(strict-rfc,
559 AS_HELP_STRING([--enable-strict-rfc],
560 [strict RFC conformance -- may break clients!]),
561 if test "$enableval" = "yes"; then
562 AC_DEFINE(STRICT_RFC, 1)
569 AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu" )
570 AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor" )
571 AC_DEFINE_UNQUOTED(HOST_OS, "$host_os" )
573 # Add additional CFLAGS, eventually specified on the command line, but after
574 # running this configure script. Useful for "-Werror" for example.
575 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
577 # -- Generate files --
581 contrib/Anope/Makefile \
582 contrib/Debian/Makefile \
583 contrib/MacOSX/Makefile \
584 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
585 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
590 src/ipaddr/Makefile \
592 src/ngircd/Makefile \
593 src/portab/Makefile \
594 src/testsuite/Makefile \
600 type dpkg >/dev/null 2>&1
601 if test $? -eq 0; then
602 # Generate debian/ link if the dpkg command exists
603 # (read: if we are running on a debian compatible system)
604 echo "creating Debian-specific links ..."
605 test -f debian/rules || ln -s contrib/Debian debian
611 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
614 # Someone please show me a better way :) [borrowed by OpenSSH]
615 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
616 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
617 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
618 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
619 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
621 echo " Host: ${host}"
622 echo " Compiler: ${CC}"
623 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
624 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
625 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
626 test -n "$LIBS" && echo " Libraries: ${LIBS}"
628 echo " 'ngircd' binary: $S"
629 echo " Configuration file: $C"
630 echo " Manual pages: $M"
631 echo " Documentation: $D"
634 echo $ECHO_N " Syslog support: $ECHO_C"
635 test "$x_syslog_on" = "yes" \
636 && echo $ECHO_N "yes $ECHO_C" \
637 || echo $ECHO_N "no $ECHO_C"
638 echo $ECHO_N " Enable debug code: $ECHO_C"
639 test "$x_debug_on" = "yes" \
643 echo $ECHO_N " zlib compression: $ECHO_C"
644 test "$x_zlib_on" = "yes" \
645 && echo $ECHO_N "yes $ECHO_C" \
646 || echo $ECHO_N "no $ECHO_C"
647 echo $ECHO_N " IRC sniffer: $ECHO_C"
648 test "$x_sniffer_on" = "yes" \
652 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
653 test "$x_tcpwrap_on" = "yes" \
654 && echo $ECHO_N "yes $ECHO_C" \
655 || echo $ECHO_N "no $ECHO_C"
656 echo $ECHO_N " Strict RFC mode: $ECHO_C"
657 test "$x_strict_rfc_on" = "yes" \
661 echo $ECHO_N " IDENT support: $ECHO_C"
662 test "$x_identauth_on" = "yes" \
663 && echo $ECHO_N "yes $ECHO_C" \
664 || echo $ECHO_N "no $ECHO_C"
665 echo $ECHO_N " IRC+ protocol: $ECHO_C"
666 test "$x_ircplus_on" = "yes" \
670 echo $ECHO_N " IPv6 protocol: $ECHO_C"
671 test "$x_ipv6_on" = "yes" \
672 && echo $ECHO_N "yes $ECHO_C" \
673 || echo $ECHO_N "no $ECHO_C"
674 echo $ECHO_N " I/O backend: $ECHO_C"
675 echo "\"$x_io_backend\""
677 echo $ECHO_N " PAM support: $ECHO_C"
678 test "$x_pam_on" = "yes" \
679 && echo $ECHO_N "yes $ECHO_C" \
680 || echo $ECHO_N "no $ECHO_C"
681 echo $ECHO_N " SSL support: $ECHO_C"
686 if ! grep "^AUTOMAKE_OPTIONS = ../portab/ansi2knr" src/ngircd/Makefile.am >/dev/null 2>&1; then
688 echo "This GNU automake generated build system does not support \"de-ANSI-fication\","
689 echo "therefore don't use it to generate \"official\" distribution archives!"
690 echo "(Most probably you want to use GNU automake 1.11.x for this purpose ...)"