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"
84 CPPFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS -D_XPG4_2 -D__EXTENSIONS__"
90 AM_CONDITIONAL([MINGW], [test "$is_mingw" = "yes"])
93 # backwards support for IRC_CFLAGS
94 CFLAGS="$IRC_CFLAGS $CFLAGS -O0 -Wall"
96 dnl use directory structure of cached as default (hack)
97 if test "$libexecdir" = '${exec_prefix}/libexec' &&
98 test "$localstatedir" = '${prefix}/var'; then
99 libexecdir='${bindir}'
100 localstatedir='${prefix}'
109 dnl Checks for header files.
112 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])
115 dnl Networking Functions
116 dnl ====================
118 AC_SEARCH_LIBS(socket, [socket],,)
121 AC_CHECK_MEMBER([struct sockaddr.sa_len], [AC_DEFINE(SOCKADDR_IN_HAS_LEN, 1, [Define to 1 if sockaddr has a 'sa_len'
123 #ifdef HAVE_SYS_TYPES_H
124 #include <sys/types.h>
126 #ifdef HAVE_SYS_SOCKET_H
127 #include <sys/socket.h>
129 #ifdef HAVE_WINSOCK2_H
130 #include <winsock2.h>
134 AC_CHECK_TYPE([socklen_t], rb_socklen_t=socklen_t,[
135 AC_MSG_CHECKING([for socklen_t equivalent])
136 AC_CACHE_VAL([rb_socklen_t],
138 # Systems have either "struct sockaddr *" or
139 # "void *" as the second argument to getpeername
141 for arg2 in "struct sockaddr" void; do
142 for t in int size_t unsigned long "unsigned long"; do
144 #include <sys/types.h>
145 #include <sys/socket.h>
147 int getpeername (int, $arg2 *, $t *);
150 getpeername(0,0,&len);
158 if test "x$rb_socklen_t" = x; then
159 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
162 AC_MSG_RESULT($rb_socklen_t)],
163 [#include <sys/types.h>
164 #include <sys/socket.h>])
170 AC_ARG_ENABLE(ipv6,AC_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),[ipv6=$enableval],[ipv6=yes])
172 if test x$ipv6 != xyes; then
178 AC_MSG_NOTICE([Disabling IPv6 support: PF_INET6 not found])
182 if test "X$have_v6" = "Xyes"; then
183 RB_TYPE_STRUCT_SOCKADDR_IN6([], [
184 AC_MSG_NOTICE([Disabling IPv6 support: struct sockaddr_in6 not found])
191 AC_CHECK_TYPES([struct sockaddr_storage],[
192 rb_have_sockaddr_storage=yes
194 #include <sys/types.h>
195 #include <sys/socket.h>
200 AC_SEARCH_LIBS(crypt, [crypt descrypt],,)
203 CRYPT_LIB=$ac_cv_search_crypt
205 if test "$CRYPT_LIB" = "none required"; then
207 elif test "$CRYPT_LIB" = no; then
209 AC_DEFINE(NEED_CRYPT, 1, [Define if your system needs crypt.])
213 AM_CONDITIONAL([NEED_CRYPT], [test x"$need_crypt" = "xyes"])
218 dnl Check for stdarg.h - if we cant find it, halt configure
219 AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - libratbox will not compile without it **])])
221 AC_CHECK_TYPE([sa_family_t], [],
222 [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
223 [[#include <sys/types.h>
224 #include <sys/socket.h>]])
227 dnl check for various functions...
228 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])
230 AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep]))
231 AC_SEARCH_LIBS(timer_create, rt, AC_DEFINE(HAVE_TIMER_CREATE, 1, [Define if you have timer_create]))
232 RB_CHECK_TIMER_CREATE
238 AC_MSG_CHECKING(for /dev/poll)
239 if test -c "/dev/poll"; then
241 AC_DEFINE(HAVE_DEVPOLL, [1], [Define to 1 if you have devpoll])
247 if test "$is_mingw" = "yes"; then
248 AC_DEFINE(HAVE_WIN32, [1], [Define to 1 if you are on windows])
253 AC_MSG_CHECKING(for OpenSSL)
254 AC_ARG_ENABLE(openssl,
255 [AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
256 AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
257 [cf_enable_openssl=$enableval],
258 [cf_enable_openssl="auto"])
260 if test "$cf_enable_openssl" != "no" ; then
261 cf_openssl_basedir=""
262 if test "$cf_enable_openssl" != "auto" &&
263 test "$cf_enable_openssl" != "yes" ; then
264 dnl Support for --enable-openssl=/some/place
265 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
267 dnl Do the auto-probe here. Check some common directory paths.
268 for dirs in /usr/local/ssl /usr/pkg /usr/local \
269 /usr/local/openssl ; do
270 if test -f "${dirs}/include/openssl/opensslv.h" ; then
271 cf_openssl_basedir="${dirs}"
277 dnl Now check cf_openssl_found to see if we found anything.
278 if test ! -z "$cf_openssl_basedir"; then
279 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
280 SSL_CFLAGS="-I${cf_openssl_basedir}/include"
281 SSL_LIBS="-L${cf_openssl_basedir}/lib"
283 dnl OpenSSL wasn't found in the directory specified. Naughty
285 cf_openssl_basedir=""
288 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
289 dnl are in /usr/include and /usr/lib. In this case, we don't want to
290 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
291 dnl We can't do this check above, because some people want two versions
292 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
293 dnl and they want /usr/local/ssl to have preference.
294 if test -f "/usr/include/openssl/opensslv.h" ; then
295 cf_openssl_basedir="/usr"
299 dnl If we have a basedir defined, then everything is okay. Otherwise,
300 dnl we have a problem.
301 if test ! -z "$cf_openssl_basedir"; then
302 AC_MSG_RESULT($cf_openssl_basedir)
303 cf_enable_openssl="yes"
305 AC_MSG_RESULT([not found. Specify a correct path?])
306 cf_enable_openssl="no"
308 unset cf_openssl_basedir
310 dnl If --disable-openssl was specified
311 AC_MSG_RESULT(disabled)
314 save_CPPFLAGS="$CPPFLAGS"
315 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS"
317 LIBS="$LIBS $SSL_LIBS"
318 if test "$cf_enable_openssl" != no; then
319 dnl Check OpenSSL version (must be 0.9.7 or above!)
320 AC_MSG_CHECKING(for OpenSSL 0.9.7 or above)
323 [#include <openssl/opensslv.h>
324 #include <stdlib.h>],
325 [[if (OPENSSL_VERSION_NUMBER >= 0x00907000)
326 exit(0); else exit(1);]]),
327 cf_enable_openssl=yes,
328 cf_enable_openssl=no,
329 cf_enable_openssl=no)
331 if test "$cf_enable_openssl" != no; then
334 AC_MSG_RESULT(no - OpenSSL support disabled)
340 if test "$cf_enable_openssl" != no; then
341 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
342 AC_CHECK_LIB(crypto, RAND_status,
343 [cf_enable_openssl=yes],
344 [cf_enable_openssl=no])
348 if test "$cf_enable_openssl" != no; then
349 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
350 AC_CHECK_LIB(ssl, SSL_read,
351 [SSL_LIBS="-lssl -lcrypto"],
352 [cf_enable_openssl=no], [-lcrypto])
358 AC_MSG_CHECKING(for GnuTLS)
359 AC_ARG_ENABLE(gnutls,
360 [AC_HELP_STRING([--enable-gnutls],[Enable GnuTLS support.])
361 AC_HELP_STRING([--disable-gnutls],[Disable GnuTLS support.])],
362 [cf_enable_gnutls=$enableval],
363 [cf_enable_gnutls="auto"])
365 if test "$cf_enable_gnutls" != no; then
366 PKG_CHECK_MODULES(GNUTLS, [gnutls], [
367 cf_enable_gnutls="yes"
368 ], [cf_enable_gnutls="no"])
371 if test "$cf_enable_gnutls" = "auto" -a "$cf_enable_openssl" = "yes"; then
372 cf_enable_gnutls="no"
375 if test x"$cf_enable_openssl" != xno; then
376 AC_DEFINE(HAVE_OPENSSL,1,[Has OpenSSL])
380 elif test x"$cf_enable_gnutls" != xno; then
381 AC_DEFINE(HAVE_GNUTLS, 1, [Has GnuTLS])
390 CPPFLAGS="$save_CPPFLAGS"
393 dnl End OpenSSL detection
398 dnl Debug-related options
399 dnl =====================
401 AC_ARG_ENABLE(assert,
402 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
403 [assert=$enableval], [assert=no])
405 if test "$assert" = no; then
406 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
407 elif test "$assert" = soft; then
408 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
409 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
410 elif test "$assert" = yes; then
414 AC_MSG_CHECKING(if you want to do a profile build)
415 AC_ARG_ENABLE(profile,
416 AC_HELP_STRING([--enable-profile],[Enable profiling]),
417 [profile=$enableval], [profile=no])
419 if test "$profile" = yes; then
420 if test "$ac_cv_c_compiler_gnu" = yes; then
421 CFLAGS="$CFLAGS -pg -static"
422 AC_MSG_RESULT([yes, adding -pg -static])
423 AC_DEFINE(RATBOX_PROFILE, 1, [Defined to mark profiling is enabled])
425 AC_MSG_RESULT([no, profile builds only work with gcc])
431 AC_ARG_ENABLE(balloc,
432 AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
433 [balloc=$enableval], [balloc=yes])
435 if test "$balloc" = no; then
436 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
439 AC_ARG_ENABLE(warnings,
440 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
441 [CFLAGS="$CFLAGS -Wall -Werror -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -W -Wno-unused -Wunused-function -Wunused-variable"],[])
449 AC_SUBST(GNUTLS_CFLAGS)
450 AC_SUBST(GNUTLS_LIBS)
452 if test "$prefix" = "NONE"; then
453 AC_DEFINE_UNQUOTED(RB_PREFIX, "$ac_default_prefix", [Prefix where libratbox is installed.])
457 dnl Don't get bitten by Cygwin's stupidity if the user specified
458 dnl a custom prefix with a trailing slash
460 prefix=`echo $prefix | sed 's/\/$//'`
461 AC_DEFINE_UNQUOTED(RB_PREFIX, "$prefix", [Prefix where libratbox is installed.])
467 AC_CONFIG_COMMANDS([include/librb-config.h],
469 outfile=include/librb-config.h.tmp
470 cat > $outfile <<\_______EOF
472 * librb-config.h: libratbox config file. Please modify configure.ac
475 #ifndef __LIBRB_CONFIG_H
476 #define __LIBRB_CONFIG_H
480 if test "x$rb_have_ipv6" = "xyes"; then
481 echo "#define RB_IPV6 1" >> $outfile
484 if test "x$rb_windows_h" = "xyes"; then
485 echo '#define WIN32_LEAN_AND_MEAN 1' >> $outfile
486 echo '#include <windows.h>' >> $outfile
487 echo '#include <winsock2.h>' >> $outfile
488 echo '#include <iphlpapi.h>' >> $outfile
491 if test "x$rb_alloca_h" = "xyes"; then
492 echo '#define RB_HAVE_ALLOCA_H 1' >> $outfile
495 if test "x$rb_header_stdc" = "xyes"; then
496 echo '#include <stdlib.h>' >> $outfile
497 echo '#include <stddef.h>' >> $outfile
498 elif test "x$rb_header_stdlib" = "xyes"; then
499 echo '#include <stdlib.h>' >> $outfile
502 if test "x$rb_header_string_h" = "xyes"; then
503 echo '#include <string.h>' >> $outfile
506 if test "x$rb_stdint_h" = "xyes"; then
507 echo '#include <stdint.h>' >> $outfile
510 if test "x$rb_inttypes_h" = "xyes"; then
511 echo '#include <inttypes.h>' >> $outfile
514 if test "x$rb_sys_types_h" = "xyes"; then
515 echo '#include <sys/types.h>' >> $outfile
517 if test "x$rb_sys_time_h" = "xyes"; then
518 echo '#include <sys/time.h>' >> $outfile
520 if test "x$rb_sys_stat_h" = "xyes"; then
521 echo '#include <sys/stat.h>' >> $outfile
523 if test "x$rb_time_h" = "xyes"; then
524 echo '#include <time.h>' >> $outfile
527 if test "x$rb_sys_socket_h" = "xyes"; then
528 echo '#include <sys/socket.h>' >> $outfile
531 if test "x$rb_netinet_in_h" = "xyes"; then
532 echo '#include <netinet/in.h>' >> $outfile
535 if test "x$rb_arpa_inet_h" = "xyes"; then
536 echo '#include <arpa/inet.h>' >> $outfile
539 if test "x$rb_unistd_h" = "xyes"; then
540 echo '#include <unistd.h>' >> $outfile
543 if test "x$rb_crypt_h" = "xyes"; then
544 echo '#include <crypt.h>' >> $outfile
547 if test "x$rb_errno_h" = "xyes"; then
548 echo '#include <errno.h>' >> $outfile
551 echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile
554 if test "x$rb_sockaddr_sa_len" = "xyes"; then
555 echo '#define RB_SOCKADDR_HAS_SA_LEN 1' >> $outfile
558 if test "x$rb_sockaddr_storage" = "xyes"; then
559 echo '#define rb_sockaddr_storage sockaddr_storage' >> $outfile
561 echo 'struct rb_sockaddr_storage { uint8_t _padding[128]; };' >> $outfile
564 cat >> $outfile <<\_______EOF
565 #endif /* __LIBRB_CONFIG_H */
568 if cmp -s $outfile include/librb-config.h; then
569 AC_MSG_NOTICE([include/librb-config.h is unchanged])
572 ${rb_mv} $outfile include/librb-config.h
576 if test x$ac_cv_header_stdc = xyes; then
579 if test x$ac_cv_header_stdlib_h = xyes; then
580 rb_header_stdlib_h=yes
582 if test x$ac_cv_header_string_h = xyes; then
583 rb_header_string_h=yes
585 if test x$ac_cv_header_memory_h = xyes; then
586 rb_header_memory_h=yes
588 if test "x${ac_cv_working_alloca_h+set}" = xset ; then
589 rb_alloca_h="$ac_cv_working_alloca_h"
591 rb_alloc_h="$ac_cv_header_alloca_h"
593 if test x$ac_cv_member_struct_sockaddr_sa_len = xyes; then
594 rb_sockaddr_sa_len=yes
596 if test x$ac_cv_header_sys_socket_h = xyes; then
599 if test x$ac_cv_header_sys_types_h = xyes; then
602 if test x$ac_cv_header_sys_stat_h = xyes; then
605 if test x$ac_cv_header_sys_time_h = xyes; then
608 if test x$ac_cv_header_time = xyes; then
612 if test x$ac_cv_header_stdint_h = xyes; then
615 if test x$ac_cv_header_inttypes_h = xyes; then
618 if test x$ac_cv_header_netinet_in_h = xyes; then
622 if test x$ac_cv_header_crypt_h = xyes; then
625 if test x$ac_cv_header_errno_h = xyes; then
628 if test x$ac_cv_header_unistd_h = xyes; then
631 if test x$ac_cv_header_windows_h = xyes; then
634 if test x$ac_cv_header_winsock2_h = xyes; then
638 rb_socklen_t=$rb_socklen_t
640 if test "x$rb_have_sockaddr_storage" = "xyes"; then
641 rb_sockaddr_storage="yes"
643 rb_sockaddr_storage="no"
646 rb_have_ipv6="$have_v6"
665 dnl Make it look sexay!
668 echo "Compiling $PACKAGE_NAME $PACKAGE_VERSION"
671 echo "Installing into: $prefix"
673 echo "IPv6 support ................... $have_v6"
674 echo "Assert debugging ............... $assert"
675 echo "Block allocator ................ $balloc"
676 echo "SSL Type........................ $SSL_TYPE"