Don't unconditionally define _LARGEFILE_SOURCE, but instead include
[rsync/rsync.git] / aclocal.m4
1 dnl AC_VALIDATE_CACHE_SYSTEM_TYPE[(cmd)]
2 dnl if the cache file is inconsistent with the current host,
3 dnl target and build system types, execute CMD or print a default
4 dnl error message.
5 AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
6     AC_REQUIRE([AC_CANONICAL_SYSTEM])
7     AC_MSG_CHECKING([config.cache system type])
8     if { test x"${ac_cv_host_system_type+set}" = x"set" &&
9          test x"$ac_cv_host_system_type" != x"$host"; } ||
10        { test x"${ac_cv_build_system_type+set}" = x"set" &&
11          test x"$ac_cv_build_system_type" != x"$build"; } ||
12        { test x"${ac_cv_target_system_type+set}" = x"set" &&
13          test x"$ac_cv_target_system_type" != x"$target"; }; then
14         AC_MSG_RESULT([different])
15         ifelse($#, 1, [$1],
16                 [AC_MSG_ERROR(["you must remove config.cache and restart configure"])])
17     else
18         AC_MSG_RESULT([same])
19     fi
20     ac_cv_host_system_type="$host"
21     ac_cv_build_system_type="$build"
22     ac_cv_target_system_type="$target"
23 ])
24
25 #serial 12
26
27 dnl By default, many hosts won't let programs access large files;
28 dnl one must use special compiler options to get large-file access to work.
29 dnl For more details about this brain damage please see:
30 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
31
32 dnl Written by Paul Eggert <eggert@twinsun.com>.
33
34 dnl Internal subroutine of AC_SYS_LARGEFILE.
35 dnl AC_SYS_LARGEFILE_TEST_INCLUDES
36 AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES,
37   [[#include <sys/types.h>
38     int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1];
39   ]])
40
41 dnl Internal subroutine of AC_SYS_LARGEFILE.
42 dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY)
43 AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
44   [AC_CACHE_CHECK([for $1 value needed for large files], $3,
45      [$3=no
46       AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES
47 $5
48         ,
49         [$6],
50         ,
51         [AC_TRY_COMPILE([#define $1 $2]
52 AC_SYS_LARGEFILE_TEST_INCLUDES
53 $5
54            ,
55            [$6],
56            [$3=$2])])])
57    if test "[$]$3" != no; then
58      AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
59    fi])
60
61 AC_DEFUN(AC_SYS_LARGEFILE,
62   [AC_ARG_ENABLE(largefile,
63      [  --disable-largefile     omit support for large files])
64    if test "$enable_largefile" != no; then
65
66      AC_CACHE_CHECK([for special C compiler options needed for large files],
67        ac_cv_sys_largefile_CC,
68        [ac_cv_sys_largefile_CC=no
69         if test "$GCC" != yes; then
70           # IRIX 6.2 and later do not support large files by default,
71           # so use the C compiler's -n32 option if that helps.
72           AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
73             [ac_save_CC="$CC"
74              CC="$CC -n32"
75              AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
76                ac_cv_sys_largefile_CC=' -n32')
77              CC="$ac_save_CC"])
78         fi])
79      if test "$ac_cv_sys_largefile_CC" != no; then
80        CC="$CC$ac_cv_sys_largefile_CC"
81      fi
82
83      AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
84        ac_cv_sys_file_offset_bits,
85        [Number of bits in a file offset, on hosts where this is settable.])
86      AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
87        ac_cv_sys_largefile_source,
88        [Define to make ftello visible on some hosts (e.g. HP-UX 10.20).],
89        [#include <stdio.h>], [return !ftello;])
90      AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
91        ac_cv_sys_large_files,
92        [Define for large files, on AIX-style hosts.])
93      AC_SYS_LARGEFILE_MACRO_VALUE(_XOPEN_SOURCE, 500,
94        ac_cv_sys_xopen_source,
95        [Define to make ftello visible on some hosts (e.g. glibc 2.1.3).],
96        [#include <stdio.h>], [return !ftello;])
97    fi
98   ])