Home | History | Annotate | Line # | Download | only in compat
configure.ac revision 1.54
      1 #	$NetBSD: configure.ac,v 1.54 2006/02/11 00:54:35 wiz 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_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 
     26 AC_NETBSD
     27 AC_PATH_PROG(BSHELL, sh, )
     28 if test x"$BSHELL" = x; then
     29 	AC_MSG_ERROR([sh must be somewhere on \$PATH])
     30 fi
     31 AC_DEFINE_UNQUOTED([PATH_BSHELL], "$BSHELL", [Path to sh(1).])
     32 
     33 AC_C_BIGENDIAN
     34 AC_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.)
     39 AC_CHECK_HEADER(zlib.h,,
     40 	AC_MSG_ERROR([zlib must be installed in a compiler-visible path]))
     41 AC_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.
     47 AC_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.
     55 AC_HEADER_DIRENT
     56 AC_CHECK_HEADERS(sys/sysmacros.h sys/syslimits.h \
     57 	getopt.h features.h malloc.h sys/poll.h stddef.h)
     58 AC_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])
     61 AC_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.
     71 AC_TYPE_SIZE_T
     72 AC_CHECK_TYPES([id_t, long long, u_long, u_char, u_short, u_int, u_quad_t])
     73 AC_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 
     78 dnl XXX - This is UGLY.  Need a better way to homogenize the bitsized types,
     79 dnl including use of compiler primitive types via AC_CHECK_SIZEOF.
     80 dnl
     81 define([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 
     96 NB_CHECK_INTTYPE(8)
     97 NB_CHECK_INTTYPE(16)
     98 NB_CHECK_INTTYPE(32)
     99 NB_CHECK_INTTYPE(64)
    100 
    101 # Struct members.
    102 AC_CHECK_MEMBERS([DIR.dd_fd, struct dirent.d_namlen],,,
    103 [#include <sys/types.h>
    104 #include <dirent.h>])
    105 AC_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>])
    109 AC_CHECK_MEMBERS(struct statvfs.f_iosize,,, [#include <sys/statvfs.h>])
    110 
    111 # Global variable decls.
    112 AC_CHECK_DECLS([optind, optreset],,, [
    113 #include <stdio.h>
    114 #include <stdlib.h>
    115 #include <unistd.h>
    116 ])
    117 AC_CHECK_DECLS(sys_signame,,, [#include <signal.h>])
    118 
    119 # Library functions (where a .h check isn't enough).
    120 AC_FUNC_ALLOCA
    121 AC_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 
    129 AC_CHECK_DECLS([strsuftoll],,,[#include <stdlib.h>])
    130 
    131 AC_CHECK_DECLS([htobe16, htobe32, htobe64, htole16, htole32, htole64, be16toh, be32toh, be64toh, le16toh, le32toh, le64toh],,, [#include <sys/types.h>])
    132 
    133 AC_CHECK_DECLS([bswap16, bswap32, bswap64],,, [#include <machine/bswap.h>])
    134 
    135 AC_CHECK_DECLS([fstatvfs],,, [#include <sys/statvfs.h>])
    136 
    137 AC_CHECK_DECLS([setgroupent, setpassent],,, [
    138 #include <sys/types.h>
    139 #include <grp.h>
    140 #include <pwd.h>
    141 ])
    142 
    143 # regcomp() and regexec() are also names of functions in the old V8
    144 # regexp package.  To avoid them, we need to find out who has regfree().
    145 
    146 dnl # Cygwin: We *MUST* look at -lregex *before* the "no libs" condition.
    147 dnl # Thus AC_CHECK_LIB(regex...) comes first, and AC_SEARCHLIBS next.
    148 AC_CHECK_LIB(regex, regfree)
    149 AC_SEARCH_LIBS(regfree, rx posix)
    150 
    151 AC_OUTPUT
    152