1 dnl $Id: configure.ac 26168 2008-10-26 20:58:40Z 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 26168 2008-10-26 20:58:40Z 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)
53 AC_PATH_PROG(TOUCH, touch)
58 LIBTOOL="$LIBTOOL --silent"
62 AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
63 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
66 AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
67 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
68 AC_CHECK_HEADER(windows.h, , [AC_MSG_ERROR([** MinGW and no windows.h. I give up.])])
69 AC_CHECK_HEADER(winsock2.h, , [AC_MSG_ERROR([** MinGW and no winsock2.h. I give up.])])
70 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1, [Have WINSOCK2_H])
71 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1, [Have WINSOCK_H])
72 LIBS="$LIBS -lws2_32 -liphlpapi"
76 CPPFLAGS="$CFLAGS -D_ALL_SOURCE -D_XOPEN_SOURCE=500"
79 CPPFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS -D_XPG4_2 -D__EXTENSIONS__"
85 AM_CONDITIONAL([MINGW], [test "$is_mingw" = "yes"])
88 # backwards support for IRC_CFLAGS
89 CFLAGS="$IRC_CFLAGS $CFLAGS -Wall"
91 dnl use directory structure of cached as default (hack)
92 if test "$libexecdir" = '${exec_prefix}/libexec' &&
93 test "$localstatedir" = '${prefix}/var'; then
94 libexecdir='${bindir}'
95 localstatedir='${prefix}'
104 dnl Checks for header files.
107 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])
110 dnl Networking Functions
111 dnl ====================
113 AC_SEARCH_LIBS(socket, [socket],,)
116 AC_CHECK_MEMBER([struct sockaddr.sa_len], [AC_DEFINE(SOCKADDR_IN_HAS_LEN, 1, [Define to 1 if sockaddr has a 'sa_len'
118 #ifdef HAVE_SYS_TYPES_H
119 #include <sys/types.h>
121 #ifdef HAVE_SYS_SOCKET_H
122 #include <sys/socket.h>
124 #ifdef HAVE_WINSOCK2_H
125 #include <winsock2.h>
129 AC_CHECK_TYPE([socklen_t], rb_socklen_t=socklen_t,[
130 AC_MSG_CHECKING([for socklen_t equivalent])
131 AC_CACHE_VAL([rb_socklen_t],
133 # Systems have either "struct sockaddr *" or
134 # "void *" as the second argument to getpeername
136 for arg2 in "struct sockaddr" void; do
137 for t in int size_t unsigned long "unsigned long"; do
139 #ifdef HAVE_SYS_TYPES_H
140 #include <sys/types.h>
142 #ifdef HAVE_SYS_SOCKET_H
143 #include <sys/socket.h>
145 #ifdef HAVE_WINSOCK2_H
146 #include <winsock2.h>
148 int getpeername (int, $arg2 *, $t *);
151 getpeername(0,0,&len);
159 if test "x$rb_socklen_t" = x; then
160 AC_MSG_WARN([Cannot find a type to use in place of socklen_t using int])
164 AC_MSG_RESULT($rb_socklen_t)],
165 [#include <sys/types.h>
166 #include <sys/socket.h>])
172 AC_ARG_ENABLE(ipv6,AC_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),[ipv6=$enableval],[ipv6=yes])
174 if test x$ipv6 != xyes; then
180 AC_MSG_NOTICE([Disabling IPv6 support: PF_INET6 not found])
184 if test "X$have_v6" = "Xyes"; then
185 RB_TYPE_STRUCT_SOCKADDR_IN6([], [
186 AC_MSG_NOTICE([Disabling IPv6 support: struct sockaddr_in6 not found])
193 AC_CHECK_TYPES([struct sockaddr_storage],[
194 rb_have_sockaddr_storage=yes
196 #include <sys/types.h>
197 #include <sys/socket.h>
202 AC_SEARCH_LIBS(crypt, [crypt descrypt],,)
205 CRYPT_LIB=$ac_cv_search_crypt
207 if test "$CRYPT_LIB" = "none required"; then
209 elif test "$CRYPT_LIB" = no; then
211 AC_DEFINE(NEED_CRYPT, 1, [Define if your system needs crypt.])
215 AM_CONDITIONAL([NEED_CRYPT], [test x"$need_crypt" = "xyes"])
220 dnl Check for stdarg.h - if we cant find it, halt configure
221 AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - libratbox will not compile without it **])])
223 AC_CHECK_TYPE([sa_family_t], [],
224 [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
225 [[#include <sys/types.h>
226 #include <sys/socket.h>]])
229 dnl check for various functions...
230 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 timerfd_create])
232 AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep]))
233 AC_SEARCH_LIBS(timer_create, rt, AC_DEFINE(HAVE_TIMER_CREATE, 1, [Define if you have timer_create]))
234 RB_CHECK_TIMER_CREATE
235 RB_CHECK_TIMERFD_CREATE
241 AC_MSG_CHECKING(for /dev/poll)
242 if test -c "/dev/poll"; then
244 AC_DEFINE(HAVE_DEVPOLL, [1], [Define to 1 if you have devpoll])
250 if test "$is_mingw" = "yes"; then
251 AC_DEFINE(HAVE_WIN32, [1], [Define to 1 if you are on windows])
256 AC_MSG_CHECKING(for OpenSSL)
257 AC_ARG_ENABLE(openssl,
258 [AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
259 AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
260 [cf_enable_openssl=$enableval],
261 [cf_enable_openssl="auto"])
263 if test "$cf_enable_openssl" != "no" ; then
264 cf_openssl_basedir=""
265 if test "$cf_enable_openssl" != "auto" &&
266 test "$cf_enable_openssl" != "yes" ; then
267 dnl Support for --enable-openssl=/some/place
268 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
270 dnl Do the auto-probe here. Check some common directory paths.
271 for dirs in /usr/local/ssl /usr/pkg /usr/local \
272 /usr/local/openssl ; do
273 if test -f "${dirs}/include/openssl/opensslv.h" ; then
274 cf_openssl_basedir="${dirs}"
280 dnl Now check cf_openssl_found to see if we found anything.
281 if test ! -z "$cf_openssl_basedir"; then
282 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
283 SSL_CFLAGS="-I${cf_openssl_basedir}/include"
284 SSL_LIBS="-L${cf_openssl_basedir}/lib"
286 dnl OpenSSL wasn't found in the directory specified. Naughty
288 cf_openssl_basedir=""
291 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
292 dnl are in /usr/include and /usr/lib. In this case, we don't want to
293 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
294 dnl We can't do this check above, because some people want two versions
295 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
296 dnl and they want /usr/local/ssl to have preference.
297 if test -f "/usr/include/openssl/opensslv.h" ; then
298 cf_openssl_basedir="/usr"
302 dnl If we have a basedir defined, then everything is okay. Otherwise,
303 dnl we have a problem.
304 if test ! -z "$cf_openssl_basedir"; then
305 AC_MSG_RESULT($cf_openssl_basedir)
306 cf_enable_openssl="yes"
308 AC_MSG_RESULT([not found. Specify a correct path?])
309 cf_enable_openssl="no"
311 unset cf_openssl_basedir
313 dnl If --disable-openssl was specified
314 AC_MSG_RESULT(disabled)
317 save_CPPFLAGS="$CPPFLAGS"
318 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS"
320 LIBS="$LIBS $SSL_LIBS"
321 if test "$cf_enable_openssl" != no; then
322 dnl Check OpenSSL version (must be 0.9.7 or above!)
323 AC_MSG_CHECKING(for OpenSSL 0.9.7 or above)
326 [#include <openssl/opensslv.h>
327 #include <stdlib.h>],
328 [[if (OPENSSL_VERSION_NUMBER >= 0x00907000)
329 exit(0); else exit(1);]]),
330 cf_enable_openssl=yes,
331 cf_enable_openssl=no,
332 cf_enable_openssl=no)
334 if test "$cf_enable_openssl" != no; then
337 AC_MSG_RESULT(no - OpenSSL support disabled)
343 if test "$cf_enable_openssl" != no; then
344 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
345 AC_CHECK_LIB(crypto, RAND_status,
346 [cf_enable_openssl=yes],
347 [cf_enable_openssl=no])
350 if test "$cf_enable_openssl" != no; then
351 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
352 AC_CHECK_LIB(ssl, SSL_read,
353 [SSL_LIBS="$SSL_LIBS -lssl -lcrypto"],
354 [cf_enable_openssl=no], [-lcrypto])
360 AC_MSG_CHECKING(for GnuTLS)
361 AC_ARG_ENABLE(gnutls,
362 [AC_HELP_STRING([--enable-gnutls],[Enable GnuTLS support.])
363 AC_HELP_STRING([--disable-gnutls],[Disable GnuTLS support.])],
364 [cf_enable_gnutls=$enableval],
365 [cf_enable_gnutls="auto"])
367 if test "$cf_enable_gnutls" != no; then
368 PKG_CHECK_MODULES(GNUTLS, [gnutls], [
369 cf_enable_gnutls="yes"
370 ], [cf_enable_gnutls="no"])
373 if test "$cf_enable_gnutls" = "auto" -a "$cf_enable_openssl" = "yes"; then
374 cf_enable_gnutls="no"
377 if test x"$cf_enable_openssl" != xno; then
378 AC_DEFINE(HAVE_OPENSSL,1,[Has OpenSSL])
382 elif test x"$cf_enable_gnutls" != xno; then
383 AC_DEFINE(HAVE_GNUTLS, 1, [Has GnuTLS])
392 CPPFLAGS="$save_CPPFLAGS"
395 dnl End OpenSSL detection
400 dnl Debug-related options
401 dnl =====================
403 AC_ARG_ENABLE(assert,
404 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
405 [assert=$enableval], [assert=no])
407 if test "$assert" = no; then
408 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
409 elif test "$assert" = soft; then
410 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
411 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
412 elif test "$assert" = yes; then
416 AC_MSG_CHECKING(if you want to do a profile build)
417 AC_ARG_ENABLE(profile,
418 AC_HELP_STRING([--enable-profile],[Enable profiling]),
419 [profile=$enableval], [profile=no])
421 if test "$profile" = yes; then
422 if test "$ac_cv_c_compiler_gnu" = yes; then
423 CFLAGS="$CFLAGS -pg -static"
424 AC_MSG_RESULT([yes, adding -pg -static])
425 AC_DEFINE(RATBOX_PROFILE, 1, [Defined to mark profiling is enabled])
427 AC_MSG_RESULT([no, profile builds only work with gcc])
433 AC_ARG_ENABLE(balloc,
434 AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
435 [balloc=$enableval], [balloc=yes])
437 if test "$balloc" = no; then
438 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
441 AC_ARG_ENABLE(warnings,
442 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
443 [CFLAGS="$CFLAGS -Wall -Werror -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -W -Wno-unused -Wunused-function -Wunused-variable"],[])
451 AC_SUBST(GNUTLS_CFLAGS)
452 AC_SUBST(GNUTLS_LIBS)
454 if test "$prefix" = "NONE"; then
455 AC_DEFINE_UNQUOTED(RB_PREFIX, "$ac_default_prefix", [Prefix where libratbox is installed.])
459 dnl Don't get bitten by Cygwin's stupidity if the user specified
460 dnl a custom prefix with a trailing slash
462 prefix=`echo $prefix | sed 's/\/$//'`
463 AC_DEFINE_UNQUOTED(RB_PREFIX, "$prefix", [Prefix where libratbox is installed.])
469 AC_CONFIG_COMMANDS([include/librb-config.h],
471 outfile=include/librb-config.h.tmp
472 cat > $outfile <<\_______EOF
474 * librb-config.h: libratbox config file. Please modify configure.ac
477 #ifndef __LIBRB_CONFIG_H
478 #define __LIBRB_CONFIG_H
482 if test "x$rb_have_ipv6" = "xyes"; then
483 echo "#define RB_IPV6 1" >> $outfile
486 if test "x$rb_windows_h" = "xyes"; then
487 echo '#define WIN32_LEAN_AND_MEAN 1' >> $outfile
488 echo '#include <windows.h>' >> $outfile
489 echo '#include <winsock2.h>' >> $outfile
490 echo '#include <iphlpapi.h>' >> $outfile
493 if test "x$rb_alloca_h" = "xyes"; then
494 echo '#define RB_HAVE_ALLOCA_H 1' >> $outfile
497 if test "x$rb_header_stdc" = "xyes"; then
498 echo '#include <stdlib.h>' >> $outfile
499 echo '#include <stddef.h>' >> $outfile
500 elif test "x$rb_header_stdlib" = "xyes"; then
501 echo '#include <stdlib.h>' >> $outfile
504 if test "x$rb_header_string_h" = "xyes"; then
505 echo '#include <string.h>' >> $outfile
508 if test "x$rb_stdint_h" = "xyes"; then
509 echo '#include <stdint.h>' >> $outfile
512 if test "x$rb_inttypes_h" = "xyes"; then
513 echo '#include <inttypes.h>' >> $outfile
516 if test "x$rb_sys_types_h" = "xyes"; then
517 echo '#include <sys/types.h>' >> $outfile
519 if test "x$rb_sys_time_h" = "xyes"; then
520 echo '#include <sys/time.h>' >> $outfile
522 if test "x$rb_sys_stat_h" = "xyes"; then
523 echo '#include <sys/stat.h>' >> $outfile
525 if test "x$rb_time_h" = "xyes"; then
526 echo '#include <time.h>' >> $outfile
529 if test "x$rb_sys_socket_h" = "xyes"; then
530 echo '#include <sys/socket.h>' >> $outfile
533 if test "x$rb_netinet_in_h" = "xyes"; then
534 echo '#include <netinet/in.h>' >> $outfile
537 if test "x$rb_arpa_inet_h" = "xyes"; then
538 echo '#include <arpa/inet.h>' >> $outfile
541 if test "x$rb_unistd_h" = "xyes"; then
542 echo '#include <unistd.h>' >> $outfile
545 if test "x$rb_crypt_h" = "xyes"; then
546 echo '#include <crypt.h>' >> $outfile
549 if test "x$rb_errno_h" = "xyes"; then
550 echo '#include <errno.h>' >> $outfile
553 echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile
556 if test "x$rb_sockaddr_sa_len" = "xyes"; then
557 echo '#define RB_SOCKADDR_HAS_SA_LEN 1' >> $outfile
560 if test "x$rb_sockaddr_storage" = "xyes"; then
561 echo '#define rb_sockaddr_storage sockaddr_storage' >> $outfile
563 echo 'struct rb_sockaddr_storage { uint8_t _padding[[128]]; };' >> $outfile
566 cat >> $outfile <<\_______EOF
567 #endif /* __LIBRB_CONFIG_H */
570 if cmp -s $outfile include/librb-config.h; then
571 AC_MSG_NOTICE([include/librb-config.h is unchanged])
574 ${rb_mv} $outfile include/librb-config.h
578 if test x$ac_cv_header_stdc = xyes; then
581 if test x$ac_cv_header_stdlib_h = xyes; then
582 rb_header_stdlib_h=yes
584 if test x$ac_cv_header_string_h = xyes; then
585 rb_header_string_h=yes
587 if test x$ac_cv_header_memory_h = xyes; then
588 rb_header_memory_h=yes
590 if test "x${ac_cv_working_alloca_h+set}" = xset ; then
591 rb_alloca_h="$ac_cv_working_alloca_h"
593 rb_alloc_h="$ac_cv_header_alloca_h"
595 if test x$ac_cv_member_struct_sockaddr_sa_len = xyes; then
596 rb_sockaddr_sa_len=yes
598 if test x$ac_cv_header_sys_socket_h = xyes; then
601 if test x$ac_cv_header_sys_types_h = xyes; then
604 if test x$ac_cv_header_sys_stat_h = xyes; then
607 if test x$ac_cv_header_sys_time_h = xyes; then
610 if test x$ac_cv_header_time = xyes; then
614 if test x$ac_cv_header_stdint_h = xyes; then
617 if test x$ac_cv_header_inttypes_h = xyes; then
620 if test x$ac_cv_header_netinet_in_h = xyes; then
624 if test x$ac_cv_header_crypt_h = xyes; then
627 if test x$ac_cv_header_errno_h = xyes; then
630 if test x$ac_cv_header_unistd_h = xyes; then
633 if test x$ac_cv_header_windows_h = xyes; then
636 if test x$ac_cv_header_winsock2_h = xyes; then
640 rb_socklen_t=$rb_socklen_t
642 if test "x$rb_have_sockaddr_storage" = "xyes"; then
643 rb_sockaddr_storage="yes"
645 rb_sockaddr_storage="no"
648 rb_have_ipv6="$have_v6"
667 dnl Make it look sexay!
670 echo "Compiling $PACKAGE_NAME $PACKAGE_VERSION"
673 echo "Installing into: $prefix"
675 echo "IPv6 support ................... $have_v6"
676 echo "Assert debugging ............... $assert"
677 echo "Block allocator ................ $balloc"
678 echo "SSL Type........................ $SSL_TYPE"