[ntpsec commit] Simplify the way we test for headers with dependencies.

Eric S. Raymond esr at ntpsec.org
Tue Oct 20 00:59:54 UTC 2015


Module:    ntpsec
Branch:    master
Commit:    27adb843de3ca6b90d4fa5a281f00f15b9c14443
Changeset: http://git.ntpsec.org/ntpsec/commit/?id=27adb843de3ca6b90d4fa5a281f00f15b9c14443

Author:    Eric S. Raymond <esr at thyrsus.com>
Date:      Mon Oct 19 20:59:19 2015 -0400

Simplify the way we test for headers with dependencies.

---

 pylib/configure.py | 17 +++++++++++------
 pylib/probes.py    |  4 +++-
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/pylib/configure.py b/pylib/configure.py
index e8c9799..91f1a37 100644
--- a/pylib/configure.py
+++ b/pylib/configure.py
@@ -246,7 +246,7 @@ def cmd_configure(ctx):
 		#"linux/seccomp.h",	- Doesn't build yet, investigate
 		"machine/soundcard.h",
 		"netinet/in_systm.h",
-		"md5.h",
+		("md5.h", ["sys/types.h"]),
 		"net/if6.h",
 		"net/if_var.h",
 		"net/route.h",
@@ -272,17 +272,22 @@ def cmd_configure(ctx):
 		"sys/sysctl.h",
 		"sys/systune.h",
 		"sysexits.h",
+		("timepps.h", ["inttypes.h"]),
+		("sys/timepps.h", ["inttypes.h"]),
 		"utime.h",
 	)
 	for hdr in optional_headers:
-		if not ctx.check_cc(header_name=hdr, mandatory=False) \
-		   and os.path.exists("/usr/include/" + hdr):
+		if type(hdr) == type(""):
+			if ctx.check_cc(header_name=hdr, mandatory=False):
+				continue
+		else:
+			(hdr, prereqs) = hdr
+			if probe_header_with_prerequisites(ctx, hdr, prereqs):
+				continue
+		if os.path.exists("/usr/include/" + hdr):
 			# Sanity check...
 			print "Compilation check failed but include exists %s" % hdr
 
-	for header in ["timepps.h", "sys/timepps.h"]:
-		probe_header_with_prerequisites(ctx, header, ["inttypes.h"])
-
 	if ctx.get_define("HAVE_TIMEPPS_H") or ctx.get_define("HAVE_SYS_TIMEPPS_H"):
 		ctx.define("HAVE_PPSAPI", 1)
 
diff --git a/pylib/probes.py b/pylib/probes.py
index b5a2668..4907543 100644
--- a/pylib/probes.py
+++ b/pylib/probes.py
@@ -9,11 +9,13 @@ def probe_header_with_prerequisites(ctx, header, prerequisites):
         for hdr in prerequisites + [header]:
         	src += "#include <%s>\n" % hdr
         src += "int main() { return 0; }\n"
+	have_name = "HAVE_%s" % header.replace(".","_").replace("/","_").upper()
 	ctx.check_cc(
 		fragment=src,
-		define_name="HAVE_%s" % header.replace(".","_").replace("/","_").upper(),
+		define_name=have_name,
 		msg = "Checking for %s" % header,
 		mandatory = False)
+	return ctx.get_define(have_name)
 
 def probe_multicast(ctx, symbol, legend):
 	"Probe for IP multicast capability."



More information about the vc mailing list