001-unix-configure-borrow-the-LFS-test-from-autotools.patch 2.6 KB

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