]> git.sur5r.net Git - bacula/bacula/blob - bacula/autoconf/bacula-macros/largefiles.m4
8e2b86933b31aa3ce41193a31ce34d1902de1c48
[bacula/bacula] / bacula / autoconf / bacula-macros / largefiles.m4
1 dnl
2 dnl =========  Large File Support ==============
3 dnl By default, many hosts won't let programs access large files;
4 dnl one must use special compiler options to get large-file access to work.
5 dnl For more details about this brain damage please see:
6 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
7
8 dnl Written by Paul Eggert <eggert@twinsun.com>.
9 dnl 
10 dnl Modified by Kern Sibbald to turn on the large file
11 dnl   flags on all machines. Otherwise functions such as
12 dnl   fseek are not large file capable.
13 dnl
14
15 dnl Internal subroutine of AC_SYS_LARGEFILE.
16 dnl AC_SYS_LARGEFILE_FLAGS(FLAGSNAME)
17 AC_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.
25 changequote(, )dnl
26            irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
27 changequote([, ])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
38 dnl Internal subroutine of AC_SYS_LARGEFILE.
39 dnl AC_SYS_LARGEFILE_SPACE_APPEND(VAR, VAL)
40 AC_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
50 dnl Internal subroutine of AC_SYS_LARGEFILE.
51 dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
52 AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
53   [AC_CACHE_CHECK([for $1], $2,
54      [$2=no
55 changequote(, )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
65 changequote([, ])dnl
66       ])
67    if test "[$]$2" != no; then
68      AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
69    fi])
70
71 AC_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   ])
109 dnl ==========================================================