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