osmith has uploaded this change for review.

View Change

Generate a version.h file

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

git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/19/40519/1
diff --git a/.gitignore b/.gitignore
index 12f3c4a..7c3444d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -86,3 +86,5 @@
/debian/gtp-echo-responder/
/debian/osmo-ggsn-doc/
/utils/gtp-echo-responder
+
+include/osmocom/gtp/version.h
diff --git a/include/osmocom/gtp/Makefile.am b/include/osmocom/gtp/Makefile.am
index db696e5..cf9235d 100644
--- a/include/osmocom/gtp/Makefile.am
+++ b/include/osmocom/gtp/Makefile.am
@@ -1,8 +1,18 @@
+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" \
+ $< > $@
+
libgtp_HEADERS = \
gsn.h \
gtp.h \
gtpie.h \
pdp.h \
+ version.h \
$(NULL)

libgtpdir = $(includedir)/osmocom/gtp
diff --git a/include/osmocom/gtp/version.h.tpl b/include/osmocom/gtp/version.h.tpl
new file mode 100644
index 0000000..5b09393
--- /dev/null
+++ b/include/osmocom/gtp/version.h.tpl
@@ -0,0 +1,16 @@
+#pragma once
+
+#define LIBGTP_VERSION {{VERSION}}
+#define LIBGTP_VERSION_STR "{{VERSION}}"
+
+#define LIBGTP_VERSION_MAJOR {{VERSION_MAJOR}}
+#define LIBGTP_VERSION_MINOR {{VERSION_MINOR}}
+#define LIBGTP_VERSION_PATCH {{VERSION_PATCH}}
+
+#define LIBGTP_VERSION_GREATER_EQUAL(major, minor, patch) \
+ (LIBGTP_VERSION_MAJOR > (major) || \
+ (LIBGTP_VERSION_MAJOR == (major) && \
+ LIBGTP_VERSION_MINOR > (minor)) || \
+ (LIBGTP_VERSION_MAJOR == (major) && \
+ LIBGTP_VERSION_MINOR == (minor) && \
+ LIBGTP_VERSION_PATCH >= (patch)))

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

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: If3972eb4e56073f8faf58b09d014a811d4a5f401
Gerrit-Change-Number: 40519
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith@sysmocom.de>