1 # $NetBSD: configure.ac,v 1.74 2011/11/03 14:13:53 joerg Exp $
3 # Autoconf definition file for libnbcompat.
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.)
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. Regen again, to pick up changed RCS IDs from the above commit:
18 # cd ${SRCDIR}/tools/compat && ${TOOLDIR}/bin/nbmake-${MACHINE} regen
19 # 6. cvs commit files that were generated.
22 AC_INIT([libnbcompat], [noversion], [lib-bug-people@NetBSD.org])
23 AC_CONFIG_HEADERS(nbtool_config.h)
24 AC_CONFIG_FILES(defs.mk)
26 # Autoheader header and footer
27 AH_TOP([/* $][NetBSD$ */
29 #ifndef __NETBSD_NBTOOL_CONFIG_H__
30 #define __NETBSD_NBTOOL_CONFIG_H__])
32 AH_BOTTOM([#include "compat_defs.h"
33 #endif /* !__NETBSD_NBTOOL_CONFIG_H__ */])
36 [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
37 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
38 AC_MSG_CHECKING([for NetBSD])
45 AC_DEFINE([_POSIX_SOURCE], 1, [Define for NetBSD headers.])
46 AC_DEFINE([_POSIX_C_SOURCE], 200112L, [Define for NetBSD headers.])
47 AC_DEFINE([_XOPEN_SOURCE], 600, [Define for NetBSD headers.])],
48 [AC_MSG_RESULT([no])])
52 AC_PATH_PROG(BSHELL, sh, )
53 if test x"$BSHELL" = x; then
54 AC_MSG_ERROR([sh must be somewhere on \$PATH])
56 AC_DEFINE_UNQUOTED([PATH_BSHELL], "$BSHELL", [Path to sh(1).])
61 # Confirm existence of zlib. (This is available as a default install
62 # option on many OS's; this could be added as a reachover build in the
64 AC_CHECK_HEADER(zlib.h,,
65 AC_MSG_ERROR([zlib must be installed in a compiler-visible path]))
66 AC_CHECK_LIB(z, gzdopen,,
67 AC_MSG_ERROR([zlib must be installed in a compiler-visible path]))
69 # Make sure certain required headers are available.
70 # These are not necessarily required by the code, but they are not
71 # currently conditionalized.
72 AC_CHECK_HEADERS(sys/ioctl.h sys/mman.h sys/param.h \
73 sys/socket.h sys/stat.h sys/time.h sys/types.h sys/utsname.h \
74 sys/wait.h assert.h ctype.h errno.h fcntl.h grp.h limits.h locale.h \
75 netdb.h pwd.h signal.h stdarg.h stdio.h stdlib.h string.h \
77 AC_MSG_ERROR([standard system header file not found]))
79 # Find headers that may not be available.
81 AC_CHECK_HEADERS(sys/mtio.h sys/sysmacros.h sys/syslimits.h \
82 getopt.h features.h malloc.h sys/poll.h pthread.h stddef.h)
83 AC_CHECK_HEADERS(sys/bswap.h machine/bswap.h sys/cdefs.h machine/endian.h \
84 sys/endian.h sys/featuretest.h err.h inttypes.h libgen.h paths.h \
85 stdint.h util.h resolv.h arpa/nameser.h,,
86 [test -f include/$ac_header || touch include/$ac_header])
87 AC_CHECK_HEADERS(rpc/types.h netconfig.h,,
88 [echo '#include "nbtool_config.h"' >include/$ac_header.new
89 echo '#include "'$srcdir/../../include/$ac_header'"' \
90 >>include/$ac_header.new
91 if cmp include/$ac_header.new include/$ac_header >/dev/null 2>&1; then
92 rm -f include/$ac_header.new
94 mv -f include/$ac_header.new include/$ac_header
99 AC_CHECK_TYPES([id_t, long long, u_long, u_char, u_short, u_int, u_quad_t])
100 AC_CHECK_TYPE(socklen_t, [AC_DEFINE([HAVE_SOCKLEN_T], 1,
101 [Define if you have the socklen_t type.])],,
102 [#include <sys/types.h>
103 #include <sys/socket.h>])
105 dnl XXX - This is UGLY. Need a better way to homogenize the bitsized types,
106 dnl including use of compiler primitive types via AC_CHECK_SIZEOF.
108 define([NB_CHECK_INTTYPE], [
109 AC_CHECK_TYPE(uint][$1][_t,, [
110 AC_CHECK_TYPE(u_int][$1][_t,
111 AC_DEFINE(uint][$1][_t, u_int][$1][_t, \
112 [Define if you have u_int][$1][_t, but not uint][$1][_t.]),
113 AC_MSG_ERROR([cannot find a suitable type for uint][$1][_t]))
115 AC_CHECK_TYPE(u_int][$1][_t,, [
116 AC_CHECK_TYPE(uint][$1][_t,
117 AC_DEFINE(u_int][$1][_t, uint][$1][_t, \
118 [Define if you have uint][$1][_t, but not u_int][$1][_t.]),
119 AC_MSG_ERROR([cannot find a suitable type for u_int][$1][_t]))
129 AC_CHECK_MEMBERS([DIR.dd_fd, DIR.__dd_fd, struct dirent.d_namlen],,,
130 [#include <sys/types.h>
131 #include <dirent.h>])
132 AC_CHECK_MEMBERS([struct stat.st_flags, struct stat.st_gen,
133 struct stat.st_birthtime, struct stat.st_birthtimensec,
134 struct stat.st_atim, struct stat.st_mtimensec],,,
135 [#include <sys/stat.h>])
136 AC_CHECK_MEMBERS(struct statvfs.f_iosize,,, [#include <sys/statvfs.h>])
138 # Global variable decls.
139 AC_CHECK_DECLS([optind, optreset],,, [
144 AC_CHECK_DECLS(sys_signame,,, [#include <signal.h>])
146 # Library functions (where a .h check isn't enough).
148 AC_CHECK_FUNCS(atoll asprintf asnprintf basename devname dirfd dirname \
149 esetfunc fgetln flock fpurge __fpurge futimes getline \
150 getopt getopt_long group_from_gid gid_from_group \
151 heapsort isblank issetugid lchflags lchmod lchown lutimes mkstemp \
152 mkdtemp poll pread putc_unlocked pwcache_userdb pwcache_groupdb \
153 pwrite raise_default_signal random setenv \
154 setgroupent setprogname setpassent snprintf strlcat strlcpy strmode \
155 strndup strsep strsuftoll strtoll \
156 user_from_uid uid_from_user vasprintf vasnprintf vsnprintf)
158 AC_CHECK_DECLS([user_from_uid, uid_from_user, pwcache_userdb],,,[
161 AC_CHECK_DECLS([group_from_gid, gid_from_group, pwcache_groupdb],,,[
164 AC_CHECK_DECLS([strndup],,,[#include <string.h>])
165 AC_CHECK_DECLS([strsuftoll],,,[#include <stdlib.h>])
166 AC_CHECK_DECLS([lchflags, lchmod, lchown],,,[
167 #include <sys/stat.h>
171 AC_CHECK_DECLS([htobe16, htobe32, htobe64, htole16, htole32, htole64,
172 be16toh, be32toh, be64toh, le16toh, le32toh, le64toh],,,
173 [#include <sys/types.h>])
175 AC_CHECK_DECLS([bswap16, bswap32, bswap64],,, [#include <machine/bswap.h>])
177 AC_CHECK_DECLS([be16enc, le16enc, be16dec, le16dec, be32enc, le32enc,
178 be32dec, le32dec, be64enc, le64enc, be64dec, le64dec],,,
179 [#include <sys/endian.h>])
181 AC_CHECK_DECLS([fstatvfs],,, [#include <sys/statvfs.h>])
183 AC_CHECK_DECLS([setgroupent, setpassent],,, [
184 #include <sys/types.h>
189 # regcomp() and regexec() are also names of functions in the old V8
190 # regexp package. To avoid them, we need to find out who has regfree().
192 dnl # Cygwin: We *MUST* look at -lregex *before* the "no libs" condition.
193 dnl # Thus AC_CHECK_LIB(regex...) comes first, and AC_SEARCHLIBS next.
194 AC_CHECK_LIB(regex, regfree)
195 AC_SEARCH_LIBS(regfree, rx posix)
197 AC_CHECK_FUNCS(fparseln, [
198 AC_MSG_CHECKING(if fparseln seems to work)
201 #define _NETBSD_SOURCE
204 #define CONFTEST "conftest.fparseln"
209 static const char delim[3] = { '\0', '\0', COMMENT };
212 fp = fopen(CONFTEST, "w+");
216 ptr = fparseln(fp, NULL, NULL, delim,
225 [AC_MSG_RESULT(yes)],
227 AC_DEFINE(BROKEN_FPARSELN, 1,
228 [Define to 1 if your `fparseln' function is broken.])],
229 [AC_MSG_WARN([cross compiling: not checking farseln])]
233 # Variables substituted via @VARNAME@ in defs.mk.in
234 AC_SUBST(HAVE_PTHREAD_H, $ac_cv_header_pthread_h)