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 tar 1.13.11 distribution
89 dnl by Paul Eggert <eggert@twinsun.com>
90 dnl ---------------------------------------------------------------------------
92 dnl By default, many hosts won't let programs access large files;
93 dnl one must use special compiler options to get large-file access to work.
94 dnl For more details about this brain damage please see:
95 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
97 dnl Written by Paul Eggert <eggert@twinsun.com>.
99 dnl Internal subroutine of AC_SYS_LARGEFILE.
100 dnl AC_SYS_LARGEFILE_FLAGS(FLAGSNAME)
101 AC_DEFUN(AC_SYS_LARGEFILE_FLAGS,
102 [AC_CACHE_CHECK([for $1 value to request large file support],
103 ac_cv_sys_largefile_$1,
104 [ac_cv_sys_largefile_$1=`($GETCONF LFS_$1) 2>/dev/null` || {
105 ac_cv_sys_largefile_$1=no
108 # IRIX 6.2 and later require cc -n32.
110 irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
112 if test "$GCC" != yes; then
113 ac_cv_sys_largefile_CFLAGS=-n32
116 CC="$CC $ac_cv_sys_largefile_CFLAGS"
117 AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
122 dnl Internal subroutine of AC_SYS_LARGEFILE.
123 dnl AC_SYS_LARGEFILE_SPACE_APPEND(VAR, VAL)
124 AC_DEFUN(AC_SYS_LARGEFILE_SPACE_APPEND,
134 dnl Internal subroutine of AC_SYS_LARGEFILE.
135 dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
136 AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
137 [AC_CACHE_CHECK([for $1], $2,
141 for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
146 $2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
151 if test "[$]$2" != no; then
152 AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
155 AC_DEFUN(AC_SYS_LARGEFILE,
156 [AC_REQUIRE([AC_CANONICAL_HOST])
157 AC_ARG_ENABLE(largefile,
158 [ --disable-largefile omit support for large files])
159 if test "$enable_largefile" != no; then
160 AC_CHECK_TOOL(GETCONF, getconf)
161 AC_SYS_LARGEFILE_FLAGS(CFLAGS)
162 AC_SYS_LARGEFILE_FLAGS(LDFLAGS)
163 AC_SYS_LARGEFILE_FLAGS(LIBS)
165 for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
168 -D_FILE_OFFSET_BITS=*) ;;
169 -D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
170 -D_LARGE_FILES | -D_LARGE_FILES=*) ;;
172 AC_SYS_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
174 AC_SYS_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
177 AC_SYS_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
178 AC_SYS_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
179 AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
180 ac_cv_sys_file_offset_bits,
181 [Number of bits in a file offset, on hosts where this is settable.],
183 # HP-UX 10.20 and later
184 hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
185 ac_cv_sys_file_offset_bits=64 ;;
187 AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
188 ac_cv_sys_largefile_source,
189 [Define to make fseeko etc. visible, on some hosts.],
191 # HP-UX 10.20 and later
192 hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
193 ac_cv_sys_largefile_source=1 ;;
195 AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
196 ac_cv_sys_large_files,
197 [Define for large files, on AIX-style hosts.],
200 aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
201 ac_cv_sys_large_files=1 ;;
207 dnl ---------------------------------------------------------------------------
208 dnl From Paul Eggert <eggert@twinsun.com>
210 dnl Define HAVE_INTTYPES_H if <inttypes.h> exists,
211 dnl doesn't clash with <sys/types.h>, and declares uintmax_t.
213 AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
216 dnl This code is deliberately never run via ./configure.
217 dnl FIXME: this is a gross hack to make autoheader put an entry
218 dnl for `HAVE_INTTYPES_H' in config.h.in.
219 AC_CHECK_FUNCS(INTTYPES_H)
221 AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
223 [#include <sys/types.h>
224 #include <inttypes.h>],
225 [uintmax_t i = (uintmax_t) -1;],
226 jm_ac_cv_header_inttypes_h=yes,
227 jm_ac_cv_header_inttypes_h=no)])
228 if test $jm_ac_cv_header_inttypes_h = yes; then
229 ac_kludge=HAVE_INTTYPES_H
230 AC_DEFINE_UNQUOTED($ac_kludge)
235 dnl ---------------------------------------------------------------------------
236 dnl From Paul Eggert <eggert@twinsun.com>
238 AC_DEFUN(AC_STRUCT_ST_MTIM_NSEC,
239 [AC_CACHE_CHECK([for nanoseconds member of struct stat.st_mtim],
240 ac_cv_struct_st_mtim_nsec,
241 [ac_save_CPPFLAGS="$CPPFLAGS"
242 ac_cv_struct_st_mtim_nsec=no
243 # tv_nsec -- the usual case
244 # _tv_nsec -- Solaris 2.6, if
245 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
246 # && !defined __EXTENSIONS__)
247 # st__tim.tv_nsec -- UnixWare 2.1.2
248 for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
249 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
250 AC_TRY_COMPILE([#include <sys/types.h>
251 #include <sys/stat.h>], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
252 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
254 CPPFLAGS="$ac_save_CPPFLAGS"])
256 if test $ac_cv_struct_st_mtim_nsec != no; then
257 AC_DEFINE_UNQUOTED(ST_MTIM_NSEC, $ac_cv_struct_st_mtim_nsec)
262 dnl ---------------------------------------------------------------------------
263 dnl From Paul Eggert <eggert@twinsun.com>
265 dnl Define uintmax_t to `unsigned long' or `unsigned long long'
266 dnl if <inttypes.h> does not exist.
268 AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
270 AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
271 if test $jm_ac_cv_header_inttypes_h = no; then
272 AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
273 [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
274 [unsigned long long ullmax = (unsigned long long) -1;
275 return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
276 ac_cv_type_unsigned_long_long=yes,
277 ac_cv_type_unsigned_long_long=no)])
278 if test $ac_cv_type_unsigned_long_long = yes; then
279 AC_DEFINE(uintmax_t, unsigned long long)
281 AC_DEFINE(uintmax_t, unsigned long)
287 dnl ---------------------------------------------------------------------------
288 dnl From Steve Robbins <steve@nyongwa.montreal.qc.ca>
290 dnl From a proposed change made on the autoconf list on 2 Feb 1999
291 dnl http://sourceware.cygnus.com/ml/autoconf/1999-02/msg00001.html
292 dnl Patch for AIX 3.2 by Lars Hecking <lhecking@nmrc.ucc.ie> on 17 May 1999
294 AC_DEFUN(AC_FUNC_SELECT,
295 [AC_CHECK_FUNCS(select)
296 if test "$ac_cv_func_select" = yes; then
297 AC_CHECK_HEADERS(unistd.h sys/types.h sys/time.h sys/select.h sys/socket.h)
298 AC_MSG_CHECKING([argument types of select()])
299 AC_CACHE_VAL(ac_cv_type_fd_set_size_t,dnl
300 [AC_CACHE_VAL(ac_cv_type_fd_set,dnl
301 [for ac_cv_type_fd_set in 'fd_set' 'int' 'void'; do
302 for ac_cv_type_fd_set_size_t in 'int' 'size_t' 'unsigned long' 'unsigned'; do
303 for ac_type_timeval in 'struct timeval' 'const struct timeval'; do
305 [#ifdef HAVE_SYS_TIME_H
306 #include <sys/time.h>
308 #ifdef HAVE_SYS_TYPES_H
309 #include <sys/types.h>
314 #ifdef HAVE_SYS_SELECT_H
315 #include <sys/select.h>
317 #ifdef HAVE_SYS_SOCKET_H
318 #include <sys/socket.h>
321 extern select ($ac_cv_type_fd_set_size_t,
322 $ac_cv_type_fd_set *, $ac_cv_type_fd_set *, $ac_cv_type_fd_set *,
326 $ac_cv_type_fd_set_size_t s;
327 $ac_cv_type_fd_set *p;
330 [ac_found=yes ; break 3],ac_found=no)
336 if test "$ac_found" = no; then
337 AC_MSG_ERROR([can't determine argument types])
340 AC_MSG_RESULT([select($ac_cv_type_fd_set_size_t,$ac_cv_type_fd_set *,...)])
341 AC_DEFINE_UNQUOTED(fd_set_size_t, $ac_cv_type_fd_set_size_t)
343 if test "$ac_cv_type_fd_set" != fd_set; then
344 # Arguments 2-4 are not fd_set. Some weirdo systems use fd_set type for
345 # FD_SET macros, but insist that you cast the argument to select. I don't
346 # understand why that might be, but it means we cannot define fd_set.
348 changequote(<<,>>)dnl
349 <<(^|[^a-zA-Z_0-9])fd_set[^a-zA-Z_0-9]>>dnl
351 [#ifdef HAVE_SYS_TIME_H
352 #include <sys/time.h>
354 #ifdef HAVE_SYS_TYPES_H
355 #include <sys/types.h>
360 #ifdef HAVE_SYS_SELECT_H
361 #include <sys/select.h>
363 #ifdef HAVE_SYS_SOCKET_H
364 #include <sys/socket.h>
366 # We found fd_set type in a header, need special cast
367 ac_cast="($ac_cv_type_fd_set *)",dnl
368 # No fd_set type; it is safe to define it
369 AC_DEFINE_UNQUOTED(fd_set,$ac_cv_type_fd_set))
371 AC_DEFINE_UNQUOTED(SELECT_FD_SET_CAST,$ac_cast)
376 # The following is taken from automake 1.4,
377 # except that it prefers the compiler option -Ae to "-Aa -D_HPUX_SOURCE"
378 # because only the former supports 64-bit integral types on HP-UX 10.20.
380 ## ----------------------------------------- ##
381 ## ANSIfy the C compiler whenever possible. ##
382 ## From Franc,ois Pinard ##
383 ## ----------------------------------------- ##
387 # @defmac AC_PROG_CC_STDC
388 # @maindex PROG_CC_STDC
390 # If the C compiler in not in ANSI C mode by default, try to add an option
391 # to output variable @code{CC} to make it so. This macro tries various
392 # options that select ANSI C on some system or another. It considers the
393 # compiler to be in ANSI C mode if it handles function prototypes correctly.
395 # If you use this macro, you should check after calling it whether the C
396 # compiler has been set to accept ANSI C; if not, the shell variable
397 # @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
398 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
399 # program @code{ansi2knr}, which comes with Ghostscript.
402 AC_DEFUN(AM_PROG_CC_STDC,
403 [AC_REQUIRE([AC_PROG_CC])
404 AC_BEFORE([$0], [AC_C_INLINE])
405 AC_BEFORE([$0], [AC_C_CONST])
406 dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
407 dnl a magic option to avoid problems with ANSI preprocessor commands
409 dnl FIXME: can't do this because then AC_AIX won't work due to a
410 dnl circular dependency.
411 dnl AC_BEFORE([$0], [AC_PROG_CPP])
412 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
413 AC_CACHE_VAL(am_cv_prog_cc_stdc,
414 [am_cv_prog_cc_stdc=no
416 # Don't try gcc -ansi; that turns off useful extensions and
417 # breaks some systems' header files.
419 # Ultrix and OSF/1 -std1
420 # HP-UX -Aa -D_HPUX_SOURCE
421 # SVR4 -Xc -D__EXTENSIONS__
422 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
424 CC="$ac_save_CC $ac_arg"
428 #include <sys/types.h>
429 #include <sys/stat.h>
430 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
431 struct buf { int x; };
432 FILE * (*rcsopen) (struct buf *, struct stat *, int);
433 static char *e (p, i)
439 static char *f (char * (*g) (char **, int), char **p, ...)
444 s = g (p, va_arg (v,int));
448 int test (int i, double x);
449 struct s1 {int (*f) (int a);};
450 struct s2 {int (*f) (double a);};
451 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
455 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
457 [am_cv_prog_cc_stdc="$ac_arg"; break])
461 if test -z "$am_cv_prog_cc_stdc"; then
462 AC_MSG_RESULT([none needed])
464 AC_MSG_RESULT($am_cv_prog_cc_stdc)
466 case "x$am_cv_prog_cc_stdc" in
468 *) CC="$CC $am_cv_prog_cc_stdc" ;;