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