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