1 dnl $Id: configure.ac 26260 2008-12-10 04:08:39Z 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 26260 2008-12-10 04:08:39Z androsyn $])
12 AC_INIT([librb],[devel])
13 AM_INIT_AUTOMAKE([subdir-objects])
14 AM_SILENT_RULES([yes])
16 AM_CONFIG_HEADER(include/librb_config.h)
18 AC_PREFIX_DEFAULT(/usr/local/librb)
21 dnl Checks for programs.
24 if test x"$ac_cv_prog_cc_c99" = "xno"; then
25 AC_ERROR([charybdis requires a C99 capable compiler])
47 AC_PATH_PROG(AUTOMAKE, automake)
48 AC_PATH_PROG(ACLOCAL, aclocal)
49 AC_PATH_PROG(AUTOHEADER, autoheader)
55 AC_PATH_PROG(TOUCH, touch)
60 LIBTOOL="$LIBTOOL --silent"
64 AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
65 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
68 AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
69 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
70 AC_CHECK_HEADER(windows.h, , [AC_MSG_ERROR([** MinGW and no windows.h. I give up.])])
71 AC_CHECK_HEADER(winsock2.h, , [AC_MSG_ERROR([** MinGW and no winsock2.h. I give up.])])
72 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1, [Have WINSOCK2_H])
73 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1, [Have WINSOCK_H])
74 LIBS="$LIBS -lws2_32 -liphlpapi"
78 CPPFLAGS="$CFLAGS -D_ALL_SOURCE -D_XOPEN_SOURCE=500"
81 CPPFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS -D_XPG4_2"
87 AM_CONDITIONAL([MINGW], [test "$is_mingw" = "yes"])
90 # backwards support for IRC_CFLAGS
91 CFLAGS="$IRC_CFLAGS $CFLAGS -Wall"
93 dnl use directory structure of cached as default (hack)
94 if test "$libexecdir" = '${exec_prefix}/libexec' &&
95 test "$localstatedir" = '${prefix}/var'; then
96 libexecdir='${bindir}'
97 localstatedir='${prefix}'
106 dnl Checks for header files.
109 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 sys/timerfd.h linux/tcp.h])
112 dnl Networking Functions
113 dnl ====================
115 AC_SEARCH_LIBS(socket, [socket],,)
118 AC_CHECK_MEMBER([struct sockaddr.sa_len], [AC_DEFINE(SOCKADDR_IN_HAS_LEN, 1, [Define to 1 if sockaddr has a 'sa_len'
120 #ifdef HAVE_SYS_TYPES_H
121 #include <sys/types.h>
123 #ifdef HAVE_SYS_SOCKET_H
124 #include <sys/socket.h>
126 #ifdef HAVE_WINSOCK2_H
127 #include <winsock2.h>
131 AC_CHECK_TYPE([socklen_t], rb_cv_socklen_t=socklen_t,[
132 AC_MSG_CHECKING([for socklen_t equivalent])
133 AC_CACHE_VAL([rb_cv_socklen_t],
135 # Systems have either "struct sockaddr *" or
136 # "void *" as the second argument to getpeername
138 for arg2 in "struct sockaddr" void; do
139 for t in int size_t unsigned long "unsigned long"; do
141 #ifdef HAVE_SYS_TYPES_H
142 #include <sys/types.h>
144 #ifdef HAVE_SYS_SOCKET_H
145 #include <sys/socket.h>
147 #ifdef HAVE_WINSOCK2_H
148 #include <winsock2.h>
150 int getpeername (int, $arg2 *, $t *);
153 getpeername(0,0,&len);
161 if test "x$rb_cv_socklen_t" = x; then
162 AC_MSG_WARN([Cannot find a type to use in place of socklen_t using int])
166 AC_MSG_RESULT($rb_cv_socklen_t)],
167 [#include <sys/types.h>
168 #include <sys/socket.h>])
170 rb_socklen_t=$rb_cv_socklen_t
176 AC_ARG_ENABLE(ipv6,AC_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),[ipv6=$enableval],[ipv6=yes])
178 if test x$ipv6 != xyes; then
184 AC_MSG_NOTICE([Disabling IPv6 support: PF_INET6 not found])
188 if test "X$have_v6" = "Xyes"; then
189 RB_TYPE_STRUCT_SOCKADDR_IN6([], [
190 AC_MSG_NOTICE([Disabling IPv6 support: struct sockaddr_in6 not found])
197 AC_CHECK_TYPES([struct sockaddr_storage],[
198 rb_have_sockaddr_storage=yes
200 #include <sys/types.h>
201 #include <sys/socket.h>
205 dnl Check for stdarg.h - if we cant find it, halt configure
206 AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - librb will not compile without it **])])
208 AC_CHECK_TYPE([sa_family_t], [],
209 [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
210 [[#include <sys/types.h>
211 #include <sys/socket.h>]])
214 dnl check for various functions...
215 AC_CHECK_FUNCS([snprintf vsnprintf 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 timerfd_create])
217 AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep]))
218 AC_SEARCH_LIBS(timer_create, rt, AC_DEFINE(HAVE_TIMER_CREATE, 1, [Define if you have timer_create]))
219 RB_CHECK_TIMER_CREATE
220 RB_CHECK_TIMERFD_CREATE
226 AC_MSG_CHECKING(for /dev/poll)
227 if test -c "/dev/poll"; then
229 AC_DEFINE(HAVE_DEVPOLL, [1], [Define to 1 if you have devpoll])
235 if test "$is_mingw" = "yes"; then
236 AC_DEFINE(HAVE_WIN32, [1], [Define to 1 if you are on windows])
241 AC_MSG_CHECKING(for OpenSSL)
242 AC_ARG_ENABLE(openssl,
243 [AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
244 AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
245 [cf_enable_openssl=$enableval],
246 [cf_enable_openssl="auto"])
248 if test "$cf_enable_openssl" != "no" ; then
249 cf_openssl_basedir=""
250 if test "$cf_enable_openssl" != "auto" &&
251 test "$cf_enable_openssl" != "yes" ; then
252 dnl Support for --enable-openssl=/some/place
253 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
255 dnl Do the auto-probe here. Check some common directory paths.
256 for dirs in /usr/local/ssl /usr/pkg /usr/local \
257 /usr/local/openssl ; do
258 if test -f "${dirs}/include/openssl/opensslv.h" ; then
259 cf_openssl_basedir="${dirs}"
265 dnl Now check cf_openssl_found to see if we found anything.
266 if test ! -z "$cf_openssl_basedir"; then
267 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
268 SSL_CFLAGS="-I${cf_openssl_basedir}/include"
269 SSL_LIBS="-L${cf_openssl_basedir}/lib"
271 dnl OpenSSL wasn't found in the directory specified. Naughty
273 cf_openssl_basedir=""
276 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
277 dnl are in /usr/include and /usr/lib. In this case, we don't want to
278 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
279 dnl We can't do this check above, because some people want two versions
280 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
281 dnl and they want /usr/local/ssl to have preference.
282 if test -f "/usr/include/openssl/opensslv.h" ; then
283 cf_openssl_basedir="/usr"
287 dnl If we have a basedir defined, then everything is okay. Otherwise,
288 dnl we have a problem.
289 if test ! -z "$cf_openssl_basedir"; then
290 AC_MSG_RESULT($cf_openssl_basedir)
291 cf_enable_openssl="yes"
293 AC_MSG_RESULT([not found. Specify a correct path?])
294 cf_enable_openssl="no"
296 unset cf_openssl_basedir
298 dnl If --disable-openssl was specified
299 AC_MSG_RESULT(disabled)
302 save_CPPFLAGS="$CPPFLAGS"
303 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS"
305 LIBS="$LIBS $SSL_LIBS"
306 if test "$cf_enable_openssl" != no; then
307 dnl Check OpenSSL version (must be 0.9.7 or above!)
308 AC_MSG_CHECKING(for OpenSSL 0.9.7 or above)
311 [#include <openssl/opensslv.h>
312 #include <stdlib.h>],
313 [[if (OPENSSL_VERSION_NUMBER >= 0x00907000)
314 exit(0); else exit(1);]])],
315 cf_enable_openssl=yes,
316 cf_enable_openssl=no,
317 cf_enable_openssl=no)
319 if test "$cf_enable_openssl" != no; then
322 AC_MSG_RESULT(no - OpenSSL support disabled)
328 if test "$cf_enable_openssl" != no; then
329 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
330 AC_CHECK_LIB(crypto, RAND_status,
331 [cf_enable_openssl=yes],
332 [cf_enable_openssl=no])
335 if test "$cf_enable_openssl" != no; then
336 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
337 AC_CHECK_LIB(ssl, SSL_read,
338 [SSL_LIBS="$SSL_LIBS -lssl -lcrypto"],
339 [cf_enable_openssl=no], [-lcrypto])
344 AC_ARG_ENABLE(mbedtls,
345 [AC_HELP_STRING([--enable-mbedtls], [Enable mbedTLS support.])
346 AC_HELP_STRING([--disable-mbedtls], [Disable mbedTLS support.])],
347 [cf_enable_mbedtls=$enableval],
348 [cf_enable_mbedtls="auto"])
350 if test "$cf_enable_mbedtls" != no; then
351 save_CPPFLAGS="$CPPFLAGS"
353 LIBS="$LIBS $MBEDTLS_LIBS"
354 AC_CHECK_LIB(mbedtls, mbedtls_ssl_init, [
355 MBEDTLS_LIBS="$MBEDTLS_LIBS -lmbedtls -lmbedcrypto -lmbedx509"
356 cf_enable_mbedtls=yes
357 ], [cf_enable_mbedtls=no], [-lmbedcrypto -lmbedx509])
361 AC_MSG_CHECKING(for GnuTLS)
362 AC_ARG_ENABLE(gnutls,
363 [AC_HELP_STRING([--enable-gnutls],[Enable GnuTLS support.])
364 AC_HELP_STRING([--disable-gnutls],[Disable GnuTLS support.])],
365 [cf_enable_gnutls=$enableval],
366 [cf_enable_gnutls="auto"])
368 if test "$cf_enable_gnutls" != no; then
369 PKG_CHECK_MODULES(GNUTLS, [gnutls], [
370 cf_enable_gnutls="yes"
371 ], [cf_enable_gnutls="no"])
374 dnl mbed TLS is given highest preference when no specified TLS library is provided
375 if test "$cf_enable_openssl" = "auto" -a "$cf_enable_mbedtls" = "yes"; then
376 cf_enable_openssl="no"
379 if test "$cf_enable_gnutls" = "auto" -a "$cf_enable_openssl" = "yes" -a "$cf_enable_mbedtls" = "yes"; then
380 cf_enable_gnutls="no"
383 if test x"$cf_enable_openssl" != xno; then
384 AC_DEFINE(HAVE_OPENSSL,1,[Has OpenSSL])
390 elif test x"$cf_enable_mbedtls" != xno; then
391 AC_DEFINE(HAVE_MBEDTLS, 1, [Has mbedTLS])
397 elif test x"$cf_enable_gnutls" != xno; then
398 AC_DEFINE(HAVE_GNUTLS, 1, [Has GnuTLS])
409 CPPFLAGS="$save_CPPFLAGS"
412 dnl End OpenSSL detection
417 dnl Debug-related options
418 dnl =====================
420 AC_ARG_ENABLE(assert,
421 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
422 [assert=$enableval], [assert=no])
424 if test "$assert" = no; then
425 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
426 elif test "$assert" = soft; then
427 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
428 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
429 elif test "$assert" = yes; then
433 AC_MSG_CHECKING(if you want to do a profile build)
434 AC_ARG_ENABLE(profile,
435 AC_HELP_STRING([--enable-profile],[Enable profiling]),
436 [profile=$enableval], [profile=no])
438 if test "$profile" = yes; then
439 if test "$ac_cv_c_compiler_gnu" = yes; then
440 CFLAGS="$CFLAGS -pg -static"
441 AC_MSG_RESULT([yes, adding -pg -static])
442 AC_DEFINE(RATBOX_PROFILE, 1, [Defined to mark profiling is enabled])
444 AC_MSG_RESULT([no, profile builds only work with gcc])
450 AC_ARG_ENABLE(warnings,
451 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
452 [CFLAGS="$CFLAGS -Wall -Werror -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -W -Wno-unused -Wunused-function -Wunused-variable"],[])
460 AC_SUBST(GNUTLS_CFLAGS)
461 AC_SUBST(GNUTLS_LIBS)
462 AC_SUBST(MBEDTLS_CFLAGS)
463 AC_SUBST(MBEDTLS_LIBS)
465 if test "$prefix" = "NONE"; then
466 AC_DEFINE_UNQUOTED(RB_PREFIX, "$ac_default_prefix", [Prefix where librb is installed.])
470 dnl Don't get bitten by Cygwin's stupidity if the user specified
471 dnl a custom prefix with a trailing slash
473 prefix=`echo $prefix | sed 's/\/$//'`
474 AC_DEFINE_UNQUOTED(RB_PREFIX, "$prefix", [Prefix where librb is installed.])
480 AC_CONFIG_COMMANDS([include/librb-config.h],
482 outfile=include/librb-config.h.tmp
483 cat > $outfile <<\_______EOF
485 * librb-config.h: librb config file. Please modify configure.ac
488 #ifndef __LIBRB_CONFIG_H
489 #define __LIBRB_CONFIG_H
493 if test "x$rb_have_ipv6" = "xyes"; then
494 echo "#define RB_IPV6 1" >> $outfile
497 if test "x$rb_windows_h" = "xyes"; then
498 echo '#define WIN32_LEAN_AND_MEAN 1' >> $outfile
499 echo '#include <windows.h>' >> $outfile
500 echo '#include <winsock2.h>' >> $outfile
501 echo '#include <iphlpapi.h>' >> $outfile
504 if test "x$rb_alloca_h" = "xyes"; then
505 echo '#define RB_HAVE_ALLOCA_H 1' >> $outfile
508 if test "x$rb_header_stdc" = "xyes"; then
509 echo '#include <stdlib.h>' >> $outfile
510 echo '#include <stddef.h>' >> $outfile
511 elif test "x$rb_header_stdlib" = "xyes"; then
512 echo '#include <stdlib.h>' >> $outfile
515 if test "x$rb_header_string_h" = "xyes"; then
516 echo '#include <string.h>' >> $outfile
519 if test "x$rb_stdint_h" = "xyes"; then
520 echo '#include <stdint.h>' >> $outfile
523 if test "x$rb_inttypes_h" = "xyes"; then
524 echo '#include <inttypes.h>' >> $outfile
527 if test "x$rb_sys_types_h" = "xyes"; then
528 echo '#include <sys/types.h>' >> $outfile
530 if test "x$rb_sys_time_h" = "xyes"; then
531 echo '#include <sys/time.h>' >> $outfile
533 if test "x$rb_sys_stat_h" = "xyes"; then
534 echo '#include <sys/stat.h>' >> $outfile
536 if test "x$rb_time_h" = "xyes"; then
537 echo '#include <time.h>' >> $outfile
540 if test "x$rb_sys_socket_h" = "xyes"; then
541 echo '#include <sys/socket.h>' >> $outfile
544 if test "x$rb_netinet_in_h" = "xyes"; then
545 echo '#include <netinet/in.h>' >> $outfile
548 if test "x$rb_arpa_inet_h" = "xyes"; then
549 echo '#include <arpa/inet.h>' >> $outfile
552 if test "x$rb_unistd_h" = "xyes"; then
553 echo '#include <unistd.h>' >> $outfile
556 if test "x$rb_crypt_h" = "xyes"; then
557 echo '#include <crypt.h>' >> $outfile
560 if test "x$rb_errno_h" = "xyes"; then
561 echo '#include <errno.h>' >> $outfile
564 echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile
567 if test "x$rb_sockaddr_sa_len" = "xyes"; then
568 echo '#define RB_SOCKADDR_HAS_SA_LEN 1' >> $outfile
571 if test "x$rb_sockaddr_storage" = "xyes"; then
572 echo '#define rb_sockaddr_storage sockaddr_storage' >> $outfile
574 echo 'struct rb_sockaddr_storage { uint8_t _padding[[128]]; };' >> $outfile
577 cat >> $outfile <<\_______EOF
578 #endif /* __LIBRB_CONFIG_H */
581 if cmp -s $outfile include/librb-config.h; then
582 AC_MSG_NOTICE([include/librb-config.h is unchanged])
585 ${rb_mv} $outfile include/librb-config.h
589 if test x$ac_cv_header_stdc = xyes; then
592 if test x$ac_cv_header_stdlib_h = xyes; then
593 rb_header_stdlib_h=yes
595 if test x$ac_cv_header_string_h = xyes; then
596 rb_header_string_h=yes
598 if test x$ac_cv_header_memory_h = xyes; then
599 rb_header_memory_h=yes
601 if test "x${ac_cv_working_alloca_h+set}" = xset ; then
602 rb_alloca_h="$ac_cv_working_alloca_h"
604 rb_alloc_h="$ac_cv_header_alloca_h"
606 if test x$ac_cv_member_struct_sockaddr_sa_len = xyes; then
607 rb_sockaddr_sa_len=yes
609 if test x$ac_cv_header_sys_socket_h = xyes; then
612 if test x$ac_cv_header_sys_types_h = xyes; then
615 if test x$ac_cv_header_sys_stat_h = xyes; then
618 if test x$ac_cv_header_sys_time_h = xyes; then
621 if test x$ac_cv_header_time = xyes; then
625 if test x$ac_cv_header_stdint_h = xyes; then
628 if test x$ac_cv_header_inttypes_h = xyes; then
631 if test x$ac_cv_header_netinet_in_h = xyes; then
635 if test x$ac_cv_header_crypt_h = xyes; then
638 if test x$ac_cv_header_errno_h = xyes; then
641 if test x$ac_cv_header_unistd_h = xyes; then
644 if test x$ac_cv_header_windows_h = xyes; then
647 if test x$ac_cv_header_winsock2_h = xyes; then
651 rb_socklen_t=$rb_socklen_t
653 if test "x$rb_have_sockaddr_storage" = "xyes"; then
654 rb_sockaddr_storage="yes"
656 rb_sockaddr_storage="no"
659 rb_have_ipv6="$have_v6"
678 dnl Make it look sexay!
681 echo "Compiling $PACKAGE_NAME $PACKAGE_VERSION"
684 echo "Installing into: $prefix"
686 echo "IPv6 support ................... $have_v6"
687 echo "Assert debugging ............... $assert"
688 echo "SSL Type........................ $SSL_TYPE"