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,
	"Vladislav Valtchev (VMware)" <vladislav.valtchev@gmail.com>
Subject: [PATCH 5/6] trace-cmd: Make the python targets buildable out-of-tree
Date: Wed, 10 Jan 2018 17:58:31 +0200	[thread overview]
Message-ID: <20180110155832.15928-6-vladislav.valtchev@gmail.com> (raw)
In-Reply-To: <20180110155832.15928-1-vladislav.valtchev@gmail.com>

This patch allows the python targets 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
for some targets like 'gui' (as it *already* happens on the master branch):
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        |  4 ++--
 python/Makefile | 30 +++++++++++++++++-------------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile
index c42bea0..88f252e 100644
--- a/Makefile
+++ b/Makefile
@@ -375,10 +375,10 @@ export PYTHON_LDFLAGS
 export PYGTK_CFLAGS
 
 ctracecmd.so: force $(LIBTRACECMD_STATIC)
-	$(Q)$(MAKE) -C $(src)/python $@
+	$(Q)$(MAKE) -C $(src)/python $(obj)/python/ctracecmd.so
 
 ctracecmdgui.so: force $(LIBTRACECMD_STATIC) trace-view
-	$(Q)$(MAKE) -C $(src)/python $@
+	$(Q)$(MAKE) -C $(src)/python $(obj)/python/ctracecmdgui.so
 
 PHONY += python
 python: $(PYTHON)
diff --git a/python/Makefile b/python/Makefile
index b07c0d8..f8e7328 100644
--- a/python/Makefile
+++ b/python/Makefile
@@ -1,40 +1,44 @@
 include $(src)/scripts/utils.mk
 
+bdir:=$(obj)/python
+
 TRACE_VIEW_OBJS =
 TRACE_VIEW_OBJS += $(obj)/kernel-shark/trace-view.o
 TRACE_VIEW_OBJS += $(obj)/kernel-shark/trace-view-store.o
 
 ifdef BUILD_PYTHON_WORKS
-PYTHON_SO_INSTALL := ctracecmd.install
-PYTHON_PY_PROGS := event-viewer.install
-PYTHON_PY_LIBS := tracecmd.install tracecmdgui.install
+PYTHON_SO_INSTALL := $(bdir)/ctracecmd.install
+PYTHON_PY_PROGS := $(bdir)/event-viewer.install
+PYTHON_PY_LIBS := $(bdir)/tracecmd.install $(bdir)/tracecmdgui.install
 endif
 
-ctracecmd.so: ctracecmd.i $(LIBTRACECMD_STATIC)
+$(bdir)/ctracecmd.so: ctracecmd.i $(LIBTRACECMD_STATIC) | $(bdir)
 	swig -Wall -python -noproxy -I$(src)/include/traceevent -I$(src)/include/trace-cmd ctracecmd.i
-	$(CC) -fpic -c $(CPPFLAGS) $(CFLAGS) $(PYTHON_INCLUDES)  ctracecmd_wrap.c
-	$(CC) --shared $(LIBTRACECMD_STATIC) $(LDFLAGS) ctracecmd_wrap.o -o ctracecmd.so
+	$(CC) -fpic -c $(CPPFLAGS) $(CFLAGS) $(PYTHON_INCLUDES) -o $(bdir)/ctracecmd_wrap.o ctracecmd_wrap.c
+	$(CC) --shared $(LIBTRACECMD_STATIC) $(LDFLAGS) $(bdir)/ctracecmd_wrap.o -o $(bdir)/ctracecmd.so
 
-ctracecmdgui.so: ctracecmdgui.i $(LIBTRACECMD_STATIC) $(TRACE_VIEW_OBJS)
+$(bdir)/ctracecmdgui.so: ctracecmdgui.i $(LIBTRACECMD_STATIC) $(TRACE_VIEW_OBJS) | $(bdir)
 	swig -Wall -python -noproxy -I$(src)/kernel-shark/include ctracecmdgui.i
-	$(CC) -fpic -c  $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(PYTHON_INCLUDES) $(PYGTK_CFLAGS) ctracecmdgui_wrap.c
-	$(CC) --shared $(TRACE_VIEW_OBJS) $(LIBTRACECMD_STATIC) $(LDFLAGS) $(LIBS) $(CONFIG_LIBS) ctracecmdgui_wrap.o -o ctracecmdgui.so
+	$(CC) -fpic -c  $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(PYTHON_INCLUDES) $(PYGTK_CFLAGS) -o $(bdir)/ctracecmdgui_wrap.o ctracecmdgui_wrap.c
+	$(CC) --shared $(TRACE_VIEW_OBJS) $(LIBTRACECMD_STATIC) $(LDFLAGS) $(LIBS) $(CONFIG_LIBS) $(bdir)/ctracecmdgui_wrap.o -o $(bdir)/ctracecmdgui.so
 
+$(bdir):
+	@mkdir -p $(bdir)
 
-$(PYTHON_SO_INSTALL): %.install : %.so force
+$(PYTHON_SO_INSTALL): $(bdir)/%.install : $(bdir)/%.so force
 	$(Q)$(call do_install_data,$<,$(python_dir_SQ))
 
-$(PYTHON_PY_PROGS): %.install : %.py force
+$(PYTHON_PY_PROGS): $(bdir)/%.install : %.py force
 	$(Q)$(call do_install,$<,$(python_dir_SQ))
 
-$(PYTHON_PY_LIBS): %.install : %.py force
+$(PYTHON_PY_LIBS): $(bdir)/%.install : %.py force
 	$(Q)$(call do_install_data,$<,$(python_dir_SQ))
 
 install_python: $(PYTHON_SO_INSTALL) $(PYTHON_PY_PROGS) $(PYTHON_PY_LIBS)
 
 
 clean:
-	$(RM) *.a *.so *.o .*.d ctracecmd_wrap.* ctracecmdgui_wrap.*
+	$(RM) $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d $(bdir)/ctracecmd_wrap.* $(bdir)/ctracecmdgui_wrap.*
 
 force:
 .PHONY: clean force
-- 
2.14.1

  parent reply	other threads:[~2018-01-10 15:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10 15:58 [PATCH 0/6] trace-cmd: Make out-of-tree builds to work Vladislav Valtchev (VMware)
2018-01-10 15:58 ` [PATCH 1/6] trace-cmd: Make libtraceevent builable out-of-tree Vladislav Valtchev (VMware)
2018-01-10 15:58 ` [PATCH 2/6] trace-cmd: Make the plugins buildable out-of-tree Vladislav Valtchev (VMware)
2018-01-10 15:58 ` [PATCH 3/6] trace-cmd: Make libtracecmd " Vladislav Valtchev (VMware)
2018-01-10 15:58 ` [PATCH 4/6] trace-cmd: Make the trace-cmd target " Vladislav Valtchev (VMware)
2018-01-10 15:58 ` Vladislav Valtchev (VMware) [this message]
2018-01-10 15:58 ` [PATCH 6/6] trace-cmd: Make the GUI targets " Vladislav Valtchev (VMware)

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=20180110155832.15928-6-vladislav.valtchev@gmail.com \
    --to=vladislav.valtchev@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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).