2009-12-07 Rolf Bjarne Kvinge <RKvinge@novell.com>
[moon.git] / m4 / large-file.m4
blobe17d8621ef1fbea1eea87d84663bdbbb14d8f68b
1 AC_DEFUN([MOONLIGHT_CHECK_LARGE_FILE],
3         AC_SYS_LARGEFILE
4         AC_CACHE_CHECK([whether _LARGEFILE64_SOURCE needs to be defined for large files], moon_cv_largefile64_source, [
5                 AC_TRY_COMPILE([
6                         #include <sys/types.h>
7                         #include <sys/stat.h>
8                         #include <fcntl.h>
9                 ],[
10                         int fd = open ("__o_largefile", O_CREAT | O_RDWR | O_LARGEFILE, 0644);
11                 ],[
12                         moon_cv_largefile64_source="no"
13                 ],[
14                         AC_TRY_COMPILE([
15                                 #define _LARGEFILE64_SOURCE 1
16                                 #include <sys/types.h>
17                                 #include <sys/stat.h>
18                                 #include <fcntl.h>
19                         ],[
20                                 int fd = open ("__o_largefile", O_CREAT | O_RDWR | O_LARGEFILE, 0644);
21                         ],[
22                                 moon_cv_largefile64_source="yes"
23                         ],[
24                                 moon_cv_largefile64_source="unknown (large files may not be supported)"
25                         ])
26                 ])
27         ])
29         if test "x$largefile64_source" = "xyes"; then
30                 LARGEFILE_CFLAGS="-D_LARGEFILE64_SOURCE=1"
31         elif test "x$largefile64_source" = "xundefined"; then
32                 AC_DEFINE(O_LARGEFILE, 0, [Define to 0 if your system does not have the O_LARGEFILE flag])
33         fi
35         if test -n "$ac_cv_sys_large_files" -a "x$ac_cv_sys_large_files" != "xno"; then
36                 LARGEFILE_CFLAGS="$LARGEFILE_CFLAGS -D_LARGE_FILES=1"
37         fi
39         if test "x$ac_cv_sys_file_offset_bits" != "xno"; then
40                 LARGEFILE_CFLAGS="$LARGEFILE_CFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits"
41         fi