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