From patchwork Wed Jan 10 15:58:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vladislav Valtchev (VMware)" X-Patchwork-Id: 10758457 Return-Path: linux-trace-devel-owner@vger.kernel.org Received: from mail-wr0-f193.google.com ([209.85.128.193]:43212 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965173AbeAJP65 (ORCPT ); Wed, 10 Jan 2018 10:58:57 -0500 Received: by mail-wr0-f193.google.com with SMTP id s13so15413677wra.10 for ; Wed, 10 Jan 2018 07:58:56 -0800 (PST) From: "Vladislav Valtchev (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Vladislav Valtchev (VMware)" Subject: [PATCH 1/6] trace-cmd: Make libtraceevent builable out-of-tree Date: Wed, 10 Jan 2018 17:58:27 +0200 Message-Id: <20180110155832.15928-2-vladislav.valtchev@gmail.com> In-Reply-To: <20180110155832.15928-1-vladislav.valtchev@gmail.com> References: <20180110155832.15928-1-vladislav.valtchev@gmail.com> Sender: linux-trace-devel-owner@vger.kernel.org List-ID: Content-Length: 3678 This patch allows the libtraceevent 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 libtraceevent: with this patch the final goal of a fully working out-of-tree build gets significantly 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) --- Makefile | 31 +++++++++++-------------------- lib/traceevent/Makefile | 25 +++++++++++++++++-------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 2370c8d..d1fed58 100644 --- a/Makefile +++ b/Makefile @@ -144,27 +144,18 @@ endef blk-flags := $(call test-build,$(BLK_TC_FLUSH_SOURCE),-DHAVE_BLK_TC_FLUSH) ifeq ("$(origin O)", "command line") - BUILD_OUTPUT := $(O) + + saved-output := $(O) + BUILD_OUTPUT := $(shell cd $(O) && /bin/pwd) + $(if $(BUILD_OUTPUT),, \ + $(error output directory "$(saved-output)" does not exist)) + +else + BUILD_OUTPUT = $(CURDIR) endif -ifeq ($(BUILD_SRC),) -ifneq ($(BUILD_OUTPUT),) - -define build_output - $(if $(VERBOSE:1=),@)$(MAKE) -C $(BUILD_OUTPUT) \ - BUILD_SRC=$(CURDIR) -f $(CURDIR)/Makefile $1 -endef - -saved-output := $(BUILD_OUTPUT) -BUILD_OUTPUT := $(shell cd $(BUILD_OUTPUT) && /bin/pwd) -$(if $(BUILD_OUTPUT),, \ - $(error output directory "$(saved-output)" does not exist)) - -endif # BUILD_OUTPUT -endif # BUILD_SRC - srctree := $(if $(BUILD_SRC),$(BUILD_SRC),$(CURDIR)) -objtree := $(CURDIR) +objtree := $(BUILD_OUTPUT) src := $(srctree) obj := $(objtree) @@ -269,10 +260,10 @@ trace-graph: force $(CMD_TARGETS) $(Q)$(MAKE) -C $(src)/kernel-shark $@ $(LIBTRACEEVENT_SHARED): force - $(Q)$(MAKE) -C $(src)/lib/traceevent libtraceevent.so + $(Q)$(MAKE) -C $(src)/lib/traceevent $(obj)/lib/traceevent/libtraceevent.so $(LIBTRACEEVENT_STATIC): force - $(Q)$(MAKE) -C $(src)/lib/traceevent libtraceevent.a + $(Q)$(MAKE) -C $(src)/lib/traceevent $(obj)/lib/traceevent/libtraceevent.a $(LIBTRACECMD_STATIC): force $(obj)/plugins/trace_plugin_dir $(Q)$(MAKE) -C $(src)/lib/trace-cmd libtracecmd.a diff --git a/lib/traceevent/Makefile b/lib/traceevent/Makefile index f9c595c..60246aa 100644 --- a/lib/traceevent/Makefile +++ b/lib/traceevent/Makefile @@ -2,7 +2,9 @@ include $(src)/scripts/utils.mk -DEFAULT_TARGET = libtraceevent.a +bdir:=$(obj)/lib/traceevent + +DEFAULT_TARGET = $(bdir)/libtraceevent.a OBJS = OBJS += event-parse.o @@ -15,23 +17,30 @@ OBJS += parse-utils.o # Additional util objects OBJS += str_error_r.o -DEPS := $(OBJS:%.o=.%.d) +OBJS := $(OBJS:%.o=$(bdir)/%.o) +DEPS := $(OBJS:$(bdir)/%.o=$(bdir)/.%.d) all: $(DEFAULT_TARGET) -libtraceevent.a: $(OBJS) +$(bdir): + @mkdir -p $(bdir) + +$(OBJS): | $(bdir) +$(DEPS): | $(bdir) + +$(bdir)/libtraceevent.a: $(OBJS) $(Q)$(call do_build_static_lib) -libtraceevent.so: $(OBJS) +$(bdir)/libtraceevent.so: $(OBJS) $(Q)$(call do_compile_shared_library) -%.o: %.c +$(bdir)/%.o: %.c $(Q)$(call do_fpic_compile) -$(DEPS): .%.d: %.c +$(DEPS): $(bdir)/.%.d: %.c $(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@ -$(OBJS): %.o : .%.d +$(OBJS): $(bdir)/%.o : $(bdir)/.%.d dep_includes := $(wildcard $(DEPS)) @@ -40,6 +49,6 @@ ifneq ($(dep_includes),) endif clean: - $(RM) *.a *.so *.o .*.d + $(RM) -f $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d .PHONY: clean From patchwork Wed Jan 10 15:58:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vladislav Valtchev (VMware)" X-Patchwork-Id: 10758451 Return-Path: linux-trace-devel-owner@vger.kernel.org Received: from mail-wr0-f194.google.com ([209.85.128.194]:43214 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965652AbeAJP66 (ORCPT ); Wed, 10 Jan 2018 10:58:58 -0500 Received: by mail-wr0-f194.google.com with SMTP id s13so15413723wra.10 for ; Wed, 10 Jan 2018 07:58:57 -0800 (PST) From: "Vladislav Valtchev (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Vladislav Valtchev (VMware)" Subject: [PATCH 2/6] trace-cmd: Make the plugins buildable out-of-tree Date: Wed, 10 Jan 2018 17:58:28 +0200 Message-Id: <20180110155832.15928-3-vladislav.valtchev@gmail.com> In-Reply-To: <20180110155832.15928-1-vladislav.valtchev@gmail.com> References: <20180110155832.15928-1-vladislav.valtchev@gmail.com> Sender: linux-trace-devel-owner@vger.kernel.org List-ID: Content-Length: 5122 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) --- Makefile | 10 +++++----- plugins/Makefile | 37 ++++++++++++++++++++++--------------- scripts/utils.mk | 2 +- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index d1fed58..73e14e8 100644 --- a/Makefile +++ b/Makefile @@ -260,10 +260,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 @@ -282,10 +282,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\"" @@ -389,7 +389,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) \ From patchwork Wed Jan 10 15:58:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vladislav Valtchev (VMware)" X-Patchwork-Id: 10758455 Return-Path: linux-trace-devel-owner@vger.kernel.org Received: from mail-wr0-f193.google.com ([209.85.128.193]:44365 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964976AbeAJP66 (ORCPT ); Wed, 10 Jan 2018 10:58:58 -0500 Received: by mail-wr0-f193.google.com with SMTP id w50so8612017wrc.11 for ; Wed, 10 Jan 2018 07:58:58 -0800 (PST) From: "Vladislav Valtchev (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Vladislav Valtchev (VMware)" Subject: [PATCH 3/6] trace-cmd: Make libtracecmd buildable out-of-tree Date: Wed, 10 Jan 2018 17:58:29 +0200 Message-Id: <20180110155832.15928-4-vladislav.valtchev@gmail.com> In-Reply-To: <20180110155832.15928-1-vladislav.valtchev@gmail.com> References: <20180110155832.15928-1-vladislav.valtchev@gmail.com> Sender: linux-trace-devel-owner@vger.kernel.org List-ID: Content-Length: 2730 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) --- 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 From patchwork Wed Jan 10 15:58:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vladislav Valtchev (VMware)" X-Patchwork-Id: 10758459 Return-Path: linux-trace-devel-owner@vger.kernel.org Received: from mail-wm0-f68.google.com ([74.125.82.68]:37527 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965652AbeAJP7A (ORCPT ); Wed, 10 Jan 2018 10:59:00 -0500 Received: by mail-wm0-f68.google.com with SMTP id f140so27907632wmd.2 for ; Wed, 10 Jan 2018 07:58:59 -0800 (PST) From: "Vladislav Valtchev (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Vladislav Valtchev (VMware)" Subject: [PATCH 4/6] trace-cmd: Make the trace-cmd target buildable out-of-tree Date: Wed, 10 Jan 2018 17:58:30 +0200 Message-Id: <20180110155832.15928-5-vladislav.valtchev@gmail.com> In-Reply-To: <20180110155832.15928-1-vladislav.valtchev@gmail.com> References: <20180110155832.15928-1-vladislav.valtchev@gmail.com> Sender: linux-trace-devel-owner@vger.kernel.org List-ID: Content-Length: 3265 This patch allows the trace-cmd app 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) --- Makefile | 3 ++- tracecmd/Makefile | 33 ++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 3b71206..c42bea0 100644 --- a/Makefile +++ b/Makefile @@ -188,6 +188,7 @@ INCLUDES += -I$(src)/lib/traceevent/include INCLUDES += -I$(src)/lib/trace-cmd/include INCLUDES += -I$(src)/kernel-shark/include INCLUDES += -I$(src)/tracecmd/include +INCLUDES += -I$(obj)/tracecmd/include include $(src)/features.mk @@ -248,7 +249,7 @@ gui: force $(CMD_TARGETS) echo "gui build complete" trace-cmd: force $(LIBTRACEEVENT_STATIC) $(LIBTRACECMD_STATIC) - $(Q)$(MAKE) -C $(src)/tracecmd $@ + $(Q)$(MAKE) -C $(src)/tracecmd $(obj)/tracecmd/$@ kernelshark: force $(CMD_TARGETS) $(Q)$(MAKE) -C $(src)/kernel-shark $@ diff --git a/tracecmd/Makefile b/tracecmd/Makefile index 860dc89..3a11024 100644 --- a/tracecmd/Makefile +++ b/tracecmd/Makefile @@ -3,8 +3,10 @@ VERSION := $(TC_VERSION) PATCHLEVEL := $(TC_PATCHLEVEL) EXTRAVERSION := $(TC_EXTRAVERSION) -TC_VERSION := $(obj)/tracecmd/include/tc_version.h -TARGETS = trace-cmd $(TC_VERSION) +bdir:=$(obj)/tracecmd + +TC_VERSION := $(bdir)/include/tc_version.h +TARGETS = $(bdir)/trace-cmd $(TC_VERSION) BUILDGUI := 0 include $(src)/scripts/utils.mk @@ -31,10 +33,10 @@ TRACE_CMD_OBJS += trace-output.o TRACE_CMD_OBJS += trace-usage.o TRACE_CMD_OBJS += trace-msg.o -ALL_OBJS = $(TRACE_CMD_OBJS) +ALL_OBJS := $(TRACE_CMD_OBJS:%.o=$(bdir)/%.o) all_objs := $(sort $(ALL_OBJS)) -all_deps := $(all_objs:%.o=.%.d) +all_deps := $(all_objs:$(bdir)/%.o=$(bdir)/.%.d) CONFIG_INCLUDES = CONFIG_LIBS = @@ -42,23 +44,32 @@ CONFIG_FLAGS = all: $(TARGETS) -$(TC_VERSION): force +$(bdir): + @mkdir -p $(bdir) + +$(bdir)/include: | $(bidr) + @mkdir -p $(bdir)/include + +$(TC_VERSION): force | $(bdir)/include $(Q)$(call update_version.h) -trace-cmd: $(ALL_OBJS) +$(all_deps): | $(bdir) +$(all_objs): | $(bdir) + +$(bdir)/trace-cmd: $(ALL_OBJS) $(Q)$(do_app_build) -trace-cmd: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC) +$(bdir)/trace-cmd: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC) -%.o: %.c +$(bdir)/%.o: %.c $(Q)$(call do_compile) -$(all_deps): .%.d: %.c +$(all_deps): $(bdir)/.%.d: %.c $(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@ $(all_deps): $(TC_VERSION) -$(all_objs): %.o : .%.d +$(all_objs): $(bdir)/%.o : $(bdir)/.%.d dep_includes := $(wildcard $(DEPS)) @@ -67,7 +78,7 @@ ifneq ($(dep_includes),) endif clean: - $(RM) *.a *.so *.o .*.d $(TARGETS) + $(RM) $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d $(TARGETS) force: .PHONY: clean From patchwork Wed Jan 10 15:58:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vladislav Valtchev (VMware)" X-Patchwork-Id: 10758461 Return-Path: linux-trace-devel-owner@vger.kernel.org Received: from mail-wr0-f196.google.com ([209.85.128.196]:39163 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965900AbeAJP7A (ORCPT ); Wed, 10 Jan 2018 10:59:00 -0500 Received: by mail-wr0-f196.google.com with SMTP id z48so12101265wrz.6 for ; Wed, 10 Jan 2018 07:59:00 -0800 (PST) From: "Vladislav Valtchev (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Vladislav Valtchev (VMware)" Subject: [PATCH 5/6] trace-cmd: Make the python targets buildable out-of-tree Date: Wed, 10 Jan 2018 17:58:31 +0200 Message-Id: <20180110155832.15928-6-vladislav.valtchev@gmail.com> In-Reply-To: <20180110155832.15928-1-vladislav.valtchev@gmail.com> References: <20180110155832.15928-1-vladislav.valtchev@gmail.com> Sender: linux-trace-devel-owner@vger.kernel.org List-ID: Content-Length: 4050 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) --- 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 From patchwork Wed Jan 10 15:58:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vladislav Valtchev (VMware)" X-Patchwork-Id: 10758463 Return-Path: linux-trace-devel-owner@vger.kernel.org Received: from mail-wr0-f194.google.com ([209.85.128.194]:32948 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964976AbeAJP7C (ORCPT ); Wed, 10 Jan 2018 10:59:02 -0500 Received: by mail-wr0-f194.google.com with SMTP id p6so17824163wrd.0 for ; Wed, 10 Jan 2018 07:59:01 -0800 (PST) From: "Vladislav Valtchev (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, "Vladislav Valtchev (VMware)" Subject: [PATCH 6/6] trace-cmd: Make the GUI targets buildable out-of-tree Date: Wed, 10 Jan 2018 17:58:32 +0200 Message-Id: <20180110155832.15928-7-vladislav.valtchev@gmail.com> In-Reply-To: <20180110155832.15928-1-vladislav.valtchev@gmail.com> References: <20180110155832.15928-1-vladislav.valtchev@gmail.com> Sender: linux-trace-devel-owner@vger.kernel.org List-ID: Content-Length: 4606 This patch allows the GUI targets to be buildable out-of-tree when the 'O' variable is set at command line while invoking make. With this final patch, the out-of-tree build of all targets works. Signed-off-by: Vladislav Valtchev (VMware) --- Makefile | 9 +++++---- kernel-shark/Makefile | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 88f252e..e9fe243 100644 --- a/Makefile +++ b/Makefile @@ -189,6 +189,7 @@ INCLUDES += -I$(src)/lib/trace-cmd/include INCLUDES += -I$(src)/kernel-shark/include INCLUDES += -I$(src)/tracecmd/include INCLUDES += -I$(obj)/tracecmd/include +INCLUDES += -I$(obj)/kernel-shark/include include $(src)/features.mk @@ -228,7 +229,7 @@ LIBS += -laudit endif # Append required CFLAGS -override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ) $(VAR_DIR) +override CFLAGS += $(INCLUDES) $(PLUGIN_DIR_SQ) $(VAR_DIR) override CFLAGS += $(udis86-flags) $(blk-flags) @@ -252,13 +253,13 @@ trace-cmd: force $(LIBTRACEEVENT_STATIC) $(LIBTRACECMD_STATIC) $(Q)$(MAKE) -C $(src)/tracecmd $(obj)/tracecmd/$@ kernelshark: force $(CMD_TARGETS) - $(Q)$(MAKE) -C $(src)/kernel-shark $@ + $(Q)$(MAKE) -C $(src)/kernel-shark $(obj)/kernel-shark/$@ trace-view: force $(CMD_TARGETS) - $(Q)$(MAKE) -C $(src)/kernel-shark $@ + $(Q)$(MAKE) -C $(src)/kernel-shark $(obj)/kernel-shark/$@ trace-graph: force $(CMD_TARGETS) - $(Q)$(MAKE) -C $(src)/kernel-shark $@ + $(Q)$(MAKE) -C $(src)/kernel-shark $(obj)/kernel-shark/$@ $(LIBTRACEEVENT_SHARED): force $(Q)$(MAKE) -C $(src)/lib/traceevent $@ diff --git a/kernel-shark/Makefile b/kernel-shark/Makefile index 8e3ba8b..8576f3d 100644 --- a/kernel-shark/Makefile +++ b/kernel-shark/Makefile @@ -5,6 +5,8 @@ PATCHLEVEL = 2 EXTRAVERSION = KERNELSHARK_VERSION = $(VERSION).$(PATCHLEVEL).$(EXTRAVERSION) +bdir:=$(obj)/kernel-shark + BUILDGUI := 1 include $(src)/scripts/utils.mk @@ -21,9 +23,9 @@ CONFIG_LIBS = $(shell pkg-config --libs $(PACKAGES)) CONFIG_FLAGS += $(HELP_DIR_SQ) -KS_VERSION := $(obj)/kernel-shark/include/ks_version.h +KS_VERSION := $(bdir)/include/ks_version.h -GUI_TARGETS = $(KS_VERSION) trace-graph trace-view kernelshark +GUI_TARGETS = $(KS_VERSION) $(bdir)/trace-graph $(bdir)/trace-view $(bdir)/kernelshark TRACE_GUI_OBJS = trace-filter.o trace-compat.o trace-filter-hash.o \ trace-dialog.o trace-xml.o @@ -34,16 +36,17 @@ TRACE_GRAPH_MAIN_OBJS = trace-graph-main.o $(TRACE_GRAPH_OBJS) $(TRACE_GUI_OBJS) KERNEL_SHARK_OBJS = $(TRACE_VIEW_OBJS) $(TRACE_GRAPH_OBJS) $(TRACE_GUI_OBJS) \ trace-capture.o kernel-shark.o +KERNEL_SHARK_OBJS := $(KERNEL_SHARK_OBJS:%.o=$(bdir)/%.o) +TRACE_VIEW_MAIN_OBJS := $(TRACE_VIEW_MAIN_OBJS:%.o=$(bdir)/%.o) +TRACE_GRAPH_MAIN_OBJS := $(TRACE_GRAPH_MAIN_OBJS:%.o=$(bdir)/%.o) + ALL_OBJS = $(KERNEL_SHARK_OBJS) $(TRACE_VIEW_MAIN_OBJS) $(TRACE_GRAPH_MAIN_OBJS) PIC_OBJS = $(TRACE_VIEW_OBJS) all_objs := $(sort $(ALL_OBJS)) pic_objs = $(sort $(PIC_OBJS)) -all_deps := $(all_objs:%.o=.%.d) +all_deps := $(all_objs:$(bdir)/%.o=$(bdir)/.%.d) -# Temporary HACK! -# This hack is OK only until the non-gui builds do not have any config_includes -# nor config flags. In case they do, keeping this hack might be a problem. override CFLAGS += $(CONFIG_INCLUDES) $(CONFIG_FLAGS) LIBS += -L$(LIBTRACEEVENT_DIR) -L$(LIBTRACECMD_DIR) @@ -51,29 +54,38 @@ LIBS += -ltracecmd -ltraceevent -ldl all: $(GUI_TARGETS) -$(KS_VERSION): force +$(bdir): + @mkdir -p $(bdir) + +$(bdir)/include: | $(bdir) + @mkdir -p $(bdir)/include + +$(all_objs): | $(bdir) +$(all_deps): | $(bdir) + +$(KS_VERSION): force | $(bdir)/include $(Q)$(call update_version.h) -kernelshark: $(KERNEL_SHARK_OBJS) +$(bdir)/kernelshark: $(KERNEL_SHARK_OBJS) $(Q)$(do_app_build) -trace-view: $(TRACE_VIEW_MAIN_OBJS) +$(bdir)/trace-view: $(TRACE_VIEW_MAIN_OBJS) $(Q)$(do_app_build) -trace-graph: $(TRACE_GRAPH_MAIN_OBJS) +$(bdir)/trace-graph: $(TRACE_GRAPH_MAIN_OBJS) $(Q)$(do_app_build) $(pic_objs): GENERATE_PIC := 1 -%.o: %.c +$(bdir)/%.o: %.c $(Q)$(call do_compile) -$(all_deps): .%.d: %.c +$(all_deps): $(bdir)/.%.d: %.c $(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@ $(all_deps): $(KS_VERSION) -$(all_objs): %.o : .%.d +$(all_objs): $(bdir)/%.o : $(bdir)/.%.d dep_includes := $(wildcard $(DEPS)) @@ -82,7 +94,7 @@ ifneq ($(dep_includes),) endif clean: - $(RM) *.a *.so *.o .*.d $(GUI_TARGETS) + $(RM) $(bdir)/*.a $(bdir)/*.so $(bdir)/*.o $(bdir)/.*.d $(GUI_TARGETS) force: .PHONY: clean