[Git][NTPsec/ntpsec][master] Simplify mDNS configure checks

Matt Selsky gitlab at mg.gitlab.com
Fri May 25 23:08:57 UTC 2018


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
37a9c8fb by Matt Selsky at 2018-05-25T06:02:38Z
Simplify mDNS configure checks

Use 1 define instead of several. And header/library compilation/linking is
sufficient. There's no need to build custom code fragments.

Fixes Gitlab issue #483

- - - - -


6 changed files:

- devel/ifdex-ignores
- ntpd/ntp_config.c
- ntpd/ntpd.c
- ntpd/wscript
- − wafhelpers/check_mdns.py
- wscript


Changes:

=====================================
devel/ifdex-ignores
=====================================
--- a/devel/ifdex-ignores
+++ b/devel/ifdex-ignores
@@ -66,7 +66,6 @@ ENABLE_EARLY_DROPROOT
 ENABLE_LEAP_SMEAR
 ENABLE_DEBUG_TIMING
 ENABLE_LOCKCLOCK
-ENABLE_MDNS_REGISTRATION
 ENABLE_MSSNTP
 ENABLE_LEAP_TESTING
 HAVE_LINUX_CAPABILITY


=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -2239,11 +2239,11 @@ config_mdnstries(
 	config_tree *ptree
 	)
 {
-#if defined(HAVE_DNS_SD_H) && defined(ENABLE_MDNS_REGISTRATION)
+#if defined(HAVE_DNS_SD_H)
 	mdnstries = ptree->mdnstries;
 #else
 	UNUSED_ARG(ptree);
-#endif  /* ENABLE_MDNS_REGISTRATION */
+#endif  /* HAVE_DNS_SD_H */
 }
 
 static void


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -42,7 +42,7 @@ static	void	finish_safe	(int)
 # include <ulimit.h>
 #endif /* SIGDANGER */
 
-#if defined(HAVE_DNS_SD_H) && defined(ENABLE_MDNS_REGISTRATION)
+#if defined(HAVE_DNS_SD_H)
 # include <dns_sd.h>
 static DNSServiceRef mdns;
 #endif
@@ -64,7 +64,7 @@ static bool dumpopts;
 static long wait_sync = -1;
 static const char *driftfile, *pidfile;
 
-#if defined(HAVE_DNS_SD_H) && defined(ENABLE_MDNS_REGISTRATION)
+#if defined(HAVE_DNS_SD_H)
 /*
  * mDNS registration flag. If set, we attempt to register with the
  * mDNS system, but only after we have synched the first time. If the
@@ -73,7 +73,7 @@ static const char *driftfile, *pidfile;
  */
 static bool mdnsreg = false;
 int mdnstries = 5;
-#endif  /* ENABLE_MDNS_REGISTRATION */
+#endif  /* HAVE_DNS_SD_H */
 
 static bool droproot = false;
 static char *user;		/* User to switch to */
@@ -291,9 +291,9 @@ parse_cmdline_opts(
 		listen_to_virtual_ips = false;
 		break;
 	    case 'm':
-#if defined(HAVE_DNS_SD_H) && defined(ENABLE_MDNS_REGISTRATION)
+#if defined(HAVE_DNS_SD_H)
 		mdnsreg = true;
-#endif  /* ENABLE_MDNS_REGISTRATION */
+#endif  /* HAVE_DNS_SD_H */
 		break;
 	    case 'M':
 		/* defer */
@@ -852,10 +852,10 @@ ntpdmain(
 		fprintf(stdout, "logfile \"%s\";\n", logfilename);
 	    fprintf(stdout, "#listen_to_virtual_ips = %s\n",
 		    listen_to_virtual_ips ? "true" : "false");
-#if defined(HAVE_DNS_SD_H) && defined(ENABLE_MDNS_REGISTRATION)
+#if defined(HAVE_DNS_SD_H)
 	    fprintf(stdout, "#mdnsreg = %s\n",
 		    mdnsreg ? "true" : "false");
-#endif  /* ENABLE_MDNS_REGISTRATION */
+#endif  /* HAVE_DNS_SD_H */
 	    if (pidfile)
 		fprintf(stdout, "pidfile \"%s\";\n", pidfile);
 	    /* FIXME: dump priority */
@@ -1014,7 +1014,7 @@ static void mainloop(void)
 		 * Go around again
 		 */
 
-# if defined(HAVE_DNS_SD_H) && defined(ENABLE_MDNS_REGISTRATION)
+# if defined(HAVE_DNS_SD_H)
 		if (mdnsreg && (current_time - mdnsreg ) > 60 && mdnstries && sys_vars.sys_leap != LEAP_NOTINSYNC) {
 			mdnsreg = current_time;
 			msyslog(LOG_INFO, "INIT: Attempting to register mDNS");
@@ -1030,7 +1030,7 @@ static void mainloop(void)
 				mdnsreg = false;
 			}
 		}
-# endif /* ENABLE_MDNS_REGISTRATION */
+# endif /* HAVE_DNS_SD_H */
 
 	}
 }
@@ -1052,7 +1052,7 @@ finish_safe(
 	msyslog(LOG_NOTICE, "ERR: %s exiting on signal %d (%s)", progname,
 		sig, sig_desc);
 	/* See Classic Bugs 2513 and Bug 2522 re the unlink of PIDFILE */
-# if defined(HAVE_DNS_SD_H) && defined(ENABLE_MDNS_REGISTRATION)
+# if defined(HAVE_DNS_SD_H)
 	if (mdns != NULL)
 		DNSServiceRefDeallocate(mdns);
 # endif


=====================================
ntpd/wscript
=====================================
--- a/ntpd/wscript
+++ b/ntpd/wscript
@@ -121,7 +121,7 @@ def build(ctx):
         source=ntpd_source,
         target="ntpd",
         use="libntpd_obj ntp M parse RT CAP SECCOMP PTHREAD NTPD "
-            "CRYPTO DNS_SD DNS_SD_INCLUDES %s SOCKET NSL SCF" % use_refclock,
+            "CRYPTO DNS_SD %s SOCKET NSL SCF" % use_refclock,
     )
 
     ctx.manpage(8, "ntpd-man.txt")


=====================================
wafhelpers/check_mdns.py deleted
=====================================
--- a/wafhelpers/check_mdns.py
+++ /dev/null
@@ -1,43 +0,0 @@
-MDNS_FRAG = """
-# include <dns_sd.h>
-
-int main(void) {
-    DNSServiceRef mdns;
-    DNSServiceRefDeallocate(mdns);
-    return 0;
-}
-"""
-
-
-def check_mdns_header(ctx):
-    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)
-
-    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, comment="multicast dns support")
-        return
-
-    ctx.check_cc(
-        fragment=MDNS_FRAG,
-        define_name="HAVE_MDNS",
-        features="c",
-        includes=ctx.env.PLATFORM_INCLUDES,
-        libpath=ctx.env.PLATFORM_LIBPATH,
-        export_includes=ctx.env.PLATFORM_INCLUDES,
-        msg="Checking if mDNSResponder works",
-        name="MDNS_INCLUDES",
-        mandatory=False,
-        comment="Multicast DNS support"
-    )
-
-    if ctx.get_define("HAVE_MDNS"):
-        ctx.define("ENABLE_MDNS_REGISTRATION", 1,
-                   comment="Multicast DNS support")


=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -675,7 +675,6 @@ int main(int argc, char **argv) {
     optional_headers = (
         "alloca.h",
         ("arpa/nameser.h", ["sys/types.h"]),
-        "dns_sd.h",         # NetBSD, Apple, mDNS
         "bsd/string.h",     # bsd emulation
         ("ifaddrs.h", ["sys/types.h"]),
         ("linux/if_addr.h", ["sys/socket.h"]),
@@ -826,17 +825,13 @@ int main(int argc, char **argv) {
     check_pthread_header_lib(ctx)
 
     if not ctx.options.disable_mdns_registration:
-        from wafhelpers.check_mdns import check_mdns_header
-        check_mdns_header(ctx)
+        ctx.check_cc(header_name="dns_sd.h", lib="dns_sd", mandatory=False,
+                     uselib_store="DNS_SD")
 
     if not ctx.options.disable_dns_lookup:
         from wafhelpers.check_pthread import check_pthread_run
         check_pthread_run(ctx)
 
-    if not ctx.options.disable_mdns_registration:
-        from wafhelpers.check_mdns import check_mdns_run
-        check_mdns_run(ctx)
-
     # Solaris needs -lsocket and -lnsl for socket code
     if ctx.env.DEST_OS == "sunos":
         ctx.check(features="c cshlib", lib="socket", mandatory=False)



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/37a9c8fba2d8a3011ca5838b7e7a9c3b923575f8

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/37a9c8fba2d8a3011ca5838b7e7a9c3b923575f8
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/20180525/5ef4e533/attachment.html>


More information about the vc mailing list