1 dnl $Id: configure.ac 23020 2006-09-01 18:20:19Z 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 23020 2006-09-01 18:20:19Z 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"
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}'
122 dnl Checks for header files.
125 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])
128 dnl Networking Functions
129 dnl ====================
131 AC_SEARCH_LIBS(socket, [socket],,)
134 AC_CHECK_MEMBER([struct sockaddr.sa_len], [AC_DEFINE(SOCKADDR_IN_HAS_LEN, 1, [Define to 1 if sockaddr has a 'sa_len'
136 #ifdef HAVE_SYS_TYPES_H
137 #include <sys/types.h>
139 #ifdef HAVE_SYS_SOCKET_H
140 #include <sys/socket.h>
142 #ifdef HAVE_WINSOCK2_H
143 #include <winsock2.h>
147 AC_CHECK_TYPE(socklen_t, ,
148 [AC_DEFINE([socklen_t], [unsigned int],
149 [If we don't have a real socklen_t, unsigned int is good enough.])],
151 #ifdef HAVE_SYS_TYPES_H
152 #include <sys/types.h>
154 #ifdef HAVE_SYS_SOCKET_H
155 #include <sys/socket.h>
157 #ifdef HAVE_WINSOCK2_H
158 #include <winsock2.h>
163 AC_ARG_ENABLE(ipv6,AC_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),[ipv6=$enableval],[ipv6=yes])
165 if test x$ipv6 != xyes; then
171 AC_MSG_NOTICE([Disabling IPv6 support: PF_INET6 not found])
175 if test "X$have_v6" = "Xyes"; then
176 RB_TYPE_STRUCT_SOCKADDR_IN6([], [
177 AC_MSG_NOTICE([Disabling IPv6 support: struct sockaddr_in6 not found])
184 AC_CHECK_TYPES([struct sockaddr_storage],[
185 rb_have_sockaddr_storage=yes
187 #include <sys/types.h>
188 #include <sys/socket.h>
193 AC_SEARCH_LIBS(crypt, [crypt descrypt],,)
196 CRYPT_LIB=$ac_cv_search_crypt
198 if test "$CRYPT_LIB" = "none required"; then
200 elif test "$CRYPT_LIB" = no; then
202 AC_DEFINE(NEED_CRYPT, 1, [Define if your system needs crypt.])
206 AM_CONDITIONAL([NEED_CRYPT], [test x"$need_crypt" == "xyes"])
211 dnl Check for stdarg.h - if we cant find it, halt configure
212 AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - libratbox will not compile without it **])])
214 AC_CHECK_TYPE([sa_family_t], [],
215 [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
216 [[#include <sys/types.h>
217 #include <sys/socket.h>]])
220 dnl check for various functions...
221 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])
223 AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep]))
224 AC_SEARCH_LIBS(timer_create, rt, AC_DEFINE(HAVE_TIMER_CREATE, 1, [Define if you have timer_create]))
225 RB_CHECK_TIMER_CREATE
231 AC_MSG_CHECKING(for /dev/poll)
232 if test -c "/dev/poll"; then
234 AC_DEFINE(HAVE_DEVPOLL, [1], [Define to 1 if you have devpoll])
240 if test "$is_mingw" = "yes"; then
241 AC_DEFINE(HAVE_WIN32, [1], [Define to 1 if you are on windows])
245 AC_MSG_CHECKING(for GnuTLS)
246 AC_ARG_ENABLE(gnutls,
247 [AC_HELP_STRING([--enable-gnutls],[Enable GnuTLS support.])
248 AC_HELP_STRING([--disable-gnutls],[Disable GnuTLS support.])],
249 [cf_enable_gnutls=$enableval],
250 [cf_enable_gnutls="auto"])
252 if test "$cf_enable_gnutls" != no; then
253 PKG_CHECK_MODULES(GNUTLS, [gnutls], [
254 CPPFLAGS="$CPPFLAGS $GNUTLS_CFLAGS"
255 LIBS="$LIBS $GNUTLS_LIBS"
256 cf_enable_gnutls="yes"
257 ], [cf_enable_gnutls="no"])
260 if test "$cf_enable_gnutls" != no; then
261 AC_DEFINE(HAVE_GNUTLS, 1, [Has GNUTLS])
265 AC_MSG_CHECKING(for OpenSSL)
266 AC_ARG_ENABLE(openssl,
267 [AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
268 AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
269 [cf_enable_openssl=$enableval],
270 [cf_enable_openssl="auto"])
272 dnl Prefer GnuTLS over OpenSSL due to licensing issues, this could use improvement
273 if test "$cf_enable_gnutls" = "yes" -a "$cf_enable_openssl" = "auto"; then
274 cf_enable_openssl="no"
277 if test "$cf_enable_openssl" != "no" ; then
278 cf_openssl_basedir=""
279 if test "$cf_enable_openssl" != "auto" &&
280 test "$cf_enable_openssl" != "yes" ; then
281 dnl Support for --enable-openssl=/some/place
282 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
284 dnl Do the auto-probe here. Check some common directory paths.
285 for dirs in /usr/local/ssl /usr/pkg /usr/local \
286 /usr/local/openssl ; do
287 if test -f "${dirs}/include/openssl/opensslv.h" ; then
288 cf_openssl_basedir="${dirs}"
294 dnl Now check cf_openssl_found to see if we found anything.
295 if test ! -z "$cf_openssl_basedir"; then
296 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
297 SSL_INCLUDES="-I${cf_openssl_basedir}/include"
298 SSL_LIBS="-L${cf_openssl_basedir}/lib"
300 dnl OpenSSL wasn't found in the directory specified. Naughty
302 cf_openssl_basedir=""
305 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
306 dnl are in /usr/include and /usr/lib. In this case, we don't want to
307 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
308 dnl We can't do this check above, because some people want two versions
309 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
310 dnl and they want /usr/local/ssl to have preference.
311 if test -f "/usr/include/openssl/opensslv.h" ; then
312 cf_openssl_basedir="/usr"
316 dnl If we have a basedir defined, then everything is okay. Otherwise,
317 dnl we have a problem.
318 if test ! -z "$cf_openssl_basedir"; then
319 AC_MSG_RESULT($cf_openssl_basedir)
320 cf_enable_openssl="yes"
322 AC_MSG_RESULT([not found. Specify a correct path?])
323 cf_enable_openssl="no"
325 unset cf_openssl_basedir
327 dnl If --disable-openssl was specified
328 AC_MSG_RESULT(disabled)
331 save_CPPFLAGS="$CPPFLAGS"
332 CPPFLAGS="$CPPFLAGS $SSL_INCLUDES"
334 LIBS="$LIBS $SSL_LIBS"
335 if test "$cf_enable_openssl" != no; then
336 dnl Check OpenSSL version (must be 0.9.7 or above!)
337 AC_MSG_CHECKING(for OpenSSL 0.9.7 or above)
340 [#include <openssl/opensslv.h>
341 #include <stdlib.h>],
342 [[if (OPENSSL_VERSION_NUMBER >= 0x00907000)
343 exit(0); else exit(1);]]),
344 cf_enable_openssl=yes,
345 cf_enable_openssl=no,
346 cf_enable_openssl=no)
348 if test "$cf_enable_openssl" != no; then
351 AC_MSG_RESULT(no - OpenSSL support disabled)
357 if test "$cf_enable_openssl" != no; then
358 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
359 AC_CHECK_LIB(crypto, RAND_status,
360 [cf_enable_openssl=yes],
361 [cf_enable_openssl=no])
365 if test "$cf_enable_openssl" != no; then
366 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
367 AC_CHECK_LIB(ssl, SSL_read,
368 [SSL_LIBS="-lssl -lcrypto"],
369 [cf_enable_openssl=no], [-lcrypto])
372 if test "$cf_enable_openssl" != no; then
373 AC_DEFINE(HAVE_OPENSSL,1,[Has OpenSSL])
377 CPPFLAGS="$save_CPPFLAGS"
380 dnl End OpenSSL detection
385 dnl Debug-related options
386 dnl =====================
388 AC_ARG_ENABLE(assert,
389 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
390 [assert=$enableval], [assert=no])
392 if test "$assert" = no; then
393 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
394 elif test "$assert" = soft; then
395 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
396 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
397 elif test "$assert" = yes; then
401 AC_MSG_CHECKING(if you want to do a profile build)
402 AC_ARG_ENABLE(profile,
403 AC_HELP_STRING([--enable-profile],[Enable profiling]),
404 [profile=$enableval], [profile=no])
406 if test "$profile" = yes; then
407 if test "$ac_cv_c_compiler_gnu" = yes; then
408 CFLAGS="$CFLAGS -pg -static"
409 AC_MSG_RESULT([yes, adding -pg -static])
410 AC_DEFINE(RATBOX_PROFILE, 1, [Defined to mark profiling is enabled])
412 AC_MSG_RESULT([no, profile builds only work with gcc])
418 AC_ARG_ENABLE(balloc,
419 AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
420 [balloc=$enableval], [balloc=yes])
422 if test "$balloc" = no; then
423 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
426 AC_ARG_ENABLE(warnings,
427 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
428 [CFLAGS="$CFLAGS -Wall -Werror -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -W -Wno-unused -Wunused-function -Wunused-variable"],[])
434 AC_SUBST(SSL_INCLUDES)
438 if test "$prefix" = "NONE"; then
439 AC_DEFINE_UNQUOTED(RB_PREFIX, "$ac_default_prefix", [Prefix where libratbox is installed.])
443 dnl Don't get bitten by Cygwin's stupidity if the user specified
444 dnl a custom prefix with a trailing slash
446 prefix=`echo $prefix | sed 's/\/$//'`
447 AC_DEFINE_UNQUOTED(RB_PREFIX, "$prefix", [Prefix where libratbox is installed.])
453 for dtype in uint64_t uint32_t uint16_t uint8_t int64_t int32_t int16_t int8_t intmax_t intptr_t uintmax_t uintptr_t
455 var="\$ac_cv_c_${dtype}"
456 t_type=$(eval echo $var);
457 if test "x$t_type" = "xyes"; then
458 eval rb_$dtype="\"$dtype\""
460 eval rb_$dtype="\"$t_type\""
464 AC_CONFIG_COMMANDS([include/librb-config.h],
466 outfile=include/librb-config.h.tmp
467 cat > $outfile <<\_______EOF
469 * librb-config.h: libratbox config file. Please modify configure.ac
472 #ifndef __LIBRB_CONFIG_H
473 #define __LIBRB_CONFIG_H
477 if test "x$rb_have_ipv6" = "xyes"; then
478 echo "#define RB_IPV6 1" >> $outfile
481 if test "x$rb_windows_h" = "xyes"; then
482 echo '#define WIN32_LEAN_AND_MEAN 1' >> $outfile
483 echo '#include <windows.h>' >> $outfile
484 echo '#include <winsock2.h>' >> $outfile
485 echo '#include <iphlpapi.h>' >> $outfile
488 if test "x$rb_alloca_h" = "xyes"; then
489 echo '#define RB_HAVE_ALLOCA_H 1' >> $outfile
492 if test "x$rb_header_stdc" = "xyes"; then
493 echo '#include <stdlib.h>' >> $outfile
494 echo '#include <stddef.h>' >> $outfile
495 elif test "x$rb_header_stdlib" = "xyes"; then
496 echo '#include <stdlib.h>' >> $outfile
499 if test "x$rb_header_string_h" = "xyes"; then
500 echo '#include <string.h>' >> $outfile
503 if test "x$rb_stdint_h" = "xyes"; then
504 echo '#include <stdint.h>' >> $outfile
507 if test "x$rb_inttypes_h" = "xyes"; then
508 echo '#include <inttypes.h>' >> $outfile
511 if test "x$rb_sys_types_h" = "xyes"; then
512 echo '#include <sys/types.h>' >> $outfile
514 if test "x$rb_sys_time_h" = "xyes"; then
515 echo '#include <sys/time.h>' >> $outfile
517 if test "x$rb_sys_stat_h" = "xyes"; then
518 echo '#include <sys/stat.h>' >> $outfile
520 if test "x$rb_time_h" = "xyes"; then
521 echo '#include <time.h>' >> $outfile
524 if test "x$rb_sys_socket_h" = "xyes"; then
525 echo '#include <sys/socket.h>' >> $outfile
528 if test "x$rb_netinet_in_h" = "xyes"; then
529 echo '#include <netinet/in.h>' >> $outfile
532 if test "x$rb_arpa_inet_h" = "xyes"; then
533 echo '#include <arpa/inet.h>' >> $outfile
536 if test "x$rb_unistd_h" = "xyes"; then
537 echo '#include <unistd.h>' >> $outfile
540 if test "x$rb_crypt_h" = "xyes"; then
541 echo '#include <crypt.h>' >> $outfile
544 if test "x$rb_errno_h" = "xyes"; then
545 echo '#include <errno.h>' >> $outfile
548 if test "x$rb_sockaddr_sa_len" = "xyes"; then
549 echo '#define RB_SOCKADDR_HAS_SA_LEN 1' >> $outfile
552 echo "typedef $rb_uint64_t rb_uint64_t;" >> $outfile
553 echo "typedef $rb_uint32_t rb_uint32_t;" >> $outfile
554 echo "typedef $rb_uint16_t rb_uint16_t;" >> $outfile
555 echo "typedef $rb_uint8_t rb_uint8_t;" >> $outfile
556 echo "typedef $rb_int64_t rb_int64_t;" >> $outfile
557 echo "typedef $rb_int32_t rb_int32_t;" >> $outfile
558 echo "typedef $rb_int16_t rb_int16_t;" >> $outfile
559 echo "typedef $rb_int8_t rb_int8_t;" >> $outfile
560 echo "typedef $rb_intmax_t rb_intmax_t;" >> $outfile
561 echo "typedef $rb_intptr_t rb_intptr_t;" >> $outfile
562 echo "typedef $rb_uintmax_t rb_uintmax_t;" >> $outfile
563 echo "typedef $rb_uintptr_t rb_uintptr_t;" >> $outfile
564 echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile
566 if test "x$rb_sockaddr_storage" = "xyes"; then
567 echo '#define rb_sockaddr_storage sockaddr_storage' >> $outfile
569 echo 'struct rb_sockaddr_storage { rb_uint8_t _padding[128]; };' >> $outfile
572 cat >> $outfile <<\_______EOF
573 #endif /* __LIBRB_CONFIG_H */
576 if cmp -s $outfile include/librb-config.h; then
577 AC_MSG_NOTICE([include/librb-config.h is unchanged])
580 ${rb_mv} $outfile include/librb-config.h
584 rb_uint64_t="$rb_uint64_t"
585 rb_uint32_t="$rb_uint32_t"
586 rb_uint16_t="$rb_uint16_t"
587 rb_uint8_t="$rb_uint8_t"
588 rb_int64_t="$rb_int64_t"
589 rb_int32_t="$rb_int32_t"
590 rb_int16_t="$rb_int16_t"
591 rb_int8_t="$rb_int8_t"
592 rb_intmax_t="$rb_intmax_t"
593 rb_intptr_t="$rb_intptr_t"
594 rb_uintmax_t="$rb_uintmax_t"
595 rb_uintptr_t="$rb_uintptr_t"
596 if test x$ac_cv_header_stdc = xyes; then
599 if test x$ac_cv_header_stdlib_h = xyes; then
600 rb_header_stdlib_h=yes
602 if test x$ac_cv_header_string_h = xyes; then
603 rb_header_string_h=yes
605 if test x$ac_cv_header_memory_h = xyes; then
606 rb_header_memory_h=yes
608 if test "x${ac_cv_working_alloca_h+set}" = xset ; then
609 rb_alloca_h="$ac_cv_working_alloca_h"
611 rb_alloc_h="$ac_cv_header_alloca_h"
613 if test x$ac_cv_member_struct_sockaddr_sa_len = xyes; then
614 rb_sockaddr_sa_len=yes
616 if test x$ac_cv_header_sys_socket_h = xyes; then
619 if test x$ac_cv_header_sys_types_h = xyes; then
622 if test x$ac_cv_header_sys_stat_h = xyes; then
625 if test x$ac_cv_header_sys_time_h = xyes; then
628 if test x$ac_cv_header_time = xyes; then
632 if test x$ac_cv_header_stdint_h = xyes; then
635 if test x$ac_cv_header_inttypes_h = xyes; then
638 if test x$ac_cv_header_netinet_in_h = xyes; then
642 if test x$ac_cv_header_crypt_h = xyes; then
645 if test x$ac_cv_header_errno_h = xyes; then
648 if test x$ac_cv_header_unistd_h = xyes; then
651 if test x$ac_cv_header_windows_h = xyes; then
654 if test x$ac_cv_header_winsock2_h = xyes; then
657 if test x$ac_cv_type_socklen_t = xyes; then
658 rb_socklen_t="socklen_t"
660 rb_socklen_t="unsigned int"
662 if test "x$rb_have_sockaddr_storage" = "xyes"; then
663 rb_sockaddr_storage="yes"
665 rb_sockaddr_storage="no"
668 rb_have_ipv6="$have_v6"
686 dnl Make it look sexay!
689 echo "Compiling $PACKAGE_NAME $PACKAGE_VERSION"
692 echo "Installing into: $prefix"
694 echo "IPv6 support ................... $have_v6"
695 echo "Assert debugging ............... $assert"
696 echo "Block allocator ................ $balloc"
697 echo "OpenSSL ........................ $cf_enable_openssl"
698 echo "GnuTLS ......................... $cf_enable_gnutls"