1From fc392c939b9a18959482f588aff0afc29dd6d30a Mon Sep 17 00:00:00 2001
2From: Romain Naour <romain.naour@openwide.fr>
3Date: Fri, 23 Jan 2015 22:20:18 +0100
4Subject: [PATCH 6/6] unix/configure: borrow the LFS test from autotools.
5
6Infozip's LFS check can't work for cross-compilation
7since it try to run a target's binary on the host system.
8
9Instead, use to LFS test used by autotools which is a
10compilation test.
11(see autotools/lib/autoconf/specific.m4)
12
13Reported-by: Richard Genoud <richard.genoud@gmail.com>
14Signed-off-by: Romain Naour <romain.naour@openwide.fr>
15---
16 unix/configure | 51 ++++++++++++++++++---------------------------------
17 1 file changed, 18 insertions(+), 33 deletions(-)
18
19diff --git a/unix/configure b/unix/configure
20index 7bfc9eb..588f269 100644
21--- a/unix/configure
22+++ b/unix/configure
23@@ -237,9 +237,8 @@ _EOF_
24 $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null
25 [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_OFF_T"
26
27-# Now we set the 64-bit file environment and check the size of off_t
28-# Added 11/4/2003 EG
29-# Revised 8/12/2004 EG
30+# LFS check borrowed from autotools sources
31+# lib/autoconf/specific.m4
32
33 echo Check for Large File Support
34 cat > conftest.c << _EOF_
35@@ -247,24 +246,22 @@ cat > conftest.c << _EOF_
36 # define _LARGEFILE64_SOURCE
37 # define _FILE_OFFSET_BITS 64       /* select default interface as 64 bit */
38 # define _LARGE_FILES        /* some OSes need this for 64-bit off_t */
39+
40 #include <sys/types.h>
41-#include <sys/stat.h>
42-#include <unistd.h>
43-#include <stdio.h>
44-int main()
45+ /* Check that off_t can represent 2**63 - 1 correctly.
46+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
47+    since some C++ compilers masquerading as C compilers
48+    incorrectly reject 9223372036854775807.  */
49+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
50+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
51+		       && LARGE_OFF_T % 2147483647 == 1)
52+		      ? 1 : -1];
53+int
54+main ()
55 {
56-  off_t offset;
57-  struct stat s;
58-  /* see if have 64-bit off_t */
59-  if (sizeof(offset) < 8)
60-    return 1;
61-  printf("  off_t is %d bytes\n", sizeof(off_t));
62-  /* see if have 64-bit stat */
63-  if (sizeof(s.st_size) < 8) {
64-    printf("  s.st_size is %d bytes\n", sizeof(s.st_size));
65-    return 2;
66-  }
67-  return 3;
68+
69+  ;
70+  return 0;
71 }
72 _EOF_
73 # compile it
74@@ -272,22 +269,10 @@ $CC -o conftest conftest.c >/dev/null 2>/dev/null
75 if [ $? -ne 0 ]; then
76   echo -- no Large File Support
77 else
78-# run it
79-  ./conftest
80-  r=$?
81-  if [ $r -eq 1 ]; then
82-    echo -- no Large File Support - no 64-bit off_t
83-  elif [ $r -eq 2 ]; then
84-    echo -- no Large File Support - no 64-bit stat
85-  elif [ $r -eq 3 ]; then
86-    echo -- yes we have Large File Support!
87-    CFLAGS="${CFLAGS} -DLARGE_FILE_SUPPORT"
88-  else
89-    echo -- no Large File Support - conftest returned $r
90-  fi
91+      echo -- yes we have Large File Support!
92+      CFLAGS="${CFLAGS} -DLARGE_FILE_SUPPORT"
93 fi
94
95-
96 # Check for wide char for Unicode support
97 # Added 11/24/2005 EG
98
99--
1001.9.3
101
102