|
From: Motiejus J. <des...@gm...> - 2012-09-24 19:50:55
|
Sox couldn't compile on 32-bit mingw due to stat and fstat defintions
pointing to wrong structs. Now check where they point to and define
accordingly.
---
CMakeLists.txt | 6 ++++++
src/soxconfig.h.cmake | 4 ++++
src/util.h | 15 +++++++++++++--
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 469b302..13a0aa8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.4)
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckLibraryExists)
+include(CheckStructHasMember)
macro(optional variable header library function source)
check_include_files(${header} ${variable}1)
@@ -98,6 +99,11 @@ check_function_exists("strcasecmp" HAVE_STRCASECMP)
check_function_exists("strrstr" HAVE_STRRSTR)
check_function_exists("vsnprintf" HAVE_VSNPRINTF)
+check_struct_has_member("struct _fstat" st_mtime sys/stat.h HAVE__FSTAT)
+check_struct_has_member("struct _fstati64" st_mtime sys/stat.h HAVE__FSTATI64)
+check_struct_has_member("struct _stat" st_mtime sys/stat.h HAVE__STAT)
+check_struct_has_member("struct _stati64" st_mtime sys/stat.h HAVE__STATI64)
+
test_big_endian(WORDS_BIGENDIAN)
optional(NEED_LIBM math.h m pow "")
diff --git a/src/soxconfig.h.cmake b/src/soxconfig.h.cmake
index c228839..0468b78 100644
--- a/src/soxconfig.h.cmake
+++ b/src/soxconfig.h.cmake
@@ -13,6 +13,8 @@
#cmakedefine HAVE_FLAC 1
#cmakedefine HAVE_FMEMOPEN 1
#cmakedefine HAVE_FSEEKO 1
+#cmakedefine HAVE__FSTAT 1
+#cmakedefine HAVE__FSTATI64 1
#cmakedefine HAVE_GETTIMEOFDAY 1
#cmakedefine HAVE_GLOB_H 1
#define HAVE_GSM 1
@@ -38,6 +40,8 @@
#cmakedefine HAVE_SNDFILE_1_0_18 1
#cmakedefine HAVE_SNDIO 1
#cmakedefine HAVE_SPEEXDSP 1
+#cmakedefine HAVE__STATI 1
+#cmakedefine HAVE__STATI64 1
#cmakedefine HAVE_STDINT_H 1
#cmakedefine HAVE_STRCASECMP 1
#cmakedefine HAVE_STRING_H 1
diff --git a/src/util.h b/src/util.h
index cf95cc4..e7a1067 100644
--- a/src/util.h
+++ b/src/util.h
@@ -148,13 +148,24 @@
#if !defined(HAVE_FSEEKO)
#undef off_t
#define fseeko fseeko64
-#define fstat _fstati64
#define ftello ftello64
#define off_t off64_t
+
+#if defined(HAVE__FSTATI64)
+#define fstat _fstati64
+#elif defined(HAVE__FSTAT)
+#define fstat _fstat
+#endif
+
+#if defined(HAVE__STATI64)
#define stat _stati64
-#define HAVE_FSEEKO 1
+#elif defined(HAVE__STAT)
+#define stat _stat
#endif
+#define HAVE_FSEEKO 1
+#endif /* !defined(HAVE_FSEEK0) */
+
#endif
#if defined(DOS) || defined(WIN32) || defined(__NT__) || defined(__DJGPP__) || defined(__OS2__)
--
1.7.9.5
|