summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2021-11-19 15:37:50 +0100
committerMartin Burnicki <martin.burnicki@meinberg.de>2021-11-19 15:37:50 +0100
commit6da10ed59424e5d3a59d4eb1da32f9b5ed8c47d4 (patch)
treed8cd7e90f7e0c4b2b0f962becb82fbb3c008c55d
parent7eedb29da12d9f914533cecf8390a33178f5855d (diff)
downloadntptest-master.tar.gz
ntptest-master.zip
If built from a git repo, use the version from git preferably.HEAD1.12master
-rwxr-xr-xntptest.c19
-rwxr-xr-xunix/Makefile18
2 files changed, 27 insertions, 10 deletions
diff --git a/ntptest.c b/ntptest.c
index d33d7eb..d4da31b 100755
--- a/ntptest.c
+++ b/ntptest.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
- * $Id: ntptest.c 1.16 2020/04/01 12:50:08 martin REL_M $
+ * $Id: ntptest.c 1.17 2021/11/19 14:33:54 martin.burnicki REL_M $
*
* Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
@@ -12,6 +12,10 @@
*
* -----------------------------------------------------------------------
* $Log: ntptest.c $
+ * Revision 1.17 2021/11/19 14:33:54 martin.burnicki
+ * If built from a git repo, use the version from git preferably.
+ * Fixed a potential infinite loop with getopt on systems
+ * where char is unsigned.
* Revision 1.16 2020/04/01 12:50:08 martin
* Use exit codes defined in mbgerror.h.
* Revision 1.15 2019/09/04 07:42:17 martin
@@ -92,8 +96,14 @@
static const char program_name[] = "ntptest";
-static const char program_version[] = "v1.11";
-static const char program_copyright[] = "(c) Meinberg 2014-2019";
+// If built from a git repo, the version can be
+// predefined by the Makefile.
+#if !defined( NTPTEST_VERSION )
+ #define NTPTEST_VERSION 1.12
+#endif
+
+static const char program_version[] = "v" STRINGIFY( NTPTEST_VERSION );
+static const char program_copyright[] = "(c) Meinberg 2014-2021";
static const char program_contact[] = "contact: <martin.burnicki@meinberg.de>";
static int exit_code = MBG_NTP_EXIT_SUCCESS;
@@ -384,7 +394,6 @@ void usage( void )
const char *exit_code_str[N_MBG_NTP_EXIT_CODES] = MBG_NTP_EXIT_CODE_STRS;
int i;
- printf( "\n" );
printf( "Usage: %s [[OPTION]...] <host>\n", program_name );
printf( "\n" );
printf( "Send NTP client requests to an NTP server with IP address or\n"
@@ -532,7 +541,7 @@ int main( int argc, char *argv[] )
program_copyright, program_contact );
#if 0 && defined( _MSC_VER )
- printf( "built with _MSC_VER %i, _MSC_FULL_VER %i\n", _MSC_VER, _MSC_FULL_VER );
+ printf( "built with _MSC_VER %i, _MSC_FULL_VER %i\n\n", _MSC_VER, _MSC_FULL_VER );
#endif
check_options( argc, argv );
diff --git a/unix/Makefile b/unix/Makefile
index 029b635..6417693 100755
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -1,13 +1,16 @@
#########################################################################
#
-# $Id: Makefile 1.7 2020/04/01 16:31:11 martin REL_M $
+# $Id: Makefile 1.8 2021/11/19 14:34:50 martin.burnicki REL_M $
#
# Description:
# Makefile for ntptest.
#
# -----------------------------------------------------------------------
# $Log: Makefile $
+# Revision 1.8 2021/11/19 14:34:50 martin.burnicki
+# If built from a git repo, use the version from git preferably.
+# Some cleanup.
# Revision 1.7 2020/04/01 16:31:11 martin
# Add defines to support openSSL CMAC.
# Revision 1.6 2018/07/31 16:03:44 martin
@@ -45,6 +48,7 @@ else
vecho = @echo
endif
+NTPTEST_VERSION = $(shell git describe --tags 2>/dev/null)
MBGLIB = ../mbglib
MBGLIB_DIRS = common
@@ -68,7 +72,7 @@ CPPFLAGS += $(foreach dir,$(MBGLIB_DIRS),-I$(MBGLIB)/$(dir))
LDFLAGS += -lrt
-# conditionally support NTP authentication
+# Conditionally support NTP authentication.
ifneq ("$(USE_MBG_NTP_AUTH)","0")
CPPFLAGS += -D_USE_MBG_NTP_AUTH=$(USE_MBG_NTP_AUTH)
CPPFLAGS += -DHAVE_OPENSSL_CMAC_H
@@ -77,7 +81,11 @@ ifneq ("$(USE_MBG_NTP_AUTH)","0")
OBJS += mbg_ntp_auth.o
LDFLAGS += -lcrypto
- LDFLAGS += -lm # requires the math library
+ LDFLAGS += -lm # Requires the math library.
+endif
+
+ifneq ($(NTPTEST_VERSION),)
+ CPPFLAGS += -DNTPTEST_VERSION=$(NTPTEST_VERSION)
endif
VPATH += ..
@@ -86,7 +94,7 @@ VPATH += $(foreach dir,$(MBGLIB_DIRS),$(MBGLIB)/$(dir))
%.o: %.c
$(vecho) " $(CC) $@"
- $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
+ $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
.PHONY: all
@@ -94,7 +102,7 @@ all: $(TARGET)
$(TARGET): $(OBJS)
$(vecho) " Linking $@"
- $(Q)$(CC) -o $@ $^ $(LDFLAGS)
+ $(Q)$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS)
.PHONY: clean