On Thu, Sep 07, 2000 at 06:07:08PM +1000, Andrew Tridgell wrote:
> > > I wasn't aware of AC_SYS_LARGEFILE. Can you give me a pointer to it?
> >
> > Attached. Remove your getconf stuff and replace with AC_SYS_LARGEFILE,
> > copy the attachment to acinclude.m4, and run autoconf.
>
> hmmm, I've had a look at it and I think the current code is better,
> even if it doesn't work on some systems :)
>
> The problem with the AC_SYS_LARGEFILE macro you sent me is that it is
> not at all future proof. As I understand it a OS vendor is free to
> require any flags/libraries they like to implement LFS. If a vendor
> does get the getconf info correct but the autoconf macros don't test
> that particular combination then that platform won't work.
>
> I know you said that HPUX doesn't work with getconf (ie. doesn't give
> 64 bit offsets) but I presume that is because getconf is broken on
> HPUX. I'd rather be broken with broken platforms than be broken with
> non-broken platforms :)
getconf isn't broken. It just does not honor LFS_CFLAGS and
LFS_LDFLAGS as arguments (honoring the flags is not a requirement).
>From my perusing of
http://www.sas.com/standards/large.file/x_open.20Mar96.html, it is
getconf that is optional. The only time getconf is mentioned is in
section 3.3.4, "Utilities: Optional Method for Specifying the Size of
an off_t". Reading this section does not indicate to me that getconf
is a requirement.
The AC_SYS_LARGEFILE macro seems to follow section 1.6 which does not
give the impression that "a OS vendor is free to require any flags/libraries
they like to implement LFS". AC_SYS_LARGEFILE seems to be concerned,
though, with only setting CFLAGS (or is it CPPFLAGS) and not LDFLAGS
(so if any linker flags/librares are needed they won't be picked up).
I think the latter is because Paul probably has not encountered any
system that needs it. I think earlier versions of AC_SYS_LARGEFILE did
use getconf but were removed later because the current version is more
inclusive of existing systems supporting LFS.
> Maybe the macros should try getconf first and if that fails then try
> the common sets of compile/link flags?
>
> > if test "$GCC" != yes; then
> > # IRIX 6.2 and later do not support large files by default,
> > # so use the C compiler's -n32 option if that helps.
> > AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
> > [ac_save_CC="$CC"
> > CC="$CC -n32"
> > AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
> > ac_cv_sys_largefile_CC=' -n32')
> > CC="$ac_save_CC"])
> > fi])
>
> oops, the above is no good. What if I do:
>
> CC=/usr/local/bin/cc ./configure
>
> then the above will override my choice of compiler! Or have I misread
> it?
The above code is ok. $GCC is set only if an autoconf test determines
if gcc is your C compiler. The autoconf code follows:
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
echo "configure:654: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
#ifdef __GNUC__
yes;
#endif
EOF
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:663:
\"$ac_try\") 1
>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
fi
fi
echo "$ac_t""$ac_cv_prog_gcc" 1>&6
if test $ac_cv_prog_gcc = yes; then
GCC=yes
test "${CFLAGS+set}" = set || CFLAGS="-O2"
else
GCC=
test "${CFLAGS+set}" = set || CFLAGS="-O"
fi
So, regardless of what you set CC to, $GCC will only be set to "yes"
if the compiler is gcc. Of course, the above code assumes you have the
IRIX C compiler if $GCC != "yes". I don't know of any other C
compilers for IRIX besides GCC and IRIX C though so it's probably a
safe assumption.
--
albert chin ([EMAIL PROTECTED])
-- snip snip
#serial 12
dnl By default, many hosts won't let programs access large files;
dnl one must use special compiler options to get large-file access to work.
dnl For more details about this brain damage please see:
dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
dnl Written by Paul Eggert <[EMAIL PROTECTED]>.
dnl Internal subroutine of AC_SYS_LARGEFILE.
dnl AC_SYS_LARGEFILE_TEST_INCLUDES
AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES,
[[#include <sys/types.h>
int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1];
]])
dnl Internal subroutine of AC_SYS_LARGEFILE.
dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES,
FUNCTION-BODY)
AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
[AC_CACHE_CHECK([for $1 value needed for large files], $3,
[$3=no
AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES
$5
,
[$6],
,
[AC_TRY_COMPILE([#define $1 $2]
AC_SYS_LARGEFILE_TEST_INCLUDES
$5
,
[$6],
[$3=$2])])])
if test "[$]$3" != no; then
AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
fi])
AC_DEFUN(AC_SYS_LARGEFILE,
[AC_ARG_ENABLE(largefile,
[ --disable-largefile omit support for large files])
if test "$enable_largefile" != no; then
AC_CACHE_CHECK([for special C compiler options needed for large files],
ac_cv_sys_largefile_CC,
[ac_cv_sys_largefile_CC=no
if test "$GCC" != yes; then
# IRIX 6.2 and later do not support large files by default,
# so use the C compiler's -n32 option if that helps.
AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
[ac_save_CC="$CC"
CC="$CC -n32"
AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
ac_cv_sys_largefile_CC=' -n32')
CC="$ac_save_CC"])
fi])
if test "$ac_cv_sys_largefile_CC" != no; then
CC="$CC$ac_cv_sys_largefile_CC"
fi
AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
ac_cv_sys_file_offset_bits,
[Number of bits in a file offset, on hosts where this is settable.])
AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
ac_cv_sys_largefile_source,
[Define to make ftello visible on some hosts (e.g. HP-UX 10.20).],
[#include <stdio.h>], [return !ftello;])
AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
ac_cv_sys_large_files,
[Define for large files, on AIX-style hosts.])
AC_SYS_LARGEFILE_MACRO_VALUE(_XOPEN_SOURCE, 500,
ac_cv_sys_xopen_source,
[Define to make ftello visible on some hosts (e.g. glibc 2.1.3).],
[#include <stdio.h>], [return !ftello;])
fi
])