summaryrefslogtreecommitdiff
path: root/m4/largefile.m4
blob: 6de55f22ee18c2e3a3fea9ff7a68c807d3fb5be0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
dnl This code comes from evolution-data-server
dnl License LGPL

AC_DEFUN([AC_CUSTOM_LARGE_FILE], [
dnl *************************************
dnl *** Checks for large file support ***
dnl *************************************
    AC_SYS_LARGEFILE
    AC_CACHE_CHECK([for _LARGEFILE64_SOURCE value needed for large files], largefile64_cv_source,
    [
        AC_TRY_COMPILE([
                #include <sys/types.h>
                #include <sys/stat.h>
                #include <fcntl.h>
        ],[
                int fd = open ("__o_largefile", O_CREAT | O_RDWR | O_LARGEFILE, 0644);
        ],[
                largefile64_source="no"
        ],[
                AC_TRY_COMPILE([
                        #define _LARGEFILE64_SOURCE
                        #include <sys/types.h>
                        #include <sys/stat.h>
                        #include <fcntl.h>
                ],[
                        int fd = open ("__o_largefile", O_CREAT | O_RDWR | O_LARGEFILE, 0644);
                ],[
                        largefile64_source="yes"
                ],[
                        largefile64_source="unknown"
                ])
        ])
    ])

    if test "x$largefile64_source" = "xyes"; then
        LARGEFILE_CFLAGS="-D_LARGEFILE64_SOURCE"
        enable_largefile="yes"
    elif test "x$largefile64_source" = "xunknown"; then
        AC_DEFINE(O_LARGEFILE, 0, [Define to 0 if your system does not have the O_LARGEFILE flag])
    fi

    if test -n "$ac_cv_sys_large_files" -a "x$ac_cv_sys_large_files" != "xno"; then
        LARGEFILE_CFLAGS="$LARGEFILE_CFLAGS -D_LARGE_FILES"
        enable_largefile="yes"
    fi

    if test "x$ac_cv_sys_file_offset_bits" != "xno"; then
        LARGEFILE_CFLAGS="$LARGEFILE_CFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
        enable_largefile="yes"
    fi

])