linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Vladislav Valtchev (VMware)" <vladislav.valtchev@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com,
	"Vladislav Valtchev (VMware)" <vladislav.valtchev@gmail.com>
Subject: [PATCH v2 20/24] trace-cmd: Make the plugins buildable out-of-tree
Date: Tue,  6 Feb 2018 10:49:02 +0200	[thread overview]
Message-ID: <20180206084906.9854-21-vladislav.valtchev@gmail.com> (raw)
In-Reply-To: <20180206084906.9854-1-vladislav.valtchev@gmail.com>

This patch allows the plugins to be buildable out-of-tree when the 'O' variable
is set at command line while invoking make.

At this stage, when the 'O' variable is set, the out-of-tree build will fail (as
it *already* does on the master branch) but with errors unrelated with the
plugins: with this patch the final goal of a fully working out-of-tree build
gets closer.

In successive steps, the remaining Makefiles will be made to support out-of-tree
builds, until everything works.

NOTE: the regular in-tree build of all targets clearly continues to work.
Signed-off-by: Vladislav Valtchev (VMware) <vladislav.valtchev@gmail.com>
---
 Makefile         | 10 +++++-----
 plugins/Makefile | 37 ++++++++++++++++++++++---------------
 scripts/utils.mk |  2 +-
 3 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/Makefile b/Makefile
index 6cd54d9..df20885 100644
--- a/Makefile
+++ b/Makefile
@@ -261,10 +261,10 @@ trace-graph: force $(CMD_TARGETS)
 	$(Q)$(MAKE) -C $(src)/kernel-shark $@
 
 $(LIBTRACEEVENT_SHARED): force
-	$(Q)$(MAKE) -C $(src)/lib/traceevent $(obj)/lib/traceevent/libtraceevent.so
+	$(Q)$(MAKE) -C $(src)/lib/traceevent $@
 
 $(LIBTRACEEVENT_STATIC): force
-	$(Q)$(MAKE) -C $(src)/lib/traceevent $(obj)/lib/traceevent/libtraceevent.a
+	$(Q)$(MAKE) -C $(src)/lib/traceevent $@
 
 $(LIBTRACECMD_STATIC): force $(obj)/plugins/trace_plugin_dir
 	$(Q)$(MAKE) -C $(src)/lib/trace-cmd libtracecmd.a
@@ -283,10 +283,10 @@ plugins: force $(obj)/plugins/trace_plugin_dir $(obj)/plugins/trace_python_dir
 	$(Q)$(MAKE) -C $(src)/plugins
 
 $(obj)/plugins/trace_plugin_dir: force
-	$(Q)$(MAKE) -C $(src)/plugins trace_plugin_dir
+	$(Q)$(MAKE) -C $(src)/plugins $@
 
 $(obj)/plugins/trace_python_dir: force
-	$(Q)$(MAKE) -C $(src)/plugins trace_python_dir
+	$(Q)$(MAKE) -C $(src)/plugins $@
 
 show_gui_make:
 	@echo "Note: to build the gui, type \"make gui\""
@@ -395,7 +395,7 @@ PHONY += python-plugin
 python-plugin: $(PYTHON_PLUGINS)
 
 plugin_python.so: force $(obj)/plugins/trace_python_dir
-	$(Q)$(MAKE) -C $(src)/plugins plugin_python.so
+	$(Q)$(MAKE) -C $(src)/plugins $(obj)/plugins/plugin_python.so
 
 dist:
 	git archive --format=tar --prefix=trace-cmd-$(TRACECMD_VERSION)/ HEAD \
diff --git a/plugins/Makefile b/plugins/Makefile
index 7a09b82..cff71f1 100644
--- a/plugins/Makefile
+++ b/plugins/Makefile
@@ -1,5 +1,7 @@
 include $(src)/scripts/utils.mk
 
+bdir:=$(obj)/plugins
+
 PLUGIN_OBJS =
 PLUGIN_OBJS += plugin_jbd2.o
 PLUGIN_OBJS += plugin_hrtimer.o
@@ -14,33 +16,38 @@ PLUGIN_OBJS += plugin_cfg80211.o
 PLUGIN_OBJS += plugin_blk.o
 PLUGIN_OBJS += plugin_tlb.o
 
-PLUGINS := $(PLUGIN_OBJS:.o=.so)
-DEPS := $(PLUGIN_OBJS:%.o=.%.d)
+PLUGIN_OBJS := $(PLUGIN_OBJS:%.o=$(bdir)/%.o)
+PLUGINS := $(PLUGIN_OBJS:$(bdir)/%.o=$(bdir)/%.so)
+DEPS := $(PLUGIN_OBJS:$(bdir)/%.o=$(bdir)/.%.d)
 
 all: $(PLUGINS)
 
-$(PLUGIN_OBJS): %.o : %.c
+$(bdir):
+	@mkdir -p $(bdir)
+
+$(PLUGIN_OBJS): | $(bdir)
+$(DEPS): | $(bdir)
+
+$(PLUGIN_OBJS): $(bdir)/%.o : %.c
 	$(Q)$(do_compile_plugin_obj)
 
-$(PLUGINS): %.so: %.o
+$(PLUGINS): $(bdir)/%.so: $(bdir)/%.o
 	$(Q)$(do_plugin_build)
 
-$(DEPS): .%.d: %.c
+$(DEPS): $(bdir)/.%.d: %.c
 	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@
 
-$(PLUGIN_OBJS): %.o : .%.d
+$(PLUGIN_OBJS): $(bdir)/%.o : $(bdir)/.%.d
 
-CFLAGS_plugin_python.o += $(PYTHON_DIR_SQ)
-
-plugin_python.o: %.o : %.c trace_python_dir
+$(bdir)/plugin_python.o: $(bdir)/%.o : %.c $(bdir)/trace_python_dir
 	$(Q)$(do_compile_python_plugin_obj)
 
-plugin_python.so: %.so: %.o
+$(bdir)/plugin_python.so: $(bdir)/%.so: $(bdir)/%.o
 	$(Q)$(do_python_plugin_build)
 
-PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) $(subst .so,.install,$(PYTHON_PLUGINS))
+PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS))
 
-$(PLUGINS_INSTALL): %.install : %.so force
+$(PLUGINS_INSTALL): $(bdir)/%.install : $(bdir)/%.so force
 	$(Q)$(call do_install_data,$<,$(plugin_dir_SQ))
 
 install_plugins: $(PLUGINS_INSTALL)
@@ -49,10 +56,10 @@ install_plugins: $(PLUGINS_INSTALL)
 # and $(PYTHON_DIR) change. Without them, a full clean build would necessary
 # in order to get the binaries updated.
 
-trace_plugin_dir: force
+$(bdir)/trace_plugin_dir: $(bdir) force
 	$(Q)$(N)$(call update_dir, 'PLUGIN_DIR=$(PLUGIN_DIR)')
 
-trace_python_dir: force
+$(bdir)/trace_python_dir: $(bdir) force
 	$(Q)$(N)$(call update_dir, 'PYTHON_DIR=$(PYTHON_DIR)')
 
 
@@ -63,7 +70,7 @@ ifneq ($(dep_includes),)
 endif
 
 clean:
-	$(RM) *.a *.so *.o .*.d trace_plugin_dir trace_python_dir
+	$(RM) -f $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d $(bdir)/trace_plugin_dir $(bdir)/trace_python_dir
 
 force:
 .PHONY: clean force
\ No newline at end of file
diff --git a/scripts/utils.mk b/scripts/utils.mk
index 043a68a..06e8dc3 100644
--- a/scripts/utils.mk
+++ b/scripts/utils.mk
@@ -64,7 +64,7 @@ do_plugin_build =				\
 
 do_compile_python_plugin_obj =			\
 	($(print_plugin_obj_compile)		\
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$@) $(PYTHON_INCLUDES) -fPIC -o $@ $<)
+	$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PYTHON_DIR_SQ) $(PYTHON_INCLUDES) -fPIC -o $@ $<)
 
 do_python_plugin_build =			\
 	($(print_plugin_build)			\
-- 
2.14.1

  parent reply	other threads:[~2018-02-06  8:49 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-06  8:48 [PATCH v2 00/24] trace-cmd: restructure the project's source tree Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 01/24] trace-cmd: Rename libparsevent to libtraceevent Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 02/24] trace-cmd: Move libtraceevent headers in include/traceevent Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 03/24] trace-cmd: Move trace-cmd headers in include/trace-cmd Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 04/24] trace-cmd: Move event-utils.h in lib/traceevent/include Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 05/24] trace-cmd: Extract part of Makefile in scripts/utils.mk Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 06/24] trace-cmd: Move libtraceevent *.c files in lib/traceevent Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 07/24] trace-cmd: Move trace-hash-local.h in lib/trace-cmd/include Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 08/24] trace-cmd: Move libtracecmd *.c files in lib/trace-cmd Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 09/24] trace-cmd: Move GUI headers in kernel-shark/include Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 10/24] trace-cmd: Move GUI *.c files in kernel-shark/ Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 11/24] trace-cmd: Move plugin_* files in plugins/ Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 12/24] trace-cmd: Fix the broken target ctracecmdgui.so Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 13/24] trace-cmd: Move python-related files in python/ Vladislav Valtchev (VMware)
2018-02-07 19:22   ` Steven Rostedt
2018-02-07 19:36     ` Steven Rostedt
2018-02-08  7:17       ` Vladislav K. Valtchev
2018-02-07 20:11     ` Steven Rostedt
2018-02-08  7:29       ` Vladislav K. Valtchev
2018-02-06  8:48 ` [PATCH v2 14/24] trace-cmd: Move tracecmd headers in tracecmd/include Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 15/24] trace-cmd: Move version.h in include/ Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 16/24] trace-cmd: Move trace-cmd app files in tracecmd/ Vladislav Valtchev (VMware)
2018-02-06  8:48 ` [PATCH v2 17/24] trace-cmd: Fix the logic behind SWIG_DEFINED in the Makefile Vladislav Valtchev (VMware)
2018-02-06  8:49 ` [PATCH v2 18/24] trace-cmd: Make the build to tell when python-dev is missing Vladislav Valtchev (VMware)
2018-02-06  8:49 ` [PATCH v2 19/24] trace-cmd: Make libtraceevent builable out-of-tree Vladislav Valtchev (VMware)
2018-02-06  8:49 ` Vladislav Valtchev (VMware) [this message]
2018-02-06  8:49 ` [PATCH v2 21/24] trace-cmd: Make libtracecmd buildable out-of-tree Vladislav Valtchev (VMware)
2018-02-06  8:49 ` [PATCH v2 22/24] trace-cmd: Make the trace-cmd target " Vladislav Valtchev (VMware)
2018-02-06  8:49 ` [PATCH v2 23/24] trace-cmd: Make the python targets " Vladislav Valtchev (VMware)
2018-02-06  8:49 ` [PATCH v2 24/24] trace-cmd: Make the GUI " Vladislav Valtchev (VMware)
2018-02-07  0:27 ` [PATCH v2 00/24] trace-cmd: restructure the project's source tree Steven Rostedt
2018-02-07 13:15   ` Vladislav Valtchev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180206084906.9854-21-vladislav.valtchev@gmail.com \
    --to=vladislav.valtchev@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=y.karadz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).