As the title says, i am trying to find a way to enable largefile support on a project which uses autotools. I am using the AC_SYS_LARGEFILE macro on the configure.ac file and it works fine on 64 bit Linux (by default) and 32 bit Linux. Now i ported the project so it can compile on Windows (32 bits) using mingw but sadly the AC_SYS_LARGEFILE doesn't work (for example off_t is 4 bytes while on Linux is 8 in both 32 and 64 bits and fopen/fstat isn't replaced by fopen64/fstat64).
Here is a testcase where i can reproduce one of the problems (off_t is 4 bytes):
configure.ac
AC_INIT([testcase], [1.0.0], [[email protected]])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
# Support for large files in 32bit systems
AC_SYS_LARGEFILE
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
Makefile.am
ACLOCAL_AMFLAGS=-I m4
bin_PROGRAMS=testcase
testcase_SOURCES=testcase.c
testcase_CFLAGS= -std=gnu99 -O2
testcase.c
#include "config.h"
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("sizeof off_t: %i bytes\n", sizeof(off_t));
return 0;
}
to compile/run the testcase i am using the following:
mkdir m4
autoreconf --install
./configure
make
./testcase
Output on 64-bit Linux (used gcc/autotools)
sizeof off_t: 8 bytes
Output on 32-bit Linux (used gcc/autotools)
sizeof off_t: 8 bytes
Output on Windows 7 32-bit (used mingw-get to prepare the environment):
sizeof off_t: 4 bytes
Any ideas about what i can add/modify in the configure script so i can get largefile support on both platforms? Is this possible using mingw/autotools?