From ebf532b106fed4bb4c2993be43e3ec2a42573f6b Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 25 Aug 2006 16:07:06 -0400
Subject: ENH: Separate the notion of a request for LFS and its availability. 
 Allow user code to block definitions of LFS macros.  Added framework to give
 error if sys/types.h is included before this header when LFS is requested
 (currently disabled).

---
 Source/kwsys/Configure.h.in | 44 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 35 insertions(+), 9 deletions(-)

diff --git a/Source/kwsys/Configure.h.in b/Source/kwsys/Configure.h.in
index ba4b99c..1afd416 100644
--- a/Source/kwsys/Configure.h.in
+++ b/Source/kwsys/Configure.h.in
@@ -22,18 +22,44 @@
 # define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
 #endif
 
-/* This is a support for files on the disk that are larger than 2GB.  Since
-   this is the first place that any include should happen, do this here. */
-#if @KWSYS_LFS_AVAILABLE@
-#  ifndef _LARGEFILE_SOURCE
-#    define _LARGEFILE_SOURCE
+/* Whether Large File Support is requested.  */
+#define @KWSYS_NAMESPACE@_LFS_REQUESTED @KWSYS_LFS_REQUESTED@
+
+/* Whether Large File Support is available.  */
+#if @KWSYS_NAMESPACE@_LFS_REQUESTED
+# define @KWSYS_NAMESPACE@_LFS_AVAILABLE @KWSYS_LFS_AVAILABLE@
+#endif
+
+/* Setup Large File Support if requested.  */
+#if @KWSYS_NAMESPACE@_LFS_REQUESTED
+  /* Since LFS is requested this header must be included before system
+     headers whether or not LFS is available. */
+# if 0 && (defined(_SYS_TYPES_H) || defined(_SYS_TYPES_INCLUDED))
+#  error "@KWSYS_NAMESPACE@/Configure.h must be included before sys/types.h"
+# endif
+  /* Enable the large file API if it is available.  */
+# if @KWSYS_NAMESPACE@_LFS_AVAILABLE && \
+     !defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINES)
+#  if !defined(_LARGEFILE_SOURCE) && \
+      !defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGEFILE_SOURCE)
+#   define _LARGEFILE_SOURCE
 #  endif
-#  ifndef _LARGE_FILES
-#    define _LARGE_FILES
+#  if !defined(_LARGEFILE64_SOURCE) && \
+      !defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGEFILE64_SOURCE)
+#   define _LARGEFILE64_SOURCE
 #  endif
-#  ifndef _FILE_OFFSET_BITS
-#    define _FILE_OFFSET_BITS 64
+#  if !defined(_LARGE_FILES) && \
+      !defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGE_FILES)
+#   define _LARGE_FILES
 #  endif
+#  if !defined(_FILE_OFFSET_BITS) && \
+      !defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_FILE_OFFSET_BITS)
+#   define _FILE_OFFSET_BITS 64
+#  endif
+#  if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS < 64
+#   error "_FILE_OFFSET_BITS must be defined to at least 64"
+#  endif
+# endif
 #endif
 
 /* Setup the export macro.  */
-- 
cgit v0.12