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