<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }
</style>
<body>
<div class='content'>
<h3>
Amar Takhar pushed to branch master
at <a href="https://gitlab.com/NTPsec/ntpsec">NTPsec / ntpsec</a>
</h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/b0de1316199d254d65b5d1b09e51e882c8b4016d">b0de1316</a></strong>
<div>
<span>by Amar Takhar</span>
<i>at 2016-01-14T13:26:52-05:00</i>
</div>
<pre class='commit-message'>Better support for cross compiling

--enable-cross should do the right thing for sizeof(), header, library and run
tests for now.</pre>
</li>
</ul>
<h4>7 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
pylib/check_cap.py
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
pylib/check_libevent2.py
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
pylib/check_mdns.py
</a>
</li>
<li class='file-stats'>
<a href='#diff-3'>
pylib/check_sizeof.py
</a>
</li>
<li class='file-stats'>
<a href='#diff-4'>
pylib/configure.py
</a>
</li>
<li class='file-stats'>
<a href='#diff-5'>
<span class='new-file'>
+
pylib/tool.py
</span>
</a>
</li>
<li class='file-stats'>
<a href='#diff-6'>
pylib/waf.py
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/b0de1316199d254d65b5d1b09e51e882c8b4016d#diff-0'>
<strong>
pylib/check_cap.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/pylib/check_cap.py
</span><span style="color: #000000;background-color: #ddffdd">+++ b/pylib/check_cap.py
</span><span style="color: #aaaaaa">@@ -1,3 +1,5 @@
</span><span style="color: #000000;background-color: #ddffdd">+from tool import check_sanity
+
</span> PCAP_FRAG = """
 # include <sys/capability.h>
 
<span style="color: #aaaaaa">@@ -12,13 +14,31 @@ int main(void) {
</span> }
 """
 
<span style="color: #000000;background-color: #ddffdd">+def check_cap_header(ctx):
+       ctx.check_cc(header_name="sys/capability.h", mandatory=False)
+       ctx.check_cc(lib="cap", mandatory=False)
+
+       if ctx.get_define("HAVE_SYS_CAPABILITY_H") and ctx.get_define("HAVE_SYS_PRCTL_H") and ctx.env.LIB_LIBCAP:
+               ctx.env.LIBCAP_HEADER = True
+
+
+def check_cap_run(ctx):
+       if ctx.env.ENABLE_CROSS: # XXX Remove when variant builds exist
+               if ctx.env.LIBCAP_HEADER:
+                       ctx.define("HAVE_CAPABILITY", 1)
+               return
</span> 
<span style="color: #000000;background-color: #ffdddd">-def check_cap(ctx):
</span>   ctx.check_cc(
                fragment        = PCAP_FRAG,
                define_name = "HAVE_CAPABILITY",
                features        = "c",
<span style="color: #000000;background-color: #ffdddd">-                use             = "CAP",
</span><span style="color: #000000;background-color: #ddffdd">+           use                     = "CAP",
</span>           msg         = "Checking if libcap works",
                mandatory       = False
        )
<span style="color: #000000;background-color: #ddffdd">+
+       check_sanity(ctx, ctx.env.LIBCAP_HEADER, "CAPABILITY")
+
+
+       if ctx.get_define("HAVE_CAPABILITY"):
+               ctx.define("HAVE_LINUX_CAPABILITY", 1)
</span></code></pre>

<br>
</li>
<li id='diff-1'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/b0de1316199d254d65b5d1b09e51e882c8b4016d#diff-1'>
<strong>
pylib/check_libevent2.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/pylib/check_libevent2.py
</span><span style="color: #000000;background-color: #ddffdd">+++ b/pylib/check_libevent2.py
</span><span style="color: #aaaaaa">@@ -1,4 +1,6 @@
</span> from waflib.Logs import pprint
<span style="color: #000000;background-color: #ddffdd">+from tool import check_sanity
+
</span> LIBEVENT2_FRAG = """
 #include <event2/thread.h>
 #include <event2/event.h>
<span style="color: #aaaaaa">@@ -13,19 +15,21 @@ int main(void) {
</span> """
 
 
<span style="color: #000000;background-color: #ffdddd">-def check_libevent2(ctx):
-       check_libevent2.false = False
-
-       def check(**kwargs):
-               if not ctx.check_cc(**kwargs):
-                       check_libevent2.false = True
-
</span><span style="color: #000000;background-color: #ddffdd">+def check_libevent2_header(ctx):
+       ctx.check(header_name="event2/event.h", includes=ctx.env.PLATFORM_INCLUDES, mandatory = False)
+       ctx.check(header_name="event2/thread.h", includes=ctx.env.PLATFORM_INCLUDES, mandatory = False)
+       ctx.check(feature="c cshlib", lib="event_core", libpath=ctx.env.PLATFORM_LIBPATH, uselib_store="LIBEVENT_CORE", mandatory = False)
+       ctx.check(feature="c cshlib", lib="event_pthreads", libpath=ctx.env.PLATFORM_LIBPATH, uselib_store="LIBEVENT_PTHREADS", use="LIBEVENT_CORE", mandatory = False)
</span> 
<span style="color: #000000;background-color: #ffdddd">-        check(header_name="event2/event.h", includes=ctx.env.PLATFORM_INCLUDES, mandatory = False)
-       check(header_name="event2/thread.h", includes=ctx.env.PLATFORM_INCLUDES, mandatory = False)
-       check(feature="c cshlib", lib="event_core", libpath=ctx.env.PLATFORM_LIBPATH, uselib_store="LIBEVENT_CORE", mandatory = False)
-       check(feature="c cshlib", lib="event_pthreads", libpath=ctx.env.PLATFORM_LIBPATH, uselib_store="LIBEVENT_PTHREADS", use="LIBEVENT_CORE", mandatory = False)
</span><span style="color: #000000;background-color: #ddffdd">+   if ctx.get_define("HAVE_EVENT2_THREAD_H") and ctx.get_define("HAVE_EVENT2_EVENT_H") and ctx.env.LIB_LIBEVENT_PTHREADS and ctx.env.LIB_LIBEVENT_CORE:
+               ctx.env.EVENT2_HEADER = True
</span> 
<span style="color: #000000;background-color: #ddffdd">+def check_libevent2_run(ctx):
+       if ctx.env.ENABLE_CROSS:
+               if ctx.env.EVENT2_HEADER: # XXX Remove when variant builds exist
+                       ctx.define("HAVE_LIBEVENT2", 1)
+                       ctx.env.LIBEVENT2_ENABLE = True
+       return
</span> 
        ctx.check(
                fragment        = LIBEVENT2_FRAG,
<span style="color: #aaaaaa">@@ -38,13 +42,14 @@ def check_libevent2(ctx):
</span>           mandatory       = False
        )
 
<span style="color: #000000;background-color: #ddffdd">+        check_sanity(ctx, ctx.env.EVENT2_HEADER, "libevent2")
</span> 
<span style="color: #000000;background-color: #ffdddd">-        if check_libevent2.false:
</span><span style="color: #000000;background-color: #ddffdd">+   if not ctx.get_define("HAVE_LIBEVENT2"):
</span>           print("")
                pprint("RED", "Warning libevent2 does not work")
                pprint("RED", "This means ntpdig will not be built")
                pprint("RED", "While not necessary you will lose 'ntpdate' functionality.")
                print("")
        else:
<span style="color: #000000;background-color: #ffdddd">-                ctx.env.LIBEVENT2_ENABLE=True
</span><span style="color: #000000;background-color: #ddffdd">+           ctx.env.LIBEVENT2_ENABLE = True
</span>           ctx.define("HAVE_LIBEVENT2", 1)
</code></pre>

<br>
</li>
<li id='diff-2'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/b0de1316199d254d65b5d1b09e51e882c8b4016d#diff-2'>
<strong>
pylib/check_mdns.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/pylib/check_mdns.py
</span><span style="color: #000000;background-color: #ddffdd">+++ b/pylib/check_mdns.py
</span><span style="color: #aaaaaa">@@ -8,10 +8,20 @@ int main(void) {
</span> }
 """
 
<span style="color: #000000;background-color: #ffdddd">-def check_mdns(ctx):
</span><span style="color: #000000;background-color: #ddffdd">+def check_mdns_header(ctx):
</span>   ctx.check_cc(lib="dns_sd", libpath=ctx.env.PLATFORM_LIBPATH, mandatory=False)
        ctx.check_cc(header_name="dns_sd.h", includes=ctx.env.PLATFORM_INCLUDES, uselib_store="DNS_SD_INCLUDES", mandatory=False)
 
<span style="color: #000000;background-color: #ddffdd">+        if ctx.get_define("HAVE_DNS_SD_H") and ctx.env.LIB_LIBDNS_SD:
+               ctx.env.DNS_SD_HEADER = True
+
+
+def check_mdns_run(ctx):
+       if ctx.env.ENABLE_CROSS: # XXX Remove when variant builds exist
+               if ctx.env.DNS_SD_HEADER:
+                       ctx.define("HAVE_MDNS", 1)
+               return
+
</span>   ctx.check_cc(
                fragment        = MDNS_FRAG,
                define_name = "HAVE_MDNS",
<span style="color: #aaaaaa">@@ -24,6 +34,5 @@ def check_mdns(ctx):
</span>           mandatory       = False
        )
 
<span style="color: #000000;background-color: #ffdddd">-
</span>   if ctx.get_define("HAVE_MDNS"):
                ctx.define("ENABLE_MDNS_REGISTRATION", 1)
</code></pre>

<br>
</li>
<li id='diff-3'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/b0de1316199d254d65b5d1b09e51e882c8b4016d#diff-3'>
<strong>
pylib/check_sizeof.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/pylib/check_sizeof.py
</span><span style="color: #000000;background-color: #ddffdd">+++ b/pylib/check_sizeof.py
</span><span style="color: #aaaaaa">@@ -1,4 +1,5 @@
</span> from waflib.Configure import conf
<span style="color: #000000;background-color: #ddffdd">+from waflib import Errors
</span> 
 SIZE_FRAG = """
 %s
<span style="color: #aaaaaa">@@ -9,8 +10,7 @@ int main () {
</span> }
 """
 
<span style="color: #000000;background-color: #ffdddd">-@conf
-def check_sizeof(ctx, header, sizeof, mandatory=True):
</span><span style="color: #000000;background-color: #ddffdd">+def check_sizeof_host(ctx, header, sizeof, mandatory=True):
</span>   sizeof_ns = sizeof.replace(" ", "_")
        name = "SIZEOF_%s" % sizeof_ns.upper()
 
<span style="color: #aaaaaa">@@ -30,3 +30,52 @@ def check_sizeof(ctx, header, sizeof, mandatory=True):
</span>           mandatory       = mandatory,
        )
        ctx.end_msg(ctx.get_define(name))
<span style="color: #000000;background-color: #ddffdd">+
+
+# Cross compile check.  Much slower so we do not run it all the time.
+
+SIZE_FRAG_CROSS = """
+%s
+#include <sys/stat.h>
+int main () {
+  static int test_array [1 - 2 * !(((long int) (sizeof (%s))) <= %d)];
+  test_array [0] = 0;
+  return test_array[0];
+}
+"""
+
+def check_sizeof_cross(ctx, header, sizeof, mandatory=True):
+       sizeof_ns = sizeof.replace(" ", "_")
+       name = "SIZEOF_%s" % sizeof_ns.upper()
+
+       header_snippet = ""
+       if header:
+               ctx.start_msg("Checking sizeof %s (%s)" % (sizeof, header))
+               header_snippet = "#include <%s>" % header
+       else:
+               ctx.start_msg("Checking sizeof %s" % (sizeof))
+
+
+       for size in range(2,13):
+
+               try:
+                       ctx.check_cc(
+                               fragment        = SIZE_FRAG_CROSS % (header_snippet, sizeof, size),
+                               execute     = False,
+                               mandatory       = mandatory,
+                       )
+                       ctx.define(name, size)
+                       ctx.end_msg(ctx.get_define(name))
+                       return
+               except Errors.ConfigurationError:
+                       pass
+
+       raise # never reached.
+
+@conf
+def check_sizeof(*kwargs):
+       if kwargs[0].env.ENABLE_CROSS:
+               return check_sizeof_cross(*kwargs)
+       else:
+               return check_sizeof_host(*kwargs)
+
</span></code></pre>

<br>
</li>
<li id='diff-4'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/b0de1316199d254d65b5d1b09e51e882c8b4016d#diff-4'>
<strong>
pylib/configure.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/pylib/configure.py
</span><span style="color: #000000;background-color: #ddffdd">+++ b/pylib/configure.py
</span><span style="color: #aaaaaa">@@ -190,9 +190,8 @@ def cmd_configure(ctx):
</span> #HGM              (None,                  "signed char"),
        ]
 
<span style="color: #000000;background-color: #ffdddd">-        if not ctx.env.ENABLE_CROSS:
-               for header, sizeof in sorted(sizeofs):
-                       ctx.check_sizeof(header, sizeof)
</span><span style="color: #000000;background-color: #ddffdd">+   for header, sizeof in sorted(sizeofs):
+               ctx.check_sizeof(header, sizeof)
</span> 
        # The protocol major number
        ctx.define("NTP_API", 4)
<span style="color: #aaaaaa">@@ -336,19 +335,6 @@ def cmd_configure(ctx):
</span> #HGM  Can delete pylib/check_timepps.py
                ctx.define("HAVE_PPSAPI", 1)
 
<span style="color: #000000;background-color: #ffdddd">-        # Check for libevent and whether it is working.
-       from pylib.check_libevent2 import check_libevent2
-       check_libevent2(ctx)
-
-
-       # Check for Linux capability.
-       ctx.check_cc(header_name="sys/capability.h", mandatory=False)
-       ctx.check_cc(lib="cap", mandatory=False)
-       if ctx.env.LIB_CAP:
-               from check_cap import check_cap
-               check_cap(ctx)
-       if ctx.get_define("HAVE_CAPABILITY") and ctx.get_define("HAVE_SYS_CAPABILITY_H") and ctx.get_define("HAVE_SYS_PRCTL_H"):
-               ctx.define("HAVE_LINUX_CAPABILITY", 1)
</span> 
        # Check for Solaris capabilities
        if ctx.get_define("HAVE_PRIV_H") and sys.platform == "Solaris":
<span style="color: #aaaaaa">@@ -405,10 +391,6 @@ def cmd_configure(ctx):
</span>   if not ctx.options.disable_dns_retry:
                ctx.define("ENABLE_DNS_RETRY", 1)
 
<span style="color: #000000;background-color: #ffdddd">-        if not ctx.options.disable_mdns_registration:
-               from check_mdns import check_mdns
-               check_mdns(ctx)
-
</span> 
        # There is an ENABLE_AUTOKEY as well, but as that feature
        # is not working and likely to be replaced it's not exposed
<span style="color: #aaaaaa">@@ -502,6 +484,32 @@ def cmd_configure(ctx):
</span>   ctx.define("ISC_PLATFORM_USETHREADS", 1)
        ctx.define("HAVE_IFLIST_SYSCTL", 1)
 
<span style="color: #000000;background-color: #ddffdd">+
+
+       # Header checks
+       from pylib.check_cap import check_cap_header
+       check_cap_header(ctx)
+
+       from pylib.check_libevent2 import check_libevent2_header
+       check_libevent2_header(ctx)
+
+       if not ctx.options.disable_mdns_registration:
+               from pylib.check_mdns import check_mdns_header
+               check_mdns_header(ctx)
+
+
+       # Run checks
+       from pylib.check_cap import check_cap_run
+       check_cap_run(ctx)
+
+       from pylib.check_libevent2 import check_libevent2_run
+       check_libevent2_run(ctx)
+
+       if not ctx.options.disable_mdns_registration:
+               from pylib.check_mdns import check_mdns_run
+               check_mdns_run(ctx)
+
+
</span>   ctx.start_msg("Writing configuration header:")
        ctx.write_config_header("config.h")
        ctx.end_msg("config.h", "PINK")
</code></pre>

<br>
</li>
<li id='diff-5'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/b0de1316199d254d65b5d1b09e51e882c8b4016d#diff-5'>
<strong>
pylib/tool.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- /dev/null
</span><span style="color: #000000;background-color: #ddffdd">+++ b/pylib/tool.py
</span><span style="color: #aaaaaa">@@ -0,0 +1,11 @@
</span><span style="color: #000000;background-color: #ddffdd">+from waflib.Logs import pprint
+
+def check_sanity(ctx, cond, lib):
+       define = "HAVE_%s" % lib.upper()
+
+       if cond and (not ctx.get_define(define)):
+               pprint("RED", "Warning %s headers detected, binaries do not build/run")
+       elif (not cond) and ctx.get_define(define):
+               pprint("RED", "Warning %s headers not detected, binaries build/run")
+
+
</span></code></pre>

<br>
</li>
<li id='diff-6'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/b0de1316199d254d65b5d1b09e51e882c8b4016d#diff-6'>
<strong>
pylib/waf.py
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/pylib/waf.py
</span><span style="color: #000000;background-color: #ddffdd">+++ b/pylib/waf.py
</span><span style="color: #aaaaaa">@@ -79,3 +79,4 @@ def ntp_test(ctx, **kwargs):
</span>           args += tg.test_args
 
        tg.ut_exec = args
<span style="color: #000000;background-color: #ddffdd">+
</span></code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://gitlab.com/NTPsec/ntpsec/commit/b0de1316199d254d65b5d1b09e51e882c8b4016d">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.com/NTPsec/ntpsec/commit/b0de1316199d254d65b5d1b09e51e882c8b4016d"}}</script>
</p>
</div>
</body>
</html>