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 Original obtained from the libit 0.7 distribution
489 dnl Rewritten by Paul D. Smith <psmith@gnu.org>
490 dnl This version is much more straightforward than the original (I think);
491 dnl If the user doesn't disable NLS, check whether she asked for the
492 dnl included gettext. If so, we use that. If not, test to see if the
493 dnl system gettext is GNU. If not, use the included gettext. If so,
494 dnl use the system gettext. We are very strict about testing for GNU
495 dnl gettext; not only must the library be GNU gettext, but the libintl.h
496 dnl file must also be GNU.
498 AC_DEFUN(pds_CHECK_SYSTEM_GETTEXT, [
500 # OK. What we're going to do is see if the system gettext is really
501 # GNU gettext, and we're going to make _sure_ (as we can) that if
502 # it's not we'll use the included gettext.
504 pds_keep_LIBS="$LIBS"
506 # Look around for gettext() and libintl.h on the system
507 AC_CHECK_HEADERS(locale.h)
508 AC_SEARCH_LIBS(gettext, intl)
509 if test "$ac_cv_search_gettext" = no; then
510 with_included_gettext=yes
513 # We only want to deal with GNU's gettext; if we don't have that
514 # we'll just use our own, thanks very much.
515 AC_CACHE_CHECK([whether the system has GNU gettext],
516 pds_cv_system_gnu_gettext, [
523 #if __USE_GNU_GETTEXT
524 extern int _nl_msg_cat_cntr;
525 return _nl_msg_cat_cntr;
530 pds_cv_system_gnu_gettext=yes, pds_cv_system_gnu_gettext=no)])
532 if test "x$pds_cv_system_gnu_gettext" = xyes; then
533 with_included_gettext=no
534 AC_DEFINE(HAVE_LIBINTL_H, 1, [Define if you have <libintl.h>.])
536 with_included_gettext=yes
543 AC_DEFUN(pds_WITH_GETTEXT, [
545 AC_MSG_CHECKING(whether NLS is wanted)
547 [ --disable-nls disallow Native Language Support],
548 enable_nls=$enableval, enable_nls=yes)
549 AC_MSG_RESULT($enable_nls)
551 AM_CONDITIONAL(USE_NLS, test $use_nls = yes)
553 if test $enable_nls = yes; then
554 AC_DEFINE(ENABLE_NLS, 1, [Define if NLS is requested.])
556 # We don't support catgets at all
557 if test "x$with_catgets" != x; then
558 AC_MSG_WARN([catgets not supported; --with-catgets ignored])
561 # Find out what the user wants.
563 AC_ARG_WITH(included-gettext,
564 [ --with-included-gettext use the GNU gettext library included here],
565 with_included_gettext=yes,
566 with_included_gettext=maybe)
568 if test "x$with_included_gettext" != xyes; then
569 pds_CHECK_SYSTEM_GETTEXT
572 AC_MSG_CHECKING([whether to use included gettext])
573 AC_MSG_RESULT($with_included_gettext)
575 if test "$with_included_gettext" = yes; then
576 LIBOBJS="$LIBOBJS gettext.o"
579 AC_DEFINE(HAVE_GETTEXT, 1, [Define if you have the gettext function.])
580 AC_DEFINE(HAVE_DCGETTEXT, 1, [Define if you have the dcgettext function.])
582 AC_CHECK_FUNCS(getcwd setlocale stpcpy)
585 if test -z "$ALL_LINGUAS"; then
586 AC_MSG_WARN(This package does not install translations yet.)
588 ac_items="$ALL_LINGUAS"
589 for ac_item in $ac_items; do
590 ALL_POFILES="$ALL_POFILES $ac_item.po"
591 ALL_MOFILES="$ALL_MOFILES $ac_item.mo"
594 AC_SUBST(ALL_LINGUAS)
595 AC_SUBST(ALL_POFILES)
596 AC_SUBST(ALL_MOFILES)
598 AC_MSG_CHECKING(which translations to install)
599 if test -z "$LINGUAS"; then
600 ac_print="$ALL_LINGUAS"
601 MOFILES="$ALL_MOFILES"
604 for ac_item in $ac_items; do
605 case "$ALL_LINGUAS" in
607 ac_print="$ac_print $ac_item"
608 MOFILES="$MOFILES $ac_item.mo"
614 if test -z "$ac_print"; then
617 AC_MSG_RESULT($ac_print)
620 if test "x$prefix" = xNONE; then
621 AC_DEFINE_UNQUOTED(LOCALEDIR, "$ac_default_prefix/share/locale")
623 AC_DEFINE_UNQUOTED(LOCALEDIR, "$prefix/share/locale")