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])
343 if test x"$cf_enable_openssl" != xno; then
344 AC_DEFINE(HAVE_OPENSSL,1,[Has OpenSSL])
351 CPPFLAGS="$save_CPPFLAGS"
354 dnl End OpenSSL detection
359 dnl Debug-related options
360 dnl =====================
362 AC_ARG_ENABLE(assert,
363 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
364 [assert=$enableval], [assert=no])
366 if test "$assert" = no; then
367 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
368 elif test "$assert" = soft; then
369 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
370 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
371 elif test "$assert" = yes; then
375 AC_MSG_CHECKING(if you want to do a profile build)
376 AC_ARG_ENABLE(profile,
377 AC_HELP_STRING([--enable-profile],[Enable profiling]),
378 [profile=$enableval], [profile=no])
380 if test "$profile" = yes; then
381 if test "$ac_cv_c_compiler_gnu" = yes; then
382 CFLAGS="$CFLAGS -pg -static"
383 AC_MSG_RESULT([yes, adding -pg -static])
384 AC_DEFINE(RATBOX_PROFILE, 1, [Defined to mark profiling is enabled])
386 AC_MSG_RESULT([no, profile builds only work with gcc])
392 AC_ARG_ENABLE(balloc,
393 AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
394 [balloc=$enableval], [balloc=yes])
396 if test "$balloc" = no; then
397 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
400 AC_ARG_ENABLE(warnings,
401 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
402 [CFLAGS="$CFLAGS -Wall -Werror -Wcast-qual -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -W -Wno-unused -Wunused-function -Wunused-variable"],[])
411 if test "$prefix" = "NONE"; then
412 AC_DEFINE_UNQUOTED(RB_PREFIX, "$ac_default_prefix", [Prefix where libratbox is installed.])
416 dnl Don't get bitten by Cygwin's stupidity if the user specified
417 dnl a custom prefix with a trailing slash
419 prefix=`echo $prefix | sed 's/\/$//'`
420 AC_DEFINE_UNQUOTED(RB_PREFIX, "$prefix", [Prefix where libratbox is installed.])
426 AC_CONFIG_COMMANDS([include/librb-config.h],
428 outfile=include/librb-config.h.tmp
429 cat > $outfile <<\_______EOF
431 * librb-config.h: libratbox config file. Please modify configure.ac
434 #ifndef __LIBRB_CONFIG_H
435 #define __LIBRB_CONFIG_H
439 if test "x$rb_have_ipv6" = "xyes"; then
440 echo "#define RB_IPV6 1" >> $outfile
443 if test "x$rb_windows_h" = "xyes"; then
444 echo '#define WIN32_LEAN_AND_MEAN 1' >> $outfile
445 echo '#include <windows.h>' >> $outfile
446 echo '#include <winsock2.h>' >> $outfile
447 echo '#include <iphlpapi.h>' >> $outfile
450 if test "x$rb_alloca_h" = "xyes"; then
451 echo '#define RB_HAVE_ALLOCA_H 1' >> $outfile
454 if test "x$rb_header_stdc" = "xyes"; then
455 echo '#include <stdlib.h>' >> $outfile
456 echo '#include <stddef.h>' >> $outfile
457 elif test "x$rb_header_stdlib" = "xyes"; then
458 echo '#include <stdlib.h>' >> $outfile
461 if test "x$rb_header_string_h" = "xyes"; then
462 echo '#include <string.h>' >> $outfile
465 if test "x$rb_stdint_h" = "xyes"; then
466 echo '#include <stdint.h>' >> $outfile
469 if test "x$rb_inttypes_h" = "xyes"; then
470 echo '#include <inttypes.h>' >> $outfile
473 if test "x$rb_sys_types_h" = "xyes"; then
474 echo '#include <sys/types.h>' >> $outfile
476 if test "x$rb_sys_time_h" = "xyes"; then
477 echo '#include <sys/time.h>' >> $outfile
479 if test "x$rb_sys_stat_h" = "xyes"; then
480 echo '#include <sys/stat.h>' >> $outfile
482 if test "x$rb_time_h" = "xyes"; then
483 echo '#include <time.h>' >> $outfile
486 if test "x$rb_sys_socket_h" = "xyes"; then
487 echo '#include <sys/socket.h>' >> $outfile
490 if test "x$rb_netinet_in_h" = "xyes"; then
491 echo '#include <netinet/in.h>' >> $outfile
494 if test "x$rb_arpa_inet_h" = "xyes"; then
495 echo '#include <arpa/inet.h>' >> $outfile
498 if test "x$rb_unistd_h" = "xyes"; then
499 echo '#include <unistd.h>' >> $outfile
502 if test "x$rb_crypt_h" = "xyes"; then
503 echo '#include <crypt.h>' >> $outfile
506 if test "x$rb_errno_h" = "xyes"; then
507 echo '#include <errno.h>' >> $outfile
510 echo "typedef $rb_socklen_t rb_socklen_t;" >> $outfile
513 if test "x$rb_sockaddr_sa_len" = "xyes"; then
514 echo '#define RB_SOCKADDR_HAS_SA_LEN 1' >> $outfile
517 if test "x$rb_sockaddr_storage" = "xyes"; then
518 echo '#define rb_sockaddr_storage sockaddr_storage' >> $outfile
520 echo 'struct rb_sockaddr_storage { uint8_t _padding[[128]]; };' >> $outfile
523 cat >> $outfile <<\_______EOF
524 #endif /* __LIBRB_CONFIG_H */
527 if cmp -s $outfile include/librb-config.h; then
528 AC_MSG_NOTICE([include/librb-config.h is unchanged])
531 ${rb_mv} $outfile include/librb-config.h
535 if test x$ac_cv_header_stdc = xyes; then
538 if test x$ac_cv_header_stdlib_h = xyes; then
539 rb_header_stdlib_h=yes
541 if test x$ac_cv_header_string_h = xyes; then
542 rb_header_string_h=yes
544 if test x$ac_cv_header_memory_h = xyes; then
545 rb_header_memory_h=yes
547 if test "x${ac_cv_working_alloca_h+set}" = xset ; then
548 rb_alloca_h="$ac_cv_working_alloca_h"
550 rb_alloc_h="$ac_cv_header_alloca_h"
552 if test x$ac_cv_member_struct_sockaddr_sa_len = xyes; then
553 rb_sockaddr_sa_len=yes
555 if test x$ac_cv_header_sys_socket_h = xyes; then
558 if test x$ac_cv_header_sys_types_h = xyes; then
561 if test x$ac_cv_header_sys_stat_h = xyes; then
564 if test x$ac_cv_header_sys_time_h = xyes; then
567 if test x$ac_cv_header_time = xyes; then
571 if test x$ac_cv_header_stdint_h = xyes; then
574 if test x$ac_cv_header_inttypes_h = xyes; then
577 if test x$ac_cv_header_netinet_in_h = xyes; then
581 if test x$ac_cv_header_crypt_h = xyes; then
584 if test x$ac_cv_header_errno_h = xyes; then
587 if test x$ac_cv_header_unistd_h = xyes; then
590 if test x$ac_cv_header_windows_h = xyes; then
593 if test x$ac_cv_header_winsock2_h = xyes; then
597 rb_socklen_t=$rb_socklen_t
599 if test "x$rb_have_sockaddr_storage" = "xyes"; then
600 rb_sockaddr_storage="yes"
602 rb_sockaddr_storage="no"
605 rb_have_ipv6="$have_v6"
624 dnl Make it look sexay!
627 echo "Compiling $PACKAGE_NAME $PACKAGE_VERSION"
630 echo "Installing into: $prefix"
632 echo "IPv6 support ................... $have_v6"
633 echo "Assert debugging ............... $assert"
634 echo "Block allocator ................ $balloc"
635 echo "SSL Type........................ $SSL_TYPE"