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