1 dnl $Id: configure.ac 25689 2008-07-10 17:13:27Z androsyn $
2 dnl Process this file with autoconf to produce a configure script.
4 dnl TODO: clean up all the OpenSSL and shared module checking stuff;
5 dnl the most major changes have already been made and it looks like
6 dnl said functions need to be just about as complex as they already are.
9 AUTOMAKE_OPTIONS = 1.10
10 dnl Sneaky way to get an Id tag into the configure script
11 AC_COPYRIGHT([$Id: configure.ac 25689 2008-07-10 17:13:27Z androsyn $])
12 AC_INIT([libratbox],[devel])
13 AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME, AC_PACKAGE_VERSION, -)
15 AM_CONFIG_HEADER(include/libratbox_config.h)
17 AC_PREFIX_DEFAULT(/usr/local/libratbox)
20 dnl Checks for programs.
23 if test x"$ac_cv_prog_cc_c99" = "xno"; then
24 AC_ERROR([ircd-ratbox requires a C99 capable compiler])
45 AC_PATH_PROG(AUTOMAKE, automake)
46 AC_PATH_PROG(ACLOCAL, aclocal)
47 AC_PATH_PROG(AUTOHEADER, autoheader)
55 AC_PATH_PROG(RANLIB, ranlib)
56 AC_PATH_PROG(TOUCH, touch)
61 LIBTOOL="$LIBTOOL --silent"
63 AC_CONFIG_SUBDIRS(libltdl)
68 AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
69 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
72 AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
73 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
74 AC_CHECK_HEADER(windows.h, , [AC_MSG_ERROR([** MinGW and no windows.h. I give up.])])
75 AC_CHECK_HEADER(winsock2.h, , [AC_MSG_ERROR([** MinGW and no winsock2.h. I give up.])])
76 LIBS="$LIBS -lws2_32 -liphlpapi"
80 CPPFLAGS="$CFLAGS -D_ALL_SOURCE -D_XOPEN_SOURCE=500"
83 CPPFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS -D_XPG4_2 -D__EXTENSIONS__"
89 AM_CONDITIONAL([MINGW], [test "$is_mingw" = "yes"])
92 # backwards support for IRC_CFLAGS
93 CFLAGS="$IRC_CFLAGS $CFLAGS -O0 -Wall"
95 dnl use directory structure of cached as default (hack)
96 if test "$libexecdir" = '${exec_prefix}/libexec' &&
97 test "$localstatedir" = '${prefix}/var'; then
98 libexecdir='${bindir}'
99 localstatedir='${prefix}'
108 dnl Checks for header files.
111 AC_CHECK_HEADERS([crypt.h unistd.h sys/socket.h sys/stat.h sys/time.h time.h netinet/in.h arpa/inet.h errno.h sys/uio.h spawn.h sys/poll.h sys/epoll.h sys/select.h sys/devpoll.h sys/event.h port.h signal.h sys/signalfd.h])
114 dnl Networking Functions
115 dnl ====================
117 AC_SEARCH_LIBS(socket, [socket],,)
120 AC_CHECK_MEMBER([struct sockaddr.sa_len], [AC_DEFINE(SOCKADDR_IN_HAS_LEN, 1, [Define to 1 if sockaddr has a 'sa_len'
122 #ifdef HAVE_SYS_TYPES_H
123 #include <sys/types.h>
125 #ifdef HAVE_SYS_SOCKET_H
126 #include <sys/socket.h>
128 #ifdef HAVE_WINSOCK2_H
129 #include <winsock2.h>
133 AC_CHECK_TYPE([socklen_t], rb_socklen_t=socklen_t,[
134 AC_MSG_CHECKING([for socklen_t equivalent])
135 AC_CACHE_VAL([rb_socklen_t],
137 # Systems have either "struct sockaddr *" or
138 # "void *" as the second argument to getpeername
140 for arg2 in "struct sockaddr" void; do
141 for t in int size_t unsigned long "unsigned long"; do
143 #include <sys/types.h>
144 #include <sys/socket.h>
146 int getpeername (int, $arg2 *, $t *);
149 getpeername(0,0,&len);
157 if test "x$rb_socklen_t" = x; then
158 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
161 AC_MSG_RESULT($rb_socklen_t)],
162 [#include <sys/types.h>
163 #include <sys/socket.h>])
169 AC_ARG_ENABLE(ipv6,AC_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),[ipv6=$enableval],[ipv6=yes])
171 if test x$ipv6 != xyes; then
177 AC_MSG_NOTICE([Disabling IPv6 support: PF_INET6 not found])
181 if test "X$have_v6" = "Xyes"; then
182 RB_TYPE_STRUCT_SOCKADDR_IN6([], [
183 AC_MSG_NOTICE([Disabling IPv6 support: struct sockaddr_in6 not found])
190 AC_CHECK_TYPES([struct sockaddr_storage],[
191 rb_have_sockaddr_storage=yes
193 #include <sys/types.h>
194 #include <sys/socket.h>
199 AC_SEARCH_LIBS(crypt, [crypt descrypt],,)
202 CRYPT_LIB=$ac_cv_search_crypt
204 if test "$CRYPT_LIB" = "none required"; then
206 elif test "$CRYPT_LIB" = no; then
208 AC_DEFINE(NEED_CRYPT, 1, [Define if your system needs crypt.])
212 AM_CONDITIONAL([NEED_CRYPT], [test x"$need_crypt" = "xyes"])
217 dnl Check for stdarg.h - if we cant find it, halt configure
218 AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - libratbox will not compile without it **])])
220 AC_CHECK_TYPE([sa_family_t], [],
221 [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
222 [[#include <sys/types.h>
223 #include <sys/socket.h>]])
226 dnl check for various functions...
227 AC_CHECK_FUNCS([socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strlcpy strlcat strnlen fstat signalfd select poll kevent port_create epoll_ctl arc4random getrusage])
229 AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep]))
230 AC_SEARCH_LIBS(timer_create, rt, AC_DEFINE(HAVE_TIMER_CREATE, 1, [Define if you have timer_create]))
231 RB_CHECK_TIMER_CREATE
237 AC_MSG_CHECKING(for /dev/poll)
238 if test -c "/dev/poll"; then
240 AC_DEFINE(HAVE_DEVPOLL, [1], [Define to 1 if you have devpoll])
246 if test "$is_mingw" = "yes"; then
247 AC_DEFINE(HAVE_WIN32, [1], [Define to 1 if you are on windows])
252 AC_MSG_CHECKING(for OpenSSL)
253 AC_ARG_ENABLE(openssl,
254 [AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
255 AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
256 [cf_enable_openssl=$enableval],
257 [cf_enable_openssl="auto"])
259 if test "$cf_enable_openssl" != "no" ; then
260 cf_openssl_basedir=""
261 if test "$cf_enable_openssl" != "auto" &&
262 test "$cf_enable_openssl" != "yes" ; then
263 dnl Support for --enable-openssl=/some/place
264 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
266 dnl Do the auto-probe here. Check some common directory paths.
267 for dirs in /usr/local/ssl /usr/pkg /usr/local \
268 /usr/local/openssl ; do
269 if test -f "${dirs}/include/openssl/opensslv.h" ; then
270 cf_openssl_basedir="${dirs}"
276 dnl Now check cf_openssl_found to see if we found anything.
277 if test ! -z "$cf_openssl_basedir"; then
278 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
279 SSL_CFLAGS="-I${cf_openssl_basedir}/include"
280 SSL_LIBS="-L${cf_openssl_basedir}/lib"
282 dnl OpenSSL wasn't found in the directory specified. Naughty
284 cf_openssl_basedir=""
287 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
288 dnl are in /usr/include and /usr/lib. In this case, we don't want to
289 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
290 dnl We can't do this check above, because some people want two versions
291 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
292 dnl and they want /usr/local/ssl to have preference.
293 if test -f "/usr/include/openssl/opensslv.h" ; then
294 cf_openssl_basedir="/usr"
298 dnl If we have a basedir defined, then everything is okay. Otherwise,
299 dnl we have a problem.
300 if test ! -z "$cf_openssl_basedir"; then
301 AC_MSG_RESULT($cf_openssl_basedir)
302 cf_enable_openssl="yes"
304 AC_MSG_RESULT([not found. Specify a correct path?])
305 cf_enable_openssl="no"
307 unset cf_openssl_basedir
309 dnl If --disable-openssl was specified
310 AC_MSG_RESULT(disabled)
313 save_CPPFLAGS="$CPPFLAGS"
314 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS"
316 LIBS="$LIBS $SSL_LIBS"
317 if test "$cf_enable_openssl" != no; then
318 dnl Check OpenSSL version (must be 0.9.7 or above!)
319 AC_MSG_CHECKING(for OpenSSL 0.9.7 or above)
322 [#include <openssl/opensslv.h>
323 #include <stdlib.h>],
324 [[if (OPENSSL_VERSION_NUMBER >= 0x00907000)
325 exit(0); else exit(1);]]),
326 cf_enable_openssl=yes,
327 cf_enable_openssl=no,
328 cf_enable_openssl=no)
330 if test "$cf_enable_openssl" != no; then
333 AC_MSG_RESULT(no - OpenSSL support disabled)
339 if test "$cf_enable_openssl" != no; then
340 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
341 AC_CHECK_LIB(crypto, RAND_status,
342 [cf_enable_openssl=yes],
343 [cf_enable_openssl=no])
347 if test "$cf_enable_openssl" != no; then
348 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
349 AC_CHECK_LIB(ssl, SSL_read,
350 [SSL_LIBS="-lssl -lcrypto"],
351 [cf_enable_openssl=no], [-lcrypto])
357 AC_MSG_CHECKING(for GnuTLS)
358 AC_ARG_ENABLE(gnutls,
359 [AC_HELP_STRING([--enable-gnutls],[Enable GnuTLS support.])
360 AC_HELP_STRING([--disable-gnutls],[Disable GnuTLS support.])],
361 [cf_enable_gnutls=$enableval],
362 [cf_enable_gnutls="auto"])
364 if test "$cf_enable_gnutls" != no; then
365 PKG_CHECK_MODULES(GNUTLS, [gnutls], [
366 cf_enable_gnutls="yes"
367 ], [cf_enable_gnutls="no"])
370 if test "$cf_enable_gnutls" = "auto" -a "$cf_enable_openssl" = "yes"; then
371 cf_enable_gnutls="no"
374 if test x"$cf_enable_openssl" != xno; then
375 AC_DEFINE(HAVE_OPENSSL,1,[Has OpenSSL])
379 elif test x"$cf_enable_gnutls" != xno; then
380 AC_DEFINE(HAVE_GNUTLS, 1, [Has GnuTLS])
389 CPPFLAGS="$save_CPPFLAGS"
392 dnl End OpenSSL detection
397 dnl Debug-related options
398 dnl =====================
400 AC_ARG_ENABLE(assert,
401 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
402 [assert=$enableval], [assert=no])
404 if test "$assert" = no; then
405 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
406 elif test "$assert" = soft; then
407 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
408 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
409 elif test "$assert" = yes; then
413 AC_MSG_CHECKING(if you want to do a profile build)
414 AC_ARG_ENABLE(profile,
415 AC_HELP_STRING([--enable-profile],[Enable profiling]),
416 [profile=$enableval], [profile=no])
418 if test "$profile" = yes; then
419 if test "$ac_cv_c_compiler_gnu" = yes; then
420 CFLAGS="$CFLAGS -pg -static"
421 AC_MSG_RESULT([yes, adding -pg -static])
422 AC_DEFINE(RATBOX_PROFILE, 1, [Defined to mark profiling is enabled])
424 AC_MSG_RESULT([no, profile builds only work with gcc])
430 AC_ARG_ENABLE(balloc,
431 AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
432 [balloc=$enableval], [balloc=yes])
434 if test "$balloc" = no; then
435 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
438 AC_ARG_ENABLE(warnings,
439 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
440 [CFLAGS="$CFLAGS -Wall -Werror -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -W -Wno-unused -Wunused-function -Wunused-variable"],[])
448 AC_SUBST(GNUTLS_CFLAGS)
449 AC_SUBST(GNUTLS_LIBS)
451 if test "$prefix" = "NONE"; then
452 AC_DEFINE_UNQUOTED(RB_PREFIX, "$ac_default_prefix", [Prefix where libratbox is installed.])
456 dnl Don't get bitten by Cygwin's stupidity if the user specified
457 dnl a custom prefix with a trailing slash
459 prefix=`echo $prefix | sed 's/\/$//'`
460 AC_DEFINE_UNQUOTED(RB_PREFIX, "$prefix", [Prefix where libratbox is installed.])
466 AC_CONFIG_COMMANDS([include/librb-config.h],
468 outfile=include/librb-config.h.tmp
469 cat > $outfile <<\_______EOF
471 * librb-config.h: libratbox config file. Please modify configure.ac
474 #ifndef __LIBRB_CONFIG_H
475 #define __LIBRB_CONFIG_H
479 if test "x$rb_have_ipv6" = "xyes"; then
480 echo "#define RB_IPV6 1" >> $outfile
483 if test "x$rb_windows_h" = "xyes"; then
484 echo '#define WIN32_LEAN_AND_MEAN 1' >> $outfile
485 echo '#include <windows.h>' >> $outfile
486 echo '#include <winsock2.h>' >> $outfile
487 echo '#include <iphlpapi.h>' >> $outfile
490 if test "x$rb_alloca_h" = "xyes"; then
491 echo '#define RB_HAVE_ALLOCA_H 1' >> $outfile
494 if test "x$rb_header_stdc" = "xyes"; then
495 echo '#include <stdlib.h>' >> $outfile
496 echo '#include <stddef.h>' >> $outfile
497 elif test "x$rb_header_stdlib" = "xyes"; then
498 echo '#include <stdlib.h>' >> $outfile
501 if test "x$rb_header_string_h" = "xyes"; then
502 echo '#include <string.h>' >> $outfile
505 if test "x$rb_stdint_h" = "xyes"; then
506 echo '#include <stdint.h>' >> $outfile
509 if test "x$rb_inttypes_h" = "xyes"; then
510 echo '#include <inttypes.h>' >> $outfile
513 if test "x$rb_sys_types_h" = "xyes"; then
514 echo '#include <sys/types.h>' >> $outfile
516 if test "x$rb_sys_time_h" = "xyes"; then
517 echo '#include <sys/time.h>' >> $outfile
519 if test "x$rb_sys_stat_h" = "xyes"; then
520 echo '#include <sys/stat.h>' >> $outfile
522 if test "x$rb_time_h" = "xyes"; then
523 echo '#include <time.h>' >> $outfile
526 if test "x$rb_sys_socket_h" = "xyes"; then
527 echo '#include <sys/socket.h>' >> $outfile
530 if test "x$rb_netinet_in_h" = "xyes"; then
531 echo '#include <netinet/in.h>' >> $outfile
534 if test "x$rb_arpa_inet_h" = "xyes"; then
535 echo '#include <arpa/inet.h>' >> $outfile
538 if test "x$rb_unistd_h" = "xyes"; then
539 echo '#include <unistd.h>' >> $outfile
542 if test "x$rb_crypt_h" = "xyes"; then
543 echo '#include <crypt.h>' >> $outfile
546 if test "x$rb_errno_h" = "xyes"; then
547 echo '#include <errno.h>' >> $outfile
550 echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile
553 if test "x$rb_sockaddr_sa_len" = "xyes"; then
554 echo '#define RB_SOCKADDR_HAS_SA_LEN 1' >> $outfile
557 if test "x$rb_sockaddr_storage" = "xyes"; then
558 echo '#define rb_sockaddr_storage sockaddr_storage' >> $outfile
560 echo 'struct rb_sockaddr_storage { uint8_t _padding[128]; };' >> $outfile
563 cat >> $outfile <<\_______EOF
564 #endif /* __LIBRB_CONFIG_H */
567 if cmp -s $outfile include/librb-config.h; then
568 AC_MSG_NOTICE([include/librb-config.h is unchanged])
571 ${rb_mv} $outfile include/librb-config.h
575 if test x$ac_cv_header_stdc = xyes; then
578 if test x$ac_cv_header_stdlib_h = xyes; then
579 rb_header_stdlib_h=yes
581 if test x$ac_cv_header_string_h = xyes; then
582 rb_header_string_h=yes
584 if test x$ac_cv_header_memory_h = xyes; then
585 rb_header_memory_h=yes
587 if test "x${ac_cv_working_alloca_h+set}" = xset ; then
588 rb_alloca_h="$ac_cv_working_alloca_h"
590 rb_alloc_h="$ac_cv_header_alloca_h"
592 if test x$ac_cv_member_struct_sockaddr_sa_len = xyes; then
593 rb_sockaddr_sa_len=yes
595 if test x$ac_cv_header_sys_socket_h = xyes; then
598 if test x$ac_cv_header_sys_types_h = xyes; then
601 if test x$ac_cv_header_sys_stat_h = xyes; then
604 if test x$ac_cv_header_sys_time_h = xyes; then
607 if test x$ac_cv_header_time = xyes; then
611 if test x$ac_cv_header_stdint_h = xyes; then
614 if test x$ac_cv_header_inttypes_h = xyes; then
617 if test x$ac_cv_header_netinet_in_h = xyes; then
621 if test x$ac_cv_header_crypt_h = xyes; then
624 if test x$ac_cv_header_errno_h = xyes; then
627 if test x$ac_cv_header_unistd_h = xyes; then
630 if test x$ac_cv_header_windows_h = xyes; then
633 if test x$ac_cv_header_winsock2_h = xyes; then
637 rb_socklen_t=$rb_socklen_t
639 if test "x$rb_have_sockaddr_storage" = "xyes"; then
640 rb_sockaddr_storage="yes"
642 rb_sockaddr_storage="no"
645 rb_have_ipv6="$have_v6"
664 dnl Make it look sexay!
667 echo "Compiling $PACKAGE_NAME $PACKAGE_VERSION"
670 echo "Installing into: $prefix"
672 echo "IPv6 support ................... $have_v6"
673 echo "Assert debugging ............... $assert"
674 echo "Block allocator ................ $balloc"
675 echo "SSL Type........................ $SSL_TYPE"