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 AC_CONFIG_SRCDIR(src/ngircd/ngircd.c)
21 AC_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_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
29 AH_TEMPLATE([HAVE_socklen_t], [Define if socklen_t exists])
30 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
31 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
32 AH_TEMPLATE([PAM], [Define if PAM should be used])
33 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
34 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
35 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
36 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
37 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
38 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
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],,
164 AC_MSG_ERROR([required function missing!]))
167 gai_strerror getaddrinfo getnameinfo inet_aton sigaction \
168 sigprocmask snprintf vsnprintf strdup strlcpy strlcat strtok_r])
170 # -- Configuration options --
176 [ --without-syslog disable syslog (autodetected by default)],
177 [ if test "$withval" != "no"; then
178 if test "$withval" != "yes"; then
179 CFLAGS="-I$withval/include $CFLAGS"
180 CPPFLAGS="-I$withval/include $CPPFLAGS"
181 LDFLAGS="-L$withval/lib $LDFLAGS"
183 AC_CHECK_LIB(be, syslog)
184 AC_CHECK_FUNCS(syslog, x_syslog_on=yes,
185 AC_MSG_ERROR([Can't enable syslog!])
190 AC_CHECK_LIB(be, syslog)
191 AC_CHECK_FUNCS(syslog, x_syslog_on=yes)
194 if test "$x_syslog_on" = "yes"; then
196 AC_CHECK_HEADERS(syslog.h,,AC_MSG_ERROR([required C header missing!]))
199 # use zlib compression?
203 [ --without-zlib disable zlib compression (autodetected by default)],
204 [ if test "$withval" != "no"; then
205 if test "$withval" != "yes"; then
206 CFLAGS="-I$withval/include $CFLAGS"
207 CPPFLAGS="-I$withval/include $CPPFLAGS"
208 LDFLAGS="-L$withval/lib $LDFLAGS"
210 AC_CHECK_LIB(z, deflate)
211 AC_CHECK_FUNCS(deflate, x_zlib_on=yes,
212 AC_MSG_ERROR([Can't enable zlib!])
216 [ AC_CHECK_LIB(z, deflate)
217 AC_CHECK_FUNCS(deflate, x_zlib_on=yes)
220 if test "$x_zlib_on" = "yes"; then
222 AC_CHECK_HEADERS(zlib.h,,AC_MSG_ERROR([required C header missing!]))
225 # detect which IO API to use:
230 [ --without-select disable select IO support (autodetected by default)],
231 [ if test "$withval" != "no"; then
232 if test "$withval" != "yes"; then
233 CFLAGS="-I$withval/include $CFLAGS"
234 CPPFLAGS="-I$withval/include $CPPFLAGS"
235 LDFLAGS="-L$withval/lib $LDFLAGS"
237 AC_CHECK_FUNCS(select, x_io_select=yes,
238 AC_MSG_ERROR([Can't enable select IO support!])
243 AC_CHECK_FUNCS(select, x_io_select=yes)
248 [ --without-poll disable poll support (autodetected by default)],
249 [ if test "$withval" != "no"; then
250 if test "$withval" != "yes"; then
251 CFLAGS="-I$withval/include $CFLAGS"
252 CPPFLAGS="-I$withval/include $CPPFLAGS"
253 LDFLAGS="-L$withval/lib $LDFLAGS"
255 AC_CHECK_FUNCS(poll, [
256 AC_CHECK_HEADERS(poll.h,
257 x_io_backend=poll\(\),
259 [Can't enable poll IO support!])
262 AC_MSG_ERROR([Can't enable poll IO support!])
267 AC_CHECK_FUNCS(poll, [
268 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
274 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
275 [ if test "$withval" != "no"; then
276 if test "$withval" != "yes"; then
277 CFLAGS="-I$withval/include $CFLAGS"
278 CPPFLAGS="-I$withval/include $CPPFLAGS"
279 LDFLAGS="-L$withval/lib $LDFLAGS"
282 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
286 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
291 [ --without-epoll disable epoll IO support (autodetected by default)],
292 [ if test "$withval" != "no"; then
293 if test "$withval" != "yes"; then
294 CFLAGS="-I$withval/include $CFLAGS"
295 CPPFLAGS="-I$withval/include $CPPFLAGS"
296 LDFLAGS="-L$withval/lib $LDFLAGS"
298 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
299 AC_MSG_ERROR([Can't enable epoll IO support!])
304 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
309 [ --without-kqueue disable kqueue IO support (autodetected by default)],
310 [ if test "$withval" != "no"; then
311 if test "$withval" != "yes"; then
312 CFLAGS="-I$withval/include $CFLAGS"
313 CPPFLAGS="-I$withval/include $CPPFLAGS"
314 LDFLAGS="-L$withval/lib $LDFLAGS"
316 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
317 AC_MSG_ERROR([Can't enable kqueue IO support!])
322 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
326 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
327 # when epoll() and select() are available, we'll use both!
328 x_io_backend="epoll(), select()"
330 if test "$x_io_epoll" = "yes"; then
331 # we prefere epoll() if it is available
332 x_io_backend="epoll()"
334 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
335 # we'll use select, when available and no "better"
336 # interface has been detected ...
337 x_io_backend="select()"
342 if test "$x_io_backend" = "none"; then
343 AC_MSG_ERROR([No useable IO API activated/found!?])
349 [ --with-openssl enable SSL support using OpenSSL],
350 [ if test "$withval" != "no"; then
351 if test "$withval" != "yes"; then
352 CFLAGS="-I$withval/include $CFLAGS"
353 CPPFLAGS="-I$withval/include $CPPFLAGS"
354 LDFLAGS="-L$withval/lib $LDFLAGS"
356 AC_CHECK_LIB(crypto, BIO_s_mem)
357 AC_CHECK_LIB(ssl, SSL_library_init)
358 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
359 AC_MSG_ERROR([Can't enable openssl])
366 [ --with-gnutls enable SSL support using gnutls],
367 [ if test "$withval" != "no"; then
368 if test "$withval" != "yes"; then
369 CFLAGS="-I$withval/include $CFLAGS"
370 CPPFLAGS="-I$withval/include $CPPFLAGS"
371 LDFLAGS="-L$withval/lib $LDFLAGS"
373 AC_CHECK_LIB(gnutls, gnutls_global_init)
374 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
375 AC_MSG_ERROR([Can't enable gnutls])
382 if test "$x_ssl_gnutls" = "yes"; then
383 if test "$x_ssl_openssl" = "yes";then
384 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
388 if test "$x_ssl_openssl" = "yes"; then
395 AC_ARG_WITH(tcp-wrappers,
396 [ --with-tcp-wrappers enable TCP wrappers support],
397 [ if test "$withval" != "no"; then
398 if test "$withval" != "yes"; then
399 CFLAGS="-I$withval/include $CFLAGS"
400 CPPFLAGS="-I$withval/include $CPPFLAGS"
401 LDFLAGS="-L$withval/lib $LDFLAGS"
403 AC_MSG_CHECKING(for hosts_access)
407 int allow_severity = 0;
408 int deny_severity = 0;
410 tcpd_warn("link test");
413 AC_DEFINE(TCPWRAP, 1)
417 AC_MSG_ERROR([Can't enable TCP wrappers!])
423 # do IDENT requests using libident?
427 [ --with-ident enable "IDENT" ("AUTH") protocol support],
428 [ if test "$withval" != "no"; then
429 if test "$withval" != "yes"; then
430 CFLAGS="-I$withval/include $CFLAGS"
431 CPPFLAGS="-I$withval/include $CPPFLAGS"
432 LDFLAGS="-L$withval/lib $LDFLAGS"
434 AC_CHECK_LIB(ident, ident_id)
435 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
436 AC_MSG_ERROR([Can't enable IDENT support!])
441 if test "$x_identauth_on" = "yes"; then
442 AC_DEFINE(IDENTAUTH, 1)
443 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
446 # compile in PAM support?
450 [ --with-pam enable user authentication using PAM],
451 [ if test "$withval" != "no"; then
452 if test "$withval" != "yes"; then
453 CFLAGS="-I$withval/include $CFLAGS"
454 CPPFLAGS="-I$withval/include $CPPFLAGS"
455 LDFLAGS="-L$withval/lib $LDFLAGS"
457 AC_CHECK_LIB(pam, pam_authenticate)
458 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
459 AC_MSG_ERROR([Can't enable PAM support!])
464 if test "$x_pam_on" = "yes"; then
466 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
467 if test "$pam_ok" != "yes"; then
468 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
469 AC_MSG_ERROR([required C header missing!]))
473 # compile in IRC+ protocol support?
476 AC_ARG_ENABLE(ircplus,
477 [ --disable-ircplus disable IRC+ protocol],
478 if test "$enableval" = "no"; then x_ircplus_on=no; fi
480 if test "$x_ircplus_on" = "yes"; then
481 AC_DEFINE(IRCPLUS, 1)
484 # enable support for IPv6?
487 [ --enable-ipv6 enable IPv6 protocol support],
488 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
490 if test "$x_ipv6_on" = "yes"; then
491 # getaddrinfo() and getnameinfo() are optional when not compiling
492 # with IPv6 support, but are required for IPv6 to work!
494 getaddrinfo getnameinfo \
495 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
496 AC_DEFINE(WANT_IPV6, 1)
499 # compile in IRC "sniffer"?
501 x_sniffer_on=no; x_debug_on=no
502 AC_ARG_ENABLE(sniffer,
503 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
504 if test "$enableval" = "yes"; then
505 AC_DEFINE(SNIFFER, 1)
506 x_sniffer_on=yes; x_debug_on=yes
510 # enable additional debugging code?
513 [ --enable-debug show additional debug output],
514 if test "$enableval" = "yes"; then x_debug_on=yes; fi
516 if test "$x_debug_on" = "yes"; then
518 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
519 AC_CHECK_FUNCS(mtrace)
522 # enable "strict RFC rules"?
525 AC_ARG_ENABLE(strict-rfc,
526 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
527 if test "$enableval" = "yes"; then
528 AC_DEFINE(STRICT_RFC, 1)
535 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
536 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
537 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
539 # Add additional CFLAGS, eventually specified on the command line, but after
540 # running this configure script. Useful for "-Werror" for example.
541 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
543 # -- Generate files --
547 contrib/Anope/Makefile \
548 contrib/Debian/Makefile \
549 contrib/MacOSX/Makefile \
550 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
551 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
556 src/ipaddr/Makefile \
558 src/ngircd/Makefile \
559 src/portab/Makefile \
560 src/testsuite/Makefile \
564 type dpkg >/dev/null 2>&1
565 if test $? -eq 0; then
566 # Generate debian/ link if the dpkg command exists
567 # (read: if we are running on a debian compatible system)
568 echo "creating Debian-specific links ..."
569 test -f debian/rules || ln -s contrib/Debian debian
575 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
578 # Someone please show me a better way :) [borrowed by OpenSSH]
579 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
580 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
581 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
582 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
583 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
585 echo " Target: ${target}"
586 test "$target" != "$host" && echo " Host: ${host}"
587 echo " Compiler: ${CC}"
588 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
589 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
590 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
591 test -n "$LIBS" && echo " Libraries: ${LIBS}"
593 echo " 'ngircd' binary: $S"
594 echo " Configuration file: $C"
595 echo " Manual pages: $M"
596 echo " Documentation: $D"
599 echo $ECHO_N " Syslog support: $ECHO_C"
600 test "$x_syslog_on" = "yes" \
601 && echo $ECHO_N "yes $ECHO_C" \
602 || echo $ECHO_N "no $ECHO_C"
603 echo $ECHO_N " Enable debug code: $ECHO_C"
604 test "$x_debug_on" = "yes" \
608 echo $ECHO_N " zlib compression: $ECHO_C"
609 test "$x_zlib_on" = "yes" \
610 && echo $ECHO_N "yes $ECHO_C" \
611 || echo $ECHO_N "no $ECHO_C"
612 echo $ECHO_N " IRC sniffer: $ECHO_C"
613 test "$x_sniffer_on" = "yes" \
617 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
618 test "$x_tcpwrap_on" = "yes" \
619 && echo $ECHO_N "yes $ECHO_C" \
620 || echo $ECHO_N "no $ECHO_C"
621 echo $ECHO_N " Strict RFC mode: $ECHO_C"
622 test "$x_strict_rfc_on" = "yes" \
626 echo $ECHO_N " IDENT support: $ECHO_C"
627 test "$x_identauth_on" = "yes" \
628 && echo $ECHO_N "yes $ECHO_C" \
629 || echo $ECHO_N "no $ECHO_C"
630 echo $ECHO_N " IRC+ protocol: $ECHO_C"
631 test "$x_ircplus_on" = "yes" \
635 echo $ECHO_N " IPv6 protocol: $ECHO_C"
636 test "$x_ipv6_on" = "yes" \
637 && echo $ECHO_N "yes $ECHO_C" \
638 || echo $ECHO_N "no $ECHO_C"
639 echo $ECHO_N " I/O backend: $ECHO_C"
640 echo "\"$x_io_backend\""
642 echo $ECHO_N " PAM support: $ECHO_C"
643 test "$x_pam_on" = "yes" \
644 && echo $ECHO_N "yes $ECHO_C" \
645 || echo $ECHO_N "no $ECHO_C"
646 echo $ECHO_N " SSL support: $ECHO_C"