osmith has uploaded this change for review.

View Change

Generate a version.h file

Related: OS#6626
Change-Id: I764d2dce1305441b353d4f9315b57cbaeb8b873e
---
M .gitignore
M include/osmocom/netif/Makefile.am
A include/osmocom/netif/version.h.tpl
3 files changed, 27 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/06/40506/1
diff --git a/.gitignore b/.gitignore
index fd14f41..74848f5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -63,3 +63,4 @@
amr_test

contrib/libosmo-netif.spec
+include/osmocom/netif/version.h
diff --git a/include/osmocom/netif/Makefile.am b/include/osmocom/netif/Makefile.am
index 5c10d71..feb6335 100644
--- a/include/osmocom/netif/Makefile.am
+++ b/include/osmocom/netif/Makefile.am
@@ -1,3 +1,12 @@
+version.h: version.h.tpl
+ $(AM_V_GEN)$(MKDIR_P) $(dir $@)
+ $(AM_V_GEN)sed \
+ -e "s/{{VERSION}}/$$(echo '@VERSION@' | cut -d. -f1-3)/g" \
+ -e "s/{{VERSION_MAJOR}}/$$(echo '@VERSION@' | cut -d. -f1)/g" \
+ -e "s/{{VERSION_MINOR}}/$$(echo '@VERSION@' | cut -d. -f2)/g" \
+ -e "s/{{VERSION_PATCH}}/$$(echo '@VERSION@' | cut -d. -f3)/g" \
+ $< > $@
+
noinst_HEADERS = \
stream_private.h \
$(NULL)
@@ -13,6 +22,7 @@
rs232.h \
rtp.h \
stream.h \
+ version.h \
$(NULL)

if ENABLE_LIBSCTP
diff --git a/include/osmocom/netif/version.h.tpl b/include/osmocom/netif/version.h.tpl
new file mode 100644
index 0000000..289ecbd
--- /dev/null
+++ b/include/osmocom/netif/version.h.tpl
@@ -0,0 +1,16 @@
+#pragma once
+
+#define LIBOSMO_NETIF_VERSION {{VERSION}}
+#define LIBOSMO_NETIF_VERSION_STR "{{VERSION}}"
+
+#define LIBOSMO_NETIF_VERSION_MAJOR {{VERSION_MAJOR}}
+#define LIBOSMO_NETIF_VERSION_MINOR {{VERSION_MINOR}}
+#define LIBOSMO_NETIF_VERSION_PATCH {{VERSION_PATCH}}
+
+#define LIBOSMO_NETIF_VERSION_GREATER_EQUAL(major, minor, patch) \
+ (LIBOSMO_NETIF_VERSION_MAJOR > (major) || \
+ (LIBOSMO_NETIF_VERSION_MAJOR == (major) && \
+ LIBOSMO_NETIF_VERSION_MINOR > (minor)) || \
+ (LIBOSMO_NETIF_VERSION_MAJOR == (major) && \
+ LIBOSMO_NETIF_VERSION_MINOR == (minor) && \
+ LIBOSMO_NETIF_VERSION_PATCH >= (patch)))

To view, visit change 40506. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I764d2dce1305441b353d4f9315b57cbaeb8b873e
Gerrit-Change-Number: 40506
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith@sysmocom.de>