[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fix AC_FUNC_ERROR_AT_LINE and others
From: |
Paul Eggert |
Subject: |
Re: Fix AC_FUNC_ERROR_AT_LINE and others |
Date: |
Tue, 26 Sep 2006 14:00:01 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
Ralf Wildenhues <address@hidden> writes:
> -[AC_LIBSOURCES([error.h, error.c])dnl
> +[AC_CHECK_HEADERS_ONCE(error.h)
> +AC_LIBSOURCES([error.h, error.c])dnl
> AC_CACHE_CHECK([for error_at_line], ac_cv_lib_error_at_line,
> -[AC_LINK_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
> - [error_at_line (0, 0, "", 0, "");])],
> +[AC_LINK_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
> + #ifdef HAVE_ERROR_H
> + # include <error.h>
> + #endif],
Thanks, but it's simpler just to include <error.h> without testing for it.
That should work on all modern hosts.
> - address@hidden:@include <stdio.h>], [return !fseeko;])
> + address@hidden:@include <stdio.h>], [typedef int (*fp) ();
> + fp p = (fp) fseeko;
> + return !p;])
How about if we just call fseeko as a function, and use it in parentheses
(to avoid macros, which was part of the point.)? The patch below does that.
> +[AC_REQUIRE([AC_GNU_SOURCE])dnl
I think you are right, it's better to use AC_USE_SYSTEM_EXTENSIONS hee.
Thanks. I installed this revised patch.
2006-09-26 Paul Eggert <address@hidden>
* lib/autoconf/functions.m4 (AC_FUNC_FSEEKO): Don't compile the
fseeko testing program twice; just use the earlier result.
* lib/autoconf/specific.m4 (_AC_SYS_LARGEFILE_MACRO_VALUE):
Set cache var to 'unknown' (not 'no') if leaving the macro unset
still doesn't let the program compile.
(AC_SYS_LARGEFILE): Test for _LARGE_FILES only if earlier tests
failed.
* lib/autoconf/functions.m4: Fix problems reported by Ralf Wildenhues.
(AC_FUNC_ERROR_AT_LINE): Don't bother to check for error.h. Just
include it, without including anything else.
(AC_FUNC_FSEEKO): Avoid gcc -Wall warnings about constant
expressions.
(AC_FUNC_STRNLEN): Require AC_USE_SYSTEM_EXTENSIONS.
2006-09-26 Ralf Wildenhues <address@hidden>
* lib/autoconf/functions.m4 (AC_FUNC_ERROR_AT_LINE): Check for
`error.h', and include it, for a `error_at_line' prototype.
Use a nonempty format string in the link test.
* lib/autoconf/functions.m4 (AC_FUNC_WAIT3): Include <sys/wait.h>,
for a declaration of wait3.
Index: lib/autoconf/functions.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/functions.m4,v
retrieving revision 1.110
diff -p -u -r1.110 functions.m4
--- lib/autoconf/functions.m4 25 Sep 2006 17:50:06 -0000 1.110
+++ lib/autoconf/functions.m4 26 Sep 2006 20:53:23 -0000
@@ -472,8 +472,8 @@ AN_FUNCTION([error_at_line], [AC_FUNC_ER
AC_DEFUN([AC_FUNC_ERROR_AT_LINE],
[AC_LIBSOURCES([error.h, error.c])dnl
AC_CACHE_CHECK([for error_at_line], ac_cv_lib_error_at_line,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
- [error_at_line (0, 0, "", 0, "");])],
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <error.h>],
+ [error_at_line (0, 0, "", 0, "an error
occurred");])],
[ac_cv_lib_error_at_line=yes],
[ac_cv_lib_error_at_line=no])])
if test $ac_cv_lib_error_at_line = no; then
@@ -589,17 +589,13 @@ AC_DEFUN([AC_FUNC_FSEEKO],
[_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
[ac_cv_sys_largefile_source],
[Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).],
- address@hidden:@include <stdio.h>], [return !fseeko;])
+ address@hidden:@include <stdio.h>],
+ [[return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);]])
# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
# in glibc 2.1.3, but that breaks too many other things.
# If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
-AC_CACHE_CHECK([for fseeko], [ac_cv_func_fseeko],
-[AC_LINK_IFELSE([AC_LANG_PROGRAM(address@hidden:@include <stdio.h>],
- [[return fseeko && fseeko (stdin, 0, 0);]])],
- [ac_cv_func_fseeko=yes],
- [ac_cv_func_fseeko=no])])
-if test $ac_cv_func_fseeko = yes; then
+if test $ac_cv_sys_largefile_source != unknown; then
AC_DEFINE(HAVE_FSEEKO, 1,
[Define to 1 if fseeko (and presumably ftello) exists and is declared.])
fi
@@ -1653,7 +1649,8 @@ LIBS="-lintl $LIBS"])])dnl
# ---------------
AN_FUNCTION([strnlen], [AC_FUNC_STRNLEN])
AC_DEFUN([AC_FUNC_STRNLEN],
-[AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
+[AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])dnl
+AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
#define S "foobar"
#define S_LEN (sizeof S - 1)
@@ -1998,6 +1995,7 @@ AC_CACHE_CHECK([for wait3 that fills in
[AC_INCLUDES_DEFAULT[
#include <sys/time.h>
#include <sys/resource.h>
+#include <sys/wait.h>
/* HP-UX has wait3 but does not fill in rusage at all. */
int
main ()
Index: lib/autoconf/specific.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/specific.m4,v
retrieving revision 1.370
diff -p -u -r1.370 specific.m4
--- lib/autoconf/specific.m4 15 Aug 2006 16:24:42 -0000 1.370
+++ lib/autoconf/specific.m4 26 Sep 2006 20:53:23 -0000
@@ -130,17 +130,18 @@ m4_define([_AC_SYS_LARGEFILE_TEST_INCLUD
m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
[AC_CACHE_CHECK([for $1 value needed for large files], [$3],
[while :; do
- $3=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$5], [$6])],
- [break])
+ [$3=no; break])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(address@hidden:@define $1 $2
$5], [$6])],
[$3=$2; break])
+ $3=unknown
break
done])
-if test "$$3" != no; then
- AC_DEFINE_UNQUOTED([$1], [$$3], [$4])
-fi
+case $$3 in #(
+ no | unknown) ;;
+ *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
+esac
rm -f conftest*[]dnl
])# _AC_SYS_LARGEFILE_MACRO_VALUE
@@ -181,10 +182,12 @@ if test "$enable_largefile" != no; then
ac_cv_sys_file_offset_bits,
[Number of bits in a file offset, on hosts where this is settable.],
[_AC_SYS_LARGEFILE_TEST_INCLUDES])
- _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
- ac_cv_sys_large_files,
- [Define for large files, on AIX-style hosts.],
- [_AC_SYS_LARGEFILE_TEST_INCLUDES])
+ if test $ac_cv_sys_file_offset_bits = unknown; then
+ _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
+ ac_cv_sys_large_files,
+ [Define for large files, on AIX-style hosts.],
+ [_AC_SYS_LARGEFILE_TEST_INCLUDES])
+ fi
fi
])# AC_SYS_LARGEFILE