configure.ac revision 1.9
1#	$NetBSD: configure.ac,v 1.9 2002/03/07 18:28:47 tv Exp $
2#
3# Autoconf definition file for libnbcompat.
4#
5
6AC_INIT([libnbcompat], [noversion], [lib-bug-people@netbsd.org])
7AC_CONFIG_HEADERS(config.h)
8AC_CONFIG_FILES(defs.mk)
9
10AC_C_BIGENDIAN
11AC_HEADER_STDC
12
13# Confirm existence of zlib.  (This is available as a default install
14# option on many OS's; this could be added as a reachover build in the
15# future.)
16AC_CHECK_HEADER(zlib.h,,
17	AC_MSG_ERROR([zlib must be installed in a compiler-visible path]))
18AC_CHECK_LIB(z, gzdopen,,
19	AC_MSG_ERROR([zlib must be installed in a compiler-visible path]))
20
21# Make sure certain required headers are available.
22# These are not necessarily required by the code, but they are not
23# currently conditionalized.
24AC_CHECK_HEADERS(sys/ioctl.h sys/mman.h sys/mtio.h sys/param.h \
25	sys/stat.h sys/time.h sys/types.h sys/utsname.h sys/wait.h \
26	assert.h ctype.h errno.h fcntl.h grp.h limits.h locale.h \
27	netdb.h pwd.h signal.h stdarg.h stdio.h stdlib.h string.h \
28	unistd.h,,
29	AC_MSG_ERROR([standard system header file not found]))
30
31# Find headers that may not be available.
32AC_HEADER_DIRENT
33AC_CHECK_HEADERS(sys/sysmacros.h sys/syslimits.h features.h inttypes.h malloc.h stddef.h stdint.h)
34AC_CHECK_HEADERS(machine/bswap.h sys/cdefs.h sys/featuretest.h \
35	err.h libgen.h paths.h util.h,, [touch include/$ac_header])
36AC_CHECK_HEADERS(rpc/types.h fts.h getopt.h netconfig.h vis.h,,
37	[echo '#include "'$srcdir/../../include/$ac_header'"' >include/$ac_header])
38
39# Typedefs.
40AC_TYPE_SIZE_T
41AC_CHECK_TYPES([id_t, long long, u_quad_t])
42
43dnl XXX - This is UGLY.  Need a better way to homogenize the bitsized types,
44dnl including use of compiler primitive types via AC_CHECK_SIZEOF.
45dnl
46define([NB_CHECK_INTTYPE], [
47	AC_CHECK_TYPE(uint][$1][_t,, [
48		AC_CHECK_TYPE(u_int][$1][_t,
49			AC_DEFINE(uint][$1][_t, u_int][$1][_t),
50			AC_MSG_ERROR([cannot find a suitable type for uint][$1][_t]))
51	])
52	AC_CHECK_TYPE(u_int][$1][_t,, [
53		AC_CHECK_TYPE(uint][$1][_t,
54			AC_DEFINE(u_int][$1][_t, uint][$1][_t),
55			AC_MSG_ERROR([cannot find a suitable type for u_int][$1][_t]))
56	])
57])
58
59NB_CHECK_INTTYPE(8)
60NB_CHECK_INTTYPE(16)
61NB_CHECK_INTTYPE(32)
62NB_CHECK_INTTYPE(64)
63
64# Struct members.
65AC_CHECK_MEMBERS([DIR.dd_fd, struct dirent.d_namlen],,,
66	[#include <dirent.h>])
67AC_CHECK_MEMBERS([struct stat.st_flags, struct stat.st_gen,
68	struct stat.st_mtimensec],,, [#include <sys/stat.h>])
69AC_CHECK_MEMBERS(struct statfs.f_iosize,,, [#include <sys/mount.h>])
70
71# Global variable decls.
72AC_CHECK_DECLS([optind, optreset],,, [
73#include <stdio.h>
74#include <stdlib.h>
75#include <unistd.h>
76])
77AC_CHECK_DECLS(sys_signame,,, [#include <signal.h>])
78
79# Library functions (where a .h check isn't enough).
80AC_SEARCH_LIBS(fparseln, util)
81AC_CHECK_FUNCS(asprintf asnprintf basename dirfd dirname \
82	fgetln flock fparseln futimes getopt getopt_long \
83	isblank lchmod lchown lutimes pread pwcache_userdb \
84	pwrite setenv setgroupent setprogname setpassent \
85	snprintf strlcat strlcpy strsep vasprintf vasnprintf vsnprintf)
86
87AC_CHECK_DECLS([setgroupent, setpassent],,, [
88#include <grp.h>
89#include <pwd.h>
90])
91
92# regcomp() and regexec() are also names of functions in the old V8
93# regexp package.  To avoid them, we need to find out who has regfree().
94
95dnl # Cygwin: We *MUST* look at -lregex *before* the "no libs" condition.
96dnl # Thus AC_CHECK_LIB(regex...) comes first, and AC_SEARCHLIBS next.
97AC_CHECK_LIB(regex, regfree)
98AC_SEARCH_LIBS(regfree, rx posix)
99
100AC_OUTPUT
101