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 3/6] trace-cmd: Make libtracecmd buildable out-of-tree
Date: Wed, 10 Jan 2018 17:58:29 +0200	[thread overview]
Message-ID: <20180110155832.15928-4-vladislav.valtchev@gmail.com> (raw)
In-Reply-To: <20180110155832.15928-1-vladislav.valtchev@gmail.com>

This patch allows the libtracecmd 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
libtracecmd: 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 ++--
 lib/trace-cmd/Makefile | 27 ++++++++++++++++++---------
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index 73e14e8..3b71206 100644
--- a/Makefile
+++ b/Makefile
@@ -266,10 +266,10 @@ $(LIBTRACEEVENT_STATIC): force
 	$(Q)$(MAKE) -C $(src)/lib/traceevent $@
 
 $(LIBTRACECMD_STATIC): force $(obj)/plugins/trace_plugin_dir
-	$(Q)$(MAKE) -C $(src)/lib/trace-cmd libtracecmd.a
+	$(Q)$(MAKE) -C $(src)/lib/trace-cmd $@
 
 $(LIBTRACECMD_SHARED): force $(obj)/plugins/trace_plugin_dir
-	$(Q)$(MAKE) -C $(src)/lib/trace-cmd libtracecmd.so
+	$(Q)$(MAKE) -C $(src)/lib/trace-cmd $@
 
 libtraceevent.so: $(LIBTRACEEVENT_SHARED)
 libtraceevent.a: $(LIBTRACEEVENT_STATIC)
diff --git a/lib/trace-cmd/Makefile b/lib/trace-cmd/Makefile
index e8fb088..ee09099 100644
--- a/lib/trace-cmd/Makefile
+++ b/lib/trace-cmd/Makefile
@@ -2,7 +2,9 @@
 
 include $(src)/scripts/utils.mk
 
-DEFAULT_TARGET = libtracecmd.a
+bdir:=$(obj)/lib/trace-cmd
+
+DEFAULT_TARGET = $(bdir)/libtracecmd.a
 
 OBJS =
 OBJS += trace-hash.o
@@ -15,25 +17,32 @@ OBJS += trace-util.o
 OBJS += trace-blk-hack.o
 OBJS += trace-ftrace.o
 
-DEPS := $(OBJS:%.o=.%.d)
+OBJS := $(OBJS:%.o=$(bdir)/%.o)
+DEPS := $(OBJS:$(bdir)/%.o=$(bdir)/.%.d)
 
 all: $(DEFAULT_TARGET)
 
-libtracecmd.a: $(OBJS)
+$(bdir):
+	@mkdir -p $(bdir)
+
+$(OBJS): | $(bdir)
+$(DEPS): | $(bdir)
+
+$(bdir)/libtracecmd.a: $(OBJS)
 	$(Q)$(call do_build_static_lib)
 
-libtracecmd.so: $(OBJS)
+$(bdir)/libtracecmd.so: $(OBJS)
 	$(Q)$(call do_compile_shared_library)
 
-%.o: %.c
+$(bdir)/%.o: %.c
 	$(Q)$(call do_fpic_compile)
 
-trace-util.o: $(obj)/plugins/trace_plugin_dir
+$(bdir)/trace-util.o: $(obj)/plugins/trace_plugin_dir
 
-$(DEPS): .%.d: %.c
+$(DEPS): $(bdir)/.%.d: %.c
 	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@
 
-$(OBJS): %.o : .%.d
+$(OBJS): $(bdir)/%.o : $(bdir)/.%.d
 
 dep_includes := $(wildcard $(DEPS))
 
@@ -42,6 +51,6 @@ ifneq ($(dep_includes),)
 endif
 
 clean:
-	$(RM) *.a *.so *.o .*.d
+	$(RM) $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d
 
 .PHONY: clean
-- 
2.14.1

  parent reply	other threads:[~2018-01-10 15:58 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 ` Vladislav Valtchev (VMware) [this message]
2018-01-10 15:58 ` [PATCH 4/6] trace-cmd: Make the trace-cmd target " Vladislav Valtchev (VMware)
2018-01-10 15:58 ` [PATCH 5/6] trace-cmd: Make the python targets " Vladislav Valtchev (VMware)
2018-01-10 15:58 ` [PATCH 6/6] trace-cmd: Make the GUI " 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-4-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).