osmith has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/40470?usp=email )
Change subject: Generate a version.h file ......................................................................
Generate a version.h file
Related: OS#6626 Change-Id: I1fd09e23a9842cfa671f332bc52b380cbcdadf78 --- M .gitignore M include/osmocom/core/Makefile.am A include/osmocom/core/version.h.tpl 3 files changed, 28 insertions(+), 1 deletion(-)
Approvals: pespin: Looks good to me, approved laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve
diff --git a/.gitignore b/.gitignore index 29148d0..b14f67c 100644 --- a/.gitignore +++ b/.gitignore @@ -106,6 +106,7 @@ include/osmocom/core/crc*gen.h include/osmocom/core/bit*gen.h include/osmocom/core/socket_compat.h +include/osmocom/core/version.h include/osmocom/gsm/gsm0503.h tests/conv/gsm0503_test_vectors.c
diff --git a/include/osmocom/core/Makefile.am b/include/osmocom/core/Makefile.am index 980f813..9a949ae 100644 --- a/include/osmocom/core/Makefile.am +++ b/include/osmocom/core/Makefile.am @@ -59,6 +59,7 @@ timer_compat.h \ tun.h \ utils.h \ + version.h \ write_queue.h \ sockaddr_str.h \ soft_uart.h \ @@ -101,4 +102,13 @@ $(AM_V_GEN)$(MKDIR_P) $(dir $@) $(AM_V_GEN)sed -e's/XX/$(HAVE_SYS_SOCKET_H)/g' $< > $@
-EXTRA_DIST = socket_compat.h.tpl +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" \ + $< > $@ + +EXTRA_DIST = socket_compat.h.tpl version.h.tpl diff --git a/include/osmocom/core/version.h.tpl b/include/osmocom/core/version.h.tpl new file mode 100644 index 0000000..b0da293 --- /dev/null +++ b/include/osmocom/core/version.h.tpl @@ -0,0 +1,16 @@ +#pragma once + +#define LIBOSMOCORE_VERSION {{VERSION}} +#define LIBOSMOCORE_VERSION_STR "{{VERSION}}" + +#define LIBOSMOCORE_VERSION_MAJOR {{VERSION_MAJOR}} +#define LIBOSMOCORE_VERSION_MINOR {{VERSION_MINOR}} +#define LIBOSMOCORE_VERSION_PATCH {{VERSION_PATCH}} + +#define LIBOSMOCORE_VERSION_GREATER_EQUAL(major, minor, patch) \ + (LIBOSMOCORE_VERSION_MAJOR > (major) || \ + (LIBOSMOCORE_VERSION_MAJOR == (major) && \ + LIBOSMOCORE_VERSION_MINOR > (minor)) || \ + (LIBOSMOCORE_VERSION_MAJOR == (major) && \ + LIBOSMOCORE_VERSION_MINOR == (minor) && \ + LIBOSMOCORE_VERSION_PATCH >= (patch)))