/*- * Copyright (c)1997-2005 by Hartmut Brandt * All rights reserved. * * Author: Harti Brandt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Begemot: libbegemot/configure.ac,v 1.18 2005/06/01 08:01:44 brandt_h Exp $ */ AC_INIT([Begemot support library], [1.11], [harti@freebsd.org], libbegemot) AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c)1997-2005 Hartmut Brandt. All rights reserved. See the file COPYRIGHT for details of redistribution and use.]) AC_REVISION($Revision$) AC_CONFIG_SRCDIR(rpoll.man) AC_CONFIG_AUX_DIR(config) AC_CANONICAL_BUILD AC_CANONICAL_HOST AC_CANONICAL_TARGET AC_PROG_CC AC_PROG_CPP AC_PROG_MAKE_SET AC_PROG_INSTALL AC_PROG_LIBTOOL AC_SUBST(LIBTOOL_DEPS) # ------------------------------------------------------------ # Figure out, how the times are stored in struct stat. There # are at least four variants: st_atime, which are time_t's # (BDS/OS 1.0), st_atimespec, which is a timeval, st_atimespec # which is a timespec and st_atim, which is a timeval. # We got the following route: # 1. figure out, if we have timespecs # 1.1 if yes: find out wheter it contains tv_sec or ts_sec # 2. else figure out if we have timevals # 3. else assume we have time_t's # ------------------------------------------------------------ AC_CACHE_CHECK([whether struct stat times are timespecs], ac_cv_stat_has_timespec, AC_TRY_COMPILE([ # include # include # include ], [struct stat statb; (void)memset(&statb.st_atimespec, 0, 10)], ac_cv_stat_has_timespec=yes, ac_cv_stat_has_timespec=no)) if test $ac_cv_stat_has_timespec = yes ; then AC_DEFINE(STAT_HAS_TIMESPEC) fi if test $ac_cv_stat_has_timespec = yes ; then AC_CACHE_CHECK([whether timespecs have ts_sec (instead of tv_sec)], ac_cv_timespec_has_ts, AC_TRY_COMPILE([ # include # include ], [struct stat statb; statb.st_atimespec.ts_nsec = 12], ac_cv_timespec_has_ts=yes, ac_cv_timespec_has_ts=no)) if test $ac_cv_timespec_has_ts = yes ; then AC_DEFINE(TIMESPEC_HAS_TS) fi else AC_CACHE_CHECK([whether struct stat times are timevals], ac_cv_stat_has_timeval, AC_TRY_COMPILE([ # include # include ], [struct stat statb; (void)memset(&statb.st_atim, 0, 10)], ac_cv_stat_has_timeval=yes, ac_cv_stat_has_timeval=no)) if test $ac_cv_stat_has_timeval = yes ; then AC_DEFINE(STAT_HAS_TIMEVAL) fi fi # ------------------------------------------------------------ # look for the st_fstype member in struct stat. On Solaris # this is a string we can print. # ------------------------------------------------------------ AC_CACHE_CHECK([whether struct stat has st_fstype], ac_cv_fstype, AC_TRY_COMPILE([ # include # include ], [struct stat statb; foo(&statb.st_fstype)], ac_cv_fstype=yes, ac_cv_fstype=no)) if test $ac_cv_fstype = yes ; then AC_DEFINE(STAT_HAS_FSTYPE) fi # ------------------------------------------------------------ # look for the st_flags member in struct stat. On BSD4.4 derived systems # this is a flag field. # ------------------------------------------------------------ AC_CACHE_CHECK([whether struct stat has st_flags], ac_cv_stat_flags, AC_TRY_COMPILE([ # include # include ], [struct stat statb; foo(&statb.st_flags)], ac_cv_stat_flags=yes, ac_cv_stat_flags=no)) if test $ac_cv_stat_flags = yes ; then AC_DEFINE(STAT_HAS_FLAGS) fi # ------------------------------------------------------------ # look for the st_gen member in struct stat. On BSD4.4 derived systems # this is a generation number. # ------------------------------------------------------------ AC_CACHE_CHECK([whether struct stat has st_gen], ac_cv_stat_gen, AC_TRY_COMPILE([ # include # include ], [struct stat statb; foo(&statb.st_gen)], ac_cv_stat_gen=yes, ac_cv_stat_gen=no)) if test $ac_cv_stat_gen = yes ; then AC_DEFINE(STAT_HAS_GEN) fi # ------------------------------------------------------------ # look for the st_birthtimespec member in struct stat. # ------------------------------------------------------------ AC_CACHE_CHECK([whether struct stat has st_birthtimespec], ac_cv_stat_birthtimespec, AC_TRY_COMPILE([ # include # include ], [struct stat statb; foo(&statb.st_birthtimespec)], ac_cv_stat_birthtimespec=yes, ac_cv_stat_birthtimespec=no)) if test $ac_cv_stat_birthtimespec = yes ; then AC_DEFINE(STAT_HAS_BIRTHTIMESPEC) fi # ------------------------------------------------------------ # Look for streams. If we have them use poll(2) for the poll_ # functions. Else use select(). In theory this are entirely # different things. Maybe we should always use select(2). # XXX if we use select, we should figure out, whether it # leaves the remaining time in the time value, if it returns # due to a ready file descriptor. This could save us a system call # ------------------------------------------------------------ AC_CHECK_HEADER(stropts.h, AC_DEFINE(HAVE_STREAMS) use_poll=yes AC_DEFINE(USE_POLL), use_poll=no AC_DEFINE(USE_SELECT)) # ------------------------------------------------------------ # # figure out, whether we have to fiddle with USE_XOPEN under F... linux. # # ------------------------------------------------------------ if test $use_poll = "yes" ; then AC_EGREP_CPP(yes, [# include # ifndef POLLRDNORM yes # endif ], AC_DEFINE(NEED_POLL_XOPEN_TWIDDLE)) fi # ------------------------------------------------------------ # These are needed on Solaris # ------------------------------------------------------------ AC_CHECK_HEADER(sys/sysmacros.h, AC_DEFINE(HAVE_SYSMACROS_H)) # ------------------------------------------------------------ # BSD4.4 (I think) changed the way rights are passed accross # a socket. Find out whether we have the old or the new struct # msghdr. # ------------------------------------------------------------ AC_CACHE_CHECK([whether we have the historical struct msghdr], ac_cv_oldmsghdr, AC_TRY_COMPILE([ # include # include ], [struct msghdr msg; msg.msg_control = 0], ac_cv_oldmsghdr=no, ac_cv_oldmsghdr=yes)) if test $ac_cv_oldmsghdr = yes ; then AC_DEFINE(HAVE_OLDMSGHDR) fi # ------------------------------------------------------------ # Quads are printed differently on different systems. Figure # out how to do it. # ------------------------------------------------------------ # If we have an inttypes.h assume this is a posixly one and has the # correct definition of the print flag AC_CHECK_HEADER(inttypes.h, [AC_DEFINE(HAVE_INTTYPES_H) ac_have_inttypes_h=yes]) AC_CACHE_CHECK([how to print quads], ac_cv_quad_fmt, [if test "$ac_have_inttypes_h" = "yes" ; then AC_EGREP_CPP(yes, [ # include # ifdef PRIu64 yes # endif ], ac_cv_quad_fmt=PRIu64, AC_TRY_RUN( [[ # include # include # include int main() { char buf[100]; sprintf(buf, "%qx", 0x1234567887654321LLU); exit((strcmp(buf, "1234567887654321") == 0) ? 0 : 1); } ]], ac_cv_quad_fmt='"q"', ac_cv_quad_fmt='"ll"', ac_cv_quad_fmt='"ll"') fi ])) AC_DEFINE_UNQUOTED(QUADFMT, $ac_cv_quad_fmt) # ------------------------------------------------------------ # The following is really hard to figure out. We would need a # test program the compilation of which depends on other config options. # Let's define it statically for now. It seems, that # the Solaris 2.5 socket emulation has a brokeness. # ------------------------------------------------------------ AC_MSG_CHECKING([whether send fd is broken]) case $host_os in solaris2.6|solaris2.7) ac_send_fd_bug=no ;; solaris*) ac_send_fd_bug=yes ;; *) ac_send_fd_bug=no ;; esac AC_MSG_RESULT([$ac_send_fd_bug]) if test $ac_send_fd_bug = yes; then AC_DEFINE(SEND_FD_BUG) fi # ------------------------------------------------------------ # Figure out, which library we need for sendmsg/recvmsg and # socketpair. Use the right order of test to get Solaris 2.6 # right. # ------------------------------------------------------------ SYSLIBS= AC_CHECK_LIB(xnet, socketpair, SYSLIBS="$SYSLIBS -lxnet", AC_CHECK_LIB(socket, socketpair, SYSLIBS="$SYSLIBS -lsocket -lnsl", , -lnsl)) AC_CHECK_LIB(socket, sendmsg, SYSLIBS="$SYSLIBS -lsocket -lnsl", ,-lnsl) AC_SUBST(SYSLIBS) # ------------------------------------------------------------ # HP/UX has definitions for fd_set, but fails to use these in # the prototype of select. Figure out, whether the prototype # is correct. # ------------------------------------------------------------ AC_MSG_CHECKING([whether select prototype is broken]) AC_EGREP_CPP([int[ ]*select[ ]*\([ ]*int.*fd_set], [ # include # include # include ], ac_broken_select=no, ac_broken_select=yes) AC_MSG_RESULT([$ac_broken_select]) if test $ac_broken_select = yes; then AC_DEFINE(BROKEN_SELECT_PROTO) fi # ------------------------------------------------------------ # Check whether this is f.... Linux, which defines POLL_IN/OUT. # ------------------------------------------------------------ AC_MSG_CHECKING([whether signal.h defines POLL_{IN,OUT}]) AC_EGREP_CPP(yes,[ #include #ifdef POLL_IN yes #endif ], ac_defined_pollin=yes, ac_defined_pollin=no) AC_MSG_RESULT([$ac_defined_pollin]) if test $ac_defined_pollin = yes ; then DEFINED_POLLIN=1 else DEFINED_POLLIN=0 fi AC_SUBST(DEFINED_POLLIN) # ------------------------------------------------------------ # Check whether we have clock_gettime or gethrtime # ------------------------------------------------------------ AC_CACHE_CHECK([whether we have gethrtime()], ac_cv_have_gethrtime, AC_TRY_LINK([#include ], [(void)gethrtime()], ac_cv_have_gethrtime=yes, ac_cv_have_gethrtime=no)) if test "$ac_cv_have_gethrtime" = yes ; then AC_DEFINE(HAVE_GETHRTIME) fi AC_CHECK_FUNC(clock_gettime,AC_DEFINE(HAVE_CLOCK_GETTIME),) # ------------------------------------------------------------ # Insert version number into header file. # ------------------------------------------------------------ BEGEMOT_MAJOR=`cat $srcdir/VERSION | sed 's/\..*$//'` [BEGEMOT_MINOR=`cat $srcdir/VERSION | sed 's/^.*\.\([0-9]*\).*$/\1/'`] AC_SUBST(BEGEMOT_MAJOR) AC_SUBST(BEGEMOT_MINOR) # ------------------------------------------------------------ AC_CONFIG_FILES([Makefile begemot.h]) AC_OUTPUT