1dnl
2dnl =========  Large File Support ==============
3dnl By default, many hosts won't let programs access large files;
4dnl one must use special compiler options to get large-file access to work.
5dnl For more details about this brain damage please see:
6dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
7
8dnl Written by Paul Eggert <eggert@twinsun.com>.
9dnl
10dnl Modified by Kern Sibbald to turn on the large file
11dnl   flags on all machines. Otherwise functions such as
12dnl   fseek are not large file capable.
13dnl
14
15dnl Internal subroutine of AC_SYS_LARGEFILE.
16dnl AC_SYS_LARGEFILE_FLAGS(FLAGSNAME)
17AC_DEFUN([AC_SYS_LARGEFILE_FLAGS],
18  [AC_CACHE_CHECK([for $1 value to request large file support],
19     ac_cv_sys_largefile_$1,
20     [ac_cv_sys_largefile_$1=`($GETCONF LFS_$1) 2>/dev/null` || {
21        ac_cv_sys_largefile_$1=no
22        ifelse($1, CFLAGS,
23          [case "$host_os" in
24           # IRIX 6.2 and later require cc -n32.
25changequote(, )dnl
26           irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
27changequote([, ])dnl
28             if test "$GCC" != yes; then
29               ac_cv_sys_largefile_CFLAGS=-n32
30             fi
31             ac_save_CC="$CC"
32             CC="$CC $ac_cv_sys_largefile_CFLAGS"
33             AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
34             CC="$ac_save_CC"
35           esac])
36      }])])
37
38dnl Internal subroutine of AC_SYS_LARGEFILE.
39dnl AC_SYS_LARGEFILE_SPACE_APPEND(VAR, VAL)
40AC_DEFUN([AC_SYS_LARGEFILE_SPACE_APPEND],
41  [case $2 in
42   no) ;;
43   ?*)
44     case "[$]$1" in
45     '') $1=$2 ;;
46     *) $1=[$]$1' '$2 ;;
47     esac ;;
48   esac])
49
50dnl Internal subroutine of AC_SYS_LARGEFILE.
51dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
52AC_DEFUN([AC_SYS_LARGEFILE_MACRO_VALUE],
53  [AC_CACHE_CHECK([for $1], $2,
54     [$2=no
55changequote(, )dnl
56      $4
57      for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
58        case "$ac_flag" in
59        -D$1)
60          $2=1 ;;
61        -D$1=*)
62          $2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
63        esac
64      done
65changequote([, ])dnl
66      ])
67   if test "[$]$2" != no; then
68     AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
69   fi])
70
71AC_DEFUN([AC_BAC_LARGEFILE],
72  [AC_REQUIRE([AC_CANONICAL_HOST])
73   AC_ARG_ENABLE(largefile,
74     [  --disable-largefile     omit support for large files])
75   if test "$enable_largefile" != no; then
76     AC_CHECK_TOOL(GETCONF, getconf)
77     AC_SYS_LARGEFILE_FLAGS(CFLAGS)
78     AC_SYS_LARGEFILE_FLAGS(LDFLAGS)
79     AC_SYS_LARGEFILE_FLAGS(LIBS)
80
81     for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
82       case "$ac_flag" in
83       no) ;;
84       -D_FILE_OFFSET_BITS=*) ;;
85       -D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
86       -D_LARGE_FILES | -D_LARGE_FILES=*) ;;
87       -D?* | -I?*)
88         AC_SYS_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
89       *)
90         AC_SYS_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
91       esac
92     done
93     AC_SYS_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
94     AC_SYS_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
95     AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
96       ac_cv_sys_file_offset_bits,
97       [Number of bits in a file offset, on hosts where this is settable.],
98       [ac_cv_sys_file_offset_bits=64])
99     AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
100       ac_cv_sys_largefile_source,
101       [Define to make fseeko etc. visible, on some hosts.],
102       [ac_cv_sys_largefile_source=1])
103     AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
104       ac_cv_sys_large_files,
105       [Define for large files, on AIX-style hosts.],
106          [ac_cv_sys_large_files=1])
107   fi
108  ])
109dnl ==========================================================
110