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