diff mbox series

libtraceevent: Move plugin_dir define logic to top level Makefile

Message ID 20210128163135.27ae85d5@gandalf.local.home (mailing list archive)
State Accepted
Commit e9bd314141ee6b4556d9db854bccd34159661ffa
Headers show
Series libtraceevent: Move plugin_dir define logic to top level Makefile | expand

Commit Message

Steven Rostedt Jan. 28, 2021, 9:31 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

The installation location of the plugin directory needs to be passed into
the C files via the -DPLUGIN_DIR=".." compiler option. But the logic for
that was only in the plugin directory, such that the main library did not
know where to find the plugins (as the PLUGIN_DIR macro was not set). This
caused the library not to load the plugins for the application.

By moving the logic to the top level Makefile and exporting the variables,
this fixes the issue.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Makefile         | 26 ++++++++++++++++++++++++++
 plugins/Makefile | 24 ------------------------
 2 files changed, 26 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index e4eba74..11bfe54 100644
--- a/Makefile
+++ b/Makefile
@@ -118,6 +118,32 @@  endif
 
 LIBS = -ldl
 
+set_plugin_dir := 1
+
+# Set plugin_dir to preffered global plugin location
+# If we install under $HOME directory we go under
+# $(HOME)/.local/lib/traceevent/plugins
+#
+# We dont set PLUGIN_DIR in case we install under $HOME
+# directory, because by default the code looks under:
+# $(HOME)/.local/lib/traceevent/plugins by default.
+#
+ifeq ($(plugin_dir),)
+ifeq ($(prefix),$(HOME))
+override plugin_dir = $(HOME)/.local/lib/traceevent/plugins
+set_plugin_dir := 0
+else
+override plugin_dir = $(libdir)/traceevent/plugins
+endif
+export plugin_dir
+endif
+
+ifeq ($(set_plugin_dir),1)
+PLUGIN_DIR = -DPLUGIN_DIR="$(plugin_dir)"
+PLUGIN_DIR_SQ = '$(subst ','\'',$(PLUGIN_DIR))'
+export PLUGIN_DIR PLUGIN_DIR_SQ
+endif
+
 # Append required CFLAGS
 override CFLAGS += -fPIC
 override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ)
diff --git a/plugins/Makefile b/plugins/Makefile
index e8b8850..b60352d 100644
--- a/plugins/Makefile
+++ b/plugins/Makefile
@@ -41,30 +41,6 @@  libdir_relative ?= $(libdir_relative_tmp)
 prefix ?= /usr/local
 libdir = $(prefix)/$(libdir_relative)
 
-set_plugin_dir := 1
-
-# Set plugin_dir to preffered global plugin location
-# If we install under $HOME directory we go under
-# $(HOME)/.local/lib/traceevent/plugins
-#
-# We dont set PLUGIN_DIR in case we install under $HOME
-# directory, because by default the code looks under:
-# $(HOME)/.local/lib/traceevent/plugins by default.
-#
-ifeq ($(plugin_dir),)
-ifeq ($(prefix),$(HOME))
-override plugin_dir = $(HOME)/.local/lib/traceevent/plugins
-set_plugin_dir := 0
-else
-override plugin_dir = $(libdir)/traceevent/plugins
-endif
-endif
-
-ifeq ($(set_plugin_dir),1)
-PLUGIN_DIR = -DPLUGIN_DIR="$(plugin_dir)"
-PLUGIN_DIR_SQ = '$(subst ','\'',$(PLUGIN_DIR))'
-endif
-
 include ../scripts/Makefile.include
 
 # copy a bit from Linux kbuild