1 dnl acinclude.m4 -- Extra macros needed for GNU make.
3 dnl Automake will incorporate this into its generated aclocal.m4.
5 dnl ---------------------------------------------------------------------------
6 dnl Got this from the lynx 2.8 distribution.
7 dnl by T.E.Dickey <dickey@clark.net>
8 dnl and Jim Spath <jspath@mail.bcpl.lib.md.us>
9 dnl and Philippe De Muyter <phdm@macqel.be>
11 dnl Created: 1997/1/28
12 dnl Updated: 1997/12/23
13 dnl ---------------------------------------------------------------------------
14 dnl After checking for functions in the default $LIBS, make a further check
15 dnl for the functions that are netlib-related (these aren't always in the
16 dnl libc, etc., and have to be handled specially because there are conflicting
17 dnl and broken implementations.
18 dnl Common library requirements (in order):
19 dnl -lresolv -lsocket -lnsl
23 AC_DEFUN([CF_NETLIBS],[
25 AC_MSG_CHECKING(for network libraries)
26 AC_CACHE_VAL(cf_cv_netlibs,[
27 AC_MSG_RESULT(working...)
30 AC_CHECK_FUNCS(gethostname,,[
31 CF_RECHECK_FUNC(gethostname,nsl,cf_cv_netlibs,[
32 CF_RECHECK_FUNC(gethostname,socket,cf_cv_netlibs)])])
34 # FIXME: sequent needs this library (i.e., -lsocket -linet -lnsl), but
35 # I don't know the entrypoints - 97/7/22 TD
36 AC_CHECK_LIB(inet,main,cf_cv_netlibs="-linet $cf_cv_netlibs")
38 if test "$ac_cv_func_lsocket" != no ; then
39 AC_CHECK_FUNCS(socket,,[
40 CF_RECHECK_FUNC(socket,socket,cf_cv_netlibs,[
41 CF_RECHECK_FUNC(socket,bsd,cf_cv_netlibs)])])
44 AC_CHECK_FUNCS(gethostbyname,,[
45 CF_RECHECK_FUNC(gethostbyname,nsl,cf_cv_netlibs)])
47 AC_CHECK_FUNCS(strcasecmp,,[
48 CF_RECHECK_FUNC(strcasecmp,resolv,cf_cv_netlibs)])
50 LIBS="$LIBS $cf_cv_netlibs"
51 test $cf_test_netlibs = no && echo "$cf_cv_netlibs" >&AC_FD_MSG
53 dnl ---------------------------------------------------------------------------
54 dnl Re-check on a function to see if we can pick it up by adding a library.
55 dnl $1 = function to check
56 dnl $2 = library to check in
57 dnl $3 = environment to update (e.g., $LIBS)
58 dnl $4 = what to do if this fails
60 dnl This uses 'unset' if the shell happens to support it, but leaves the
61 dnl configuration variable set to 'unknown' if not. This is a little better
62 dnl than the normal autoconf test, which gives misleading results if a test
63 dnl for the function is made (e.g., with AC_CHECK_FUNC) after this macro is
64 dnl used (autoconf does not distinguish between a null token and one that is
66 AC_DEFUN([CF_RECHECK_FUNC],[
68 CF_UPPER(cf_tr_func,$1)
69 AC_DEFINE_UNQUOTED(HAVE_$cf_tr_func)
73 unset ac_cv_func_$1 2>/dev/null
77 dnl ---------------------------------------------------------------------------
78 dnl Make an uppercase version of a variable
83 $1=`echo $2 | tr '[a-z]' '[A-Z]'`
87 dnl ---------------------------------------------------------------------------
88 dnl Got this from the GNU fileutils 3.16r distribution
89 dnl by Paul Eggert <eggert@twinsun.com>
90 dnl ---------------------------------------------------------------------------
92 dnl The problem is that the default compilation flags in Solaris 2.6 won't
93 dnl let programs access large files; you need to tell the compiler that
94 dnl you actually want your programs to work on large files. For more
95 dnl details about this brain damage please see:
96 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
100 # If available, prefer support for large files unless the user specified
101 # one of the CPPFLAGS, LDFLAGS, or LIBS variables.
102 AC_MSG_CHECKING(whether large file support needs explicit enabling)
106 ac_shellvars='CPPFLAGS LDFLAGS LIBS'
107 for ac_shellvar in $ac_shellvars; do
109 CPPFLAGS) ac_lfsvar=LFS_CFLAGS ;;
110 *) ac_lfsvar=LFS_$ac_shellvar ;;
112 eval test '"${'$ac_shellvar'+set}"' = set && ac_set=$ac_shellvar
113 (getconf $ac_lfsvar) >/dev/null 2>&1 || { ac_result=no; break; }
114 ac_getconf=`getconf $ac_lfsvar`
115 ac_getconfs=$ac_getconfs$ac_getconf
116 eval ac_test_$ac_shellvar=\$ac_getconf
118 case "$ac_result$ac_getconfs" in
121 case "$ac_result$ac_set" in
122 yes?*) ac_result="yes, but $ac_set is already set, so use its settings"
124 AC_MSG_RESULT($ac_result)
127 for ac_shellvar in $ac_shellvars; do
128 eval $ac_shellvar=\$ac_test_$ac_shellvar
134 dnl ---------------------------------------------------------------------------
135 dnl From Paul Eggert <eggert@twinsun.com>
137 dnl Define HAVE_INTTYPES_H if <inttypes.h> exists,
138 dnl doesn't clash with <sys/types.h>, and declares uintmax_t.
140 AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
143 dnl This code is deliberately never run via ./configure.
144 dnl FIXME: this is a gross hack to make autoheader put an entry
145 dnl for `HAVE_INTTYPES_H' in config.h.in.
146 AC_CHECK_FUNCS(INTTYPES_H)
148 AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
150 [#include <sys/types.h>
151 #include <inttypes.h>],
152 [uintmax_t i = (uintmax_t) -1;],
153 jm_ac_cv_header_inttypes_h=yes,
154 jm_ac_cv_header_inttypes_h=no)])
155 if test $jm_ac_cv_header_inttypes_h = yes; then
156 ac_kludge=HAVE_INTTYPES_H
157 AC_DEFINE_UNQUOTED($ac_kludge)
162 dnl ---------------------------------------------------------------------------
163 dnl From Paul Eggert <eggert@twinsun.com>
165 AC_DEFUN(AC_STRUCT_ST_MTIM_NSEC,
166 [AC_CACHE_CHECK([for nanoseconds member of struct stat.st_mtim],
167 ac_cv_struct_st_mtim_nsec,
168 [ac_save_CPPFLAGS="$CPPFLAGS"
169 ac_cv_struct_st_mtim_nsec=no
170 # tv_nsec -- the usual case
171 # _tv_nsec -- Solaris 2.6, if
172 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
173 # && !defined __EXTENSIONS__)
174 # st__tim.tv_nsec -- UnixWare 2.1.2
175 for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
176 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
177 AC_TRY_COMPILE([#include <sys/types.h>
178 #include <sys/stat.h>], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
179 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
181 CPPFLAGS="$ac_save_CPPFLAGS"])
183 if test $ac_cv_struct_st_mtim_nsec != no; then
184 AC_DEFINE_UNQUOTED(ST_MTIM_NSEC, $ac_cv_struct_st_mtim_nsec)
189 dnl ---------------------------------------------------------------------------
190 dnl From Paul Eggert <eggert@twinsun.com>
192 dnl Define uintmax_t to `unsigned long' or `unsigned long long'
193 dnl if <inttypes.h> does not exist.
195 AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
197 AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
198 if test $jm_ac_cv_header_inttypes_h = no; then
199 AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
201 [unsigned long long i = (unsigned long long) -1;],
202 ac_cv_type_unsigned_long_long=yes,
203 ac_cv_type_unsigned_long_long=no)])
204 if test $ac_cv_type_unsigned_long_long = yes; then
205 AC_DEFINE(uintmax_t, unsigned long long)
207 AC_DEFINE(uintmax_t, unsigned long)
213 dnl ---------------------------------------------------------------------------
214 dnl From Steve Robbins <steve@nyongwa.montreal.qc.ca>
216 dnl From a proposed change made on the autoconf list on 2 Feb 1999
217 dnl http://sourceware.cygnus.com/ml/autoconf/1999-02/msg00001.html
218 dnl Patch for AIX 3.2 by Lars Hecking <lhecking@nmrc.ucc.ie> on 17 May 1999
220 AC_DEFUN(AC_FUNC_SELECT,
221 [AC_CHECK_FUNCS(select)
222 if test "$ac_cv_func_select" = yes; then
223 AC_CHECK_HEADERS(unistd.h sys/types.h sys/time.h sys/select.h sys/socket.h)
224 AC_MSG_CHECKING([argument types of select()])
225 AC_CACHE_VAL(ac_cv_type_fd_set_size_t,dnl
226 [AC_CACHE_VAL(ac_cv_type_fd_set,dnl
227 [for ac_cv_type_fd_set in 'fd_set' 'int' 'void'; do
228 for ac_cv_type_fd_set_size_t in 'int' 'size_t' 'unsigned long' 'unsigned'; do
229 for ac_type_timeval in 'struct timeval' 'const struct timeval'; do
231 [#ifdef HAVE_SYS_TIME_H
232 #include <sys/time.h>
234 #ifdef HAVE_SYS_TYPES_H
235 #include <sys/types.h>
240 #ifdef HAVE_SYS_SELECT_H
241 #include <sys/select.h>
243 #ifdef HAVE_SYS_SOCKET_H
244 #include <sys/socket.h>
246 [extern select ($ac_cv_type_fd_set_size_t,
247 $ac_cv_type_fd_set *, $ac_cv_type_fd_set *, $ac_cv_type_fd_set *,
248 $ac_type_timeval *);],
249 [ac_found=yes ; break 3],ac_found=no)
255 if test "$ac_found" = no; then
256 AC_MSG_ERROR([can't determine argument types])
259 AC_MSG_RESULT([select($ac_cv_type_fd_set_size_t,$ac_cv_type_fd_set *,...)])
260 AC_DEFINE_UNQUOTED(fd_set_size_t, $ac_cv_type_fd_set_size_t)
262 if test "$ac_cv_type_fd_set" != fd_set; then
263 # Arguments 2-4 are not fd_set. Some weirdo systems use fd_set type for
264 # FD_SET macros, but insist that you cast the argument to select. I don't
265 # understand why that might be, but it means we cannot define fd_set.
267 changequote(<<,>>)dnl
268 <<(^|[^a-zA-Z_0-9])fd_set[^a-zA-Z_0-9]>>dnl
270 [#ifdef HAVE_SYS_TIME_H
271 #include <sys/time.h>
273 #ifdef HAVE_SYS_TYPES_H
274 #include <sys/types.h>
279 #ifdef HAVE_SYS_SELECT_H
280 #include <sys/select.h>
282 #ifdef HAVE_SYS_SOCKET_H
283 #include <sys/socket.h>
285 # We found fd_set type in a header, need special cast
286 ac_cast="($ac_cv_type_fd_set *)",dnl
287 # No fd_set type; it is safe to define it
288 AC_DEFINE_UNQUOTED(fd_set,$ac_cv_type_fd_set))
290 AC_DEFINE_UNQUOTED(SELECT_FD_SET_CAST,$ac_cast)