2 # ngIRCd -- The Next Generation IRC Daemon
3 # Copyright (c)2001-2011 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 AM_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_socklen_t], [Define if socklen_t exists])
29 AH_TEMPLATE([SNIFFER], [Define if IRC sniffer should be enabled])
30 AH_TEMPLATE([STRICT_RFC], [Define if ngIRCd should behave strict RFC compliant])
31 AH_TEMPLATE([SYSLOG], [Define if syslog should be used for logging])
32 AH_TEMPLATE([ZLIB], [Define if zlib compression should be enabled])
33 AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used])
34 AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
35 AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
36 AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
37 AH_TEMPLATE([PAM], [Define if PAM should be used])
38 AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
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"
256 AC_CHECK_HEADERS(poll.h,
257 x_io_backend=poll\(\),
259 [Can't enable poll IO support!])
262 [Can't enable poll IO support!])
269 AC_CHECK_HEADERS(poll.h, x_io_backend=poll\(\))
275 [ --without-devpoll disable /dev/poll IO support (autodetected by default)],
276 [ if test "$withval" != "no"; then
277 if test "$withval" != "yes"; then
278 CFLAGS="-I$withval/include $CFLAGS"
279 CPPFLAGS="-I$withval/include $CPPFLAGS"
280 LDFLAGS="-L$withval/lib $LDFLAGS"
283 AC_CHECK_HEADERS(sys/devpoll.h,,AC_MSG_ERROR([required C header missing!]))
287 AC_CHECK_HEADERS(sys/devpoll.h, x_io_backend=/dev/poll)
292 [ --without-epoll disable epoll IO support (autodetected by default)],
293 [ if test "$withval" != "no"; then
294 if test "$withval" != "yes"; then
295 CFLAGS="-I$withval/include $CFLAGS"
296 CPPFLAGS="-I$withval/include $CPPFLAGS"
297 LDFLAGS="-L$withval/lib $LDFLAGS"
299 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes,
300 AC_MSG_ERROR([Can't enable epoll IO support!])
305 AC_CHECK_FUNCS(epoll_create, x_io_epoll=yes)
310 [ --without-kqueue disable kqueue IO support (autodetected by default)],
311 [ if test "$withval" != "no"; then
312 if test "$withval" != "yes"; then
313 CFLAGS="-I$withval/include $CFLAGS"
314 CPPFLAGS="-I$withval/include $CPPFLAGS"
315 LDFLAGS="-L$withval/lib $LDFLAGS"
317 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\),
318 AC_MSG_ERROR([Can't enable kqueue IO support!])
323 AC_CHECK_FUNCS(kqueue, x_io_backend=kqueue\(\))
327 if test "$x_io_epoll" = "yes" -a "$x_io_select" = "yes"; then
328 # when epoll() and select() are available, we'll use both!
329 x_io_backend="epoll(), select()"
331 if test "$x_io_epoll" = "yes"; then
332 # we prefere epoll() if it is available
333 x_io_backend="epoll()"
335 if test "$x_io_select" = "yes" -a "$x_io_backend" = "none"; then
336 # we'll use select, when available and no "better"
337 # interface has been detected ...
338 x_io_backend="select()"
343 if test "$x_io_backend" = "none"; then
344 AC_MSG_ERROR([No useabe IO API activated/found!?])
350 [ --with-openssl enable SSL support using OpenSSL],
351 [ if test "$withval" != "no"; then
352 if test "$withval" != "yes"; then
353 CFLAGS="-I$withval/include $CFLAGS"
354 CPPFLAGS="-I$withval/include $CPPFLAGS"
355 LDFLAGS="-L$withval/lib $LDFLAGS"
357 AC_CHECK_LIB(crypto, BIO_s_mem)
358 AC_CHECK_LIB(ssl, SSL_library_init)
359 AC_CHECK_FUNCS(SSL_library_init, x_ssl_openssl=yes,
360 AC_MSG_ERROR([Can't enable openssl])
367 [ --with-gnutls enable SSL support using gnutls],
368 [ if test "$withval" != "no"; then
369 if test "$withval" != "yes"; then
370 CFLAGS="-I$withval/include $CFLAGS"
371 CPPFLAGS="-I$withval/include $CPPFLAGS"
372 LDFLAGS="-L$withval/lib $LDFLAGS"
374 AC_CHECK_LIB(gnutls, gnutls_global_init)
375 AC_CHECK_FUNCS(gnutls_global_init, x_ssl_gnutls=yes,
376 AC_MSG_ERROR([Can't enable gnutls])
383 if test "$x_ssl_gnutls" = "yes"; then
384 if test "$x_ssl_openssl" = "yes";then
385 AC_MSG_ERROR([Cannot enable both gnutls and openssl])
389 if test "$x_ssl_openssl" = "yes"; then
396 AC_ARG_WITH(tcp-wrappers,
397 [ --with-tcp-wrappers enable TCP wrappers support],
398 [ if test "$withval" != "no"; then
399 if test "$withval" != "yes"; then
400 CFLAGS="-I$withval/include $CFLAGS"
401 CPPFLAGS="-I$withval/include $CPPFLAGS"
402 LDFLAGS="-L$withval/lib $LDFLAGS"
404 AC_MSG_CHECKING(for hosts_access)
408 int allow_severity = 0;
409 int deny_severity = 0;
411 tcpd_warn("link test");
414 AC_DEFINE(TCPWRAP, 1)
418 AC_MSG_ERROR([Can't enable TCP wrappers!])
424 # do IDENT requests using libident?
428 [ --with-ident enable "IDENT" ("AUTH") protocol support],
429 [ if test "$withval" != "no"; then
430 if test "$withval" != "yes"; then
431 CFLAGS="-I$withval/include $CFLAGS"
432 CPPFLAGS="-I$withval/include $CPPFLAGS"
433 LDFLAGS="-L$withval/lib $LDFLAGS"
435 AC_CHECK_LIB(ident, ident_id)
436 AC_CHECK_FUNCS(ident_id, x_identauth_on=yes,
437 AC_MSG_ERROR([Can't enable IDENT support!])
442 if test "$x_identauth_on" = "yes"; then
443 AC_DEFINE(IDENTAUTH, 1)
444 AC_CHECK_HEADERS(ident.h,,AC_MSG_ERROR([required C header missing!]))
447 # compile in PAM support?
451 [ --with-pam enable user authentication using PAM],
452 [ if test "$withval" != "no"; then
453 if test "$withval" != "yes"; then
454 CFLAGS="-I$withval/include $CFLAGS"
455 CPPFLAGS="-I$withval/include $CPPFLAGS"
456 LDFLAGS="-L$withval/lib $LDFLAGS"
458 AC_CHECK_LIB(pam, pam_authenticate)
459 AC_CHECK_FUNCS(pam_authenticate, x_pam_on=yes,
460 AC_MSG_ERROR([Can't enable PAM support!])
465 if test "$x_pam_on" = "yes"; then
467 AC_CHECK_HEADERS(security/pam_appl.h,pam_ok=yes)
468 if test "$pam_ok" != "yes"; then
469 AC_CHECK_HEADERS(pam/pam_appl.h,pam_ok=yes,
470 AC_MSG_ERROR([required C header missing!]))
474 # compile in IRC+ protocol support?
477 AC_ARG_ENABLE(ircplus,
478 [ --disable-ircplus disable IRC+ protocol],
479 if test "$enableval" = "no"; then x_ircplus_on=no; fi
481 if test "$x_ircplus_on" = "yes"; then
482 AC_DEFINE(IRCPLUS, 1)
485 # enable support for IPv6?
488 [ --enable-ipv6 enable IPv6 protocol support],
489 if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
491 if test "$x_ipv6_on" = "yes"; then
492 # getaddrinfo() and getnameinfo() are optional when not compiling
493 # with IPv6 support, but are required for IPv6 to work!
495 getaddrinfo getnameinfo \
496 ],,AC_MSG_ERROR([required function missing for IPv6 support!]))
497 AC_DEFINE(WANT_IPV6, 1)
500 # compile in IRC "sniffer"?
502 x_sniffer_on=no; x_debug_on=no
503 AC_ARG_ENABLE(sniffer,
504 [ --enable-sniffer enable IRC traffic sniffer (enables debug mode)],
505 if test "$enableval" = "yes"; then
506 AC_DEFINE(SNIFFER, 1)
507 x_sniffer_on=yes; x_debug_on=yes
511 # enable additional debugging code?
514 [ --enable-debug show additional debug output],
515 if test "$enableval" = "yes"; then x_debug_on=yes; fi
517 if test "$x_debug_on" = "yes"; then
519 test "$GCC" = "yes" && CFLAGS="-pedantic $CFLAGS"
520 AC_CHECK_FUNCS(mtrace)
523 # enable "strict RFC rules"?
526 AC_ARG_ENABLE(strict-rfc,
527 [ --enable-strict-rfc strict RFC conformance -- may break clients!],
528 if test "$enableval" = "yes"; then
529 AC_DEFINE(STRICT_RFC, 1)
536 AC_DEFINE_UNQUOTED(TARGET_CPU, "$target_cpu" )
537 AC_DEFINE_UNQUOTED(TARGET_VENDOR, "$target_vendor" )
538 AC_DEFINE_UNQUOTED(TARGET_OS, "$target_os" )
540 # Add additional CFLAGS, eventually specified on the command line, but after
541 # running this configure script. Useful for "-Werror" for example.
542 test -n "$CFLAGS_END" && CFLAGS="$CFLAGS $CFLAGS_END"
544 # -- Generate files --
551 src/portab/Makefile \
552 src/ipaddr/Makefile \
554 src/ngircd/Makefile \
555 src/testsuite/Makefile \
558 contrib/Anope/Makefile \
559 contrib/Debian/Makefile \
560 contrib/MacOSX/Makefile \
561 contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
562 contrib/MacOSX/ngIRCd.pmdoc/Makefile \
565 type dpkg >/dev/null 2>&1
566 if test $? -eq 0; then
567 # Generate debian/ link if the dpkg command exists
568 # (read: if we are running on a debian compatible system)
569 echo "creating Debian-specific links ..."
570 test -f debian/rules || ln -s contrib/Debian debian
576 echo "ngIRCd $PACKAGE_VERSION has been configured with the following options:"
579 # Someone please show me a better way :) [borrowed by OpenSSH]
580 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
581 S=`eval echo ${sbindir}` ; S=`eval echo ${S}`
582 C=`eval echo ${sysconfdir}` ; C=`eval echo ${C}`
583 M=`eval echo ${mandir}` ; M=`eval echo ${M}`
584 D=`eval echo ${docdir}` ; D=`eval echo ${D}`
586 echo " Target: ${target}"
587 test "$target" != "$host" && echo " Host: ${host}"
588 echo " Compiler: ${CC}"
589 test -n "$CFLAGS" && echo " Compiler flags: ${CFLAGS}"
590 test -n "$CPPFLAGS" && echo " Preprocessor flags: ${CPPFLAGS}"
591 test -n "$LDFLAGS" && echo " Linker flags: ${LDFLAGS}"
592 test -n "$LIBS" && echo " Libraries: ${LIBS}"
594 echo " 'ngircd' binary: $S"
595 echo " Configuration file: $C"
596 echo " Manual pages: $M"
597 echo " Documentation: $D"
600 echo $ECHO_N " Syslog support: $ECHO_C"
601 test "$x_syslog_on" = "yes" \
602 && echo $ECHO_N "yes $ECHO_C" \
603 || echo $ECHO_N "no $ECHO_C"
604 echo $ECHO_N " Enable debug code: $ECHO_C"
605 test "$x_debug_on" = "yes" \
609 echo $ECHO_N " zlib compression: $ECHO_C"
610 test "$x_zlib_on" = "yes" \
611 && echo $ECHO_N "yes $ECHO_C" \
612 || echo $ECHO_N "no $ECHO_C"
613 echo $ECHO_N " IRC sniffer: $ECHO_C"
614 test "$x_sniffer_on" = "yes" \
618 echo $ECHO_N " Use TCP Wrappers: $ECHO_C"
619 test "$x_tcpwrap_on" = "yes" \
620 && echo $ECHO_N "yes $ECHO_C" \
621 || echo $ECHO_N "no $ECHO_C"
622 echo $ECHO_N " Strict RFC mode: $ECHO_C"
623 test "$x_strict_rfc_on" = "yes" \
627 echo $ECHO_N " IDENT support: $ECHO_C"
628 test "$x_identauth_on" = "yes" \
629 && echo $ECHO_N "yes $ECHO_C" \
630 || echo $ECHO_N "no $ECHO_C"
631 echo $ECHO_N " IRC+ protocol: $ECHO_C"
632 test "$x_ircplus_on" = "yes" \
636 echo $ECHO_N " IPv6 protocol: $ECHO_C"
637 test "$x_ipv6_on" = "yes" \
638 && echo $ECHO_N "yes $ECHO_C" \
639 || echo $ECHO_N "no $ECHO_C"
640 echo $ECHO_N " I/O backend: $ECHO_C"
641 echo "\"$x_io_backend\""
643 echo $ECHO_N " PAM support: $ECHO_C"
644 test "$x_pam_on" = "yes" \
645 && echo $ECHO_N "yes $ECHO_C" \
646 || echo $ECHO_N "no $ECHO_C"
647 echo $ECHO_N " SSL support: $ECHO_C"