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 [if ($GETCONF LFS_$1) >conftest.1 2>conftest.2 && test ! -s conftest.2
106 ac_cv_sys_largefile_$1=`cat conftest.1`
108 ac_cv_sys_largefile_$1=no
111 # HP-UX 10.20 requires -D__STDC_EXT__ with gcc 2.95.1.
113 hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
115 if test "$GCC" = yes; then
116 ac_cv_sys_largefile_CFLAGS=-D__STDC_EXT__
119 # IRIX 6.2 and later require cc -n32.
121 irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
123 if test "$GCC" != yes; then
124 ac_cv_sys_largefile_CFLAGS=-n32
127 if test "$ac_cv_sys_largefile_CFLAGS" != no; then
129 CC="$CC $ac_cv_sys_largefile_CFLAGS"
130 AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
136 dnl Internal subroutine of AC_SYS_LARGEFILE.
137 dnl AC_SYS_LARGEFILE_SPACE_APPEND(VAR, VAL)
138 AC_DEFUN(AC_SYS_LARGEFILE_SPACE_APPEND,
148 dnl Internal subroutine of AC_SYS_LARGEFILE.
149 dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
150 AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
151 [AC_CACHE_CHECK([for $1], $2,
155 for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
160 $2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
165 if test "[$]$2" != no; then
166 AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
169 AC_DEFUN(AC_SYS_LARGEFILE,
170 [AC_REQUIRE([AC_CANONICAL_HOST])
171 AC_ARG_ENABLE(largefile,
172 [ --disable-largefile omit support for large files])
173 if test "$enable_largefile" != no; then
174 AC_CHECK_TOOL(GETCONF, getconf)
175 AC_SYS_LARGEFILE_FLAGS(CFLAGS)
176 AC_SYS_LARGEFILE_FLAGS(LDFLAGS)
177 AC_SYS_LARGEFILE_FLAGS(LIBS)
179 for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
182 -D_FILE_OFFSET_BITS=*) ;;
183 -D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
184 -D_LARGE_FILES | -D_LARGE_FILES=*) ;;
186 AC_SYS_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
188 AC_SYS_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
191 AC_SYS_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
192 AC_SYS_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
193 AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
194 ac_cv_sys_file_offset_bits,
195 [Number of bits in a file offset, on hosts where this is settable.],
197 # HP-UX 10.20 and later
198 hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
199 ac_cv_sys_file_offset_bits=64 ;;
201 AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
202 ac_cv_sys_largefile_source,
203 [Define to make fseeko etc. visible, on some hosts.],
205 # HP-UX 10.20 and later
206 hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
207 ac_cv_sys_largefile_source=1 ;;
209 AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
210 ac_cv_sys_large_files,
211 [Define for large files, on AIX-style hosts.],
214 aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
215 ac_cv_sys_large_files=1 ;;
221 dnl ---------------------------------------------------------------------------
222 dnl From Paul Eggert <eggert@twinsun.com>
224 dnl Define HAVE_INTTYPES_H if <inttypes.h> exists,
225 dnl doesn't clash with <sys/types.h>, and declares uintmax_t.
227 AC_DEFUN(jm_AC_HEADER_INTTYPES_H,
230 dnl This code is deliberately never run via ./configure.
231 dnl FIXME: this is a gross hack to make autoheader put an entry
232 dnl for `HAVE_INTTYPES_H' in config.h.in.
233 AC_CHECK_FUNCS(INTTYPES_H)
235 AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
237 [#include <sys/types.h>
238 #include <inttypes.h>],
239 [uintmax_t i = (uintmax_t) -1;],
240 jm_ac_cv_header_inttypes_h=yes,
241 jm_ac_cv_header_inttypes_h=no)])
242 if test $jm_ac_cv_header_inttypes_h = yes; then
243 ac_kludge=HAVE_INTTYPES_H
244 AC_DEFINE_UNQUOTED($ac_kludge)
249 dnl ---------------------------------------------------------------------------
250 dnl From Paul Eggert <eggert@twinsun.com>
252 AC_DEFUN(AC_STRUCT_ST_MTIM_NSEC,
253 [AC_CACHE_CHECK([for nanoseconds member of struct stat.st_mtim],
254 ac_cv_struct_st_mtim_nsec,
255 [ac_save_CPPFLAGS="$CPPFLAGS"
256 ac_cv_struct_st_mtim_nsec=no
257 # tv_nsec -- the usual case
258 # _tv_nsec -- Solaris 2.6, if
259 # (defined _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED == 1
260 # && !defined __EXTENSIONS__)
261 # st__tim.tv_nsec -- UnixWare 2.1.2
262 for ac_val in tv_nsec _tv_nsec st__tim.tv_nsec; do
263 CPPFLAGS="$ac_save_CPPFLAGS -DST_MTIM_NSEC=$ac_val"
264 AC_TRY_COMPILE([#include <sys/types.h>
265 #include <sys/stat.h>], [struct stat s; s.st_mtim.ST_MTIM_NSEC;],
266 [ac_cv_struct_st_mtim_nsec=$ac_val; break])
268 CPPFLAGS="$ac_save_CPPFLAGS"])
270 if test $ac_cv_struct_st_mtim_nsec != no; then
271 AC_DEFINE_UNQUOTED(ST_MTIM_NSEC, $ac_cv_struct_st_mtim_nsec)
276 dnl ---------------------------------------------------------------------------
277 dnl From Paul Eggert <eggert@twinsun.com>
279 dnl Define uintmax_t to `unsigned long' or `unsigned long long'
280 dnl if <inttypes.h> does not exist.
282 AC_DEFUN(jm_AC_TYPE_UINTMAX_T,
284 AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
285 if test $jm_ac_cv_header_inttypes_h = no; then
286 AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long,
287 [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;],
288 [unsigned long long ullmax = (unsigned long long) -1;
289 return ull << i | ull >> i | ullmax / ull | ullmax % ull;],
290 ac_cv_type_unsigned_long_long=yes,
291 ac_cv_type_unsigned_long_long=no)])
292 if test $ac_cv_type_unsigned_long_long = yes; then
293 AC_DEFINE(uintmax_t, unsigned long long)
295 AC_DEFINE(uintmax_t, unsigned long)
301 dnl ---------------------------------------------------------------------------
302 dnl From Steve Robbins <steve@nyongwa.montreal.qc.ca>
304 dnl From a proposed change made on the autoconf list on 2 Feb 1999
305 dnl http://sourceware.cygnus.com/ml/autoconf/1999-02/msg00001.html
306 dnl Patch for AIX 3.2 by Lars Hecking <lhecking@nmrc.ucc.ie> on 17 May 1999
308 AC_DEFUN(AC_FUNC_SELECT,
309 [AC_CHECK_FUNCS(select)
310 if test "$ac_cv_func_select" = yes; then
311 AC_CHECK_HEADERS(unistd.h sys/types.h sys/time.h sys/select.h sys/socket.h)
312 AC_MSG_CHECKING([argument types of select()])
313 AC_CACHE_VAL(ac_cv_type_fd_set_size_t,dnl
314 [AC_CACHE_VAL(ac_cv_type_fd_set,dnl
315 [for ac_cv_type_fd_set in 'fd_set' 'int' 'void'; do
316 for ac_cv_type_fd_set_size_t in 'int' 'size_t' 'unsigned long' 'unsigned'; do
317 for ac_type_timeval in 'struct timeval' 'const struct timeval'; do
319 [#ifdef HAVE_SYS_TIME_H
320 #include <sys/time.h>
322 #ifdef HAVE_SYS_TYPES_H
323 #include <sys/types.h>
328 #ifdef HAVE_SYS_SELECT_H
329 #include <sys/select.h>
331 #ifdef HAVE_SYS_SOCKET_H
332 #include <sys/socket.h>
335 extern select ($ac_cv_type_fd_set_size_t,
336 $ac_cv_type_fd_set *, $ac_cv_type_fd_set *, $ac_cv_type_fd_set *,
340 $ac_cv_type_fd_set_size_t s;
341 $ac_cv_type_fd_set *p;
344 [ac_found=yes ; break 3],ac_found=no)
350 if test "$ac_found" = no; then
351 AC_MSG_ERROR([can't determine argument types])
354 AC_MSG_RESULT([select($ac_cv_type_fd_set_size_t,$ac_cv_type_fd_set *,...)])
355 AC_DEFINE_UNQUOTED(fd_set_size_t, $ac_cv_type_fd_set_size_t)
357 if test "$ac_cv_type_fd_set" != fd_set; then
358 # Arguments 2-4 are not fd_set. Some weirdo systems use fd_set type for
359 # FD_SET macros, but insist that you cast the argument to select. I don't
360 # understand why that might be, but it means we cannot define fd_set.
362 changequote(<<,>>)dnl
363 <<(^|[^a-zA-Z_0-9])fd_set[^a-zA-Z_0-9]>>dnl
365 [#ifdef HAVE_SYS_TIME_H
366 #include <sys/time.h>
368 #ifdef HAVE_SYS_TYPES_H
369 #include <sys/types.h>
374 #ifdef HAVE_SYS_SELECT_H
375 #include <sys/select.h>
377 #ifdef HAVE_SYS_SOCKET_H
378 #include <sys/socket.h>
380 # We found fd_set type in a header, need special cast
381 ac_cast="($ac_cv_type_fd_set *)",dnl
382 # No fd_set type; it is safe to define it
383 AC_DEFINE_UNQUOTED(fd_set,$ac_cv_type_fd_set))
385 AC_DEFINE_UNQUOTED(SELECT_FD_SET_CAST,$ac_cast)
390 # The following is taken from automake 1.4,
391 # except that it prefers the compiler option -Ae to "-Aa -D_HPUX_SOURCE"
392 # because only the former supports 64-bit integral types on HP-UX 10.20.
394 ## ----------------------------------------- ##
395 ## ANSIfy the C compiler whenever possible. ##
396 ## From Franc,ois Pinard ##
397 ## ----------------------------------------- ##
401 # @defmac AC_PROG_CC_STDC
402 # @maindex PROG_CC_STDC
404 # If the C compiler in not in ANSI C mode by default, try to add an option
405 # to output variable @code{CC} to make it so. This macro tries various
406 # options that select ANSI C on some system or another. It considers the
407 # compiler to be in ANSI C mode if it handles function prototypes correctly.
409 # If you use this macro, you should check after calling it whether the C
410 # compiler has been set to accept ANSI C; if not, the shell variable
411 # @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
412 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
413 # program @code{ansi2knr}, which comes with Ghostscript.
416 AC_DEFUN(AM_PROG_CC_STDC,
417 [AC_REQUIRE([AC_PROG_CC])
418 AC_BEFORE([$0], [AC_C_INLINE])
419 AC_BEFORE([$0], [AC_C_CONST])
420 dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
421 dnl a magic option to avoid problems with ANSI preprocessor commands
423 dnl FIXME: can't do this because then AC_AIX won't work due to a
424 dnl circular dependency.
425 dnl AC_BEFORE([$0], [AC_PROG_CPP])
426 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
427 AC_CACHE_VAL(am_cv_prog_cc_stdc,
428 [am_cv_prog_cc_stdc=no
430 # Don't try gcc -ansi; that turns off useful extensions and
431 # breaks some systems' header files.
433 # Ultrix and OSF/1 -std1
434 # HP-UX -Aa -D_HPUX_SOURCE
435 # SVR4 -Xc -D__EXTENSIONS__
436 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
438 CC="$ac_save_CC $ac_arg"
442 #include <sys/types.h>
443 #include <sys/stat.h>
444 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
445 struct buf { int x; };
446 FILE * (*rcsopen) (struct buf *, struct stat *, int);
447 static char *e (p, i)
453 static char *f (char * (*g) (char **, int), char **p, ...)
458 s = g (p, va_arg (v,int));
462 int test (int i, double x);
463 struct s1 {int (*f) (int a);};
464 struct s2 {int (*f) (double a);};
465 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
469 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
471 [am_cv_prog_cc_stdc="$ac_arg"; break])
475 if test -z "$am_cv_prog_cc_stdc"; then
476 AC_MSG_RESULT([none needed])
478 AC_MSG_RESULT($am_cv_prog_cc_stdc)
480 case "x$am_cv_prog_cc_stdc" in
482 *) CC="$CC $am_cv_prog_cc_stdc" ;;
486 dnl ---------------------------------------------------------------------------
487 dnl Enable internationalization support for GNU make.
488 dnl Obtained from the libit 0.7 distribution
490 AC_DEFUN(fp_WITH_GETTEXT, [
492 AC_MSG_CHECKING(whether NLS is wanted)
494 [ --disable-nls disallow Native Language Support],
495 enable_nls=$enableval, enable_nls=yes)
496 AC_MSG_RESULT($enable_nls)
498 AM_CONDITIONAL(USE_NLS, test $use_nls = yes)
500 if test $enable_nls = yes; then
501 AC_DEFINE(ENABLE_NLS)
503 # We don't support catgets at all
504 if test "x$with_catgets" != x; then
505 AC_MSG_WARN([catgets not supported, --with-catgets ignored])
510 # Look around for gettext() on the system
511 AC_SEARCH_LIBS(gettext, intl)
512 if test $ac_cv_search_gettext = no; then
513 with_included_gettext=yes
515 # We only want to deal with GNU's gettext; if we don't have that
516 # we'll just use our own, thanks very much.
517 AC_MSG_CHECKING(for GNU gettext)
518 AC_TRY_LINK(,[extern int _nl_msg_cat_cntr; return _nl_msg_cat_cntr;],
519 with_included_gettext=no, with_included_gettext=yes)
520 case "$with_included_gettext" in
521 no) AC_MSG_RESULT(yes) ;;
522 yes) AC_MSG_RESULT([no; using local copy]); LIBS="$fp_keep_LIBS" ;;
526 if test $with_included_gettext = yes; then
527 LIBOBJS="$LIBOBJS gettext.o"
528 AC_DEFINE(HAVE_GETTEXT)
529 AC_DEFINE(HAVE_DCGETTEXT)
531 AC_CHECK_HEADERS(libintl.h)
532 AC_CHECK_FUNCS(dcgettext gettext)
535 AC_CHECK_HEADERS(locale.h)
536 AC_CHECK_FUNCS(getcwd setlocale stpcpy)
539 if test -z "$ALL_LINGUAS"; then
540 AC_MSG_WARN(This package does not install translations yet.)
542 ac_items="$ALL_LINGUAS"
543 for ac_item in $ac_items; do
544 ALL_POFILES="$ALL_POFILES $ac_item.po"
545 ALL_MOFILES="$ALL_MOFILES $ac_item.mo"
548 AC_SUBST(ALL_LINGUAS)
549 AC_SUBST(ALL_POFILES)
550 AC_SUBST(ALL_MOFILES)
552 AC_MSG_CHECKING(which translations to install)
553 if test -z "$LINGUAS"; then
554 ac_print="$ALL_LINGUAS"
555 MOFILES="$ALL_MOFILES"
558 for ac_item in $ac_items; do
559 case "$ALL_LINGUAS" in
561 ac_print="$ac_print $ac_item"
562 MOFILES="$MOFILES $ac_item.mo"
568 if test -z "$ac_print"; then
571 AC_MSG_RESULT($ac_print)
574 if test "x$prefix" = xNONE; then
575 AC_DEFINE_UNQUOTED(LOCALEDIR, "$ac_default_prefix/share/locale")
577 AC_DEFINE_UNQUOTED(LOCALEDIR, "$prefix/share/locale")