Writing metadata xattr on directories with sticky bit set, FR#94
[netatalk.git] / macros / largefile-check.m4
1 dnl -------------------------------------------------------------------
2 dnl This test for largefile support was written by Vadim Zeitlin for 
3 dnl wxWindows. 
4 dnl -------------------------------------------------------------------
5
6 dnl WX_SYS_LARGEFILE_TEST
7 dnl
8 dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
9 dnl     arithmetic properly but this failed miserably with gcc under Linux
10 dnl     whereas the system still supports 64 bit files, so now simply check
11 dnl     that off_t is big enough
12 define(WX_SYS_LARGEFILE_TEST,
13 [typedef struct {
14     unsigned int field: sizeof(off_t) == 8;
15 } wxlf;
16 ])
17
18 dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
19 define(WX_SYS_LARGEFILE_MACRO_VALUE,
20 [
21     AC_CACHE_CHECK([for $1 value needed for large files], [$3],
22         [
23           AC_TRY_COMPILE([#define $1 $2
24                           #include <sys/types.h>],
25                          WX_SYS_LARGEFILE_TEST,
26                          [$3=$2],
27                          [$3=no])
28         ]
29     )
30
31     if test "$$3" != no; then
32         wx_largefile=yes
33         AC_DEFINE_UNQUOTED([$1], [$$3], [$1 (for LARGEFILE support)])
34     fi
35 ])
36
37
38
39
40 dnl AC_SYS_LARGEFILE
41 dnl ----------------
42 dnl By default, many hosts won't let programs access large files;
43 dnl one must use special compiler options to get large-file access to work.
44 dnl For more details about this brain damage please see:
45 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
46 AC_DEFUN([AC_SYS_LARGEFILE],
47 [AC_ARG_ENABLE(largefile,
48                [  --disable-largefile     omit support for large files])
49 if test "$enable_largefile" != no; then
50     dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
51     dnl _LARGE_FILES -- for AIX
52     wx_largefile=no
53     WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits) 
54     if test "x$wx_largefile" != "xyes"; then
55         WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
56     fi
57
58     
59     AC_CACHE_CHECK([for 64 bit off_t],netatalk_cv_SIZEOF_OFF_T,[
60     AC_TRY_RUN([#include <stdio.h>
61 #include <stdlib.h>
62 #include <sys/stat.h>
63 main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
64 netatalk_cv_SIZEOF_OFF_T=yes,netatalk_cv_SIZEOF_OFF_T=no,netatalk_cv_SIZEOF_OFF_T=cross)])
65
66     AC_MSG_CHECKING([if large file support is available])
67     if test "x$netatalk_cv_SIZEOF_OFF_T" != "xno"; then
68         AC_DEFINE(HAVE_LARGEFILE_SUPPORT, [], [LARGEFILE support])
69         AC_MSG_RESULT([yes])
70         ifelse([$1], , :, [$1])
71     else
72         AC_MSG_RESULT([no])
73         ifelse([$2], , :, [$2])
74     fi
75 fi
76 ])
77
78 dnl ----------end of largefile test------------------------------------