[ntpsec commit] Re-enable build of ntpfrob, avoiding dependencies on dodgy build features.

Eric S. Raymond esr at ntpsec.org
Tue Oct 20 03:49:56 UTC 2015


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

Author:    Eric S. Raymond <esr at thyrsus.com>
Date:      Mon Oct 19 23:48:50 2015 -0400

Re-enable build of ntpfrob, avoiding dependencies on dodgy build features.

---

 ntpfrob/pps-api.c | 11 ++++++++++-
 ntpfrob/tickadj.c | 25 +++++++++++++++----------
 ntpfrob/wscript   | 10 ++--------
 wscript           |  3 +--
 4 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/ntpfrob/pps-api.c b/ntpfrob/pps-api.c
index 45b99b9..6c526b3 100644
--- a/ntpfrob/pps-api.c
+++ b/ntpfrob/pps-api.c
@@ -9,14 +9,17 @@
  *  SPDX-License-Identifier: BSD-2-Clause
  */
 
+#include "config.h"
+
+#ifdef HAVE_SYS_TIMEPPS_H
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <time.h>
-#include <sys/timepps.h>
 #include <unistd.h>
+#include <sys/timepps.h>
 
 #define timespecsub(vvp, uvp)                                           \
         do {                                                            \
@@ -50,9 +53,14 @@ static int err(int out, const char *legend)
     fprintf(stderr, "ntpfrob: %s\n", legend);
     exit(out);
 }
+#endif /* HAVE_SYS_TIMEPPS_H */
 
 void ppscheck(char *device)
 {
+#ifndef HAVE_SYS_TIMEPPS_H
+	fputs("ntpfrob: PPS is not available.\n");
+	exit(1);
+#else
 	int fd;
 	pps_info_t pi;
 	pps_params_t pp;
@@ -100,6 +108,7 @@ void ppscheck(char *device)
 		olda = pi.assert_sequence;
 		oldc = pi.clear_sequence;
 	}
+#endif /* HAVE_SYS_TIMEPPS_H */
 }
 
 /* end */
diff --git a/ntpfrob/tickadj.c b/ntpfrob/tickadj.c
index c61f06b..aba4ed8 100644
--- a/ntpfrob/tickadj.c
+++ b/ntpfrob/tickadj.c
@@ -17,23 +17,26 @@
 #include <unistd.h>
 #include <stdlib.h>
 
-#ifndef HAVE_ADJTIMEX
-#error This program requires the adjtimex(2) system call.
-#else
+#ifdef HAVE_ADJTIMEX
 # include <sys/time.h>	/* prerequisite on NetBSD */
 # include <sys/timex.h>
 
 static struct timex txc;
+#endif /* HAVE_ADJTIMEX */
 
 void tickadj(const bool json, const int newtick)
 {
+#ifndef HAVE_ADJTIMEX
+	fputs("ntpfrob: \n", stderr);
+	exit(1);
+#else
 	if (newtick != 0)
 	{
 #ifdef STRUCT_TIMEX_HAS_TIME_TICK
 		if ( (txc.time_tick = newtick) < 1 )
 #else
 		if ( (txc.tick = newtick) < 1 )
-#endif
+#endif /* STRUCT_TIMEX_HAS_TIME_TICK */
 		{
 			fprintf(stderr, "ntpfrob: silly value for tick: %d\n", newtick);
 			exit(1);
@@ -45,8 +48,8 @@ void tickadj(const bool json, const int newtick)
 		txc.modes = ADJ_TICK;
 #else
 		txc.mode = ADJ_TICK;
-#endif
-#endif
+#endif /* STRUCT_TIMEX_HAS_MODES */
+#endif /* ADJ_TIMETICK */
 	}
 	else
 	{
@@ -57,8 +60,8 @@ void tickadj(const bool json, const int newtick)
 		txc.modes = 0;
 #else
 		txc.mode = 0;
-#endif
-#endif
+#endif /* STRUCT_TIMEX_HAS_MODES */
+#endif /* ADJ_TIMETICK */
 	}
 
 	if (adjtimex(&txc) < 0)
@@ -79,8 +82,10 @@ void tickadj(const bool json, const int newtick)
 			printf("{\"tick\":%ld}\n", txc.tick);
 		else
 			printf("tick = %ld\n", txc.tick);
-#endif
+#endif /* STRUCT_TIMEX_HAS_TIME_TICK */
 	}
 
 }
-#endif
+#endif /* HAVE_ADJTIMEX */
+
+/* end */
diff --git a/ntpfrob/wscript b/ntpfrob/wscript
index 58cb117..924934e 100644
--- a/ntpfrob/wscript
+++ b/ntpfrob/wscript
@@ -4,14 +4,8 @@ def build(ctx):
 	srcnode = ctx.srcnode.abspath()
 	bldnode = ctx.bldnode.abspath()
 
-	frob_sources = ['main.c', 'jitter.c', 'precision.c', 'stepback.c']
-
-	# FIXME: These guards do not currently work
-	if ctx.get_define("HAVE_SYS_TIMEPPS_H"):
-		frob_sources += ["pps-api.c"]
-
-	if ctx.get_define("HAVE_ADJTIMEX"):
-		frob_sources += ["tickadj.c"]
+	frob_sources = ['main.c', 'jitter.c', 'precision.c',
+			'stepback.c', 'pps-api.c', 'tickadj.c']
 
 	ctx(
 		target		= "ntpfrob",
diff --git a/wscript b/wscript
index 334420a..68589cc 100644
--- a/wscript
+++ b/wscript
@@ -100,10 +100,9 @@ def build(ctx):
 	ctx.recurse("libntp")
 	ctx.recurse("ntpdig")
 	ctx.recurse("ntpd")
-#	ctx.recurse("ntpfrob")
+	ctx.recurse("ntpfrob")
 	ctx.recurse("ntpq")
 	ctx.recurse("ntpkeygen") 
-	#if ctx.env.PLATFORM_TARGET != "freebsd": # XXX: fix this using a test in configure().
 	ctx.recurse("ntptime")
 	ctx.recurse("util")
 #	ctx.recurse("tests")



More information about the vc mailing list