1dnl -------------------------------------------------------------------
2dnl This test for largefile support was written by Vadim Zeitlin for 
3dnl wxWindows. 
4dnl -------------------------------------------------------------------
5
6dnl WX_SYS_LARGEFILE_TEST
7dnl
8dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
9dnl     arithmetic properly but this failed miserably with gcc under Linux
10dnl     whereas the system still supports 64 bit files, so now simply check
11dnl     that off_t is big enough
12define(WX_SYS_LARGEFILE_TEST,
13[typedef struct {
14    unsigned int field: sizeof(off_t) == 8;
15} wxlf;
16])
17
18dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
19define(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
40dnl AC_SYS_LARGEFILE
41dnl ----------------
42dnl By default, many hosts won't let programs access large files;
43dnl one must use special compiler options to get large-file access to work.
44dnl For more details about this brain damage please see:
45dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
46AC_DEFUN([AC_SYS_LARGEFILE],
47[AC_ARG_ENABLE(largefile,
48               [  --disable-largefile     omit support for large files])
49if 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>
63main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
64netatalk_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
75fi
76])
77
78dnl ----------end of largefile test------------------------------------
79