[Git][NTPsec/ntpsec][master] Check for libcrypto library/headers via pkg-config

Matt Selsky gitlab at mg.gitlab.com
Fri Dec 29 23:32:18 UTC 2017


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
9e436ebf by Matt Selsky at 2017-12-29T18:14:06-05:00
Check for libcrypto library/headers via pkg-config

And then fall back to a direct search, if pkg-config either doesn't exist, or
if libcrypto.pc can't be found

- - - - -


3 changed files:

- libntp/wscript
- ntpd/wscript
- wscript


Changes:

=====================================
libntp/wscript
=====================================
--- a/libntp/wscript
+++ b/libntp/wscript
@@ -50,6 +50,7 @@ def build(ctx):
         includes=includes,
         source=libntp_source + libntp_source_sharable,
         target="ntp",
+        use="CRYPTO",
     )
 
     # Loadable Python extension


=====================================
ntpd/wscript
=====================================
--- a/ntpd/wscript
+++ b/ntpd/wscript
@@ -72,6 +72,7 @@ def build(ctx):
         includes=ctx.env.PLATFORM_INCLUDES,
         source=libntpd_source,
         target="libntpd_obj",
+        use="CRYPTO",
     )
 
     ctx(


=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -611,32 +611,39 @@ int main(int argc, char **argv) {
     ctx.define("OPEN_BCAST_SOCKET", 1,
                comment="Whether to open a broadcast socket")
 
-    # Find OpenSSL. Must happen before function checks
-    # Versions older than 0.9.7d were deemed incompatible in NTP Classic.
-    SNIP_OPENSSL_VERSION_CHECK = """
-    #include <openssl/evp.h>
-    int main(void) {
-    #if OPENSSL_VERSION_NUMBER < 0x0090704fL
-    #error OpenSSL must be at least 0.9.7
-    #endif
-        return 0;
-    }
-    """
-
-    openssl_headers = (
-        "openssl/evp.h",
-        "openssl/rand.h",
-        "openssl/objects.h",
-    )
-    for hdr in openssl_headers:
-        ctx.check_cc(header_name=hdr, includes=ctx.env.PLATFORM_INCLUDES)
-    # FIXME! Ignoring the result...
-    ctx.check_cc(lib="crypto")
-    ctx.check_cc(comment="OpenSSL support",
-                 fragment=SNIP_OPENSSL_VERSION_CHECK,
-                 includes=ctx.env.PLATFORM_INCLUDES,
-                 msg="Checking OpenSSL >= 0.9.7",
-                 )
+    # Check via pkg-config first, then fall back to a direct search
+    if not ctx.check_cfg(
+        package='libcrypto', uselib_store='CRYPTO',
+        args=['libcrypto >= 0.9.7d', '--cflags', '--libs'],
+        msg="Checking for OpenSSL >= 0.9.7d (via pkg-config)",
+        define_name='', mandatory=False,
+    ):
+        # Find OpenSSL. Must happen before function checks
+        # Versions older than 0.9.7d were deemed incompatible in NTP Classic.
+        SNIP_OPENSSL_VERSION_CHECK = """
+        #include <openssl/evp.h>
+        int main(void) {
+        #if OPENSSL_VERSION_NUMBER < 0x0090704fL
+        #error OpenSSL must be at least 0.9.7d
+        #endif
+            return 0;
+        }
+        """
+
+        openssl_headers = (
+            "openssl/evp.h",
+            "openssl/rand.h",
+            "openssl/objects.h",
+        )
+        for hdr in openssl_headers:
+            ctx.check_cc(header_name=hdr, includes=ctx.env.PLATFORM_INCLUDES)
+        # FIXME! Ignoring the result...
+        ctx.check_cc(lib="crypto")
+        ctx.check_cc(comment="OpenSSL support",
+                     fragment=SNIP_OPENSSL_VERSION_CHECK,
+                     includes=ctx.env.PLATFORM_INCLUDES,
+                     msg="Checking for OpenSSL >= 0.9.7d",
+                     )
 
     # Optional functions.  Do all function checks here, otherwise
     # we're likely to duplicate them.



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/9e436ebf99d992ab9996366c7eda5bd68b3925e7

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/9e436ebf99d992ab9996366c7eda5bd68b3925e7
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20171229/574c08f9/attachment.html>


More information about the vc mailing list