* [PATCH v2] libtracefs: Update libtracefs.pc when version changes
@ 2021-04-09 22:06 Steven Rostedt
0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2021-04-09 22:06 UTC (permalink / raw)
To: Linux Trace Devel
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
When the libtracefs version changes, the libtracefs.pc needs to be updated,
otherwise it may install the wrong version number.
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
Changes since v1:
- Fixed version define calculation
- Fixed alignment of updating tfs_version.h
- Remove tfs_version.h in make clean
.gitignore | 1 +
Makefile | 31 ++++++++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index d2d39fb..ff3e014 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ lib/
patches/
build_prefix
build_uninstall
+tfs_version.h
diff --git a/Makefile b/Makefile
index 9de3217..a3ae0b8 100644
--- a/Makefile
+++ b/Makefile
@@ -203,10 +203,12 @@ endef
BUILD_PREFIX := $(BUILD_OUTPUT)/build_prefix
+VERSION_FILE = tfs_version.h
+
$(BUILD_PREFIX): force
$(Q)$(call build_prefix,$(prefix))
-$(PKG_CONFIG_FILE) : ${PKG_CONFIG_SOURCE_FILE}.template $(BUILD_PREFIX)
+$(PKG_CONFIG_FILE) : ${PKG_CONFIG_SOURCE_FILE}.template $(BUILD_PREFIX) $(VERSION_FILE)
$(Q) $(call do_make_pkgconfig_file,$(prefix))
tags: force
@@ -310,6 +312,32 @@ all: $(DEFAULT_TARGET)
$(bdir):
@mkdir -p $(bdir)
+VERSION = $(TFS_VERSION)
+PATCHLEVEL = $(TFS_PATCHLEVEL)
+EXTRAVERSION = $(TFS_EXTRAVERSION)
+
+define make_version.h
+ (echo '/* This file is automatically generated. Do not modify. */'; \
+ echo \#define VERSION_CODE $(shell \
+ expr $(VERSION) \* 256 + $(PATCHLEVEL)); \
+ echo '#define EXTRAVERSION ' $(EXTRAVERSION); \
+ echo '#define VERSION_STRING "'$(VERSION).$(PATCHLEVEL).$(EXTRAVERSION)'"'; \
+ ) > $1
+endef
+
+define update_version.h
+ ($(call make_version.h, $@.tmp); \
+ if [ -r $@ ] && cmp -s $@ $@.tmp; then \
+ rm -f $@.tmp; \
+ else \
+ echo ' UPDATE $@'; \
+ mv -f $@.tmp $@; \
+ fi);
+endef
+
+$(VERSION_FILE): force
+ $(Q)$(call update_version.h)
+
$(LIBTRACEFS_STATIC): force
$(Q)mkdir -p $(bdir)
$(Q)$(MAKE) -C $(src)/src $@
@@ -323,5 +351,6 @@ clean:
$(MAKE) -C $(src)/src clean
$(RM) $(TARGETS) $(bdir)/*.a $(bdir)/*.so $(bdir)/*.so.* $(bdir)/*.o $(bdir)/.*.d
$(RM) $(PKG_CONFIG_FILE)
+ $(RM) $(VERSION_FILE)
.PHONY: clean
--
2.29.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-09 22:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-09 22:06 [PATCH v2] libtracefs: Update libtracefs.pc when version changes Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).