diff mbox series

rtla/Makefile: Properly handle dependencies

Message ID 48c7167c78a330d0b25dc631ee7d6f0f34c096e9.1648132686.git.bristot@kernel.org (mailing list archive)
State Superseded
Headers show
Series rtla/Makefile: Properly handle dependencies | expand

Commit Message

Daniel Bristot de Oliveira March 24, 2022, 3:01 p.m. UTC
Linus had a problem compiling RTLA, saying:

"[...] I wish the tracing tools would do a bit more package
checking and helpful error messages too, rather than just
fail with:

    fatal error: tracefs.h: No such file or directory"

Which is indeed not a helpful message. Update the Makefile, adding
proper checks for the dependencies, with useful information about
how to resolve possible problems.

For example, the previous error is now reported as:

    $ make
    ********************************************
    ** NOTICE: libtracefs version 1.3 or higher not found
    **
    ** Consider installing the latest libtracefs from your
    ** distribution, e.g., 'dnf install libtracefs' on Fedora,
    ** or from source:
    **
    **  https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ 
    **
    ********************************************

These messages are inspired by the ones used on trace-cmd, as suggested
by Stevel Rostedt.

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
---
 tools/tracing/rtla/Makefile | 72 +++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
diff mbox series

Patch

diff --git a/tools/tracing/rtla/Makefile b/tools/tracing/rtla/Makefile
index 5a1eda617992..448e9073736a 100644
--- a/tools/tracing/rtla/Makefile
+++ b/tools/tracing/rtla/Makefile
@@ -57,6 +57,78 @@  else
 DOCSRC	=	$(SRCTREE)/../../../Documentation/tools/rtla/
 endif
 
+LIBTRACEEVENT = libtraceevent
+LIBTRACEFS = libtracefs
+LIBPROCPS = libprocps
+
+LIBTRACEEVENT_MIN_VERSION = 1.5
+LIBTRACEFS_MIN_VERSION = 1.3
+LIBPROCPS_MIN_VERSION = 3.3
+
+TEST_LIBTRACEEVENT = $(shell sh -c "$(PKG_CONFIG) --atleast-version $(LIBTRACEEVENT_MIN_VERSION) $(LIBTRACEEVENT) > /dev/null 2>&1 || echo n")
+ifeq ("$(TEST_LIBTRACEEVENT)", "n")
+.PHONY: warning_traceevent
+warning_traceevent:
+	@echo "********************************************"
+	@echo "** NOTICE: $(LIBTRACEEVENT) version $(LIBTRACEEVENT_MIN_VERSION) or higher not found"
+	@echo "**"
+	@echo "** Consider installing the latest $(LIBTRACEEVENT) from your"
+	@echo "** distribution, e.g., 'dnf install $(LIBTRACEEVENT)' on Fedora,"
+	@echo "** or from source:"
+	@echo "**"
+	@echo "**  https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/ "
+	@echo "**"
+	@echo "********************************************"
+endif
+
+TEST_LIBTRACEFS = $(shell sh -c "$(PKG_CONFIG) --atleast-version $(LIBTRACEFS_MIN_VERSION) $(LIBTRACEFS) > /dev/null 2>&1 || echo n")
+ifeq ("$(TEST_LIBTRACEFS)", "n")
+.PHONY: warning_tracefs
+warning_tracefs:
+	@echo "********************************************"
+	@echo "** NOTICE: $(LIBTRACEFS) version $(LIBTRACEFS_MIN_VERSION) or higher not found"
+	@echo "**"
+	@echo "** Consider installing the latest $(LIBTRACEFS) from your"
+	@echo "** distribution, e.g., 'dnf install $(LIBTRACEFS)' on Fedora,"
+	@echo "** or from source:"
+	@echo "**"
+	@echo "**  https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ "
+	@echo "**"
+	@echo "********************************************"
+endif
+
+TEST_LIBPROCPS = $(shell sh -c "$(PKG_CONFIG) --atleast-version $(LIBPROCPS_MIN_VERSION) $(LIBPROCPS) > /dev/null 2>&1 || echo n")
+ifeq ("$(TEST_LIBPROCPS)", "n")
+.PHONY: warning_procps
+warning_procps:
+	@echo "********************************************"
+	@echo "** NOTICE: $(LIBPROCPS) version $(LIBPROCPS_MIN_VERSION) or higher not found"
+	@echo "**"
+	@echo "** Consider installing the latest procps-ng-devel from your"
+	@echo "** distribution, e.g., 'dnf install procps-ng-devel' on Fedora,"
+	@echo "** or from source:"
+	@echo "**"
+	@echo "**  https://gitlab.com/procps-ng/procps "
+	@echo "**"
+	@echo "********************************************"
+endif
+
+TEST_RST2MAN = $(shell sh -c "rst2man --version > /dev/null 2>&1 || echo n")
+ifeq ("$(TEST_RST2MAN)", "n")
+.PHONY: warning_rst2man
+warning_rst2man:
+	@echo "********************************************"
+	@echo "** NOTICE: rst2man not found"
+	@echo "**"
+	@echo "** Consider installing the latest rst2man from your"
+	@echo "** distribution, e.g., 'dnf install python3-docutils' on Fedora,"
+	@echo "** or from source:"
+	@echo "**"
+	@echo "**  https://docutils.sourceforge.io/docs/dev/repository.html "
+	@echo "**"
+	@echo "********************************************"
+endif
+
 .PHONY:	all
 all:	rtla