[PATCH 4 of 6] setup: test some header files

Jun Wu quark at fb.com
Mon Mar 20 20:04:37 EDT 2017


# HG changeset patch
# User Jun Wu <quark at 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.

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']


More information about the Mercurial-devel mailing list