summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Burnicki <martin.burnicki@meinberg.de>2024-01-03 10:58:53 +0100
committerMartin Burnicki <martin.burnicki@meinberg.de>2024-01-03 10:58:53 +0100
commit5ebc50745f1aa5605374585efa016c57d9c3463c (patch)
tree3a56e581cd58f5d8cd519c054bdb646a364ed7ab
parent83393aabddaa814aa6896f15f62670e4b3090b4d (diff)
downloadmbgreadtimestring-5ebc50745f1aa5605374585efa016c57d9c3463c.tar.gz
mbgreadtimestring-5ebc50745f1aa5605374585efa016c57d9c3463c.zip
Support getting full version string from git1.3-dev
Change version to 1.3-dev for the development branch. Change last copyright year to 2024.
-rw-r--r--mbgreadtimestring.c40
-rw-r--r--unix/Makefile38
2 files changed, 35 insertions, 43 deletions
diff --git a/mbgreadtimestring.c b/mbgreadtimestring.c
index fbc9079..d8166cd 100644
--- a/mbgreadtimestring.c
+++ b/mbgreadtimestring.c
@@ -1,30 +1,20 @@
/**************************************************************************
*
- * $Id: mbgreadtimestring.c 1.2 2023/02/28 21:54:29 martin.burnicki REL_M $
+ * Sample program demonstrating how to read a serial time string
+ * from an external device.
*
- * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
- *
- * Description:
- * Sample program demonstrating how to read a serial time string from
- * an external device. Optionally a request character can be sent.
- * The received time string is printed to stdout.
+ * Optionally, a request character can be sent before waiting
+ * for the time string.
*
- * Other modules needed to build the executable:
- * mbgserio.c
+ * The received time string is printed to stdout.
*
* For makefiles and build environment setups check the associated
* subdirectories.
*
- * Please send changes required for other OSs to <support@meinberg.de>
+ * Comments can be sent to <martin.burnicki@meinberg.de>
*
- * -----------------------------------------------------------------------
- * $Log: mbgreadtimestring.c $
- * Revision 1.2 2023/02/28 21:54:29 martin.burnicki
- * New version 1.2 and copyright year 2023.
- * Account for mbglib API changes.
- * Revision 1.1 2009/10/09 15:49:56 martin
- * Initial revision.
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
*
**************************************************************************/
@@ -35,9 +25,19 @@
#include <string.h>
+#define MBG_NUMERIC_VERSION_STR "1.3-dev"
+
+// If building within a git repo, we prefer the version
+// string from git, else the version defined above.
+
+#if defined( MBG_VERSION_FROM_GIT )
+ #define MBG_FULL_VERSION_STR STRINGIFY( MBG_VERSION_FROM_GIT )
+#else
+ #define MBG_FULL_VERSION_STR MBG_NUMERIC_VERSION_STR
+#endif
+
static const char *pname = "mbgreadtimestring";
-static const char *pversion = "v1.2";
-static const char *pcopyright = "(c) Meinberg 2009-2023";
+static const char *pcopyright = "(c) Meinberg 2009-2024";
/* other local variables */
@@ -286,7 +286,7 @@ int main( int argc, char *argv[] )
check_command_line( argc, argv );
if ( !quiet )
- printf( "\n\n\n%s %s %s\n\n", pname, pversion, pcopyright );
+ printf( "\n\n\n%s v%s %s\n\n", pname, MBG_FULL_VERSION_STR, pcopyright );
#if _USE_SERIAL_IO
baudrate = default_baudrate;
diff --git a/unix/Makefile b/unix/Makefile
index 171e192..6ae1bc9 100644
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -1,18 +1,7 @@
#########################################################################
#
-# $Id: Makefile 1.2 2023/02/28 21:46:40 martin.burnicki REL_M $
-#
-# Description:
-# Makefile for mbgreadtimestring for Unix-like systems.
-# Currently supported OSs: Linux
-#
-# -----------------------------------------------------------------------
-# $Log: Makefile $
-# Revision 1.2 2023/02/28 21:46:40 martin.burnicki
-# Added some mbglib files.
-# Revision 1.1 2009/10/09 15:49:56 martin
-# Initial revision.
+# Makefile for mbgreadtimestring for Unix-like systems.
#
#########################################################################
@@ -20,23 +9,27 @@ TARGET = mbgreadtimestring
MBGLIB = ../mbglib
MBGLIB_COMMON=$(MBGLIB)/common
-LOC_INCL = -I. -I $(MBGLIB_COMMON)
+LOC_INCL = -I. -I$(MBGLIB_COMMON)
-# set up the compiler flags
+MBG_VERSION_FROM_GIT = $(shell git describe --tag --dirty 2>/dev/null)
-CFLAGS = -Wall
+ifneq ($(MBG_VERSION_FROM_GIT),)
+ CPPFLAGS += -DMBG_VERSION_FROM_GIT=$(MBG_VERSION_FROM_GIT)
+endif
+
+CPPFLAGS += -Wall
ifneq ($(DEBUG),)
- # build with debugging enabled
- CFLAGS += -g -DDEBUG=1
+ # Build with debugging enabled.
+ CPPFLAGS += -g -DDEBUG=$(DEBUG)
else
- # build with specified optimization level
- CFLAGS += -O2
+ # Build with specified optimization level.
+ CPPFLAGS += -O2
endif
-CFLAGS += $(LOC_INCL)
-CFLAGS += -D_USE_SERIAL_IO=1
+CPPFLAGS += $(LOC_INCL)
+CPPFLAGS += -D_USE_SERIAL_IO=1
SRCS = ../$(TARGET).c
@@ -48,8 +41,7 @@ SRCS += $(MBGLIB_COMMON)/str_util.c
all: $(TARGET)
$(TARGET): $(SRCS) $(MAKEFILE_LIST)
- $(CC) $(CFLAGS) $(SRCS) -o $@
-
+ $(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $(SRCS) $(LDFLAGS) $(LDLIBS)
clean:
rm -f *.o *~ core