From 7bb64f8f9408b0ad46b019fe272058b3a3a4b6e8 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 1 Sep 2008 19:36:23 -0600 Subject: [PATCH] Improve AC_C_BIGENDIAN. * doc/autoconf.texi (C Compiler) : Mention that universal builds require a config header. * lib/autoconf/c.m4 (AC_C_BIGENDIAN): Enhance comments. Check AH_HEADER at the last possible moment, so that users can use AC_CONFIG_HEADER after this macro. Reported by Stepan Kasal. Signed-off-by: Eric Blake --- ChangeLog | 8 ++++++++ doc/autoconf.texi | 7 ++++--- lib/autoconf/c.m4 | 21 +++++++++++++-------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index f77bf784..f78c40f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2008-09-01 Eric Blake + Improve AC_C_BIGENDIAN. + * doc/autoconf.texi (C Compiler) : Mention that + universal builds require a config header. + * lib/autoconf/c.m4 (AC_C_BIGENDIAN): Enhance comments. Check + AH_HEADER at the last possible moment, so that users can use + AC_CONFIG_HEADER after this macro. + Reported by Stepan Kasal. + Fix manual date information. * doc/autoconf.tex: UPDATED refers to the day the manual was built, not the release date of Autoconf. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index eccf68da..23417b37 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -6787,9 +6787,10 @@ The default for @var{action-if-true} is to define @samp{WORDS_BIGENDIAN}. The default for @var{action-if-false} is to do nothing. The default for @var{action-if-unknown} is to abort configure and tell the installer how to bypass this test. -And finally, the default for @var{action-if-universal} is to define -@samp{WORDS_BIGENDIAN} or not, depending on the architecture that the -code is being generated for. +And finally, the default for @var{action-if-universal} is to ensure that +@samp{WORDS_BIGENDIAN} is defined if and only if a universal build is +detected and the current code is big-endian; this default works only if +@command{autoheader} is used (@pxref{autoheader Invocation}). If you use this macro without specifying @var{action-if-universal}, you should also use @code{AC_CONFIG_HEADERS}; otherwise diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index 51fdfeba..6e250eed 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -1,7 +1,7 @@ # This file is part of Autoconf. -*- Autoconf -*- # Programming languages support. -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software -# Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free +# Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -1411,9 +1411,8 @@ AC_DEFUN([AC_C_BIGENDIAN], #endif])dnl AC_CACHE_CHECK([whether byte ordering is bigendian], [ac_cv_c_bigendian], [ac_cv_c_bigendian=unknown - m4_ifval(m4_ifdef([AH_HEADER], 1)[$4], - [# See if we're dealing with a universal compiler. - AC_COMPILE_IFELSE( + # See if we're dealing with a universal compiler. + AC_COMPILE_IFELSE( [AC_LANG_SOURCE( [[#ifndef __APPLE_CC__ not a universal capable compiler @@ -1426,8 +1425,7 @@ AC_DEFUN([AC_C_BIGENDIAN], # ppc64. This check is also rather less than ideal. case "${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}" in #( *-arch*ppc*|*-arch*i386*|*-arch*x86_64*) ac_cv_c_bigendian=universal;; - esac])], - [AC_DIAGNOSE([obsolete], [AC_C_BIGENDIAN suggests AC_CONFIG_HEADERS])]) + esac]) if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. AC_COMPILE_IFELSE( @@ -1531,8 +1529,15 @@ AC_DEFUN([AC_C_BIGENDIAN], no) $2 ;; #( universal) +dnl Note that AC_APPLE_UNIVERSAL_BUILD sorts less than WORDS_BIGENDIAN; +dnl this is a necessity for proper config header operation. Warn if +dnl the user did not specify a config header but is relying on the +dnl default behavior for universal builds. m4_default([$4], - [AC_DEFINE([AC_APPLE_UNIVERSAL_BUILD],1, + [AC_CONFIG_COMMANDS_PRE([m4_ifset([AH_HEADER], [], + [AC_DIAGNOSE([obsolete], + [AC_C_BIGENDIAN should be used with AC_CONFIG_HEADERS])])])dnl + AC_DEFINE([AC_APPLE_UNIVERSAL_BUILD],1, [Define if building universal (internal helper macro)])]) ;; #( *) -- 2.11.4.GIT