configure.ac revision 1.70 1 # $NetBSD: configure.ac,v 1.70 2009/06/16 22:35:34 christos Exp $
2 #
3 # Autoconf definition file for libnbcompat.
4 #
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.)
9 # 1. edit 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.
20 #
21
22 AC_INIT([libnbcompat], [noversion], [lib-bug-people (a] NetBSD.org])
23 AC_CONFIG_HEADERS(nbtool_config.h)
24 AC_CONFIG_FILES(defs.mk)
25
26 # Autoheader header and footer
27 AH_TOP([/* $NetBSD: configure.ac,v 1.70 2009/06/16 22:35:34 christos Exp $ */
28
29 #ifndef __NETBSD_NBTOOL_CONFIG_H__
30 #define __NETBSD_NBTOOL_CONFIG_H__])
31
32 AH_BOTTOM([#include "compat_defs.h"
33 #endif /* !__NETBSD_NBTOOL_CONFIG_H__ */])
34
35 AC_DEFUN([AC_NETBSD],
36 [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
37 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
38 AC_MSG_CHECKING([for NetBSD])
39 AC_EGREP_CPP(yes,
40 [#ifdef __NetBSD__
41 yes
42 #endif
43 ],
44 [AC_MSG_RESULT([yes])
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])])
49 ])# AC_NETBSD
50
51 AC_NETBSD
52 AC_PATH_PROG(BSHELL, sh, )
53 if test x"$BSHELL" = x; then
54 AC_MSG_ERROR([sh must be somewhere on \$PATH])
55 fi
56 AC_DEFINE_UNQUOTED([PATH_BSHELL], "$BSHELL", [Path to sh(1).])
57
58 AC_C_BIGENDIAN
59 AC_HEADER_STDC
60
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
63 # future.)
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]))
68
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 \
76 termios.h unistd.h,,
77 AC_MSG_ERROR([standard system header file not found]))
78
79 # Find headers that may not be available.
80 AC_HEADER_DIRENT
81 AC_CHECK_HEADERS(sys/mtio.h sys/sysmacros.h sys/syslimits.h \
82 getopt.h features.h malloc.h sys/poll.h stddef.h)
83 AC_CHECK_HEADERS(sys/bswap.h machine/bswap.h sys/cdefs.h machine/endian.h \
84 sys/featuretest.h err.h inttypes.h libgen.h paths.h stdint.h util.h \
85 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'"' >>include/$ac_header.new
90 if cmp include/$ac_header.new include/$ac_header >/dev/null 2>&1; then
91 rm -f include/$ac_header.new
92 else
93 mv -f include/$ac_header.new include/$ac_header
94 fi])
95
96 # Typedefs.
97 AC_TYPE_SIZE_T
98 AC_CHECK_TYPES([id_t, long long, u_long, u_char, u_short, u_int, u_quad_t])
99 AC_CHECK_TYPE(socklen_t, [AC_DEFINE([HAVE_SOCKLEN_T], 1,
100 [Define if you have the socklen_t type.])],,
101 [#include <sys/types.h>
102 #include <sys/socket.h>])
103
104 dnl XXX - This is UGLY. Need a better way to homogenize the bitsized types,
105 dnl including use of compiler primitive types via AC_CHECK_SIZEOF.
106 dnl
107 define([NB_CHECK_INTTYPE], [
108 AC_CHECK_TYPE(uint][$1][_t,, [
109 AC_CHECK_TYPE(u_int][$1][_t,
110 AC_DEFINE(uint][$1][_t, u_int][$1][_t, \
111 [Define if you have u_int][$1][_t, but not uint][$1][_t.]),
112 AC_MSG_ERROR([cannot find a suitable type for uint][$1][_t]))
113 ])
114 AC_CHECK_TYPE(u_int][$1][_t,, [
115 AC_CHECK_TYPE(uint][$1][_t,
116 AC_DEFINE(u_int][$1][_t, uint][$1][_t, \
117 [Define if you have uint][$1][_t, but not u_int][$1][_t.]),
118 AC_MSG_ERROR([cannot find a suitable type for u_int][$1][_t]))
119 ])
120 ])
121
122 NB_CHECK_INTTYPE(8)
123 NB_CHECK_INTTYPE(16)
124 NB_CHECK_INTTYPE(32)
125 NB_CHECK_INTTYPE(64)
126
127 # Struct members.
128 AC_CHECK_MEMBERS([DIR.dd_fd, DIR.__dd_fd, struct dirent.d_namlen],,,
129 [#include <sys/types.h>
130 #include <dirent.h>])
131 AC_CHECK_MEMBERS([struct stat.st_flags, struct stat.st_gen,
132 struct stat.st_birthtime, struct stat.st_birthtimensec,
133 struct stat.st_atim, struct stat.st_mtimensec],,,
134 [#include <sys/stat.h>])
135 AC_CHECK_MEMBERS(struct statvfs.f_iosize,,, [#include <sys/statvfs.h>])
136
137 # Global variable decls.
138 AC_CHECK_DECLS([optind, optreset],,, [
139 #include <stdio.h>
140 #include <stdlib.h>
141 #include <unistd.h>
142 ])
143 AC_CHECK_DECLS(sys_signame,,, [#include <signal.h>])
144
145 # Library functions (where a .h check isn't enough).
146 AC_FUNC_ALLOCA
147 AC_CHECK_FUNCS(atoll asprintf asnprintf basename devname dirfd dirname \
148 esetfunc fgetln flock fpurge __fpurge futimes getopt getopt_long \
149 group_from_gid gid_from_group \
150 heapsort isblank issetugid lchflags lchmod lchown lutimes mkstemp \
151 mkdtemp poll pread putc_unlocked pwcache_userdb pwcache_groupdb pwrite \
152 raise_default_signal random setenv \
153 setgroupent setprogname setpassent snprintf strlcat strlcpy strmode \
154 strndup strsep strsuftoll strtoll \
155 user_from_uid uid_from_user vasprintf vasnprintf vsnprintf)
156
157 AC_CHECK_DECLS([user_from_uid, uid_from_user, pwcache_userdb],,,[
158 #include <pwd.h>
159 ])
160 AC_CHECK_DECLS([group_from_gid, gid_from_group, pwcache_groupdb],,,[
161 #include <grp.h>
162 ])
163 AC_CHECK_DECLS([strndup],,,[#include <string.h>])
164 AC_CHECK_DECLS([strsuftoll],,,[#include <stdlib.h>])
165 AC_CHECK_DECLS([lchflags, lchmod, lchown],,,[
166 #include <sys/stat.h>
167 #include <unistd.h>
168 ])
169
170 AC_CHECK_DECLS([htobe16, htobe32, htobe64, htole16, htole32, htole64, be16toh, be32toh, be64toh, le16toh, le32toh, le64toh],,, [#include <sys/types.h>])
171
172 AC_CHECK_DECLS([bswap16, bswap32, bswap64],,, [#include <machine/bswap.h>])
173
174 AC_CHECK_DECLS([be16enc, le16enc, be16dec, le16dec, be32enc, le32enc, be32dec, le32dec, be64enc, le64enc, be64dec, le64dec],,, [#include <sys/endian.h>])
175
176 AC_CHECK_DECLS([fstatvfs],,, [#include <sys/statvfs.h>])
177
178 AC_CHECK_DECLS([setgroupent, setpassent],,, [
179 #include <sys/types.h>
180 #include <grp.h>
181 #include <pwd.h>
182 ])
183
184 # regcomp() and regexec() are also names of functions in the old V8
185 # regexp package. To avoid them, we need to find out who has regfree().
186
187 dnl # Cygwin: We *MUST* look at -lregex *before* the "no libs" condition.
188 dnl # Thus AC_CHECK_LIB(regex...) comes first, and AC_SEARCHLIBS next.
189 AC_CHECK_LIB(regex, regfree)
190 AC_SEARCH_LIBS(regfree, rx posix)
191
192 AC_CHECK_FUNCS(fparseln, [
193 AC_MSG_CHECKING(if fparseln seems to work)
194 AC_RUN_IFELSE(
195 [AC_LANG_SOURCE([[
196 #define _NETBSD_SOURCE
197 #include <stdio.h>
198 #include <stdlib.h>
199 #define CONFTEST "conftest.fparseln"
200 #define COMMENT '#'
201 int
202 main(void)
203 {
204 static const char delim[3] = { '\0', '\0', COMMENT };
205 FILE *fp;
206 char *ptr;
207 fp = fopen(CONFTEST, "w+");
208 if (fp != NULL) {
209 unlink(CONFTEST);
210 ungetc(COMMENT, fp);
211 ptr = fparseln(fp, NULL, NULL, delim,
212 FPARSELN_UNESCALL);
213 fclose(fp);
214 if (ptr == NULL)
215 exit(0);
216 }
217 exit(1);
218 }
219 ]])],
220 [AC_MSG_RESULT(yes)],
221 [AC_MSG_RESULT(no)
222 AC_DEFINE(BROKEN_FPARSELN, 1,
223 [Define to 1 if your `fparseln' function is broken.])],
224 [AC_MSG_WARN([cross compiling: not checking farseln])]
225 )
226 ])
227
228 AC_OUTPUT
229