Home | History | Annotate | Line # | Download | only in compat
configure.ac revision 1.41
      1 #	$NetBSD: configure.ac,v 1.41 2003/10/27 00:12:43 lukem Exp $
      2 #
      3 # Autoconf definition file for libnbcompat.
      4 #
      5 
      6 AC_INIT([libnbcompat], [noversion], [lib-bug-people (a] NetBSD.org])
      7 AC_CONFIG_HEADERS(nbtool_config.h)
      8 AC_CONFIG_FILES(defs.mk)
      9 
     10 AC_PATH_PROG(BSHELL, sh, )
     11 if test x"$BSHELL" = x; then
     12 	AC_MSG_ERROR([sh must be somewhere on \$PATH])
     13 fi
     14 AC_DEFINE_UNQUOTED(PATH_BSHELL, "$BSHELL")
     15 
     16 AC_C_BIGENDIAN
     17 AC_HEADER_STDC
     18 
     19 # Confirm existence of zlib.  (This is available as a default install
     20 # option on many OS's; this could be added as a reachover build in the
     21 # future.)
     22 AC_CHECK_HEADER(zlib.h,,
     23 	AC_MSG_ERROR([zlib must be installed in a compiler-visible path]))
     24 AC_CHECK_LIB(z, gzdopen,,
     25 	AC_MSG_ERROR([zlib must be installed in a compiler-visible path]))
     26 
     27 # Make sure certain required headers are available.
     28 # These are not necessarily required by the code, but they are not
     29 # currently conditionalized.
     30 AC_CHECK_HEADERS(sys/ioctl.h sys/mman.h sys/mtio.h sys/param.h \
     31 	sys/socket.h sys/stat.h sys/time.h sys/types.h sys/utsname.h \
     32 	sys/wait.h assert.h ctype.h errno.h fcntl.h grp.h limits.h locale.h \
     33 	netdb.h pwd.h signal.h stdarg.h stdio.h stdlib.h string.h \
     34 	termios.h unistd.h,,
     35 	AC_MSG_ERROR([standard system header file not found]))
     36 
     37 # Find headers that may not be available.
     38 AC_HEADER_DIRENT
     39 AC_CHECK_HEADERS(sys/sysmacros.h sys/syslimits.h \
     40 	features.h malloc.h poll.h stddef.h)
     41 AC_CHECK_HEADERS(machine/bswap.h sys/cdefs.h sys/endian.h sys/featuretest.h \
     42 	err.h inttypes.h libgen.h paths.h stdint.h util.h,,
     43 	[test -f include/$ac_header || touch include/$ac_header])
     44 AC_CHECK_HEADERS(rpc/types.h getopt.h netconfig.h,,
     45 	[echo '#include "nbtool_config.h"' >include/$ac_header.new
     46 	echo '#include "'$srcdir/../../include/$ac_header'"' >>include/$ac_header.new
     47 	if cmp include/$ac_header.new include/$ac_header >/dev/null 2>&1; then
     48 		rm -f include/$ac_header.new
     49 	else
     50 		mv -f include/$ac_header.new include/$ac_header
     51 	fi])
     52 
     53 # Typedefs.
     54 AC_TYPE_SIZE_T
     55 AC_CHECK_TYPES([id_t, long long, u_long, u_quad_t])
     56 AC_CHECK_TYPE(socklen_t, [AC_DEFINE(HAVE_SOCKLEN_T)],,
     57 [#include <sys/types.h>
     58 #include <sys/socket.h>])
     59 
     60 dnl XXX - This is UGLY.  Need a better way to homogenize the bitsized types,
     61 dnl including use of compiler primitive types via AC_CHECK_SIZEOF.
     62 dnl
     63 define([NB_CHECK_INTTYPE], [
     64 	AC_CHECK_TYPE(uint][$1][_t,, [
     65 		AC_CHECK_TYPE(u_int][$1][_t,
     66 			AC_DEFINE(uint][$1][_t, u_int][$1][_t),
     67 			AC_MSG_ERROR([cannot find a suitable type for uint][$1][_t]))
     68 	])
     69 	AC_CHECK_TYPE(u_int][$1][_t,, [
     70 		AC_CHECK_TYPE(uint][$1][_t,
     71 			AC_DEFINE(u_int][$1][_t, uint][$1][_t),
     72 			AC_MSG_ERROR([cannot find a suitable type for u_int][$1][_t]))
     73 	])
     74 ])
     75 
     76 NB_CHECK_INTTYPE(8)
     77 NB_CHECK_INTTYPE(16)
     78 NB_CHECK_INTTYPE(32)
     79 NB_CHECK_INTTYPE(64)
     80 
     81 # Struct members.
     82 AC_CHECK_MEMBERS([DIR.dd_fd, struct dirent.d_namlen],,,
     83 [#include <sys/types.h>
     84 #include <dirent.h>])
     85 AC_CHECK_MEMBERS([struct stat.st_flags, struct stat.st_gen,
     86 	struct stat.st_birthtime, struct stat.st_atim,
     87 	struct stat.st_mtimensec],,, [#include <sys/stat.h>])
     88 AC_CHECK_MEMBERS(struct statfs.f_iosize,,, [#include <sys/mount.h>])
     89 
     90 # Global variable decls.
     91 AC_CHECK_DECLS([optind, optreset],,, [
     92 #include <stdio.h>
     93 #include <stdlib.h>
     94 #include <unistd.h>
     95 ])
     96 AC_CHECK_DECLS(sys_signame,,, [#include <signal.h>])
     97 
     98 # Library functions (where a .h check isn't enough).
     99 AC_FUNC_ALLOCA
    100 AC_CHECK_FUNCS(atoll asprintf asnprintf basename devname dirfd dirname \
    101 	fgetln flock fparseln futimes getopt getopt_long \
    102 	isblank issetugid lchflags lchmod lchown lutimes mkstemp mkdtemp \
    103 	poll pread putc_unlocked pwcache_userdb pwrite random setenv \
    104 	setgroupent setprogname setpassent snprintf strlcat strlcpy strsep \
    105 	strsuftoll strtoll \
    106 	user_from_uid vasprintf vasnprintf vsnprintf)
    107 
    108 AC_CHECK_DECLS([setgroupent, setpassent],,, [
    109 #include <sys/types.h>
    110 #include <grp.h>
    111 #include <pwd.h>
    112 ])
    113 
    114 # regcomp() and regexec() are also names of functions in the old V8
    115 # regexp package.  To avoid them, we need to find out who has regfree().
    116 
    117 dnl # Cygwin: We *MUST* look at -lregex *before* the "no libs" condition.
    118 dnl # Thus AC_CHECK_LIB(regex...) comes first, and AC_SEARCHLIBS next.
    119 AC_CHECK_LIB(regex, regfree)
    120 AC_SEARCH_LIBS(regfree, rx posix)
    121 
    122 AC_OUTPUT
    123