comparison setup.py @ 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 3db113eef95f
children 2243ba216f66
comparison
equal deleted inserted replaced
31595:e8bd005c0af7 31596:ab51a2b18f87
594 for plat, func in [('bsd', 'setproctitle'), ('bsd|darwin|linux', 'statfs')]: 594 for plat, func in [('bsd', 'setproctitle'), ('bsd|darwin|linux', 'statfs')]:
595 if re.search(plat, sys.platform) and hasfunction(new_compiler(), func): 595 if re.search(plat, sys.platform) and hasfunction(new_compiler(), func):
596 osutil_cflags.append('-DHAVE_%s' % func.upper()) 596 osutil_cflags.append('-DHAVE_%s' % func.upper())
597 597
598 for plat, header in [ 598 for plat, header in [
599 ('bsd|darwin|linux', 'sys/mount.h'),
600 ('bsd|darwin|linux', 'sys/param.h'),
601 ('linux', 'linux/magic.h'), 599 ('linux', 'linux/magic.h'),
602 ('linux', 'sys/vfs.h'), 600 ('linux', 'sys/vfs.h'),
603 ]: 601 ]:
604 if re.search(plat, sys.platform) and hasheader(new_compiler(), header): 602 if re.search(plat, sys.platform) and hasheader(new_compiler(), header):
605 macro = header.replace('/', '_').replace('.', '_').upper() 603 macro = header.replace('/', '_').replace('.', '_').upper()
604 osutil_cflags.append('-DHAVE_%s' % macro)
605
606 for plat, macro, code in [
607 ('bsd|darwin', 'BSD_STATFS', '''
608 #include <sys/param.h>
609 #include <sys/mount.h>
610 int main() { struct statfs s; return sizeof(s.f_fstypename); }
611 '''),
612 ]:
613 if re.search(plat, sys.platform) and cancompile(new_compiler(), code):
606 osutil_cflags.append('-DHAVE_%s' % macro) 614 osutil_cflags.append('-DHAVE_%s' % macro)
607 615
608 if sys.platform == 'darwin': 616 if sys.platform == 'darwin':
609 osutil_ldflags += ['-framework', 'ApplicationServices'] 617 osutil_ldflags += ['-framework', 'ApplicationServices']
610 618