Home | History | Annotate | Line # | Download | only in compat
configure.ac revision 1.49
      1 #	$NetBSD: configure.ac,v 1.49 2005/01/13 00:52:40 jmc 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) AC_DEFINE(_POSIX_C_SOURCE, 200112L) AC_DEFINE(_XOPEN_SOURCE, 600)],
     21 	[AC_MSG_RESULT([no])])
     22 ])# AC_NETBSD
     23 
     24 AC_NETBSD
     25 AC_PATH_PROG(BSHELL, sh, )
     26 if test x"$BSHELL" = x; then
     27 	AC_MSG_ERROR([sh must be somewhere on \$PATH])
     28 fi
     29 AC_DEFINE_UNQUOTED(PATH_BSHELL, "$BSHELL")
     30 
     31 AC_C_BIGENDIAN
     32 AC_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.)
     37 AC_CHECK_HEADER(zlib.h,,
     38 	AC_MSG_ERROR([zlib must be installed in a compiler-visible path]))
     39 AC_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.
     45 AC_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.
     53 AC_HEADER_DIRENT
     54 AC_CHECK_HEADERS(sys/sysmacros.h sys/syslimits.h \
     55 	getopt.h features.h malloc.h sys/poll.h stddef.h)
     56 AC_CHECK_HEADERS(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])
     59 AC_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.
     69 AC_TYPE_SIZE_T
     70 AC_CHECK_TYPES([id_t, long long, u_long, u_char, u_short, u_int, u_quad_t])
     71 AC_CHECK_TYPE(socklen_t, [AC_DEFINE(HAVE_SOCKLEN_T)],,
     72 [#include <sys/types.h>
     73 #include <sys/socket.h>])
     74 
     75 dnl XXX - This is UGLY.  Need a better way to homogenize the bitsized types,
     76 dnl including use of compiler primitive types via AC_CHECK_SIZEOF.
     77 dnl
     78 define([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 
     91 NB_CHECK_INTTYPE(8)
     92 NB_CHECK_INTTYPE(16)
     93 NB_CHECK_INTTYPE(32)
     94 NB_CHECK_INTTYPE(64)
     95 
     96 # Struct members.
     97 AC_CHECK_MEMBERS([DIR.dd_fd, struct dirent.d_namlen],,,
     98 [#include <sys/types.h>
     99 #include <dirent.h>])
    100 AC_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>])
    104 AC_CHECK_MEMBERS(struct statvfs.f_iosize,,, [#include <sys/statvfs.h>])
    105 
    106 # Global variable decls.
    107 AC_CHECK_DECLS([optind, optreset],,, [
    108 #include <stdio.h>
    109 #include <stdlib.h>
    110 #include <unistd.h>
    111 ])
    112 AC_CHECK_DECLS(sys_signame,,, [#include <signal.h>])
    113 
    114 # Library functions (where a .h check isn't enough).
    115 AC_FUNC_ALLOCA
    116 AC_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 
    124 AC_CHECK_FUNCS([htobe16, htobe32, htobe64, htole16, htole32, htole64, be16toh, be32toh, be64toh, le16toh, le32toh, le64toh],,, [
    125 #include <sys/types.h>
    126 ])
    127 
    128 AC_CHECK_FUNCS([bswap16, bswap32, bswap64],,, [
    129 #include <machine/bswap.h>
    130 ])
    131 
    132 AC_CHECK_FUNCS([fstatvfs],,, [
    133 #include <sys/statvfs.h>
    134 ])
    135 
    136 AC_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 
    145 dnl # Cygwin: We *MUST* look at -lregex *before* the "no libs" condition.
    146 dnl # Thus AC_CHECK_LIB(regex...) comes first, and AC_SEARCHLIBS next.
    147 AC_CHECK_LIB(regex, regfree)
    148 AC_SEARCH_LIBS(regfree, rx posix)
    149 
    150 AC_OUTPUT
    151