changeset 31596:ab51a2b18f87

setup: use a more strict way to test BSD or OSX's statfs We want to use the `f_fstypename` field to get the filesystem type. Test it directly. The new macro HAVE_BSD_STATFS implys the old HAVE_SYS_MOUNT_H and HAVE_SYS_PARAM_H. So the latter ones are removed.
author Jun Wu <quark@fb.com>
date Thu, 23 Mar 2017 22:15:36 -0700
parents e8bd005c0af7
children 2d501fb60b2d
files setup.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Thu Mar 23 12:03:19 2017 -0700
+++ b/setup.py	Thu Mar 23 22:15:36 2017 -0700
@@ -596,8 +596,6 @@
         osutil_cflags.append('-DHAVE_%s' % func.upper())
 
 for plat, header in [
-    ('bsd|darwin|linux', 'sys/mount.h'),
-    ('bsd|darwin|linux', 'sys/param.h'),
     ('linux', 'linux/magic.h'),
     ('linux', 'sys/vfs.h'),
 ]:
@@ -605,6 +603,16 @@
         macro = header.replace('/', '_').replace('.', '_').upper()
         osutil_cflags.append('-DHAVE_%s' % macro)
 
+for plat, macro, code in [
+    ('bsd|darwin', 'BSD_STATFS', '''
+     #include <sys/param.h>
+     #include <sys/mount.h>
+     int main() { struct statfs s; return sizeof(s.f_fstypename); }
+     '''),
+]:
+    if re.search(plat, sys.platform) and cancompile(new_compiler(), code):
+        osutil_cflags.append('-DHAVE_%s' % macro)
+
 if sys.platform == 'darwin':
     osutil_ldflags += ['-framework', 'ApplicationServices']