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([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])
46 AC_PATH_PROG(AUTOMAKE, automake)
47 AC_PATH_PROG(ACLOCAL, aclocal)
48 AC_PATH_PROG(AUTOHEADER, autoheader)
54 AC_PATH_PROG(TOUCH, touch)
59 LIBTOOL="$LIBTOOL --silent"
63 AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
64 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
67 AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
68 AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
69 AC_CHECK_HEADER(windows.h, , [AC_MSG_ERROR([** MinGW and no windows.h. I give up.])])
70 AC_CHECK_HEADER(winsock2.h, , [AC_MSG_ERROR([** MinGW and no winsock2.h. I give up.])])
71 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1, [Have WINSOCK2_H])
72 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1, [Have WINSOCK_H])
73 LIBS="$LIBS -lws2_32 -liphlpapi"
77 CPPFLAGS="$CFLAGS -D_ALL_SOURCE -D_XOPEN_SOURCE=500"
80 CPPFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS -D_XPG4_2"
86 AM_CONDITIONAL([MINGW], [test "$is_mingw" = "yes"])
89 # backwards support for IRC_CFLAGS
90 CFLAGS="$IRC_CFLAGS $CFLAGS -Wall"
92 dnl use directory structure of cached as default (hack)
93 if test "$libexecdir" = '${exec_prefix}/libexec' &&
94 test "$localstatedir" = '${prefix}/var'; then
95 libexecdir='${bindir}'
96 localstatedir='${prefix}'
105 dnl Checks for header files.
108 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])
111 dnl Networking Functions
112 dnl ====================
114 AC_SEARCH_LIBS(socket, [socket],,)
117 AC_CHECK_MEMBER([struct sockaddr.sa_len], [AC_DEFINE(SOCKADDR_IN_HAS_LEN, 1, [Define to 1 if sockaddr has a 'sa_len'
119 #ifdef HAVE_SYS_TYPES_H
120 #include <sys/types.h>
122 #ifdef HAVE_SYS_SOCKET_H
123 #include <sys/socket.h>
125 #ifdef HAVE_WINSOCK2_H
126 #include <winsock2.h>
130 AC_CHECK_TYPE([socklen_t], rb_cv_socklen_t=socklen_t,[
131 AC_MSG_CHECKING([for socklen_t equivalent])
132 AC_CACHE_VAL([rb_cv_socklen_t],
134 # Systems have either "struct sockaddr *" or
135 # "void *" as the second argument to getpeername
137 for arg2 in "struct sockaddr" void; do
138 for t in int size_t unsigned long "unsigned long"; do
140 #ifdef HAVE_SYS_TYPES_H
141 #include <sys/types.h>
143 #ifdef HAVE_SYS_SOCKET_H
144 #include <sys/socket.h>
146 #ifdef HAVE_WINSOCK2_H
147 #include <winsock2.h>
149 int getpeername (int, $arg2 *, $t *);
152 getpeername(0,0,&len);
160 if test "x$rb_cv_socklen_t" = x; then
161 AC_MSG_WARN([Cannot find a type to use in place of socklen_t using int])
165 AC_MSG_RESULT($rb_cv_socklen_t)],
166 [#include <sys/types.h>
167 #include <sys/socket.h>])
169 rb_socklen_t=$rb_cv_socklen_t
175 AC_ARG_ENABLE(ipv6,AC_HELP_STRING([--disable-ipv6],[Disable IPv6 support]),[ipv6=$enableval],[ipv6=yes])
177 if test x$ipv6 != xyes; then
183 AC_MSG_NOTICE([Disabling IPv6 support: PF_INET6 not found])
187 if test "X$have_v6" = "Xyes"; then
188 RB_TYPE_STRUCT_SOCKADDR_IN6([], [
189 AC_MSG_NOTICE([Disabling IPv6 support: struct sockaddr_in6 not found])
196 AC_CHECK_TYPES([struct sockaddr_storage],[
197 rb_have_sockaddr_storage=yes
199 #include <sys/types.h>
200 #include <sys/socket.h>
204 dnl Check for stdarg.h - if we cant find it, halt configure
205 AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - libratbox will not compile without it **])])
207 AC_CHECK_TYPE([sa_family_t], [],
208 [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
209 [[#include <sys/types.h>
210 #include <sys/socket.h>]])
213 dnl check for various functions...
214 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])
216 AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep]))
217 AC_SEARCH_LIBS(timer_create, rt, AC_DEFINE(HAVE_TIMER_CREATE, 1, [Define if you have timer_create]))
218 RB_CHECK_TIMER_CREATE
219 RB_CHECK_TIMERFD_CREATE
225 AC_MSG_CHECKING(for /dev/poll)
226 if test -c "/dev/poll"; then
228 AC_DEFINE(HAVE_DEVPOLL, [1], [Define to 1 if you have devpoll])
234 if test "$is_mingw" = "yes"; then
235 AC_DEFINE(HAVE_WIN32, [1], [Define to 1 if you are on windows])
240 AC_MSG_CHECKING(for OpenSSL)
241 AC_ARG_ENABLE(openssl,
242 [AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
243 AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
244 [cf_enable_openssl=$enableval],
245 [cf_enable_openssl="auto"])
247 if test "$cf_enable_openssl" != "no" ; then
248 cf_openssl_basedir=""
249 if test "$cf_enable_openssl" != "auto" &&
250 test "$cf_enable_openssl" != "yes" ; then
251 dnl Support for --enable-openssl=/some/place
252 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
254 dnl Do the auto-probe here. Check some common directory paths.
255 for dirs in /usr/local/ssl /usr/pkg /usr/local \
256 /usr/local/openssl ; do
257 if test -f "${dirs}/include/openssl/opensslv.h" ; then
258 cf_openssl_basedir="${dirs}"
264 dnl Now check cf_openssl_found to see if we found anything.
265 if test ! -z "$cf_openssl_basedir"; then
266 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
267 SSL_CFLAGS="-I${cf_openssl_basedir}/include"
268 SSL_LIBS="-L${cf_openssl_basedir}/lib"
270 dnl OpenSSL wasn't found in the directory specified. Naughty
272 cf_openssl_basedir=""
275 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
276 dnl are in /usr/include and /usr/lib. In this case, we don't want to
277 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
278 dnl We can't do this check above, because some people want two versions
279 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
280 dnl and they want /usr/local/ssl to have preference.
281 if test -f "/usr/include/openssl/opensslv.h" ; then
282 cf_openssl_basedir="/usr"
286 dnl If we have a basedir defined, then everything is okay. Otherwise,
287 dnl we have a problem.
288 if test ! -z "$cf_openssl_basedir"; then
289 AC_MSG_RESULT($cf_openssl_basedir)
290 cf_enable_openssl="yes"
292 AC_MSG_RESULT([not found. Specify a correct path?])
293 cf_enable_openssl="no"
295 unset cf_openssl_basedir
297 dnl If --disable-openssl was specified
298 AC_MSG_RESULT(disabled)
301 save_CPPFLAGS="$CPPFLAGS"
302 CPPFLAGS="$CPPFLAGS $SSL_CFLAGS"
304 LIBS="$LIBS $SSL_LIBS"
305 if test "$cf_enable_openssl" != no; then
306 dnl Check OpenSSL version (must be 0.9.7 or above!)
307 AC_MSG_CHECKING(for OpenSSL 0.9.7 or above)
310 [#include <openssl/opensslv.h>
311 #include <stdlib.h>],
312 [[if (OPENSSL_VERSION_NUMBER >= 0x00907000)
313 exit(0); else exit(1);]]),
314 cf_enable_openssl=yes,
315 cf_enable_openssl=no,
316 cf_enable_openssl=no)
318 if test "$cf_enable_openssl" != no; then
321 AC_MSG_RESULT(no - OpenSSL support disabled)
327 if test "$cf_enable_openssl" != no; then
328 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
329 AC_CHECK_LIB(crypto, RAND_status,
330 [cf_enable_openssl=yes],
331 [cf_enable_openssl=no])
334 if test "$cf_enable_openssl" != no; then
335 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
336 AC_CHECK_LIB(ssl, SSL_read,
337 [SSL_LIBS="$SSL_LIBS -lssl -lcrypto"],
338 [cf_enable_openssl=no], [-lcrypto])
344 AC_MSG_CHECKING(for GnuTLS)
345 AC_ARG_ENABLE(gnutls,
346 [AC_HELP_STRING([--enable-gnutls],[Enable GnuTLS support.])
347 AC_HELP_STRING([--disable-gnutls],[Disable GnuTLS support.])],
348 [cf_enable_gnutls=$enableval],
349 [cf_enable_gnutls="auto"])
351 if test "$cf_enable_gnutls" != no; then
352 PKG_CHECK_MODULES(GNUTLS, [gnutls], [
353 cf_enable_gnutls="yes"
354 ], [cf_enable_gnutls="no"])
357 if test "$cf_enable_gnutls" = "auto" -a "$cf_enable_openssl" = "yes"; then
358 cf_enable_gnutls="no"
361 if test x"$cf_enable_openssl" != xno; then
362 AC_DEFINE(HAVE_OPENSSL,1,[Has OpenSSL])
366 elif test x"$cf_enable_gnutls" != xno; then
367 AC_DEFINE(HAVE_GNUTLS, 1, [Has GnuTLS])
376 CPPFLAGS="$save_CPPFLAGS"
379 dnl End OpenSSL detection
384 dnl Debug-related options
385 dnl =====================
387 AC_ARG_ENABLE(assert,
388 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
389 [assert=$enableval], [assert=no])
391 if test "$assert" = no; then
392 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
393 elif test "$assert" = soft; then
394 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
395 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
396 elif test "$assert" = yes; then
400 AC_MSG_CHECKING(if you want to do a profile build)
401 AC_ARG_ENABLE(profile,
402 AC_HELP_STRING([--enable-profile],[Enable profiling]),
403 [profile=$enableval], [profile=no])
405 if test "$profile" = yes; then
406 if test "$ac_cv_c_compiler_gnu" = yes; then
407 CFLAGS="$CFLAGS -pg -static"
408 AC_MSG_RESULT([yes, adding -pg -static])
409 AC_DEFINE(RATBOX_PROFILE, 1, [Defined to mark profiling is enabled])
411 AC_MSG_RESULT([no, profile builds only work with gcc])
417 AC_ARG_ENABLE(balloc,
418 AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
419 [balloc=$enableval], [balloc=yes])
421 if test "$balloc" = no; then
422 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
425 AC_ARG_ENABLE(warnings,
426 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
427 [CFLAGS="$CFLAGS -Wall -Werror -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -W -Wno-unused -Wunused-function -Wunused-variable"],[])
435 AC_SUBST(GNUTLS_CFLAGS)
436 AC_SUBST(GNUTLS_LIBS)
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 AC_CONFIG_COMMANDS([include/librb-config.h],
455 outfile=include/librb-config.h.tmp
456 cat > $outfile <<\_______EOF
458 * librb-config.h: libratbox config file. Please modify configure.ac
461 #ifndef __LIBRB_CONFIG_H
462 #define __LIBRB_CONFIG_H
466 if test "x$rb_have_ipv6" = "xyes"; then
467 echo "#define RB_IPV6 1" >> $outfile
470 if test "x$rb_windows_h" = "xyes"; then
471 echo '#define WIN32_LEAN_AND_MEAN 1' >> $outfile
472 echo '#include <windows.h>' >> $outfile
473 echo '#include <winsock2.h>' >> $outfile
474 echo '#include <iphlpapi.h>' >> $outfile
477 if test "x$rb_alloca_h" = "xyes"; then
478 echo '#define RB_HAVE_ALLOCA_H 1' >> $outfile
481 if test "x$rb_header_stdc" = "xyes"; then
482 echo '#include <stdlib.h>' >> $outfile
483 echo '#include <stddef.h>' >> $outfile
484 elif test "x$rb_header_stdlib" = "xyes"; then
485 echo '#include <stdlib.h>' >> $outfile
488 if test "x$rb_header_string_h" = "xyes"; then
489 echo '#include <string.h>' >> $outfile
492 if test "x$rb_stdint_h" = "xyes"; then
493 echo '#include <stdint.h>' >> $outfile
496 if test "x$rb_inttypes_h" = "xyes"; then
497 echo '#include <inttypes.h>' >> $outfile
500 if test "x$rb_sys_types_h" = "xyes"; then
501 echo '#include <sys/types.h>' >> $outfile
503 if test "x$rb_sys_time_h" = "xyes"; then
504 echo '#include <sys/time.h>' >> $outfile
506 if test "x$rb_sys_stat_h" = "xyes"; then
507 echo '#include <sys/stat.h>' >> $outfile
509 if test "x$rb_time_h" = "xyes"; then
510 echo '#include <time.h>' >> $outfile
513 if test "x$rb_sys_socket_h" = "xyes"; then
514 echo '#include <sys/socket.h>' >> $outfile
517 if test "x$rb_netinet_in_h" = "xyes"; then
518 echo '#include <netinet/in.h>' >> $outfile
521 if test "x$rb_arpa_inet_h" = "xyes"; then
522 echo '#include <arpa/inet.h>' >> $outfile
525 if test "x$rb_unistd_h" = "xyes"; then
526 echo '#include <unistd.h>' >> $outfile
529 if test "x$rb_crypt_h" = "xyes"; then
530 echo '#include <crypt.h>' >> $outfile
533 if test "x$rb_errno_h" = "xyes"; then
534 echo '#include <errno.h>' >> $outfile
537 echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile
540 if test "x$rb_sockaddr_sa_len" = "xyes"; then
541 echo '#define RB_SOCKADDR_HAS_SA_LEN 1' >> $outfile
544 if test "x$rb_sockaddr_storage" = "xyes"; then
545 echo '#define rb_sockaddr_storage sockaddr_storage' >> $outfile
547 echo 'struct rb_sockaddr_storage { uint8_t _padding[[128]]; };' >> $outfile
550 cat >> $outfile <<\_______EOF
551 #endif /* __LIBRB_CONFIG_H */
554 if cmp -s $outfile include/librb-config.h; then
555 AC_MSG_NOTICE([include/librb-config.h is unchanged])
558 ${rb_mv} $outfile include/librb-config.h
562 if test x$ac_cv_header_stdc = xyes; then
565 if test x$ac_cv_header_stdlib_h = xyes; then
566 rb_header_stdlib_h=yes
568 if test x$ac_cv_header_string_h = xyes; then
569 rb_header_string_h=yes
571 if test x$ac_cv_header_memory_h = xyes; then
572 rb_header_memory_h=yes
574 if test "x${ac_cv_working_alloca_h+set}" = xset ; then
575 rb_alloca_h="$ac_cv_working_alloca_h"
577 rb_alloc_h="$ac_cv_header_alloca_h"
579 if test x$ac_cv_member_struct_sockaddr_sa_len = xyes; then
580 rb_sockaddr_sa_len=yes
582 if test x$ac_cv_header_sys_socket_h = xyes; then
585 if test x$ac_cv_header_sys_types_h = xyes; then
588 if test x$ac_cv_header_sys_stat_h = xyes; then
591 if test x$ac_cv_header_sys_time_h = xyes; then
594 if test x$ac_cv_header_time = xyes; then
598 if test x$ac_cv_header_stdint_h = xyes; then
601 if test x$ac_cv_header_inttypes_h = xyes; then
604 if test x$ac_cv_header_netinet_in_h = xyes; then
608 if test x$ac_cv_header_crypt_h = xyes; then
611 if test x$ac_cv_header_errno_h = xyes; then
614 if test x$ac_cv_header_unistd_h = xyes; then
617 if test x$ac_cv_header_windows_h = xyes; then
620 if test x$ac_cv_header_winsock2_h = xyes; then
624 rb_socklen_t=$rb_socklen_t
626 if test "x$rb_have_sockaddr_storage" = "xyes"; then
627 rb_sockaddr_storage="yes"
629 rb_sockaddr_storage="no"
632 rb_have_ipv6="$have_v6"
651 dnl Make it look sexay!
654 echo "Compiling $PACKAGE_NAME $PACKAGE_VERSION"
657 echo "Installing into: $prefix"
659 echo "IPv6 support ................... $have_v6"
660 echo "Assert debugging ............... $assert"
661 echo "Block allocator ................ $balloc"
662 echo "SSL Type........................ $SSL_TYPE"