Patchwork [4,of,6] setup: test some header files

login
register
mail settings
Submitter Jun Wu
Date March 21, 2017, 12:04 a.m.
Message ID <8a3c7ac9923732e980a3.1490054677@localhost.localdomain>
Download mbox | patch
Permalink /patch/19482/
State Accepted
Headers show

Comments

Jun Wu - March 21, 2017, 12:04 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1490049807 25200
#      Mon Mar 20 15:43:27 2017 -0700
# Node ID 8a3c7ac9923732e980a3660f0555c2e109ee93e0
# Parent  8a5bf6002f2c9f98fbbe68c216579a7803693d65
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 8a3c7ac99237
setup: test some header files

The next patch will use "statfs", which requires different header files on
different platforms.

Linux:

    sys/vfs.h or sys/statfs.h

FreeBSD or OSX:

    sys/param.h and sys/mount.h

Therefore test them so we can include the correct ones.

Patch

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -596,4 +596,14 @@  for plat, func in [('bsd', 'setproctitle
         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'),
+]:
+    if re.search(plat, sys.platform) and hasheader(new_compiler(), header):
+        macro = header.replace('/', '_').replace('.', '_').upper()
+        osutil_cflags.append('-DHAVE_%s' % macro)
+
 if sys.platform == 'darwin':
     osutil_ldflags += ['-framework', 'ApplicationServices']