1/*- 2 * Copyright (c)1997-2005 by Hartmut Brandt 3 * All rights reserved. 4 * 5 * Author: Harti Brandt <harti@freebsd.org> 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $Begemot: libbegemot/configure.ac,v 1.18 2005/06/01 08:01:44 brandt_h Exp $ 29 */ 30AC_INIT([Begemot support library], [1.11], [harti@freebsd.org], libbegemot) 31AC_PREREQ(2.59) 32AC_COPYRIGHT([Copyright (c)1997-2005 Hartmut Brandt. All rights reserved. 33See the file COPYRIGHT for details of redistribution and use.]) 34AC_REVISION($Revision$) 35 36AC_CONFIG_SRCDIR(rpoll.man) 37AC_CONFIG_AUX_DIR(config) 38AC_CANONICAL_BUILD 39AC_CANONICAL_HOST 40AC_CANONICAL_TARGET 41 42AC_PROG_CC 43AC_PROG_CPP 44AC_PROG_MAKE_SET 45AC_PROG_INSTALL 46 47AC_PROG_LIBTOOL 48AC_SUBST(LIBTOOL_DEPS) 49 50# ------------------------------------------------------------ 51# Figure out, how the times are stored in struct stat. There 52# are at least four variants: st_atime, which are time_t's 53# (BDS/OS 1.0), st_atimespec, which is a timeval, st_atimespec 54# which is a timespec and st_atim, which is a timeval. 55# We got the following route: 56# 1. figure out, if we have timespecs 57# 1.1 if yes: find out wheter it contains tv_sec or ts_sec 58# 2. else figure out if we have timevals 59# 3. else assume we have time_t's 60# ------------------------------------------------------------ 61AC_CACHE_CHECK([whether struct stat times are timespecs], 62 ac_cv_stat_has_timespec, 63 AC_TRY_COMPILE([ 64# include <sys/types.h> 65# include <sys/stat.h> 66# include <string.h>], 67 [struct stat statb; 68 (void)memset(&statb.st_atimespec, 0, 10)], 69 ac_cv_stat_has_timespec=yes, 70 ac_cv_stat_has_timespec=no)) 71if test $ac_cv_stat_has_timespec = yes ; then 72 AC_DEFINE(STAT_HAS_TIMESPEC) 73fi 74 75if test $ac_cv_stat_has_timespec = yes ; then 76 AC_CACHE_CHECK([whether timespecs have ts_sec (instead of tv_sec)], 77 ac_cv_timespec_has_ts, 78 AC_TRY_COMPILE([ 79# include <sys/types.h> 80# include <sys/stat.h>], 81 [struct stat statb; 82 statb.st_atimespec.ts_nsec = 12], 83 ac_cv_timespec_has_ts=yes, 84 ac_cv_timespec_has_ts=no)) 85 if test $ac_cv_timespec_has_ts = yes ; then 86 AC_DEFINE(TIMESPEC_HAS_TS) 87 fi 88else 89 AC_CACHE_CHECK([whether struct stat times are timevals], 90 ac_cv_stat_has_timeval, 91 AC_TRY_COMPILE([ 92# include <sys/types.h> 93# include <sys/stat.h>], 94 [struct stat statb; 95 (void)memset(&statb.st_atim, 0, 10)], 96 ac_cv_stat_has_timeval=yes, 97 ac_cv_stat_has_timeval=no)) 98 if test $ac_cv_stat_has_timeval = yes ; then 99 AC_DEFINE(STAT_HAS_TIMEVAL) 100 fi 101fi 102 103# ------------------------------------------------------------ 104# look for the st_fstype member in struct stat. On Solaris 105# this is a string we can print. 106# ------------------------------------------------------------ 107AC_CACHE_CHECK([whether struct stat has st_fstype], 108 ac_cv_fstype, 109 AC_TRY_COMPILE([ 110# include <sys/types.h> 111# include <sys/stat.h>], 112 [struct stat statb; 113 foo(&statb.st_fstype)], 114 ac_cv_fstype=yes, 115 ac_cv_fstype=no)) 116if test $ac_cv_fstype = yes ; then 117 AC_DEFINE(STAT_HAS_FSTYPE) 118fi 119 120# ------------------------------------------------------------ 121# look for the st_flags member in struct stat. On BSD4.4 derived systems 122# this is a flag field. 123# ------------------------------------------------------------ 124AC_CACHE_CHECK([whether struct stat has st_flags], 125 ac_cv_stat_flags, 126 AC_TRY_COMPILE([ 127# include <sys/types.h> 128# include <sys/stat.h>], 129 [struct stat statb; 130 foo(&statb.st_flags)], 131 ac_cv_stat_flags=yes, 132 ac_cv_stat_flags=no)) 133if test $ac_cv_stat_flags = yes ; then 134 AC_DEFINE(STAT_HAS_FLAGS) 135fi 136 137# ------------------------------------------------------------ 138# look for the st_gen member in struct stat. On BSD4.4 derived systems 139# this is a generation number. 140# ------------------------------------------------------------ 141AC_CACHE_CHECK([whether struct stat has st_gen], 142 ac_cv_stat_gen, 143 AC_TRY_COMPILE([ 144# include <sys/types.h> 145# include <sys/stat.h>], 146 [struct stat statb; 147 foo(&statb.st_gen)], 148 ac_cv_stat_gen=yes, 149 ac_cv_stat_gen=no)) 150if test $ac_cv_stat_gen = yes ; then 151 AC_DEFINE(STAT_HAS_GEN) 152fi 153 154# ------------------------------------------------------------ 155# look for the st_birthtimespec member in struct stat. 156# ------------------------------------------------------------ 157AC_CACHE_CHECK([whether struct stat has st_birthtimespec], 158 ac_cv_stat_birthtimespec, 159 AC_TRY_COMPILE([ 160# include <sys/types.h> 161# include <sys/stat.h>], 162 [struct stat statb; 163 foo(&statb.st_birthtimespec)], 164 ac_cv_stat_birthtimespec=yes, 165 ac_cv_stat_birthtimespec=no)) 166if test $ac_cv_stat_birthtimespec = yes ; then 167 AC_DEFINE(STAT_HAS_BIRTHTIMESPEC) 168fi 169 170# ------------------------------------------------------------ 171# Look for streams. If we have them use poll(2) for the poll_ 172# functions. Else use select(). In theory this are entirely 173# different things. Maybe we should always use select(2). 174# XXX if we use select, we should figure out, whether it 175# leaves the remaining time in the time value, if it returns 176# due to a ready file descriptor. This could save us a system call 177# ------------------------------------------------------------ 178AC_CHECK_HEADER(stropts.h, 179 AC_DEFINE(HAVE_STREAMS) 180 use_poll=yes 181 AC_DEFINE(USE_POLL), 182 use_poll=no 183 AC_DEFINE(USE_SELECT)) 184 185# ------------------------------------------------------------ 186# 187# figure out, whether we have to fiddle with USE_XOPEN under F... linux. 188# 189# ------------------------------------------------------------ 190if test $use_poll = "yes" ; then 191 AC_EGREP_CPP(yes, 192 [# include <sys/poll.h> 193 # ifndef POLLRDNORM 194 yes 195 # endif 196 ], 197 AC_DEFINE(NEED_POLL_XOPEN_TWIDDLE)) 198fi 199 200# ------------------------------------------------------------ 201# These are needed on Solaris 202# ------------------------------------------------------------ 203AC_CHECK_HEADER(sys/sysmacros.h, 204 AC_DEFINE(HAVE_SYSMACROS_H)) 205 206# ------------------------------------------------------------ 207# BSD4.4 (I think) changed the way rights are passed accross 208# a socket. Find out whether we have the old or the new struct 209# msghdr. 210# ------------------------------------------------------------ 211AC_CACHE_CHECK([whether we have the historical struct msghdr], 212 ac_cv_oldmsghdr, 213 AC_TRY_COMPILE([ 214# include <sys/types.h> 215# include <sys/socket.h>], 216 [struct msghdr msg; msg.msg_control = 0], 217 ac_cv_oldmsghdr=no, 218 ac_cv_oldmsghdr=yes)) 219if test $ac_cv_oldmsghdr = yes ; then 220 AC_DEFINE(HAVE_OLDMSGHDR) 221fi 222 223# ------------------------------------------------------------ 224# Quads are printed differently on different systems. Figure 225# out how to do it. 226# ------------------------------------------------------------ 227# If we have an inttypes.h assume this is a posixly one and has the 228# correct definition of the print flag 229AC_CHECK_HEADER(inttypes.h, 230 [AC_DEFINE(HAVE_INTTYPES_H) 231 ac_have_inttypes_h=yes]) 232AC_CACHE_CHECK([how to print quads], 233 ac_cv_quad_fmt, 234 [if test "$ac_have_inttypes_h" = "yes" ; then 235 ac_cv_quad_fmt=PRIu64 236 else 237 AC_TRY_RUN( 238[[ 239# include <stdio.h> 240# include <stdlib.h> 241# include <string.h> 242int 243main() 244{ 245 char buf[100]; 246 247 sprintf(buf, "%qx", 0x1234567887654321LLU); 248 exit((strcmp(buf, "1234567887654321") == 0) ? 0 : 1); 249} 250]], 251 ac_cv_quad_fmt='"q"', 252 ac_cv_quad_fmt='"ll"', 253 ac_cv_quad_fmt='"ll"') 254 fi ]) 255AC_DEFINE_UNQUOTED(QUADFMT, $ac_cv_quad_fmt) 256 257# ------------------------------------------------------------ 258# The following is really hard to figure out. We would need a 259# test program the compilation of which depends on other config options. 260# Let's define it statically for now. It seems, that 261# the Solaris 2.5 socket emulation has a brokeness. 262# ------------------------------------------------------------ 263AC_MSG_CHECKING([whether send fd is broken]) 264case $host_os in 265 solaris2.6|solaris2.7) 266 ac_send_fd_bug=no ;; 267 solaris*) 268 ac_send_fd_bug=yes ;; 269 *) 270 ac_send_fd_bug=no ;; 271esac 272AC_MSG_RESULT([$ac_send_fd_bug]) 273if test $ac_send_fd_bug = yes; then 274 AC_DEFINE(SEND_FD_BUG) 275fi 276 277# ------------------------------------------------------------ 278# Figure out, which library we need for sendmsg/recvmsg and 279# socketpair. Use the right order of test to get Solaris 2.6 280# right. 281# ------------------------------------------------------------ 282SYSLIBS= 283AC_CHECK_LIB(xnet, socketpair, 284 SYSLIBS="$SYSLIBS -lxnet", 285 AC_CHECK_LIB(socket, socketpair, 286 SYSLIBS="$SYSLIBS -lsocket -lnsl", 287 , 288 -lnsl)) 289AC_CHECK_LIB(socket, sendmsg, 290 SYSLIBS="$SYSLIBS -lsocket -lnsl", ,-lnsl) 291AC_SUBST(SYSLIBS) 292 293# ------------------------------------------------------------ 294# HP/UX has definitions for fd_set, but fails to use these in 295# the prototype of select. Figure out, whether the prototype 296# is correct. 297# ------------------------------------------------------------ 298AC_MSG_CHECKING([whether select prototype is broken]) 299AC_EGREP_CPP([int[ ]*select[ ]*\([ ]*int.*fd_set], 300[ 301# include <sys/types.h> 302# include <sys/time.h> 303# include <unistd.h> 304], ac_broken_select=no, ac_broken_select=yes) 305AC_MSG_RESULT([$ac_broken_select]) 306if test $ac_broken_select = yes; then 307 AC_DEFINE(BROKEN_SELECT_PROTO) 308fi 309 310# ------------------------------------------------------------ 311# Check whether this is f.... Linux, which defines POLL_IN/OUT. 312# ------------------------------------------------------------ 313AC_MSG_CHECKING([whether signal.h defines POLL_{IN,OUT}]) 314AC_EGREP_CPP(yes,[ 315#include <signal.h> 316#ifdef POLL_IN 317yes 318#endif 319], ac_defined_pollin=yes, ac_defined_pollin=no) 320AC_MSG_RESULT([$ac_defined_pollin]) 321 322if test $ac_defined_pollin = yes ; then 323 DEFINED_POLLIN=1 324else 325 DEFINED_POLLIN=0 326fi 327AC_SUBST(DEFINED_POLLIN) 328 329# ------------------------------------------------------------ 330# Check whether we have clock_gettime or gethrtime 331# ------------------------------------------------------------ 332AC_CACHE_CHECK([whether we have gethrtime()], ac_cv_have_gethrtime, 333 AC_TRY_LINK([#include <sys/time.h>], 334 [(void)gethrtime()], 335 ac_cv_have_gethrtime=yes, 336 ac_cv_have_gethrtime=no)) 337if test "$ac_cv_have_gethrtime" = yes ; then 338 AC_DEFINE(HAVE_GETHRTIME) 339fi 340 341AC_CHECK_FUNC(clock_gettime,AC_DEFINE(HAVE_CLOCK_GETTIME),) 342 343# ------------------------------------------------------------ 344# Insert version number into header file. 345# ------------------------------------------------------------ 346BEGEMOT_MAJOR=`cat $srcdir/VERSION | sed 's/\..*$//'` 347[BEGEMOT_MINOR=`cat $srcdir/VERSION | sed 's/^.*\.\([0-9]*\).*$/\1/'`] 348AC_SUBST(BEGEMOT_MAJOR) 349AC_SUBST(BEGEMOT_MINOR) 350 351# ------------------------------------------------------------ 352 353AC_CONFIG_FILES([Makefile begemot.h]) 354AC_OUTPUT 355