0006-unix-configure-borrow-the-LFS-test-from-autotools.patch 2.9 KB

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