Skip to contentSkip to conversation

trace-cmd: restructure the project's source tree

PATCH In review Vladislav Valtchev (VMware) 2 participants 32 messages Feb 6, 2018 – Feb 8, 2018 Kbuild

lore
Share & tools
lore
#0 lore raw

v2 cover trace-cmd: restructure the project's source tree

This series restructures trace-cmd's source tree in a way that each component inside the repo has its own directory. Now the two libraries, the GUI apps, the plugins, the python C modules, the trace-cmd's application and all of their headers are organized in dedicated directories. Almost all of the effort in this series has been spent on updating the build system to support the new structure. The side-effect of that is a simpler and easier to maintain build system.

NOTE: this rebased v2 series embeds now the previous mini-series called "trace-cmd: Make out-of-tree builds to work" which, as the title suggests, restores the out-of-tree build feature that is currently broken on the master branch.

Vladislav Valtchev (VMware) (24):
trace-cmd: Rename libparsevent to libtraceevent
trace-cmd: Move libtraceevent headers in include/traceevent
trace-cmd: Move trace-cmd headers in include/trace-cmd
trace-cmd: Move event-utils.h in lib/traceevent/include
trace-cmd: Extract part of Makefile in scripts/utils.mk
trace-cmd: Move libtraceevent *.c files in lib/traceevent
trace-cmd: Move trace-hash-local.h in lib/trace-cmd/include
trace-cmd: Move libtracecmd *.c files in lib/trace-cmd
trace-cmd: Move GUI headers in kernel-shark/include
trace-cmd: Move GUI *.c files in kernel-shark/
trace-cmd: Move plugin_* files in plugins/
trace-cmd: Fix the broken target ctracecmdgui.so
trace-cmd: Move python-related files in python/
trace-cmd: Move tracecmd headers in tracecmd/include
trace-cmd: Move version.h in include/
trace-cmd: Move trace-cmd app files in tracecmd/
trace-cmd: Fix the logic behind SWIG_DEFINED in the Makefile
trace-cmd: Make the build to tell when python-dev is missing
trace-cmd: Make libtraceevent builable out-of-tree
trace-cmd: Make the plugins buildable out-of-tree
trace-cmd: Make libtracecmd buildable out-of-tree
trace-cmd: Make the trace-cmd target buildable out-of-tree
trace-cmd: Make the python targets buildable out-of-tree
trace-cmd: Make the GUI targets buildable out-of-tree

 Makefile                                           | 543 +++++----------------
 trace-cmd.h => include/trace-cmd/trace-cmd.h       |   0
 trace-hash.h => include/trace-cmd/trace-hash.h     |   0
 event-parse.h => include/traceevent/event-parse.h  |   0
 kbuffer.h => include/traceevent/kbuffer.h          |   0
 version.h => include/version.h                     |   0
 kernel-shark/Makefile                              | 100 ++++
 cpu.h => kernel-shark/include/cpu.h                |   0
 .../include/kernel-shark.h                         |   0
 .../include/kshark-plugin.h                        |   0
 .../include/trace-capture.h                        |   0
 .../include/trace-compat.h                         |   0
 .../include/trace-filter-hash.h                    |   0
 .../include/trace-filter.h                         |   0
 .../include/trace-graph.h                          |   0
 trace-gui.h => kernel-shark/include/trace-gui.h    |   0
 .../include/trace-view-store.h                     |   0
 trace-view.h => kernel-shark/include/trace-view.h  |   0
 trace-xml.h => kernel-shark/include/trace-xml.h    |   0
 kernel-shark.c => kernel-shark/kernel-shark.c      |   0
 trace-capture.c => kernel-shark/trace-capture.c    |   0
 trace-compat.c => kernel-shark/trace-compat.c      |   0
 trace-dialog.c => kernel-shark/trace-dialog.c      |   0
 .../trace-filter-hash.c                            |   0
 trace-filter.c => kernel-shark/trace-filter.c      |   0
 .../trace-graph-main.c                             |   0
 trace-graph.c => kernel-shark/trace-graph.c        |   0
 trace-plot-cpu.c => kernel-shark/trace-plot-cpu.c  |   0
 .../trace-plot-task.c                              |   0
 trace-plot.c => kernel-shark/trace-plot.c          |   0
 .../trace-view-main.c                              |   0
 .../trace-view-store.c                             |   0
 trace-view.c => kernel-shark/trace-view.c          |   0
 trace-xml.c => kernel-shark/trace-xml.c            |   0
 lib/trace-cmd/Makefile                             |  56 +++
 .../trace-cmd/include/trace-hash-local.h           |   0
 trace-blk-hack.c => lib/trace-cmd/trace-blk-hack.c |   0
 trace-ftrace.c => lib/trace-cmd/trace-ftrace.c     |   0
 trace-hash.c => lib/trace-cmd/trace-hash.c         |   0
 trace-hooks.c => lib/trace-cmd/trace-hooks.c       |   0
 trace-input.c => lib/trace-cmd/trace-input.c       |   0
 trace-recorder.c => lib/trace-cmd/trace-recorder.c |   0
 trace-util.c => lib/trace-cmd/trace-util.c         |   0
 lib/traceevent/Makefile                            |  54 ++
 event-parse.c => lib/traceevent/event-parse.c      |   0
 event-plugin.c => lib/traceevent/event-plugin.c    |   0
 .../traceevent/include/event-utils.h               |   0
 kbuffer-parse.c => lib/traceevent/kbuffer-parse.c  |   0
 parse-filter.c => lib/traceevent/parse-filter.c    |   0
 parse-utils.c => lib/traceevent/parse-utils.c      |   0
 str_error_r.c => lib/traceevent/str_error_r.c      |   0
 trace-seq.c => lib/traceevent/trace-seq.c          |   0
 plugins/Makefile                                   |  76 +++
 plugin_blk.c => plugins/plugin_blk.c               |   0
 plugin_cfg80211.c => plugins/plugin_cfg80211.c     |   0
 plugin_function.c => plugins/plugin_function.c     |   0
 plugin_hrtimer.c => plugins/plugin_hrtimer.c       |   0
 plugin_jbd2.c => plugins/plugin_jbd2.c             |   0
 plugin_kmem.c => plugins/plugin_kmem.c             |   0
 plugin_kvm.c => plugins/plugin_kvm.c               |   0
 plugin_mac80211.c => plugins/plugin_mac80211.c     |   0
 plugin_python.c => plugins/plugin_python.c         |   0
 .../plugin_sched_switch.c                          |   0
 plugin_scsi.c => plugins/plugin_scsi.c             |   0
 plugin_tlb.c => plugins/plugin_tlb.c               |   0
 plugin_xen.c => plugins/plugin_xen.c               |   0
 python/Makefile                                    |  44 ++
 ctracecmd.i => python/ctracecmd.i                  |   0
 ctracecmdgui.i => python/ctracecmdgui.i            |   0
 event-viewer.py => python/event-viewer.py          |   0
 tracecmd.py => python/tracecmd.py                  |   0
 tracecmdgui.py => python/tracecmdgui.py            |   0
 scripts/utils.mk                                   | 117 +++++
 tracecmd/Makefile                                  |  84 ++++
 bug.h => tracecmd/include/bug.h                    |   0
 list.h => tracecmd/include/list.h                  |   0
 .../include/trace-cmd-local.h                      |   0
 trace-local.h => tracecmd/include/trace-local.h    |   0
 trace-msg.h => tracecmd/include/trace-msg.h        |   0
 .../trace-check-events.c                           |   0
 trace-cmd.bash => tracecmd/trace-cmd.bash          |   0
 trace-cmd.c => tracecmd/trace-cmd.c                |   0
 trace-hist.c => tracecmd/trace-hist.c              |   0
 trace-list.c => tracecmd/trace-list.c              |   0
 trace-listen.c => tracecmd/trace-listen.c          |   0
 trace-mem.c => tracecmd/trace-mem.c                |   0
 trace-msg.c => tracecmd/trace-msg.c                |   0
 trace-output.c => tracecmd/trace-output.c          |   0
 trace-profile.c => tracecmd/trace-profile.c        |   0
 trace-read.c => tracecmd/trace-read.c              |   0
 trace-record.c => tracecmd/trace-record.c          |   0
 trace-restore.c => tracecmd/trace-restore.c        |   0
 trace-show.c => tracecmd/trace-show.c              |   0
 trace-snapshot.c => tracecmd/trace-snapshot.c      |   0
 trace-split.c => tracecmd/trace-split.c            |   0
 trace-stack.c => tracecmd/trace-stack.c            |   0
 trace-stat.c => tracecmd/trace-stat.c              |   0
 trace-stream.c => tracecmd/trace-stream.c          |   0
 trace-usage.c => tracecmd/trace-usage.c            |   0
 99 files changed, 664 insertions(+), 410 deletions(-)
 rename trace-cmd.h => include/trace-cmd/trace-cmd.h (100%)
 rename trace-hash.h => include/trace-cmd/trace-hash.h (100%)
 rename event-parse.h => include/traceevent/event-parse.h (100%)
 rename kbuffer.h => include/traceevent/kbuffer.h (100%)
 rename version.h => include/version.h (100%)
 create mode 100644 kernel-shark/Makefile
 rename cpu.h => kernel-shark/include/cpu.h (100%)
 rename kernel-shark.h => kernel-shark/include/kernel-shark.h (100%)
 rename kshark-plugin.h => kernel-shark/include/kshark-plugin.h (100%)
 rename trace-capture.h => kernel-shark/include/trace-capture.h (100%)
 rename trace-compat.h => kernel-shark/include/trace-compat.h (100%)
 rename trace-filter-hash.h => kernel-shark/include/trace-filter-hash.h (100%)
 rename trace-filter.h => kernel-shark/include/trace-filter.h (100%)
 rename trace-graph.h => kernel-shark/include/trace-graph.h (100%)
 rename trace-gui.h => kernel-shark/include/trace-gui.h (100%)
 rename trace-view-store.h => kernel-shark/include/trace-view-store.h (100%)
 rename trace-view.h => kernel-shark/include/trace-view.h (100%)
 rename trace-xml.h => kernel-shark/include/trace-xml.h (100%)
 rename kernel-shark.c => kernel-shark/kernel-shark.c (100%)
 rename trace-capture.c => kernel-shark/trace-capture.c (100%)
 rename trace-compat.c => kernel-shark/trace-compat.c (100%)
 rename trace-dialog.c => kernel-shark/trace-dialog.c (100%)
 rename trace-filter-hash.c => kernel-shark/trace-filter-hash.c (100%)
 rename trace-filter.c => kernel-shark/trace-filter.c (100%)
 rename trace-graph-main.c => kernel-shark/trace-graph-main.c (100%)
 rename trace-graph.c => kernel-shark/trace-graph.c (100%)
 rename trace-plot-cpu.c => kernel-shark/trace-plot-cpu.c (100%)
 rename trace-plot-task.c => kernel-shark/trace-plot-task.c (100%)
 rename trace-plot.c => kernel-shark/trace-plot.c (100%)
 rename trace-view-main.c => kernel-shark/trace-view-main.c (100%)
 rename trace-view-store.c => kernel-shark/trace-view-store.c (100%)
 rename trace-view.c => kernel-shark/trace-view.c (100%)
 rename trace-xml.c => kernel-shark/trace-xml.c (100%)
 create mode 100644 lib/trace-cmd/Makefile
 rename trace-hash-local.h => lib/trace-cmd/include/trace-hash-local.h (100%)
 rename trace-blk-hack.c => lib/trace-cmd/trace-blk-hack.c (100%)
 rename trace-ftrace.c => lib/trace-cmd/trace-ftrace.c (100%)
 rename trace-hash.c => lib/trace-cmd/trace-hash.c (100%)
 rename trace-hooks.c => lib/trace-cmd/trace-hooks.c (100%)
 rename trace-input.c => lib/trace-cmd/trace-input.c (100%)
 rename trace-recorder.c => lib/trace-cmd/trace-recorder.c (100%)
 rename trace-util.c => lib/trace-cmd/trace-util.c (100%)
 create mode 100644 lib/traceevent/Makefile
 rename event-parse.c => lib/traceevent/event-parse.c (100%)
 rename event-plugin.c => lib/traceevent/event-plugin.c (100%)
 rename event-utils.h => lib/traceevent/include/event-utils.h (100%)
 rename kbuffer-parse.c => lib/traceevent/kbuffer-parse.c (100%)
 rename parse-filter.c => lib/traceevent/parse-filter.c (100%)
 rename parse-utils.c => lib/traceevent/parse-utils.c (100%)
 rename str_error_r.c => lib/traceevent/str_error_r.c (100%)
 rename trace-seq.c => lib/traceevent/trace-seq.c (100%)
 create mode 100644 plugins/Makefile
 rename plugin_blk.c => plugins/plugin_blk.c (100%)
 rename plugin_cfg80211.c => plugins/plugin_cfg80211.c (100%)
 rename plugin_function.c => plugins/plugin_function.c (100%)
 rename plugin_hrtimer.c => plugins/plugin_hrtimer.c (100%)
 rename plugin_jbd2.c => plugins/plugin_jbd2.c (100%)
 rename plugin_kmem.c => plugins/plugin_kmem.c (100%)
 rename plugin_kvm.c => plugins/plugin_kvm.c (100%)
 rename plugin_mac80211.c => plugins/plugin_mac80211.c (100%)
 rename plugin_python.c => plugins/plugin_python.c (100%)
 rename plugin_sched_switch.c => plugins/plugin_sched_switch.c (100%)
 rename plugin_scsi.c => plugins/plugin_scsi.c (100%)
 rename plugin_tlb.c => plugins/plugin_tlb.c (100%)
 rename plugin_xen.c => plugins/plugin_xen.c (100%)
 create mode 100644 python/Makefile
 rename ctracecmd.i => python/ctracecmd.i (100%)
 rename ctracecmdgui.i => python/ctracecmdgui.i (100%)
 rename event-viewer.py => python/event-viewer.py (100%)
 rename tracecmd.py => python/tracecmd.py (100%)
 rename tracecmdgui.py => python/tracecmdgui.py (100%)
 create mode 100644 scripts/utils.mk
 create mode 100644 tracecmd/Makefile
 rename bug.h => tracecmd/include/bug.h (100%)
 rename list.h => tracecmd/include/list.h (100%)
 rename trace-cmd-local.h => tracecmd/include/trace-cmd-local.h (100%)
 rename trace-local.h => tracecmd/include/trace-local.h (100%)
 rename trace-msg.h => tracecmd/include/trace-msg.h (100%)
 rename trace-check-events.c => tracecmd/trace-check-events.c (100%)
 rename trace-cmd.bash => tracecmd/trace-cmd.bash (100%)
 rename trace-cmd.c => tracecmd/trace-cmd.c (100%)
 rename trace-hist.c => tracecmd/trace-hist.c (100%)
 rename trace-list.c => tracecmd/trace-list.c (100%)
 rename trace-listen.c => tracecmd/trace-listen.c (100%)
 rename trace-mem.c => tracecmd/trace-mem.c (100%)
 rename trace-msg.c => tracecmd/trace-msg.c (100%)
 rename trace-output.c => tracecmd/trace-output.c (100%)
 rename trace-profile.c => tracecmd/trace-profile.c (100%)
 rename trace-read.c => tracecmd/trace-read.c (100%)
 rename trace-record.c => tracecmd/trace-record.c (100%)
 rename trace-restore.c => tracecmd/trace-restore.c (100%)
 rename trace-show.c => tracecmd/trace-show.c (100%)
 rename trace-snapshot.c => tracecmd/trace-snapshot.c (100%)
 rename trace-split.c => tracecmd/trace-split.c (100%)
 rename trace-stack.c => tracecmd/trace-stack.c (100%)
 rename trace-stat.c => tracecmd/trace-stat.c (100%)
 rename trace-stream.c => tracecmd/trace-stream.c (100%)
 rename trace-usage.c => tracecmd/trace-usage.c (100%)
Signature · 1 line
2.14.1
#1 lore raw

PATCH v2 1/24 trace-cmd: Rename libparsevent to libtraceevent

This simple patch renames libparsevent to libtraceevent in order to trace-cmd to be consistent with the kernel.

---
 Makefile | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
Makefile +7 -7
index a5d2c38..a3a60bf 100644
@@ -351,8 +351,8 @@ 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
 
-PEVENT_LIB_OBJS = event-parse.o trace-seq.o parse-filter.o parse-utils.o str_error_r.o
-TCMD_LIB_OBJS = $(PEVENT_LIB_OBJS) trace-util.o trace-input.o trace-ftrace.o \
+TRACEEVENT_LIB_OBJS = event-parse.o trace-seq.o parse-filter.o parse-utils.o str_error_r.o
+TCMD_LIB_OBJS = $(TRACEEVENT_LIB_OBJS) trace-util.o trace-input.o trace-ftrace.o \
 			trace-output.o trace-recorder.o \
 			trace-usage.o trace-blk-hack.o \
 			kbuffer-parse.o event-plugin.o trace-hooks.o \
@@ -377,7 +377,7 @@ PLUGINS := $(PLUGIN_OBJS:.o=.so)
 ALL_OBJS = $(TRACE_CMD_OBJS) $(KERNEL_SHARK_OBJS) $(TRACE_VIEW_MAIN_OBJS) \
 	$(TRACE_GRAPH_MAIN_OBJS) $(TCMD_LIB_OBJS) $(PLUGIN_OBJS)
 
-CMD_TARGETS = trace_plugin_dir trace_python_dir tc_version.h libparsevent.a $(LIB_FILE) \
+CMD_TARGETS = trace_plugin_dir trace_python_dir tc_version.h libtraceevent.a $(LIB_FILE) \
 	trace-cmd  $(PLUGINS) $(BUILD_PYTHON)
 
 GUI_TARGETS = ks_version.h trace-graph trace-view kernelshark
@@ -423,10 +423,10 @@ kernelshark: libtracecmd.a
 trace-view: libtracecmd.a
 trace-graph: libtracecmd.a
 
-libparsevent.so: $(PEVENT_LIB_OBJS)
+libtraceevent.so: $(TRACEEVENT_LIB_OBJS)
 	$(Q)$(do_compile_shared_library)
 
-libparsevent.a: $(PEVENT_LIB_OBJS)
+libtraceevent.a: $(TRACEEVENT_LIB_OBJS)
 	$(Q)$(do_build_static_lib)
 
 $(TCMD_LIB_OBJS): %.o: $(src)/%.c
@@ -438,7 +438,7 @@ libtracecmd.so: $(TCMD_LIB_OBJS)
 libtracecmd.a: $(TCMD_LIB_OBJS)
 	$(Q)$(do_build_static_lib)
 
-libs: libtracecmd.so libparsevent.so
+libs: libtracecmd.so libtraceevent.so
 
 trace-util.o: trace_plugin_dir
 
@@ -609,7 +609,7 @@ install_gui: install_cmd gui
 
 install_libs: libs
 	$(Q)$(call do_install,libtracecmd.so,$(libdir_SQ))
-	$(Q)$(call do_install,libparsevent.so,$(libdir_SQ))
+	$(Q)$(call do_install,libtraceevent.so,$(libdir_SQ))
 	$(Q)$(call do_install,event-parse.h,$(includedir_SQ))
 	$(Q)$(call do_install,trace-cmd.h,$(includedir_SQ))
 
Signature · 1 line
2.14.1
#2 lore raw

PATCH v2 2/24 trace-cmd: Move libtraceevent headers in include/traceevent

In reply to Vladislav Valtchev (VMware)

This patch moves event-parse.h and kbuffer.h in include/traceevent as part of a bigger restructuring plan of trace-cmd's code base. In this case, the new directory will be the "public headers" directory of the traceevent library.

---
 Makefile                                          | 5 +++--
 event-parse.h => include/traceevent/event-parse.h | 0
 kbuffer.h => include/traceevent/kbuffer.h         | 0
 3 files changed, 3 insertions(+), 2 deletions(-)
 rename event-parse.h => include/traceevent/event-parse.h (100%)
 rename kbuffer.h => include/traceevent/kbuffer.h (100%)
Makefile +3 -2
index a3a60bf..b79f91f 100644
@@ -238,6 +238,7 @@ TRACECMD_VERSION = $(TC_VERSION).$(TC_PATCHLEVEL).$(TC_EXTRAVERSION)
 KERNELSHARK_VERSION = $(KS_VERSION).$(KS_PATCHLEVEL).$(KS_EXTRAVERSION)
 
 INCLUDES = -I. -I ./include -I $(srctree)/../../include $(CONFIG_INCLUDES)
+INCLUDES += -I$(src)/include/traceevent
 
 include $(src)/features.mk
 
@@ -610,7 +611,7 @@ install_gui: install_cmd gui
 install_libs: libs
 	$(Q)$(call do_install,libtracecmd.so,$(libdir_SQ))
 	$(Q)$(call do_install,libtraceevent.so,$(libdir_SQ))
-	$(Q)$(call do_install,event-parse.h,$(includedir_SQ))
+	$(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_SQ))
 	$(Q)$(call do_install,trace-cmd.h,$(includedir_SQ))
 
 doc:
@@ -640,7 +641,7 @@ PYTHON_LDFLAGS = `pkg-config --libs $(PYTHON_VERS)` \
 PYGTK_CFLAGS = `pkg-config --cflags pygtk-2.0`
 
 ctracecmd.so: $(TCMD_LIB_OBJS) ctracecmd.i
-	swig -Wall -python -noproxy ctracecmd.i
+	swig -Wall -python -noproxy -I$(src)/include/traceevent ctracecmd.i
 	$(CC) -fpic -c $(CPPFLAGS) $(CFLAGS) $(PYTHON_INCLUDES)  ctracecmd_wrap.c
 	$(CC) --shared $(TCMD_LIB_OBJS) $(LDFLAGS) ctracecmd_wrap.o -o ctracecmd.so
 
include/traceevent/event-parse.h renamed from event-parse.h +0 -0
similarity index 100%
rename from event-parse.h
rename to include/traceevent/event-parse.h
include/traceevent/kbuffer.h renamed from kbuffer.h +0 -0
similarity index 100%
rename from kbuffer.h
rename to include/traceevent/kbuffer.h
Signature · 1 line
2.14.1
#3 lore raw

PATCH v2 3/24 trace-cmd: Move trace-cmd headers in include/trace-cmd

In reply to Vladislav Valtchev (VMware)

This patch moves trace-cmd.h and trace-hash.h in include/trace-cmd as part of a bigger restructuring plan of trace-cmd's code base. In this case, the new directory will be the "public headers" directory of the trace-cmd library.

---
 Makefile                                       | 5 +++--
 trace-cmd.h => include/trace-cmd/trace-cmd.h   | 0
 trace-hash.h => include/trace-cmd/trace-hash.h | 0
 3 files changed, 3 insertions(+), 2 deletions(-)
 rename trace-cmd.h => include/trace-cmd/trace-cmd.h (100%)
 rename trace-hash.h => include/trace-cmd/trace-hash.h (100%)
Makefile +3 -2
index b79f91f..1a25aa2 100644
@@ -239,6 +239,7 @@ KERNELSHARK_VERSION = $(KS_VERSION).$(KS_PATCHLEVEL).$(KS_EXTRAVERSION)
 
 INCLUDES = -I. -I ./include -I $(srctree)/../../include $(CONFIG_INCLUDES)
 INCLUDES += -I$(src)/include/traceevent
+INCLUDES += -I$(src)/include/trace-cmd
 
 include $(src)/features.mk
 
@@ -612,7 +613,7 @@ install_libs: libs
 	$(Q)$(call do_install,libtracecmd.so,$(libdir_SQ))
 	$(Q)$(call do_install,libtraceevent.so,$(libdir_SQ))
 	$(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_SQ))
-	$(Q)$(call do_install,trace-cmd.h,$(includedir_SQ))
+	$(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ))
 
 doc:
 	$(MAKE) -C $(src)/Documentation all
@@ -641,7 +642,7 @@ PYTHON_LDFLAGS = `pkg-config --libs $(PYTHON_VERS)` \
 PYGTK_CFLAGS = `pkg-config --cflags pygtk-2.0`
 
 ctracecmd.so: $(TCMD_LIB_OBJS) ctracecmd.i
-	swig -Wall -python -noproxy -I$(src)/include/traceevent ctracecmd.i
+	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 $(TCMD_LIB_OBJS) $(LDFLAGS) ctracecmd_wrap.o -o ctracecmd.so
 
include/trace-cmd/trace-cmd.h renamed from trace-cmd.h +0 -0
similarity index 100%
rename from trace-cmd.h
rename to include/trace-cmd/trace-cmd.h
include/trace-cmd/trace-hash.h renamed from trace-hash.h +0 -0
similarity index 100%
rename from trace-hash.h
rename to include/trace-cmd/trace-hash.h
Signature · 1 line
2.14.1
#4 lore raw

PATCH v2 4/24 trace-cmd: Move event-utils.h in lib/traceevent/include

In reply to Vladislav Valtchev (VMware)

This patch moves event-utils.h in lib/traceevent/include as part of a bigger restructuring plan of trace-cmd's code base. In this case event-utils.h has been moved into the private headers directory the traceevent library. In the next steps, the source files of the traceevent lib will be moved there as well.

---
 Makefile                                              | 1 +
 event-utils.h => lib/traceevent/include/event-utils.h | 0
 2 files changed, 1 insertion(+)
 rename event-utils.h => lib/traceevent/include/event-utils.h (100%)
Makefile +1 -0
index 1a25aa2..3c21a27 100644
@@ -240,6 +240,7 @@ KERNELSHARK_VERSION = $(KS_VERSION).$(KS_PATCHLEVEL).$(KS_EXTRAVERSION)
 INCLUDES = -I. -I ./include -I $(srctree)/../../include $(CONFIG_INCLUDES)
 INCLUDES += -I$(src)/include/traceevent
 INCLUDES += -I$(src)/include/trace-cmd
+INCLUDES += -I$(src)/lib/traceevent/include
 
 include $(src)/features.mk
 
lib/traceevent/include/event-utils.h renamed from event-utils.h +0 -0
similarity index 100%
rename from event-utils.h
rename to lib/traceevent/include/event-utils.h
Signature · 1 line
2.14.1
#5 lore raw

PATCH v2 5/24 trace-cmd: Extract part of Makefile in scripts/utils.mk

In reply to Vladislav Valtchev (VMware)

This patch extracts useful functions for Makefile in order to allow the new Makefiles that will be introduced in the next steps to reuse them.

---
 Makefile         | 57 +++----------------------------------------------
 scripts/utils.mk | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 54 deletions(-)
 create mode 100644 scripts/utils.mk
Makefile +3 -54
index 3c21a27..3b5045e 100644
@@ -204,10 +204,6 @@ VERSION		= $(KS_VERSION)
 PATCHLEVEL	= $(KS_PATCHLEVEL)
 EXTRAVERSION	= $(KS_EXTRAVERSION)
 
-GUI		= 'GUI '
-GOBJ		= $@
-GSPACE		=
-
 REBUILD_GUI	= /bin/true
 G		=
 N 		= @/bin/true ||
@@ -223,10 +219,6 @@ VERSION		= $(TC_VERSION)
 PATCHLEVEL	= $(TC_PATCHLEVEL)
 EXTRAVERSION	= $(TC_EXTRAVERSION)
 
-GUI		=
-GSPACE		= "    "
-GOBJ		= $(GSPACE)$@
-
 REBUILD_GUI	= $(MAKE) -f $(src)/Makefile BUILDGUI=1 $@
 G		= $(REBUILD_GUI); /bin/true ||
 N		=
@@ -234,6 +226,9 @@ endif
 
 export Q VERBOSE
 
+# Include the utils
+include scripts/utils.mk
+
 TRACECMD_VERSION = $(TC_VERSION).$(TC_PATCHLEVEL).$(TC_EXTRAVERSION)
 KERNELSHARK_VERSION = $(KS_VERSION).$(KS_PATCHLEVEL).$(KS_EXTRAVERSION)
 
@@ -280,52 +275,6 @@ endif
 override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ) $(VAR_DIR)
 override CFLAGS += $(udis86-flags) $(blk-flags)
 
-ifeq ($(VERBOSE),1)
-  Q =
-  print_compile =
-  print_app_build =
-  print_fpic_compile =
-  print_shared_lib_compile =
-  print_plugin_obj_compile =
-  print_plugin_build =
-  print_install =
-else
-  Q = @
-  print_compile =		echo '  $(GUI)COMPILE            '$(GOBJ);
-  print_app_build =		echo '  $(GUI)BUILD              '$(GOBJ);
-  print_fpic_compile =		echo '  $(GUI)COMPILE FPIC       '$(GOBJ);
-  print_shared_lib_compile =	echo '  $(GUI)COMPILE SHARED LIB '$(GOBJ);
-  print_plugin_obj_compile =	echo '  $(GUI)COMPILE PLUGIN OBJ '$(GOBJ);
-  print_plugin_build =		echo '  $(GUI)BUILD PLUGIN       '$(GOBJ);
-  print_static_lib_build =	echo '  $(GUI)BUILD STATIC LIB   '$(GOBJ);
-  print_install =		echo '  $(GUI)INSTALL     '$(GSPACE)$1'	to	$(DESTDIR_SQ)$2';
-endif
-
-do_fpic_compile =					\
-	($(print_fpic_compile)				\
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $(EXT) -fPIC $< -o $@)
-
-do_app_build =						\
-	($(print_app_build)				\
-	$(CC) $^ -rdynamic -o $@ $(LDFLAGS) $(CONFIG_LIBS) $(LIBS))
-
-do_compile_shared_library =			\
-	($(print_shared_lib_compile)		\
-	$(CC) --shared $^ -o $@)
-
-do_compile_plugin_obj =				\
-	($(print_plugin_obj_compile)		\
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $<)
-
-do_plugin_build =				\
-	($(print_plugin_build)			\
-	$(CC) $(CFLAGS) $(LDFLAGS) -shared -nostartfiles -o $@ $<)
-
-do_build_static_lib =				\
-	($(print_static_lib_build)		\
-	$(RM) $@;  $(AR) rcs $@ $^)
-
-
 define check_gui
 	if [ $(BUILDGUI) -ne 1 -a ! -z "$(filter $(gui_objs),$(@))" ];	then	\
 		$(REBUILD_GUI);							\
scripts/utils.mk new file +64 -0

64 lines not on this page · raw message

Signature · 1 line
2.14.1
#6 lore raw

PATCH v2 6/24 trace-cmd: Move libtraceevent *.c files in lib/traceevent

In reply to Vladislav Valtchev (VMware)

This patch moves all the files belonging to the traceevent lib in a dedicated directory. The build system has been updated to support this by introducing a Makefile in lib/traceevent and by making the parent Makefile to run it with the classic recursive make approach.

---
 Makefile                                          | 42 ++++++++++++---------
 lib/traceevent/Makefile                           | 45 +++++++++++++++++++++++
 event-parse.c => lib/traceevent/event-parse.c     |  0
 event-plugin.c => lib/traceevent/event-plugin.c   |  0
 kbuffer-parse.c => lib/traceevent/kbuffer-parse.c |  0
 parse-filter.c => lib/traceevent/parse-filter.c   |  0
 parse-utils.c => lib/traceevent/parse-utils.c     |  0
 str_error_r.c => lib/traceevent/str_error_r.c     |  0
 trace-seq.c => lib/traceevent/trace-seq.c         |  0
 9 files changed, 70 insertions(+), 17 deletions(-)
 create mode 100644 lib/traceevent/Makefile
 rename event-parse.c => lib/traceevent/event-parse.c (100%)
 rename event-plugin.c => lib/traceevent/event-plugin.c (100%)
 rename kbuffer-parse.c => lib/traceevent/kbuffer-parse.c (100%)
 rename parse-filter.c => lib/traceevent/parse-filter.c (100%)
 rename parse-utils.c => lib/traceevent/parse-utils.c (100%)
 rename str_error_r.c => lib/traceevent/str_error_r.c (100%)
 rename trace-seq.c => lib/traceevent/trace-seq.c (100%)
Makefile +25 -17
index 3b5045e..c18bf2f 100644
@@ -181,7 +181,11 @@ bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
 plugin_dir_SQ = $(subst ','\'',$(plugin_dir))
 python_dir_SQ = $(subst ','\'',$(python_dir))
 
-LIBS = -L. -ltracecmd -ldl
+LIBS = -L. -ldl
+LIBTRACEEVENT_DIR = $(obj)/lib/traceevent
+LIBTRACEEVENT_STATIC = $(LIBTRACEEVENT_DIR)/libtraceevent.a
+LIBTRACEEVENT_SHARED = $(LIBTRACEEVENT_DIR)/libtraceevent.so
+
 LIB_FILE = libtracecmd.a
 
 PACKAGES= gtk+-2.0 libxml-2.0 gthread-2.0
@@ -232,7 +236,7 @@ include scripts/utils.mk
 TRACECMD_VERSION = $(TC_VERSION).$(TC_PATCHLEVEL).$(TC_EXTRAVERSION)
 KERNELSHARK_VERSION = $(KS_VERSION).$(KS_PATCHLEVEL).$(KS_EXTRAVERSION)
 
-INCLUDES = -I. -I ./include -I $(srctree)/../../include $(CONFIG_INCLUDES)
+INCLUDES = -I$(src) -I $(src)/include -I $(srctree)/../../include $(CONFIG_INCLUDES)
 INCLUDES += -I$(src)/include/traceevent
 INCLUDES += -I$(src)/include/trace-cmd
 INCLUDES += -I$(src)/lib/traceevent/include
@@ -244,6 +248,8 @@ CFLAGS ?= -g -Wall
 CPPFLAGS ?=
 LDFLAGS ?=
 
+export CFLAGS
+
 # Required CFLAGS
 override CFLAGS += -D_GNU_SOURCE
 
@@ -303,12 +309,10 @@ 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
 
-TRACEEVENT_LIB_OBJS = event-parse.o trace-seq.o parse-filter.o parse-utils.o str_error_r.o
-TCMD_LIB_OBJS = $(TRACEEVENT_LIB_OBJS) trace-util.o trace-input.o trace-ftrace.o \
+TCMD_LIB_OBJS = trace-util.o trace-input.o trace-ftrace.o \
 			trace-output.o trace-recorder.o \
 			trace-usage.o trace-blk-hack.o \
-			kbuffer-parse.o event-plugin.o trace-hooks.o \
-			trace-msg.o
+			trace-hooks.o trace-msg.o
 
 PLUGIN_OBJS =
 PLUGIN_OBJS += plugin_jbd2.o
@@ -329,7 +333,7 @@ PLUGINS := $(PLUGIN_OBJS:.o=.so)
 ALL_OBJS = $(TRACE_CMD_OBJS) $(KERNEL_SHARK_OBJS) $(TRACE_VIEW_MAIN_OBJS) \
 	$(TRACE_GRAPH_MAIN_OBJS) $(TCMD_LIB_OBJS) $(PLUGIN_OBJS)
 
-CMD_TARGETS = trace_plugin_dir trace_python_dir tc_version.h libtraceevent.a $(LIB_FILE) \
+CMD_TARGETS = trace_plugin_dir trace_python_dir tc_version.h $(LIB_FILE) \
 	trace-cmd  $(PLUGINS) $(BUILD_PYTHON)
 
 GUI_TARGETS = ks_version.h trace-graph trace-view kernelshark
@@ -370,16 +374,19 @@ trace-view: $(TRACE_VIEW_MAIN_OBJS)
 trace-graph: $(TRACE_GRAPH_MAIN_OBJS)
 	$(Q)$(G)$(do_app_build)
 
-trace-cmd: libtracecmd.a
-kernelshark: libtracecmd.a
-trace-view: libtracecmd.a
-trace-graph: libtracecmd.a
+trace-cmd: libtracecmd.a $(LIBTRACEEVENT_STATIC)
+kernelshark: libtracecmd.a $(LIBTRACEEVENT_STATIC)
+trace-view: libtracecmd.a $(LIBTRACEEVENT_STATIC)
+trace-graph: libtracecmd.a $(LIBTRACEEVENT_STATIC)
 
-libtraceevent.so: $(TRACEEVENT_LIB_OBJS)
-	$(Q)$(do_compile_shared_library)
+$(LIBTRACEEVENT_SHARED): force
+	$(Q)$(MAKE) -C $(src)/lib/traceevent libtraceevent.so
 
-libtraceevent.a: $(TRACEEVENT_LIB_OBJS)
-	$(Q)$(do_build_static_lib)
+$(LIBTRACEEVENT_STATIC): force
+	$(Q)$(MAKE) -C $(src)/lib/traceevent libtraceevent.a
+
+libtraceevent.so: $(LIBTRACEEVENT_SHARED)
+libtraceevent.a: $(LIBTRACEEVENT_STATIC)
 
 $(TCMD_LIB_OBJS): %.o: $(src)/%.c
 	$(Q)$(do_fpic_compile)
@@ -390,7 +397,7 @@ libtracecmd.so: $(TCMD_LIB_OBJS)
 libtracecmd.a: $(TCMD_LIB_OBJS)
 	$(Q)$(do_build_static_lib)
 
-libs: libtracecmd.so libtraceevent.so
+libs: libtracecmd.so $(LIBTRACEEVENT_SHARED)
 
 trace-util.o: trace_plugin_dir
 
@@ -561,7 +568,7 @@ install_gui: install_cmd gui
 
 install_libs: libs
 	$(Q)$(call do_install,libtracecmd.so,$(libdir_SQ))
-	$(Q)$(call do_install,libtraceevent.so,$(libdir_SQ))
+	$(Q)$(call do_install,$(LIBTRACEEVENT_SHARED),$(libdir_SQ))
 	$(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_SQ))
 	$(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ))
 
@@ -577,6 +584,7 @@ install_doc:
 clean:
 	$(RM) *.o *~ $(TARGETS) *.a *.so ctracecmd_wrap.c .*.d
 	$(RM) tags TAGS cscope*
+	$(MAKE) -C $(src)/lib/traceevent clean
 
 
 ##### PYTHON STUFF #####
lib/traceevent/Makefile new file +45 -0

45 lines not on this page · raw message

lib/traceevent/event-parse.c renamed from event-parse.c +0 -0
similarity index 100%
rename from event-parse.c
rename to lib/traceevent/event-parse.c
lib/traceevent/event-plugin.c renamed from event-plugin.c +0 -0
similarity index 100%
rename from event-plugin.c
rename to lib/traceevent/event-plugin.c
lib/traceevent/kbuffer-parse.c renamed from kbuffer-parse.c +0 -0
similarity index 100%
rename from kbuffer-parse.c
rename to lib/traceevent/kbuffer-parse.c
lib/traceevent/parse-filter.c renamed from parse-filter.c +0 -0
similarity index 100%
rename from parse-filter.c
rename to lib/traceevent/parse-filter.c
lib/traceevent/parse-utils.c renamed from parse-utils.c +0 -0
similarity index 100%
rename from parse-utils.c
rename to lib/traceevent/parse-utils.c
lib/traceevent/str_error_r.c renamed from str_error_r.c +0 -0
similarity index 100%
rename from str_error_r.c
rename to lib/traceevent/str_error_r.c
lib/traceevent/trace-seq.c renamed from trace-seq.c +0 -0
similarity index 100%
rename from trace-seq.c
rename to lib/traceevent/trace-seq.c
Signature · 1 line
2.14.1
#7 lore raw

PATCH v2 7/24 trace-cmd: Move trace-hash-local.h in lib/trace-cmd/include

In reply to Vladislav Valtchev (VMware)

This patch moves trace-hash-local.h in lib/trace-cmd/include, as part of a bigger restructuring plan of trace-cmd's code base. In this case, the new directory in the "private headers" directory in the trace-cmd library. In the next step, the source files of that library will be moved in lib/trace-cmd.

---
 Makefile                                                       | 1 +
 trace-hash-local.h => lib/trace-cmd/include/trace-hash-local.h | 0
 2 files changed, 1 insertion(+)
 rename trace-hash-local.h => lib/trace-cmd/include/trace-hash-local.h (100%)
Makefile +1 -0
index c18bf2f..26b97e5 100644
@@ -240,6 +240,7 @@ INCLUDES = -I$(src) -I $(src)/include -I $(srctree)/../../include $(CONFIG_INCLU
 INCLUDES += -I$(src)/include/traceevent
 INCLUDES += -I$(src)/include/trace-cmd
 INCLUDES += -I$(src)/lib/traceevent/include
+INCLUDES += -I$(src)/lib/trace-cmd/include
 
 include $(src)/features.mk
 
lib/trace-cmd/include/trace-hash-local.h renamed from trace-hash-local.h +0 -0
similarity index 100%
rename from trace-hash-local.h
rename to lib/trace-cmd/include/trace-hash-local.h
Signature · 1 line
2.14.1
#8 lore raw

PATCH v2 8/24 trace-cmd: Move libtracecmd *.c files in lib/trace-cmd

In reply to Vladislav Valtchev (VMware)

This patch moves all the source files belonging to the trace-cmd library into the dedicated directory lib/trace-cmd. The build system has been updated to support this new directory structure by adding a dedicated Makefile in lib/trace-cmd and by making the parent Makefile to invoke it.

---
 Makefile                                           | 54 ++++++++++------------
 lib/trace-cmd/Makefile                             | 45 ++++++++++++++++++
 trace-blk-hack.c => lib/trace-cmd/trace-blk-hack.c |  0
 trace-ftrace.c => lib/trace-cmd/trace-ftrace.c     |  0
 trace-hash.c => lib/trace-cmd/trace-hash.c         |  0
 trace-hooks.c => lib/trace-cmd/trace-hooks.c       |  0
 trace-input.c => lib/trace-cmd/trace-input.c       |  0
 trace-recorder.c => lib/trace-cmd/trace-recorder.c |  0
 trace-util.c => lib/trace-cmd/trace-util.c         |  0
 9 files changed, 70 insertions(+), 29 deletions(-)
 create mode 100644 lib/trace-cmd/Makefile
 rename trace-blk-hack.c => lib/trace-cmd/trace-blk-hack.c (100%)
 rename trace-ftrace.c => lib/trace-cmd/trace-ftrace.c (100%)
 rename trace-hash.c => lib/trace-cmd/trace-hash.c (100%)
 rename trace-hooks.c => lib/trace-cmd/trace-hooks.c (100%)
 rename trace-input.c => lib/trace-cmd/trace-input.c (100%)
 rename trace-recorder.c => lib/trace-cmd/trace-recorder.c (100%)
 rename trace-util.c => lib/trace-cmd/trace-util.c (100%)
Makefile +25 -29
index 26b97e5..2c08162 100644
@@ -186,7 +186,9 @@ LIBTRACEEVENT_DIR = $(obj)/lib/traceevent
 LIBTRACEEVENT_STATIC = $(LIBTRACEEVENT_DIR)/libtraceevent.a
 LIBTRACEEVENT_SHARED = $(LIBTRACEEVENT_DIR)/libtraceevent.so
 
-LIB_FILE = libtracecmd.a
+LIBTRACECMD_DIR = $(obj)/lib/trace-cmd
+LIBTRACECMD_STATIC = $(LIBTRACECMD_DIR)/libtracecmd.a
+LIBTRACECMD_SHARED = $(LIBTRACECMD_DIR)/libtracecmd.so
 
 PACKAGES= gtk+-2.0 libxml-2.0 gthread-2.0
 
@@ -301,8 +303,9 @@ TRACE_GUI_OBJS = trace-filter.o trace-compat.o trace-filter-hash.o trace-dialog.
 		trace-xml.o
 TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-listen.o \
 	 trace-stack.o trace-hist.o trace-mem.o trace-snapshot.o trace-stat.o \
-	 trace-hash.o trace-profile.o trace-stream.o trace-record.o trace-restore.o \
-	 trace-check-events.o trace-show.o trace-list.o
+	 trace-profile.o trace-stream.o trace-record.o trace-restore.o \
+	 trace-check-events.o trace-show.o trace-list.o  \
+	 trace-output.o trace-usage.o trace-msg.o
 TRACE_VIEW_OBJS = trace-view.o trace-view-store.o
 TRACE_GRAPH_OBJS = trace-graph.o trace-plot.o trace-plot-cpu.o trace-plot-task.o
 TRACE_VIEW_MAIN_OBJS = trace-view-main.o $(TRACE_VIEW_OBJS) $(TRACE_GUI_OBJS)
@@ -310,11 +313,6 @@ 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
 
-TCMD_LIB_OBJS = trace-util.o trace-input.o trace-ftrace.o \
-			trace-output.o trace-recorder.o \
-			trace-usage.o trace-blk-hack.o \
-			trace-hooks.o trace-msg.o
-
 PLUGIN_OBJS =
 PLUGIN_OBJS += plugin_jbd2.o
 PLUGIN_OBJS += plugin_hrtimer.o
@@ -332,9 +330,9 @@ PLUGIN_OBJS += plugin_tlb.o
 PLUGINS := $(PLUGIN_OBJS:.o=.so)
 
 ALL_OBJS = $(TRACE_CMD_OBJS) $(KERNEL_SHARK_OBJS) $(TRACE_VIEW_MAIN_OBJS) \
-	$(TRACE_GRAPH_MAIN_OBJS) $(TCMD_LIB_OBJS) $(PLUGIN_OBJS)
+	$(TRACE_GRAPH_MAIN_OBJS) $(PLUGIN_OBJS)
 
-CMD_TARGETS = trace_plugin_dir trace_python_dir tc_version.h $(LIB_FILE) \
+CMD_TARGETS = trace_plugin_dir trace_python_dir tc_version.h \
 	trace-cmd  $(PLUGINS) $(BUILD_PYTHON)
 
 GUI_TARGETS = ks_version.h trace-graph trace-view kernelshark
@@ -375,10 +373,10 @@ trace-view: $(TRACE_VIEW_MAIN_OBJS)
 trace-graph: $(TRACE_GRAPH_MAIN_OBJS)
 	$(Q)$(G)$(do_app_build)
 
-trace-cmd: libtracecmd.a $(LIBTRACEEVENT_STATIC)
-kernelshark: libtracecmd.a $(LIBTRACEEVENT_STATIC)
-trace-view: libtracecmd.a $(LIBTRACEEVENT_STATIC)
-trace-graph: libtracecmd.a $(LIBTRACEEVENT_STATIC)
+trace-cmd: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC)
+kernelshark: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC)
+trace-view: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC)
+trace-graph: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC)
 
 $(LIBTRACEEVENT_SHARED): force
 	$(Q)$(MAKE) -C $(src)/lib/traceevent libtraceevent.so
@@ -386,21 +384,18 @@ $(LIBTRACEEVENT_SHARED): force
 $(LIBTRACEEVENT_STATIC): force
 	$(Q)$(MAKE) -C $(src)/lib/traceevent libtraceevent.a
 
+$(LIBTRACECMD_STATIC): force trace_plugin_dir
+	$(Q)$(MAKE) -C $(src)/lib/trace-cmd libtracecmd.a
+
+$(LIBTRACECMD_SHARED): force trace_plugin_dir
+	$(Q)$(MAKE) -C $(src)/lib/trace-cmd libtracecmd.so
+
 libtraceevent.so: $(LIBTRACEEVENT_SHARED)
 libtraceevent.a: $(LIBTRACEEVENT_STATIC)
+libtracecmd.a: $(LIBTRACECMD_STATIC)
+libtracecmd.so: $(LIBTRACECMD_SHARED)
 
-$(TCMD_LIB_OBJS): %.o: $(src)/%.c
-	$(Q)$(do_fpic_compile)
-
-libtracecmd.so: $(TCMD_LIB_OBJS)
-	$(Q)$(do_compile_shared_library)
-
-libtracecmd.a: $(TCMD_LIB_OBJS)
-	$(Q)$(do_build_static_lib)
-
-libs: libtracecmd.so $(LIBTRACEEVENT_SHARED)
-
-trace-util.o: trace_plugin_dir
+libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED)
 
 $(PLUGIN_OBJS): %.o : $(src)/%.c
 	$(Q)$(do_compile_plugin_obj)
@@ -568,7 +563,7 @@ install_gui: install_cmd gui
 	$(Q)$(call do_install,kernelshark,$(bindir_SQ))
 
 install_libs: libs
-	$(Q)$(call do_install,libtracecmd.so,$(libdir_SQ))
+	$(Q)$(call do_install,$(LIBTRACECMD_SHARED),$(libdir_SQ))
 	$(Q)$(call do_install,$(LIBTRACEEVENT_SHARED),$(libdir_SQ))
 	$(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_SQ))
 	$(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ))
@@ -586,6 +581,7 @@ clean:
 	$(RM) *.o *~ $(TARGETS) *.a *.so ctracecmd_wrap.c .*.d
 	$(RM) tags TAGS cscope*
 	$(MAKE) -C $(src)/lib/traceevent clean
+	$(MAKE) -C $(src)/lib/trace-cmd clean
 
 
 ##### PYTHON STUFF #####
@@ -603,9 +599,9 @@ PYGTK_CFLAGS = `pkg-config --cflags pygtk-2.0`
 ctracecmd.so: $(TCMD_LIB_OBJS) ctracecmd.i
 	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 $(TCMD_LIB_OBJS) $(LDFLAGS) ctracecmd_wrap.o -o ctracecmd.so
+	$(CC) --shared $(LIBTRACECMD_STATIC) $(LDFLAGS) ctracecmd_wrap.o -o ctracecmd.so
 
-ctracecmdgui.so: $(TRACE_VIEW_OBJS) $(LIB_FILE)
+ctracecmdgui.so: $(TRACE_VIEW_OBJS) $(LIBTRACECMD_STATIC)
 	swig -Wall -python -noproxy ctracecmdgui.i
 	$(CC) -fpic -c  $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(PYTHON_INCLUDES) $(PYGTK_CFLAGS) ctracecmdgui_wrap.c
 	$(CC) --shared $^ $(LDFLAGS) $(LIBS) $(CONFIG_LIBS) ctracecmdgui_wrap.o -o ctracecmdgui.so
lib/trace-cmd/Makefile new file +45 -0

45 lines not on this page · raw message

lib/trace-cmd/trace-blk-hack.c renamed from trace-blk-hack.c +0 -0
similarity index 100%
rename from trace-blk-hack.c
rename to lib/trace-cmd/trace-blk-hack.c
lib/trace-cmd/trace-ftrace.c renamed from trace-ftrace.c +0 -0
similarity index 100%
rename from trace-ftrace.c
rename to lib/trace-cmd/trace-ftrace.c
lib/trace-cmd/trace-hash.c renamed from trace-hash.c +0 -0
similarity index 100%
rename from trace-hash.c
rename to lib/trace-cmd/trace-hash.c
lib/trace-cmd/trace-hooks.c renamed from trace-hooks.c +0 -0
similarity index 100%
rename from trace-hooks.c
rename to lib/trace-cmd/trace-hooks.c
lib/trace-cmd/trace-input.c renamed from trace-input.c +0 -0
similarity index 100%
rename from trace-input.c
rename to lib/trace-cmd/trace-input.c
lib/trace-cmd/trace-recorder.c renamed from trace-recorder.c +0 -0
similarity index 100%
rename from trace-recorder.c
rename to lib/trace-cmd/trace-recorder.c
lib/trace-cmd/trace-util.c renamed from trace-util.c +0 -0
similarity index 100%
rename from trace-util.c
rename to lib/trace-cmd/trace-util.c
Signature · 1 line
2.14.1
#9 lore raw

PATCH v2 9/24 trace-cmd: Move GUI headers in kernel-shark/include

In reply to Vladislav Valtchev (VMware)

This patch moves, as part of a bigger code base restructuring, all the header files of kernelshark in a dedicated directory. The next patch will move all of kernelshark's source files in kernel-shark/.

---
 Makefile                                                        | 3 ++-
 cpu.h => kernel-shark/include/cpu.h                             | 0
 kernel-shark.h => kernel-shark/include/kernel-shark.h           | 0
 kshark-plugin.h => kernel-shark/include/kshark-plugin.h         | 0
 trace-capture.h => kernel-shark/include/trace-capture.h         | 0
 trace-compat.h => kernel-shark/include/trace-compat.h           | 0
 trace-filter-hash.h => kernel-shark/include/trace-filter-hash.h | 0
 trace-filter.h => kernel-shark/include/trace-filter.h           | 0
 trace-graph.h => kernel-shark/include/trace-graph.h             | 0
 trace-gui.h => kernel-shark/include/trace-gui.h                 | 0
 trace-view-store.h => kernel-shark/include/trace-view-store.h   | 0
 trace-view.h => kernel-shark/include/trace-view.h               | 0
 trace-xml.h => kernel-shark/include/trace-xml.h                 | 0
 13 files changed, 2 insertions(+), 1 deletion(-)
 rename cpu.h => kernel-shark/include/cpu.h (100%)
 rename kernel-shark.h => kernel-shark/include/kernel-shark.h (100%)
 rename kshark-plugin.h => kernel-shark/include/kshark-plugin.h (100%)
 rename trace-capture.h => kernel-shark/include/trace-capture.h (100%)
 rename trace-compat.h => kernel-shark/include/trace-compat.h (100%)
 rename trace-filter-hash.h => kernel-shark/include/trace-filter-hash.h (100%)
 rename trace-filter.h => kernel-shark/include/trace-filter.h (100%)
 rename trace-graph.h => kernel-shark/include/trace-graph.h (100%)
 rename trace-gui.h => kernel-shark/include/trace-gui.h (100%)
 rename trace-view-store.h => kernel-shark/include/trace-view-store.h (100%)
 rename trace-view.h => kernel-shark/include/trace-view.h (100%)
 rename trace-xml.h => kernel-shark/include/trace-xml.h (100%)
Makefile +2 -1
index 2c08162..2269a96 100644
@@ -243,6 +243,7 @@ INCLUDES += -I$(src)/include/traceevent
 INCLUDES += -I$(src)/include/trace-cmd
 INCLUDES += -I$(src)/lib/traceevent/include
 INCLUDES += -I$(src)/lib/trace-cmd/include
+INCLUDES += -I$(src)/kernel-shark/include
 
 include $(src)/features.mk
 
@@ -602,7 +603,7 @@ ctracecmd.so: $(TCMD_LIB_OBJS) ctracecmd.i
 	$(CC) --shared $(LIBTRACECMD_STATIC) $(LDFLAGS) ctracecmd_wrap.o -o ctracecmd.so
 
 ctracecmdgui.so: $(TRACE_VIEW_OBJS) $(LIBTRACECMD_STATIC)
-	swig -Wall -python -noproxy ctracecmdgui.i
+	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 $^ $(LDFLAGS) $(LIBS) $(CONFIG_LIBS) ctracecmdgui_wrap.o -o ctracecmdgui.so
 
kernel-shark/include/cpu.h renamed from cpu.h +0 -0
similarity index 100%
rename from cpu.h
rename to kernel-shark/include/cpu.h
kernel-shark/include/kernel-shark.h renamed from kernel-shark.h +0 -0
similarity index 100%
rename from kernel-shark.h
rename to kernel-shark/include/kernel-shark.h
kernel-shark/include/kshark-plugin.h renamed from kshark-plugin.h +0 -0
similarity index 100%
rename from kshark-plugin.h
rename to kernel-shark/include/kshark-plugin.h
kernel-shark/include/trace-capture.h renamed from trace-capture.h +0 -0
similarity index 100%
rename from trace-capture.h
rename to kernel-shark/include/trace-capture.h
kernel-shark/include/trace-compat.h renamed from trace-compat.h +0 -0
similarity index 100%
rename from trace-compat.h
rename to kernel-shark/include/trace-compat.h
kernel-shark/include/trace-filter-hash.h renamed from trace-filter-hash.h +0 -0
similarity index 100%
rename from trace-filter-hash.h
rename to kernel-shark/include/trace-filter-hash.h
kernel-shark/include/trace-filter.h renamed from trace-filter.h +0 -0
similarity index 100%
rename from trace-filter.h
rename to kernel-shark/include/trace-filter.h
kernel-shark/include/trace-graph.h renamed from trace-graph.h +0 -0
similarity index 100%
rename from trace-graph.h
rename to kernel-shark/include/trace-graph.h
kernel-shark/include/trace-gui.h renamed from trace-gui.h +0 -0
similarity index 100%
rename from trace-gui.h
rename to kernel-shark/include/trace-gui.h
kernel-shark/include/trace-view-store.h renamed from trace-view-store.h +0 -0
similarity index 100%
rename from trace-view-store.h
rename to kernel-shark/include/trace-view-store.h
kernel-shark/include/trace-view.h renamed from trace-view.h +0 -0
similarity index 100%
rename from trace-view.h
rename to kernel-shark/include/trace-view.h
kernel-shark/include/trace-xml.h renamed from trace-xml.h +0 -0
similarity index 100%
rename from trace-xml.h
rename to kernel-shark/include/trace-xml.h
Signature · 1 line
2.14.1
#10 lore raw

PATCH v2 10/24 trace-cmd: Move GUI *.c files in kernel-shark/

In reply to Vladislav Valtchev (VMware)

This patch moves all the source files belonging to the GUI (kernelshark, trace-view and trace-graph) into the dedicated directory kernel-shark/. The build system has been updated to support this new directory structure by adding a separate Makefile in kernel-shark/ and by making the parent Makefile to invoke it.

---
 Makefile                                           | 190 ++++-----------------
 kernel-shark/Makefile                              |  84 +++++++++
 kernel-shark.c => kernel-shark/kernel-shark.c      |   0
 trace-capture.c => kernel-shark/trace-capture.c    |   0
 trace-compat.c => kernel-shark/trace-compat.c      |   0
 trace-dialog.c => kernel-shark/trace-dialog.c      |   0
 .../trace-filter-hash.c                            |   0
 trace-filter.c => kernel-shark/trace-filter.c      |   0
 .../trace-graph-main.c                             |   0
 trace-graph.c => kernel-shark/trace-graph.c        |   0
 trace-plot-cpu.c => kernel-shark/trace-plot-cpu.c  |   0
 .../trace-plot-task.c                              |   0
 trace-plot.c => kernel-shark/trace-plot.c          |   0
 .../trace-view-main.c                              |   0
 .../trace-view-store.c                             |   0
 trace-view.c => kernel-shark/trace-view.c          |   0
 trace-xml.c => kernel-shark/trace-xml.c            |   0
 scripts/utils.mk                                   |  21 +++
 18 files changed, 140 insertions(+), 155 deletions(-)
 create mode 100644 kernel-shark/Makefile
 rename kernel-shark.c => kernel-shark/kernel-shark.c (100%)
 rename trace-capture.c => kernel-shark/trace-capture.c (100%)
 rename trace-compat.c => kernel-shark/trace-compat.c (100%)
 rename trace-dialog.c => kernel-shark/trace-dialog.c (100%)
 rename trace-filter-hash.c => kernel-shark/trace-filter-hash.c (100%)
 rename trace-filter.c => kernel-shark/trace-filter.c (100%)
 rename trace-graph-main.c => kernel-shark/trace-graph-main.c (100%)
 rename trace-graph.c => kernel-shark/trace-graph.c (100%)
 rename trace-plot-cpu.c => kernel-shark/trace-plot-cpu.c (100%)
 rename trace-plot-task.c => kernel-shark/trace-plot-task.c (100%)
 rename trace-plot.c => kernel-shark/trace-plot.c (100%)
 rename trace-view-main.c => kernel-shark/trace-view-main.c (100%)
 rename trace-view-store.c => kernel-shark/trace-view-store.c (100%)
 rename trace-view.c => kernel-shark/trace-view.c (100%)
 rename trace-xml.c => kernel-shark/trace-xml.c (100%)
Makefile +35 -155
index 2269a96..b6a023a 100644
@@ -4,11 +4,6 @@ TC_VERSION = 2
 TC_PATCHLEVEL = 7
 TC_EXTRAVERSION =
 
-# Kernel Shark version
-KS_VERSION = 0
-KS_PATCHLEVEL = 2
-KS_EXTRAVERSION =
-
 # file format version
 FILE_VERSION = 6
 
@@ -147,27 +142,9 @@ BUILD_OUTPUT := $(shell cd $(BUILD_OUTPUT) && /bin/pwd)
 $(if $(BUILD_OUTPUT),, \
      $(error output directory "$(saved-output)" does not exist))
 
-all: sub-make
-
-gui: force
-	$(call build_output, all_cmd)
-	$(call build_output, BUILDGUI=1 all_gui)
-
-$(filter-out gui,$(MAKECMDGOALS)): sub-make
-
-sub-make: force
-	$(call build_output, $(MAKECMDGOALS))
-
-
-# Leave processing to above invocation of make
-skip-makefile := 1
-
 endif # BUILD_OUTPUT
 endif # BUILD_SRC
 
-# We process the rest of the Makefile if this is the final invocation of make
-ifeq ($(skip-makefile),)
-
 srctree		:= $(if $(BUILD_SRC),$(BUILD_SRC),$(CURDIR))
 objtree		:= $(CURDIR)
 src		:= $(srctree)
@@ -181,7 +158,8 @@ bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
 plugin_dir_SQ = $(subst ','\'',$(plugin_dir))
 python_dir_SQ = $(subst ','\'',$(python_dir))
 
-LIBS = -L. -ldl
+LIBS = -ldl
+
 LIBTRACEEVENT_DIR = $(obj)/lib/traceevent
 LIBTRACEEVENT_STATIC = $(LIBTRACEEVENT_DIR)/libtraceevent.a
 LIBTRACEEVENT_SHARED = $(LIBTRACEEVENT_DIR)/libtraceevent.so
@@ -190,32 +168,8 @@ LIBTRACECMD_DIR = $(obj)/lib/trace-cmd
 LIBTRACECMD_STATIC = $(LIBTRACECMD_DIR)/libtracecmd.a
 LIBTRACECMD_SHARED = $(LIBTRACECMD_DIR)/libtracecmd.so
 
-PACKAGES= gtk+-2.0 libxml-2.0 gthread-2.0
-
-ifndef BUILDGUI
- BUILDGUI = 0
-endif
-
-ifeq ($(BUILDGUI), 1)
-
-CONFIG_INCLUDES = $(shell pkg-config --cflags $(PACKAGES)) -I$(obj)
-
-CONFIG_FLAGS = -DBUILDGUI \
-	-DGTK_VERSION=$(shell pkg-config --modversion gtk+-2.0 | \
-	awk 'BEGIN{FS="."}{ a = ($$1 * (2^16)) + $$2 * (2^8) + $$3; printf ("%d", a);}')
-
-CONFIG_LIBS = $(shell pkg-config --libs $(PACKAGES))
-
-VERSION		= $(KS_VERSION)
-PATCHLEVEL	= $(KS_PATCHLEVEL)
-EXTRAVERSION	= $(KS_EXTRAVERSION)
-
-REBUILD_GUI	= /bin/true
-G		=
-N 		= @/bin/true ||
-
-CONFIG_FLAGS	+= $(HELP_DIR_SQ)
-else
+export LIBS
+export LIBTRACEEVENT_DIR LIBTRACECMD_DIR
 
 CONFIG_INCLUDES = 
 CONFIG_LIBS	=
@@ -225,18 +179,14 @@ VERSION		= $(TC_VERSION)
 PATCHLEVEL	= $(TC_PATCHLEVEL)
 EXTRAVERSION	= $(TC_EXTRAVERSION)
 
-REBUILD_GUI	= $(MAKE) -f $(src)/Makefile BUILDGUI=1 $@
-G		= $(REBUILD_GUI); /bin/true ||
 N		=
-endif
 
-export Q VERBOSE
+export Q VERBOSE EXT
 
 # Include the utils
 include scripts/utils.mk
 
 TRACECMD_VERSION = $(TC_VERSION).$(TC_PATCHLEVEL).$(TC_EXTRAVERSION)
-KERNELSHARK_VERSION = $(KS_VERSION).$(KS_PATCHLEVEL).$(KS_EXTRAVERSION)
 
 INCLUDES = -I$(src) -I $(src)/include -I $(srctree)/../../include $(CONFIG_INCLUDES)
 INCLUDES += -I$(src)/include/traceevent
@@ -253,6 +203,7 @@ CPPFLAGS ?=
 LDFLAGS ?=
 
 export CFLAGS
+export INCLUDES
 
 # Required CFLAGS
 override CFLAGS += -D_GNU_SOURCE
@@ -285,34 +236,21 @@ endif
 override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ) $(VAR_DIR)
 override CFLAGS += $(udis86-flags) $(blk-flags)
 
-define check_gui
-	if [ $(BUILDGUI) -ne 1 -a ! -z "$(filter $(gui_objs),$(@))" ];	then	\
-		$(REBUILD_GUI);							\
-	else									\
-		$(print_compile)						\
-		$(CC) -c $(CPPFLAGS) $(CFLAGS) $(EXT) $< -o $(obj)/$@;		\
-	fi;
-endef
-
 $(obj)/%.o: $(src)/%.c
-	$(Q)$(call check_gui)
+	$(Q)$(call do_compile)
 
 %.o: $(src)/%.c
-	$(Q)$(call check_gui)
+	$(Q)$(call do_compile)
+
+TRACE_VIEW_OBJS =
+TRACE_VIEW_OBJS += $(obj)/kernel-shark/trace-view.o
+TRACE_VIEW_OBJS += $(obj)/kernel-shark/trace-view-store.o
 
-TRACE_GUI_OBJS = trace-filter.o trace-compat.o trace-filter-hash.o trace-dialog.o \
-		trace-xml.o
 TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-listen.o \
 	 trace-stack.o trace-hist.o trace-mem.o trace-snapshot.o trace-stat.o \
 	 trace-profile.o trace-stream.o trace-record.o trace-restore.o \
 	 trace-check-events.o trace-show.o trace-list.o  \
 	 trace-output.o trace-usage.o trace-msg.o
-TRACE_VIEW_OBJS = trace-view.o trace-view-store.o
-TRACE_GRAPH_OBJS = trace-graph.o trace-plot.o trace-plot-cpu.o trace-plot-task.o
-TRACE_VIEW_MAIN_OBJS = trace-view-main.o $(TRACE_VIEW_OBJS) $(TRACE_GUI_OBJS)
-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
 
 PLUGIN_OBJS =
 PLUGIN_OBJS += plugin_jbd2.o
@@ -330,15 +268,13 @@ PLUGIN_OBJS += plugin_tlb.o
 
 PLUGINS := $(PLUGIN_OBJS:.o=.so)
 
-ALL_OBJS = $(TRACE_CMD_OBJS) $(KERNEL_SHARK_OBJS) $(TRACE_VIEW_MAIN_OBJS) \
-	$(TRACE_GRAPH_MAIN_OBJS) $(PLUGIN_OBJS)
+ALL_OBJS = $(TRACE_CMD_OBJS) $(PLUGIN_OBJS)
 
 CMD_TARGETS = trace_plugin_dir trace_python_dir tc_version.h \
 	trace-cmd  $(PLUGINS) $(BUILD_PYTHON)
 
-GUI_TARGETS = ks_version.h trace-graph trace-view kernelshark
 
-TARGETS = $(CMD_TARGETS) $(GUI_TARGETS)
+TARGETS = $(CMD_TARGETS)
 
 
 #	cpp $(INCLUDES)
@@ -353,31 +289,23 @@ all: all_cmd show_gui_make
 
 all_cmd: $(CMD_TARGETS)
 
-gui: $(CMD_TARGETS)
-	$(Q)$(MAKE) -f $(src)/Makefile BUILDGUI=1 all_gui
-
-all_gui: $(GUI_TARGETS) show_gui_done
-
-GUI_OBJS = $(KERNEL_SHARK_OBJS) $(TRACE_VIEW_MAIN_OBJS) $(TRACE_GRAPH_MAIN_OBJS)
-
-gui_objs := $(sort $(GUI_OBJS))
+gui: force $(CMD_TARGETS)
+	$(Q)$(MAKE) -C $(src)/kernel-shark; \
+	echo "gui build complete"
 
 trace-cmd: $(TRACE_CMD_OBJS)
 	$(Q)$(do_app_build)
 
-kernelshark: $(KERNEL_SHARK_OBJS)
-	$(Q)$(G)$(do_app_build)
-
-trace-view: $(TRACE_VIEW_MAIN_OBJS)
-	$(Q)$(G)$(do_app_build)
-
-trace-graph: $(TRACE_GRAPH_MAIN_OBJS)
-	$(Q)$(G)$(do_app_build)
-
 trace-cmd: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC)
-kernelshark: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC)
-trace-view: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC)
-trace-graph: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC)
+
+kernelshark: force $(CMD_TARGETS)
+	$(Q)$(MAKE) -C $(src)/kernel-shark $@
+
+trace-view: force $(CMD_TARGETS)
+	$(Q)$(MAKE) -C $(src)/kernel-shark $@
+
+trace-graph: force $(CMD_TARGETS)
+	$(Q)$(MAKE) -C $(src)/kernel-shark $@
 
 $(LIBTRACEEVENT_SHARED): force
 	$(Q)$(MAKE) -C $(src)/lib/traceevent libtraceevent.so
@@ -404,29 +332,6 @@ $(PLUGIN_OBJS): %.o : $(src)/%.c
 $(PLUGINS): %.so: %.o
 	$(Q)$(do_plugin_build)
 
-define make_version.h
-	(echo '/* This file is automatically generated. Do not modify. */';		\
-	echo \#define VERSION_CODE $(shell						\
-	expr $(VERSION) \* 256 + $(PATCHLEVEL));					\
-	echo '#define EXTRAVERSION ' $(EXTRAVERSION);					\
-	echo '#define VERSION_STRING "'$(VERSION).$(PATCHLEVEL).$(EXTRAVERSION)'"';	\
-	echo '#define FILE_VERSION '$(FILE_VERSION);					\
-	) > $1
-endef
-
-define update_version.h
-	($(call make_version.h, [email protected]);		\
-	if [ -r $@ ] && cmp -s $@ [email protected]; then		\
-		rm -f [email protected];				\
-	else						\
-		echo '  UPDATE                 $@';	\
-		mv -f [email protected] $@;			\
-	fi);
-endef
-
-ks_version.h: force
-	$(Q)$(G)$(call update_version.h)
-
 tc_version.h: force
 	$(Q)$(N)$(call update_version.h)
 
@@ -450,36 +355,15 @@ trace_python_dir: force
 
 all_objs := $(sort $(ALL_OBJS))
 all_deps := $(all_objs:%.o=.%.d)
-gui_deps := $(gui_objs:%.o=.%.d)
-non_gui_deps = $(filter-out $(gui_deps),$(all_deps))
 
-define check_gui_deps
-	if [ ! -z "$(filter $(gui_deps),$(@))" ];	then	\
-		if [ $(BUILDGUI) -ne 1 ]; then			\
-			$(REBUILD_GUI);				\
-		else						\
-			$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@;	\
-		fi						\
-	elif [ $(BUILDGUI) -eq 0 ]; then			\
-		$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@;		\
-	else							\
-		echo SKIPPING $@;				\
-	fi;
-endef
-
-$(gui_deps): ks_version.h
-$(non_gui_deps): tc_version.h
+$(all_deps): tc_version.h
 
 $(all_deps): .%.d: $(src)/%.c
-	$(Q)$(call check_gui_deps)
+	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@;
 
 $(all_objs) : %.o : .%.d
 
-ifeq ($(BUILDGUI), 1)
-dep_includes := $(wildcard $(gui_deps))
-else
-dep_includes := $(wildcard $(non_gui_deps))
-endif
+dep_includes := $(wildcard $(all_deps))
 
 ifneq ($(dep_includes),)
  include $(dep_includes)
@@ -489,9 +373,6 @@ show_gui_make:
 	@echo "Note: to build the gui, type \"make gui\""
 	@echo "      to build man pages, type \"make doc\""
 
-show_gui_done:
-	@echo "gui build complete"
-
 PHONY += show_gui_make
 
 define find_tag_files
@@ -559,9 +440,9 @@ install: install_cmd
 	@echo "      to install man pages, type \"make install_doc\""
 
 install_gui: install_cmd gui
-	$(Q)$(call do_install,trace-view,$(bindir_SQ))
-	$(Q)$(call do_install,trace-graph,$(bindir_SQ))
-	$(Q)$(call do_install,kernelshark,$(bindir_SQ))
+	$(Q)$(call do_install,$(obj)/kernel-shark/trace-view,$(bindir_SQ))
+	$(Q)$(call do_install,$(obj)/kernel-shark/trace-graph,$(bindir_SQ))
+	$(Q)$(call do_install,$(obj)/kernel-shark/kernelshark,$(bindir_SQ))
 
 install_libs: libs
 	$(Q)$(call do_install,$(LIBTRACECMD_SHARED),$(libdir_SQ))
@@ -583,6 +464,7 @@ clean:
 	$(RM) tags TAGS cscope*
 	$(MAKE) -C $(src)/lib/traceevent clean
 	$(MAKE) -C $(src)/lib/trace-cmd clean
+	$(MAKE) -C $(src)/kernel-shark clean
 
 
 ##### PYTHON STUFF #####
@@ -602,10 +484,10 @@ ctracecmd.so: $(TCMD_LIB_OBJS) ctracecmd.i
 	$(CC) -fpic -c $(CPPFLAGS) $(CFLAGS) $(PYTHON_INCLUDES)  ctracecmd_wrap.c
 	$(CC) --shared $(LIBTRACECMD_STATIC) $(LDFLAGS) ctracecmd_wrap.o -o ctracecmd.so
 
-ctracecmdgui.so: $(TRACE_VIEW_OBJS) $(LIBTRACECMD_STATIC)
+ctracecmdgui.so: trace-view $(LIBTRACECMD_STATIC)
 	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 $^ $(LDFLAGS) $(LIBS) $(CONFIG_LIBS) ctracecmdgui_wrap.o -o ctracecmdgui.so
+	$(CC) --shared $(TRACE_VIEW_OBJS) $(LIBTRACECMD_STATIC) $(LDFLAGS) $(LIBS) $(CONFIG_LIBS) ctracecmdgui_wrap.o -o ctracecmdgui.so
 
 PHONY += python
 python: $(PYTHON)
@@ -632,8 +514,6 @@ plugin_python.o: %.o : $(src)/%.c trace_python_dir
 plugin_python.so: %.so: %.o
 	$(Q)$(do_python_plugin_build)
 
-endif # skip-makefile
-
 dist:
 	git archive --format=tar --prefix=trace-cmd-$(TRACECMD_VERSION)/ HEAD \
 		> ../trace-cmd-$(TRACECMD_VERSION).tar
kernel-shark/Makefile new file +84 -0

84 lines not on this page · raw message

kernel-shark/kernel-shark.c renamed from kernel-shark.c +0 -0
similarity index 100%
rename from kernel-shark.c
rename to kernel-shark/kernel-shark.c
kernel-shark/trace-capture.c renamed from trace-capture.c +0 -0
similarity index 100%
rename from trace-capture.c
rename to kernel-shark/trace-capture.c
kernel-shark/trace-compat.c renamed from trace-compat.c +0 -0
similarity index 100%
rename from trace-compat.c
rename to kernel-shark/trace-compat.c
kernel-shark/trace-dialog.c renamed from trace-dialog.c +0 -0
similarity index 100%
rename from trace-dialog.c
rename to kernel-shark/trace-dialog.c
kernel-shark/trace-filter-hash.c renamed from trace-filter-hash.c +0 -0
similarity index 100%
rename from trace-filter-hash.c
rename to kernel-shark/trace-filter-hash.c
kernel-shark/trace-filter.c renamed from trace-filter.c +0 -0
similarity index 100%
rename from trace-filter.c
rename to kernel-shark/trace-filter.c
kernel-shark/trace-graph-main.c renamed from trace-graph-main.c +0 -0
similarity index 100%
rename from trace-graph-main.c
rename to kernel-shark/trace-graph-main.c
kernel-shark/trace-graph.c renamed from trace-graph.c +0 -0
similarity index 100%
rename from trace-graph.c
rename to kernel-shark/trace-graph.c
kernel-shark/trace-plot-cpu.c renamed from trace-plot-cpu.c +0 -0
similarity index 100%
rename from trace-plot-cpu.c
rename to kernel-shark/trace-plot-cpu.c
kernel-shark/trace-plot-task.c renamed from trace-plot-task.c +0 -0
similarity index 100%
rename from trace-plot-task.c
rename to kernel-shark/trace-plot-task.c
kernel-shark/trace-plot.c renamed from trace-plot.c +0 -0
similarity index 100%
rename from trace-plot.c
rename to kernel-shark/trace-plot.c
kernel-shark/trace-view-main.c renamed from trace-view-main.c +0 -0
similarity index 100%
rename from trace-view-main.c
rename to kernel-shark/trace-view-main.c
kernel-shark/trace-view-store.c renamed from trace-view-store.c +0 -0
similarity index 100%
rename from trace-view-store.c
rename to kernel-shark/trace-view-store.c
kernel-shark/trace-view.c renamed from trace-view.c +0 -0
similarity index 100%
rename from trace-view.c
rename to kernel-shark/trace-view.c
kernel-shark/trace-xml.c renamed from trace-xml.c +0 -0
similarity index 100%
rename from trace-xml.c
rename to kernel-shark/trace-xml.c
scripts/utils.mk +21 -0
index 39cb387..abfe115 100644
@@ -62,3 +62,24 @@ do_plugin_build =				\
 	($(print_plugin_build)			\
 	$(CC) $(CFLAGS) $(LDFLAGS) -shared -nostartfiles -o $@ $<)
 
+
+define make_version.h
+	(echo '/* This file is automatically generated. Do not modify. */';		\
+	echo \#define VERSION_CODE $(shell						\
+	expr $(VERSION) \* 256 + $(PATCHLEVEL));					\
+	echo '#define EXTRAVERSION ' $(EXTRAVERSION);					\
+	echo '#define VERSION_STRING "'$(VERSION).$(PATCHLEVEL).$(EXTRAVERSION)'"';	\
+	echo '#define FILE_VERSION '$(FILE_VERSION);					\
+	) > $1
+endef
+
+define update_version.h
+	($(call make_version.h, [email protected]);		\
+	if [ -r $@ ] && cmp -s $@ [email protected]; then		\
+		rm -f [email protected];				\
+	else						\
+		echo '  UPDATE                 $@';	\
+		mv -f [email protected] $@;			\
+	fi);
+endef
+
Signature · 1 line
2.14.1
#11 lore raw

PATCH v2 11/24 trace-cmd: Move plugin_* files in plugins/

In reply to Vladislav Valtchev (VMware)

This patch moves the source files of all plugins to a dedicated directory, as part of a bigger restructuring plan of trace-cmd's code base.
The build system has been updated to support this new directory structure by adding a separate Makefile in plugins/ and by making the parent Makefile to invoke it.

---
 Makefile                                           | 115 ++++++---------------
 lib/trace-cmd/Makefile                             |   2 +
 plugins/Makefile                                   |  69 +++++++++++++
 plugin_blk.c => plugins/plugin_blk.c               |   0
 plugin_cfg80211.c => plugins/plugin_cfg80211.c     |   0
 plugin_function.c => plugins/plugin_function.c     |   0
 plugin_hrtimer.c => plugins/plugin_hrtimer.c       |   0
 plugin_jbd2.c => plugins/plugin_jbd2.c             |   0
 plugin_kmem.c => plugins/plugin_kmem.c             |   0
 plugin_kvm.c => plugins/plugin_kvm.c               |   0
 plugin_mac80211.c => plugins/plugin_mac80211.c     |   0
 plugin_python.c => plugins/plugin_python.c         |   0
 .../plugin_sched_switch.c                          |   0
 plugin_scsi.c => plugins/plugin_scsi.c             |   0
 plugin_tlb.c => plugins/plugin_tlb.c               |   0
 plugin_xen.c => plugins/plugin_xen.c               |   0
 scripts/utils.mk                                   |  32 ++++++
 17 files changed, 135 insertions(+), 83 deletions(-)
 create mode 100644 plugins/Makefile
 rename plugin_blk.c => plugins/plugin_blk.c (100%)
 rename plugin_cfg80211.c => plugins/plugin_cfg80211.c (100%)
 rename plugin_function.c => plugins/plugin_function.c (100%)
 rename plugin_hrtimer.c => plugins/plugin_hrtimer.c (100%)
 rename plugin_jbd2.c => plugins/plugin_jbd2.c (100%)
 rename plugin_kmem.c => plugins/plugin_kmem.c (100%)
 rename plugin_kvm.c => plugins/plugin_kvm.c (100%)
 rename plugin_mac80211.c => plugins/plugin_mac80211.c (100%)
 rename plugin_python.c => plugins/plugin_python.c (100%)
 rename plugin_sched_switch.c => plugins/plugin_sched_switch.c (100%)
 rename plugin_scsi.c => plugins/plugin_scsi.c (100%)
 rename plugin_tlb.c => plugins/plugin_tlb.c (100%)
 rename plugin_xen.c => plugins/plugin_xen.c (100%)
Makefile +32 -83
index b6a023a..2dfb8fd 100644
@@ -66,6 +66,12 @@ PYTHON_DIR_SQ = '$(subst ','\'',$(PYTHON_DIR))'
 var_dir = /var
 endif
 
+# Shell quotes
+bindir_SQ = $(subst ','\'',$(bindir))
+bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
+plugin_dir_SQ = $(subst ','\'',$(plugin_dir))
+python_dir_SQ = $(subst ','\'',$(python_dir))
+
 VAR_DIR = -DVAR_DIR="$(var_dir)"
 VAR_DIR_SQ = '$(subst ','\'',$(VAR_DIR))'
 var_dir_SQ = '$(subst ','\'',$(var_dir))'
@@ -76,6 +82,10 @@ HELP_DIR_SQ = '$(subst ','\'',$(HELP_DIR))'
 
 BASH_COMPLETE_DIR ?= /etc/bash_completion.d
 
+export PLUGIN_DIR
+export PYTHON_DIR
+export PYTHON_DIR_SQ
+export plugin_dir_SQ
 export var_dir
 
 # copy a bit from Linux kbuild
@@ -109,6 +119,8 @@ ifeq ($(shell sh -c "pkg-config --cflags $(PYTHON_VERS) > /dev/null 2>&1 && whic
 endif
 endif # NO_PYTHON
 
+export PYTHON_PLUGINS
+
 # $(call test-build, snippet, ret) -> ret if snippet compiles
 #                                  -> empty otherwise
 test-build = $(if $(shell sh -c 'echo "$(1)" | \
@@ -152,12 +164,6 @@ obj		:= $(objtree)
 
 export prefix bindir src obj
 
-# Shell quotes
-bindir_SQ = $(subst ','\'',$(bindir))
-bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
-plugin_dir_SQ = $(subst ','\'',$(plugin_dir))
-python_dir_SQ = $(subst ','\'',$(python_dir))
-
 LIBS = -ldl
 
 LIBTRACEEVENT_DIR = $(obj)/lib/traceevent
@@ -252,26 +258,9 @@ TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-lis
 	 trace-check-events.o trace-show.o trace-list.o  \
 	 trace-output.o trace-usage.o trace-msg.o
 
-PLUGIN_OBJS =
-PLUGIN_OBJS += plugin_jbd2.o
-PLUGIN_OBJS += plugin_hrtimer.o
-PLUGIN_OBJS += plugin_kmem.o
-PLUGIN_OBJS += plugin_kvm.o
-PLUGIN_OBJS += plugin_mac80211.o
-PLUGIN_OBJS += plugin_sched_switch.o
-PLUGIN_OBJS += plugin_function.o
-PLUGIN_OBJS += plugin_xen.o
-PLUGIN_OBJS += plugin_scsi.o
-PLUGIN_OBJS += plugin_cfg80211.o
-PLUGIN_OBJS += plugin_blk.o
-PLUGIN_OBJS += plugin_tlb.o
+ALL_OBJS = $(TRACE_CMD_OBJS)
 
-PLUGINS := $(PLUGIN_OBJS:.o=.so)
-
-ALL_OBJS = $(TRACE_CMD_OBJS) $(PLUGIN_OBJS)
-
-CMD_TARGETS = trace_plugin_dir trace_python_dir tc_version.h \
-	trace-cmd  $(PLUGINS) $(BUILD_PYTHON)
+CMD_TARGETS = tc_version.h trace-cmd $(BUILD_PYTHON)
 
 
 TARGETS = $(CMD_TARGETS)
@@ -285,7 +274,7 @@ TARGETS = $(CMD_TARGETS)
 #    If you want kernelshark, then do:  make gui
 ###
 
-all: all_cmd show_gui_make
+all: all_cmd plugins show_gui_make
 
 all_cmd: $(CMD_TARGETS)
 
@@ -313,10 +302,10 @@ $(LIBTRACEEVENT_SHARED): force
 $(LIBTRACEEVENT_STATIC): force
 	$(Q)$(MAKE) -C $(src)/lib/traceevent libtraceevent.a
 
-$(LIBTRACECMD_STATIC): force trace_plugin_dir
+$(LIBTRACECMD_STATIC): force $(obj)/plugins/trace_plugin_dir
 	$(Q)$(MAKE) -C $(src)/lib/trace-cmd libtracecmd.a
 
-$(LIBTRACECMD_SHARED): force trace_plugin_dir
+$(LIBTRACECMD_SHARED): force $(obj)/plugins/trace_plugin_dir
 	$(Q)$(MAKE) -C $(src)/lib/trace-cmd libtracecmd.so
 
 libtraceevent.so: $(LIBTRACEEVENT_SHARED)
@@ -326,30 +315,18 @@ libtracecmd.so: $(LIBTRACECMD_SHARED)
 
 libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED)
 
-$(PLUGIN_OBJS): %.o : $(src)/%.c
-	$(Q)$(do_compile_plugin_obj)
-
-$(PLUGINS): %.so: %.o
-	$(Q)$(do_plugin_build)
+plugins: force $(obj)/plugins/trace_plugin_dir $(obj)/plugins/trace_python_dir
+	$(Q)$(MAKE) -C $(src)/plugins
 
 tc_version.h: force
 	$(Q)$(N)$(call update_version.h)
 
-define update_dir
-	(echo $1 > [email protected];	\
-	if [ -r $@ ] && cmp -s $@ [email protected]; then		\
-		rm -f [email protected];				\
-	else						\
-		echo '  UPDATE                 $@';	\
-		mv -f [email protected] $@;			\
-	fi);
-endef
+$(obj)/plugins/trace_plugin_dir: force
+	$(Q)$(MAKE) -C $(src)/plugins trace_plugin_dir
 
-trace_plugin_dir: force
-	$(Q)$(N)$(call update_dir, 'PLUGIN_DIR=$(PLUGIN_DIR)')
+$(obj)/plugins/trace_python_dir: force
+	$(Q)$(MAKE) -C $(src)/plugins trace_python_dir
 
-trace_python_dir: force
-	$(Q)$(N)$(call update_dir, 'PYTHON_DIR=$(PYTHON_DIR)')
 
 ## make deps
 
@@ -392,28 +369,8 @@ cscope: force
 	$(RM) cscope*
 	$(call find_tag_files) | cscope -b -q
 
-PLUGINS_INSTALL = $(subst .so,.install,$(PLUGINS)) $(subst .so,.install,$(PYTHON_PLUGINS))
-
-define do_install
-	$(print_install)				\
-	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
-		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2';	\
-	fi;						\
-	$(INSTALL) $1 '$(DESTDIR_SQ)$2'
-endef
-
-define do_install_data
-	$(print_install)				\
-	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
-		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2';	\
-	fi;						\
-	$(INSTALL) -m 644 $1 '$(DESTDIR_SQ)$2'
-endef
-
-$(PLUGINS_INSTALL): %.install : %.so force
-	$(Q)$(call do_install_data,$<,$(plugin_dir_SQ))
-
-install_plugins: $(PLUGINS_INSTALL)
+install_plugins: force
+	$(Q)$(MAKE) -C $(src)/plugins $@
 
 $(PYTHON_SO_INSTALL): %.install : %.so force
 	$(Q)$(call do_install_data,$<,$(python_dir_SQ))
@@ -465,6 +422,7 @@ clean:
 	$(MAKE) -C $(src)/lib/traceevent clean
 	$(MAKE) -C $(src)/lib/trace-cmd clean
 	$(MAKE) -C $(src)/kernel-shark clean
+	$(MAKE) -C $(src)/plugins clean
 
 
 ##### PYTHON STUFF #####
@@ -479,6 +437,10 @@ PYTHON_LDFLAGS = `pkg-config --libs $(PYTHON_VERS)` \
 		$(shell python2 -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LINKFORSHARED')")
 PYGTK_CFLAGS = `pkg-config --cflags pygtk-2.0`
 
+export PYTHON_INCLUDES
+export PYTHON_LDFLAGS
+export PYGTK_CFLAGS
+
 ctracecmd.so: $(TCMD_LIB_OBJS) ctracecmd.i
 	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
@@ -498,21 +460,8 @@ python-gui: $(PYTHON_GUI)
 PHONY += python-plugin
 python-plugin: $(PYTHON_PLUGINS)
 
-CFLAGS_plugin_python.o += $(PYTHON_DIR_SQ)
-
-do_compile_python_plugin_obj =			\
-	($(print_plugin_obj_compile)		\
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$@) $(PYTHON_INCLUDES) -fPIC -o $@ $<)
-
-do_python_plugin_build =			\
-	($(print_plugin_build)			\
-	$(CC) $< -shared $(LDFLAGS) $(PYTHON_LDFLAGS) -o $@)
-
-plugin_python.o: %.o : $(src)/%.c trace_python_dir
-	$(Q)$(do_compile_python_plugin_obj)
-
-plugin_python.so: %.so: %.o
-	$(Q)$(do_python_plugin_build)
+plugin_python.so: force $(obj)/plugins/trace_python_dir
+	$(Q)$(MAKE) -C $(src)/plugins plugin_python.so
 
 dist:
 	git archive --format=tar --prefix=trace-cmd-$(TRACECMD_VERSION)/ HEAD \
lib/trace-cmd/Makefile +2 -0
index dcb5cd5..e8fb088 100644
@@ -28,6 +28,8 @@ libtracecmd.so: $(OBJS)
 %.o: %.c
 	$(Q)$(call do_fpic_compile)
 
+trace-util.o: $(obj)/plugins/trace_plugin_dir
+
 $(DEPS): .%.d: %.c
 	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@
 
plugins/Makefile new file +69 -0

70 lines not on this page · raw message

plugins/plugin_blk.c renamed from plugin_blk.c +0 -0
similarity index 100%
rename from plugin_blk.c
rename to plugins/plugin_blk.c
plugins/plugin_cfg80211.c renamed from plugin_cfg80211.c +0 -0
similarity index 100%
rename from plugin_cfg80211.c
rename to plugins/plugin_cfg80211.c
plugins/plugin_function.c renamed from plugin_function.c +0 -0
similarity index 100%
rename from plugin_function.c
rename to plugins/plugin_function.c
plugins/plugin_hrtimer.c renamed from plugin_hrtimer.c +0 -0
similarity index 100%
rename from plugin_hrtimer.c
rename to plugins/plugin_hrtimer.c
plugins/plugin_jbd2.c renamed from plugin_jbd2.c +0 -0
similarity index 100%
rename from plugin_jbd2.c
rename to plugins/plugin_jbd2.c
plugins/plugin_kmem.c renamed from plugin_kmem.c +0 -0
similarity index 100%
rename from plugin_kmem.c
rename to plugins/plugin_kmem.c
plugins/plugin_kvm.c renamed from plugin_kvm.c +0 -0
similarity index 100%
rename from plugin_kvm.c
rename to plugins/plugin_kvm.c
plugins/plugin_mac80211.c renamed from plugin_mac80211.c +0 -0
similarity index 100%
rename from plugin_mac80211.c
rename to plugins/plugin_mac80211.c
plugins/plugin_python.c renamed from plugin_python.c +0 -0
similarity index 100%
rename from plugin_python.c
rename to plugins/plugin_python.c
plugins/plugin_sched_switch.c renamed from plugin_sched_switch.c +0 -0
similarity index 100%
rename from plugin_sched_switch.c
rename to plugins/plugin_sched_switch.c
plugins/plugin_scsi.c renamed from plugin_scsi.c +0 -0
similarity index 100%
rename from plugin_scsi.c
rename to plugins/plugin_scsi.c
plugins/plugin_tlb.c renamed from plugin_tlb.c +0 -0
similarity index 100%
rename from plugin_tlb.c
rename to plugins/plugin_tlb.c
plugins/plugin_xen.c renamed from plugin_xen.c +0 -0
similarity index 100%
rename from plugin_xen.c
rename to plugins/plugin_xen.c
scripts/utils.mk +32 -0
index abfe115..31fc9e9 100644
@@ -62,6 +62,13 @@ do_plugin_build =				\
 	($(print_plugin_build)			\
 	$(CC) $(CFLAGS) $(LDFLAGS) -shared -nostartfiles -o $@ $<)
 
+do_compile_python_plugin_obj =			\
+	($(print_plugin_obj_compile)		\
+	$(CC) -c $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$@) $(PYTHON_INCLUDES) -fPIC -o $@ $<)
+
+do_python_plugin_build =			\
+	($(print_plugin_build)			\
+	$(CC) $< -shared $(LDFLAGS) $(PYTHON_LDFLAGS) -o $@)
 
 define make_version.h
 	(echo '/* This file is automatically generated. Do not modify. */';		\
@@ -83,3 +90,28 @@ define update_version.h
 	fi);
 endef
 
+define update_dir
+	(echo $1 > [email protected];	\
+	if [ -r $@ ] && cmp -s $@ [email protected]; then		\
+		rm -f [email protected];				\
+	else						\
+		echo '  UPDATE                 $@';	\
+		mv -f [email protected] $@;			\
+	fi);
+endef
+
+define do_install
+	$(print_install)				\
+	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
+		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2';	\
+	fi;						\
+	$(INSTALL) $1 '$(DESTDIR_SQ)$2'
+endef
+
+define do_install_data
+	$(print_install)				\
+	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
+		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2';	\
+	fi;						\
+	$(INSTALL) -m 644 $1 '$(DESTDIR_SQ)$2'
+endef
Signature · 1 line
2.14.1
#12 lore raw

PATCH v2 12/24 trace-cmd: Fix the broken target ctracecmdgui.so

In reply to Vladislav Valtchev (VMware)

Currenly the ctracecmdgui.so target is broken beacause the object files trace-view.o trace-view-store.o are not built with -fPIC. This patch just fixes the kernel-shark/Makefile in order to those files to be built with -fPIC.

---
 kernel-shark/Makefile | 10 +++++++---
 scripts/utils.mk      | 10 +++++-----
 2 files changed, 12 insertions(+), 8 deletions(-)
kernel-shark/Makefile +7 -3
index 247f4d1..8e3ba8b 100644
@@ -34,9 +34,11 @@ 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
 
-GUI_OBJS = $(KERNEL_SHARK_OBJS) $(TRACE_VIEW_MAIN_OBJS) $(TRACE_GRAPH_MAIN_OBJS)
+ALL_OBJS = $(KERNEL_SHARK_OBJS) $(TRACE_VIEW_MAIN_OBJS) $(TRACE_GRAPH_MAIN_OBJS)
+PIC_OBJS = $(TRACE_VIEW_OBJS)
 
-all_objs := $(sort $(GUI_OBJS))
+all_objs := $(sort $(ALL_OBJS))
+pic_objs = $(sort $(PIC_OBJS))
 all_deps := $(all_objs:%.o=.%.d)
 
 # Temporary HACK!
@@ -61,6 +63,8 @@ trace-view: $(TRACE_VIEW_MAIN_OBJS)
 trace-graph: $(TRACE_GRAPH_MAIN_OBJS)
 	$(Q)$(do_app_build)
 
+$(pic_objs): GENERATE_PIC := 1
+
 %.o: %.c
 	$(Q)$(call do_compile)
 
@@ -69,7 +73,7 @@ $(all_deps): .%.d: %.c
 
 $(all_deps): $(KS_VERSION)
 
-$(GUI_OBJS): %.o : .%.d
+$(all_objs): %.o : .%.d
 
 dep_includes := $(wildcard $(DEPS))
 
scripts/utils.mk +5 -5
index 31fc9e9..043a68a 100644
@@ -33,15 +33,15 @@ else
   print_install =		echo '  $(GUI)INSTALL     '$(GSPACE)$1'	to	$(DESTDIR_SQ)$2';
 endif
 
-
-do_compile =				\
-	($(print_compile)			\
-	$(CC) -c $(CPPFLAGS) $(CFLAGS) $(EXT) $< -o $@)
-
 do_fpic_compile =					\
 	($(print_fpic_compile)				\
 	$(CC) -c $(CPPFLAGS) $(CFLAGS) $(EXT) -fPIC $< -o $@)
 
+do_compile =							\
+	($(if $(GENERATE_PIC), $(do_fpic_compile),		\
+	 $(print_compile)					\
+	 $(CC) -c $(CPPFLAGS) $(CFLAGS) $(EXT) $< -o $@))
+
 do_app_build =						\
 	($(print_app_build)				\
 	$(CC) $^ -rdynamic -o $@ $(LDFLAGS) $(CONFIG_LIBS) $(LIBS))
Signature · 1 line
2.14.1
#13 lore raw

PATCH v2 13/24 trace-cmd: Move python-related files in python/

In reply to Vladislav Valtchev (VMware)

This patch moves all the files related with trace-cmd's python support to a dedicated directory, as part of a bigger restructuring plan of trace-cmd's code base. The build system has been updated to support this new directory structure by adding a separate Makefile in python/ and by making the parent Makefile to invoke it.

---
 Makefile                                  | 42 +++++++++----------------------
 python/Makefile                           | 40 +++++++++++++++++++++++++++++
 ctracecmd.i => python/ctracecmd.i         |  0
 ctracecmdgui.i => python/ctracecmdgui.i   |  0
 event-viewer.py => python/event-viewer.py |  0
 tracecmd.py => python/tracecmd.py         |  0
 tracecmdgui.py => python/tracecmdgui.py   |  0
 7 files changed, 52 insertions(+), 30 deletions(-)
 create mode 100644 python/Makefile
 rename ctracecmd.i => python/ctracecmd.i (100%)
 rename ctracecmdgui.i => python/ctracecmdgui.i (100%)
 rename event-viewer.py => python/event-viewer.py (100%)
 rename tracecmd.py => python/tracecmd.py (100%)
 rename tracecmdgui.py => python/tracecmdgui.py (100%)
Makefile +12 -30
index 2dfb8fd..b1f4c2c 100644
@@ -113,13 +113,12 @@ PYTHON_VERS ?= python
 ifeq ($(shell sh -c "pkg-config --cflags $(PYTHON_VERS) > /dev/null 2>&1 && which swig && echo y"), y)
 	PYTHON_PLUGINS := plugin_python.so
 	BUILD_PYTHON := $(PYTHON) $(PYTHON_PLUGINS)
-	PYTHON_SO_INSTALL := ctracecmd.install
-	PYTHON_PY_PROGS := event-viewer.install
-	PYTHON_PY_LIBS := tracecmd.install tracecmdgui.install
+	BUILD_PYTHON_WORKS := 1
 endif
 endif # NO_PYTHON
 
 export PYTHON_PLUGINS
+export BUILD_PYTHON_WORKS
 
 # $(call test-build, snippet, ret) -> ret if snippet compiles
 #                                  -> empty otherwise
@@ -176,6 +175,7 @@ LIBTRACECMD_SHARED = $(LIBTRACECMD_DIR)/libtracecmd.so
 
 export LIBS
 export LIBTRACEEVENT_DIR LIBTRACECMD_DIR
+export LIBTRACECMD_STATIC LIBTRACECMD_SHARED
 
 CONFIG_INCLUDES = 
 CONFIG_LIBS	=
@@ -248,10 +248,6 @@ $(obj)/%.o: $(src)/%.c
 %.o: $(src)/%.c
 	$(Q)$(call do_compile)
 
-TRACE_VIEW_OBJS =
-TRACE_VIEW_OBJS += $(obj)/kernel-shark/trace-view.o
-TRACE_VIEW_OBJS += $(obj)/kernel-shark/trace-view-store.o
-
 TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-listen.o \
 	 trace-stack.o trace-hist.o trace-mem.o trace-snapshot.o trace-stat.o \
 	 trace-profile.o trace-stream.o trace-record.o trace-restore.o \
@@ -372,19 +368,8 @@ cscope: force
 install_plugins: force
 	$(Q)$(MAKE) -C $(src)/plugins $@
 
-$(PYTHON_SO_INSTALL): %.install : %.so force
-	$(Q)$(call do_install_data,$<,$(python_dir_SQ))
-
-$(PYTHON_PY_PROGS): %.install : %.py force
-	$(Q)$(call do_install,$<,$(python_dir_SQ))
-
-$(PYTHON_PY_LIBS): %.install : %.py force
-	$(Q)$(call do_install_data,$<,$(python_dir_SQ))
-
-$(PYTHON_PY_PLUGINS): %.install : %.py force
-	$(Q)$(call do_install_data,$<,$(plugin_dir_SQ))
-
-install_python: $(PYTHON_SO_INSTALL) $(PYTHON_PY_PROGS) $(PYTHON_PY_LIBS) $(PYTHON_PY_PLUGINS)
+install_python: force
+	$(Q)$(MAKE) -C $(src)/python $@
 
 install_bash_completion: force
 	$(Q)$(call do_install_data,trace-cmd.bash,$(BASH_COMPLETE_DIR))
@@ -417,19 +402,20 @@ install_doc:
 	$(MAKE) -C $(src)/Documentation install
 
 clean:
-	$(RM) *.o *~ $(TARGETS) *.a *.so ctracecmd_wrap.c .*.d
+	$(RM) *.o *~ $(TARGETS) *.a *.so .*.d
 	$(RM) tags TAGS cscope*
 	$(MAKE) -C $(src)/lib/traceevent clean
 	$(MAKE) -C $(src)/lib/trace-cmd clean
 	$(MAKE) -C $(src)/kernel-shark clean
 	$(MAKE) -C $(src)/plugins clean
+	$(MAKE) -C $(src)/python clean
 
 
 ##### PYTHON STUFF #####
 
 report_noswig: force
 	$(Q)echo
-	$(Q)echo "    NO_PYTHON forced: swig not installed, not compling python plugins"
+	$(Q)echo "    NO_PYTHON forced: swig not installed, not compiling python plugins"
 	$(Q)echo
 
 PYTHON_INCLUDES = `pkg-config --cflags $(PYTHON_VERS)`
@@ -441,15 +427,11 @@ export PYTHON_INCLUDES
 export PYTHON_LDFLAGS
 export PYGTK_CFLAGS
 
-ctracecmd.so: $(TCMD_LIB_OBJS) ctracecmd.i
-	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
+ctracecmd.so: force $(LIBTRACECMD_STATIC)
+	$(Q)$(MAKE) -C $(src)/python $@
 
-ctracecmdgui.so: trace-view $(LIBTRACECMD_STATIC)
-	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
+ctracecmdgui.so: force $(LIBTRACECMD_STATIC) trace-view
+	$(Q)$(MAKE) -C $(src)/python $@
 
 PHONY += python
 python: $(PYTHON)
python/Makefile new file +40 -0
new file mode 100644
index 0000000..b07c0d8
@@ -0,0 +1,40 @@
+include $(src)/scripts/utils.mk
+
+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
+endif
+
+ctracecmd.so: ctracecmd.i $(LIBTRACECMD_STATIC)
+	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
+
+ctracecmdgui.so: ctracecmdgui.i $(LIBTRACECMD_STATIC) $(TRACE_VIEW_OBJS)
+	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
+
+
+$(PYTHON_SO_INSTALL): %.install : %.so force
+	$(Q)$(call do_install_data,$<,$(python_dir_SQ))
+
+$(PYTHON_PY_PROGS): %.install : %.py force
+	$(Q)$(call do_install,$<,$(python_dir_SQ))
+
+$(PYTHON_PY_LIBS): %.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.*
+
+force:
+.PHONY: clean force
python/ctracecmd.i renamed from ctracecmd.i +0 -0
similarity index 100%
rename from ctracecmd.i
rename to python/ctracecmd.i
python/ctracecmdgui.i renamed from ctracecmdgui.i +0 -0
similarity index 100%
rename from ctracecmdgui.i
rename to python/ctracecmdgui.i
python/event-viewer.py renamed from event-viewer.py +0 -0
similarity index 100%
rename from event-viewer.py
rename to python/event-viewer.py
python/tracecmd.py renamed from tracecmd.py +0 -0
similarity index 100%
rename from tracecmd.py
rename to python/tracecmd.py
python/tracecmdgui.py renamed from tracecmdgui.py +0 -0
similarity index 100%
rename from tracecmdgui.py
rename to python/tracecmdgui.py
Signature · 1 line
2.14.1
#14 lore raw

Re: [PATCH v2 13/24] trace-cmd: Move python-related files in python/

On Tue, 6 Feb 2018 10:48:55 +0200
"Vladislav Valtchev (VMware)" <[email protected]> wrote:

Hi Vladislav,

This is actually the problem commit. The other commit fixed the output of the test and this code wasn't being executed until you added the fix. Which is why the fix caused the bisect to blame it.

I'm looking at why this breaks install, but I found another concern.

Quoted 52 lines

This patch moves all the files related with trace-cmd's python support to a dedicated directory, as part of a bigger restructuring plan of trace-cmd's code base. The build system has been updated to support this new directory structure by adding a separate Makefile in python/ and by making the parent Makefile to invoke it.

---
 Makefile                                  | 42 +++++++++----------------------
 python/Makefile                           | 40 +++++++++++++++++++++++++++++
 ctracecmd.i => python/ctracecmd.i         |  0
 ctracecmdgui.i => python/ctracecmdgui.i   |  0
 event-viewer.py => python/event-viewer.py |  0
 tracecmd.py => python/tracecmd.py         |  0
 tracecmdgui.py => python/tracecmdgui.py   |  0
 7 files changed, 52 insertions(+), 30 deletions(-)
 create mode 100644 python/Makefile
 rename ctracecmd.i => python/ctracecmd.i (100%)
 rename ctracecmdgui.i => python/ctracecmdgui.i (100%)
 rename event-viewer.py => python/event-viewer.py (100%)
 rename tracecmd.py => python/tracecmd.py (100%)
 rename tracecmdgui.py => python/tracecmdgui.py (100%)
Makefile +3 -3
index 2dfb8fd..b1f4c2c 100644
@@ -113,13 +113,12 @@ PYTHON_VERS ?= python
 ifeq ($(shell sh -c "pkg-config --cflags $(PYTHON_VERS) > /dev/null 2>&1 && which swig && echo y"), y)
 	PYTHON_PLUGINS := plugin_python.so
 	BUILD_PYTHON := $(PYTHON) $(PYTHON_PLUGINS)
-	PYTHON_SO_INSTALL := ctracecmd.install
-	PYTHON_PY_PROGS := event-viewer.install
-	PYTHON_PY_LIBS := tracecmd.install tracecmdgui.install
+	BUILD_PYTHON_WORKS := 1
 endif
 endif # NO_PYTHON
 
 export PYTHON_PLUGINS
+export BUILD_PYTHON_WORKS
 
 # $(call test-build, snippet, ret) -> ret if snippet compiles
 #                                  -> empty otherwise
@@ -176,6 +175,7 @@ LIBTRACECMD_SHARED = $(LIBTRACECMD_DIR)/libtracecmd.so
 
 export LIBS
 export LIBTRACEEVENT_DIR LIBTRACECMD_DIR
+export LIBTRACECMD_STATIC LIBTRACECMD_SHARED
 
 CONFIG_INCLUDES = 
 CONFIG_LIBS	=

Makefile $(obj)/%.o: $(src)/%.c · line 253

Quoted 6 lines
Makefile +0 -3
@@ -248,10 +248,6 @@ $(obj)/%.o: $(src)/%.c
 %.o: $(src)/%.c
 	$(Q)$(call do_compile)
 
-TRACE_VIEW_OBJS =
-TRACE_VIEW_OBJS += $(obj)/kernel-shark/trace-view.o
-TRACE_VIEW_OBJS += $(obj)/kernel-shark/trace-view-store.o

Why is this being moved into python code?

-- Steve

Quoted 135 lines
Makefile +9 -24
-
 TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-listen.o \
 	 trace-stack.o trace-hist.o trace-mem.o trace-snapshot.o trace-stat.o \
 	 trace-profile.o trace-stream.o trace-record.o trace-restore.o \
@@ -372,19 +368,8 @@ cscope: force
 install_plugins: force
 	$(Q)$(MAKE) -C $(src)/plugins $@
 
-$(PYTHON_SO_INSTALL): %.install : %.so force
-	$(Q)$(call do_install_data,$<,$(python_dir_SQ))
-
-$(PYTHON_PY_PROGS): %.install : %.py force
-	$(Q)$(call do_install,$<,$(python_dir_SQ))
-
-$(PYTHON_PY_LIBS): %.install : %.py force
-	$(Q)$(call do_install_data,$<,$(python_dir_SQ))
-
-$(PYTHON_PY_PLUGINS): %.install : %.py force
-	$(Q)$(call do_install_data,$<,$(plugin_dir_SQ))
-
-install_python: $(PYTHON_SO_INSTALL) $(PYTHON_PY_PROGS) $(PYTHON_PY_LIBS) $(PYTHON_PY_PLUGINS)
+install_python: force
+	$(Q)$(MAKE) -C $(src)/python $@
 
 install_bash_completion: force
 	$(Q)$(call do_install_data,trace-cmd.bash,$(BASH_COMPLETE_DIR))
@@ -417,19 +402,20 @@ install_doc:
 	$(MAKE) -C $(src)/Documentation install
 
 clean:
-	$(RM) *.o *~ $(TARGETS) *.a *.so ctracecmd_wrap.c .*.d
+	$(RM) *.o *~ $(TARGETS) *.a *.so .*.d
 	$(RM) tags TAGS cscope*
 	$(MAKE) -C $(src)/lib/traceevent clean
 	$(MAKE) -C $(src)/lib/trace-cmd clean
 	$(MAKE) -C $(src)/kernel-shark clean
 	$(MAKE) -C $(src)/plugins clean
+	$(MAKE) -C $(src)/python clean
 
 
 ##### PYTHON STUFF #####
 
 report_noswig: force
 	$(Q)echo
-	$(Q)echo "    NO_PYTHON forced: swig not installed, not compling python plugins"
+	$(Q)echo "    NO_PYTHON forced: swig not installed, not compiling python plugins"
 	$(Q)echo
 
 PYTHON_INCLUDES = `pkg-config --cflags $(PYTHON_VERS)`
@@ -441,15 +427,11 @@ export PYTHON_INCLUDES
 export PYTHON_LDFLAGS
 export PYGTK_CFLAGS
 
-ctracecmd.so: $(TCMD_LIB_OBJS) ctracecmd.i
-	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
+ctracecmd.so: force $(LIBTRACECMD_STATIC)
+	$(Q)$(MAKE) -C $(src)/python $@
 
-ctracecmdgui.so: trace-view $(LIBTRACECMD_STATIC)
-	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
+ctracecmdgui.so: force $(LIBTRACECMD_STATIC) trace-view
+	$(Q)$(MAKE) -C $(src)/python $@
 
 PHONY += python
 python: $(PYTHON)
python/Makefile new file +40 -0
new file mode 100644
index 0000000..b07c0d8
@@ -0,0 +1,40 @@
+include $(src)/scripts/utils.mk
+
+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
+endif
+
+ctracecmd.so: ctracecmd.i $(LIBTRACECMD_STATIC)
+	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
+
+ctracecmdgui.so: ctracecmdgui.i $(LIBTRACECMD_STATIC) $(TRACE_VIEW_OBJS)
+	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
+
+
+$(PYTHON_SO_INSTALL): %.install : %.so force
+	$(Q)$(call do_install_data,$<,$(python_dir_SQ))
+
+$(PYTHON_PY_PROGS): %.install : %.py force
+	$(Q)$(call do_install,$<,$(python_dir_SQ))
+
+$(PYTHON_PY_LIBS): %.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.*
+
+force:
+.PHONY: clean force
python/ctracecmd.i renamed from ctracecmd.i +0 -0
similarity index 100%
rename from ctracecmd.i
rename to python/ctracecmd.i
python/ctracecmdgui.i renamed from ctracecmdgui.i +0 -0
similarity index 100%
rename from ctracecmdgui.i
rename to python/ctracecmdgui.i
python/event-viewer.py renamed from event-viewer.py +0 -0
similarity index 100%
rename from event-viewer.py
rename to python/event-viewer.py
python/tracecmd.py renamed from tracecmd.py +0 -0
similarity index 100%
rename from tracecmd.py
rename to python/tracecmd.py
python/tracecmdgui.py renamed from tracecmdgui.py +0 -0
similarity index 100%
rename from tracecmdgui.py
rename to python/tracecmdgui.py
#15 lore raw

Re: [PATCH v2 13/24] trace-cmd: Move python-related files in python/

Quoted 1 line · On Wed, 7 Feb 2018 14:22:38 -0500 Steven Rostedt <[email protected]> wrote:

I'm looking at why this breaks install, but I found another concern.

Here's the fix, I'll fold it into your patch.

-- Steve

Makefile +1 -0
index 9544d84..89bec15 100644
@@ -86,6 +86,7 @@ export PLUGIN_DIR
 export PYTHON_DIR
 export PYTHON_DIR_SQ
 export plugin_dir_SQ
+export python_dir_SQ
 export var_dir
 
 # copy a bit from Linux kbuild
#16 lore raw

Re: [PATCH v2 13/24] trace-cmd: Move python-related files in python/

Quoted 14 lines · Steven Rostedt
Quoted 1 line · On Wed, 7 Feb 2018 14:22:38 -0500 Steven Rostedt <[email protected]> wrote:

I'm looking at why this breaks install, but I found another concern.

Here's the fix, I'll fold it into your patch.

-- Steve

Makefile +0 -0
index 9544d84..89bec15 100644

Makefile export PLUGIN_DIR · line 91

Quoted 6 lines
Makefile +1 -0
@@ -86,6 +86,7 @@ export PLUGIN_DIR
 export PYTHON_DIR
 export PYTHON_DIR_SQ
 export plugin_dir_SQ
+export python_dir_SQ
 export var_dir
 

Aha, I suspected that something that subtle could be the problem! Thanks for doing everything, Steven!

Signature · 2 lines
Vladislav Valtchev
VMware Open Source Technology Center
#17 lore raw

Re: [PATCH v2 13/24] trace-cmd: Move python-related files in python/

In reply to Steven Rostedt
Quoted 9 lines · On Wed, 7 Feb 2018 14:22:38 -0500 Steven Rostedt <[email protected]> wrote:

Makefile $(obj)/%.o: $(src)/%.c · line 253

Quoted 7 lines
Makefile +0 -3
@@ -248,10 +248,6 @@ $(obj)/%.o: $(src)/%.c
 %.o: $(src)/%.c
 	$(Q)$(call do_compile)
 
-TRACE_VIEW_OBJS =
-TRACE_VIEW_OBJS += $(obj)/kernel-shark/trace-view.o
-TRACE_VIEW_OBJS += $(obj)/kernel-shark/trace-view-store.o  

Why is this being moved into python code?

I now understand why you did it this way.

Quoted 12 lines
Quoted 12 lines
python/Makefile new file +11 -0
+++ b/python/Makefile
@@ -0,0 +1,40 @@
+include $(src)/scripts/utils.mk
+
+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
Quoted 8 lines

python/Makefile line 18

Quoted 8 lines
python/Makefile new file +8 -0
+endif
+
+ctracecmd.so: ctracecmd.i $(LIBTRACECMD_STATIC)
+	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
+
+ctracecmdgui.so: ctracecmdgui.i $(LIBTRACECMD_STATIC) $(TRACE_VIEW_OBJS)

For this above.

I'd rather have that depend on a single file in kernel-shark directory, or something that makes it a little cleaner.

-- Steve

Quoted 43 lines
Quoted 42 lines
python/Makefile new file +22 -0
+	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
+
+
+$(PYTHON_SO_INSTALL): %.install : %.so force
+	$(Q)$(call do_install_data,$<,$(python_dir_SQ))
+
+$(PYTHON_PY_PROGS): %.install : %.py force
+	$(Q)$(call do_install,$<,$(python_dir_SQ))
+
+$(PYTHON_PY_LIBS): %.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.*
+
+force:
+.PHONY: clean force
python/ctracecmd.i renamed from ctracecmd.i +0 -0
similarity index 100%
rename from ctracecmd.i
rename to python/ctracecmd.i
python/ctracecmdgui.i renamed from ctracecmdgui.i +0 -0
similarity index 100%
rename from ctracecmdgui.i
rename to python/ctracecmdgui.i
python/event-viewer.py renamed from event-viewer.py +0 -0
similarity index 100%
rename from event-viewer.py
rename to python/event-viewer.py
python/tracecmd.py renamed from tracecmd.py +0 -0
similarity index 100%
rename from tracecmd.py
rename to python/tracecmd.py
python/tracecmdgui.py renamed from tracecmdgui.py +0 -0
similarity index 100%
rename from tracecmdgui.py
rename to python/tracecmdgui.py  
#18 lore raw

Re: [PATCH v2 13/24] trace-cmd: Move python-related files in python/

Quoted 15 lines · Steven Rostedt
Quoted 5 lines · On Wed, 7 Feb 2018 14:22:38 -0500 Steven Rostedt <[email protected]> wrote:

Makefile $(obj)/%.o: $(src)/%.c · line 253

Quoted 3 lines
Makefile +0 -3
-TRACE_VIEW_OBJS =
-TRACE_VIEW_OBJS += $(obj)/kernel-shark/trace-view.o
-TRACE_VIEW_OBJS += $(obj)/kernel-shark/trace-view-store.o  

Why is this being moved into python code?

I now understand why you did it this way.

Quoted 8 lines
Quoted 1 line
Quoted 1 line

+ctracecmdgui.so: ctracecmdgui.i $(LIBTRACECMD_STATIC) $(TRACE_VIEW_OBJS)

For this above.

I'd rather have that depend on a single file in kernel-shark directory, or something that makes it a little cleaner.

-- Steve

Yep, you're totally right.
That was mostly a hack, part of a mechanical step. Probably we should make a mini static lib for those two files and make both trace-view and the python targets depend on it.

Signature · 2 lines
Vladislav Valtchev
VMware Open Source Technology Center
#19 lore raw

PATCH v2 14/24 trace-cmd: Move tracecmd headers in tracecmd/include

In reply to Vladislav Valtchev (VMware)

This patch moves trace-cmd's private headers in a dedicated directory called tracecmd/include, as part of a bigger restructuring plan of trace-cmd's code base.

---
 Makefile                                                | 1 +
 bug.h => tracecmd/include/bug.h                         | 0
 list.h => tracecmd/include/list.h                       | 0
 trace-cmd-local.h => tracecmd/include/trace-cmd-local.h | 0
 trace-local.h => tracecmd/include/trace-local.h         | 0
 trace-msg.h => tracecmd/include/trace-msg.h             | 0
 6 files changed, 1 insertion(+)
 rename bug.h => tracecmd/include/bug.h (100%)
 rename list.h => tracecmd/include/list.h (100%)
 rename trace-cmd-local.h => tracecmd/include/trace-cmd-local.h (100%)
 rename trace-local.h => tracecmd/include/trace-local.h (100%)
 rename trace-msg.h => tracecmd/include/trace-msg.h (100%)
Makefile +1 -0
index b1f4c2c..4e604b4 100644
@@ -200,6 +200,7 @@ INCLUDES += -I$(src)/include/trace-cmd
 INCLUDES += -I$(src)/lib/traceevent/include
 INCLUDES += -I$(src)/lib/trace-cmd/include
 INCLUDES += -I$(src)/kernel-shark/include
+INCLUDES += -I$(src)/tracecmd/include
 
 include $(src)/features.mk
 
tracecmd/include/bug.h renamed from bug.h +0 -0
similarity index 100%
rename from bug.h
rename to tracecmd/include/bug.h
tracecmd/include/list.h renamed from list.h +0 -0
similarity index 100%
rename from list.h
rename to tracecmd/include/list.h
tracecmd/include/trace-cmd-local.h renamed from trace-cmd-local.h +0 -0
similarity index 100%
rename from trace-cmd-local.h
rename to tracecmd/include/trace-cmd-local.h
tracecmd/include/trace-local.h renamed from trace-local.h +0 -0
similarity index 100%
rename from trace-local.h
rename to tracecmd/include/trace-local.h
tracecmd/include/trace-msg.h renamed from trace-msg.h +0 -0
similarity index 100%
rename from trace-msg.h
rename to tracecmd/include/trace-msg.h
Signature · 1 line
2.14.1
#20 lore raw

PATCH v2 15/24 trace-cmd: Move version.h in include/

In reply to Vladislav Valtchev (VMware)

This trivial patch just moves the only header file remained in project's root directory to the include/ directory, common for all of the trace-cmd's sub-projects.

---
 version.h => include/version.h | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename version.h => include/version.h (100%)
include/version.h renamed from version.h +0 -0
similarity index 100%
rename from version.h
rename to include/version.h
Signature · 1 line
2.14.1
#21 lore raw

PATCH v2 16/24 trace-cmd: Move trace-cmd app files in tracecmd/

In reply to Vladislav Valtchev (VMware)

This patch moves all the remaining C files in the project's root directory to tracecmd, a directory dedicated to the trace-cmd application itself. This patch completes the bigger restructuring plan of trace-cmd's code base.

---
 Makefile                                           | 77 +++++-----------------
 tracecmd/Makefile                                  | 73 ++++++++++++++++++++
 .../trace-check-events.c                           |  0
 trace-cmd.bash => tracecmd/trace-cmd.bash          |  0
 trace-cmd.c => tracecmd/trace-cmd.c                |  0
 trace-hist.c => tracecmd/trace-hist.c              |  0
 trace-list.c => tracecmd/trace-list.c              |  0
 trace-listen.c => tracecmd/trace-listen.c          |  0
 trace-mem.c => tracecmd/trace-mem.c                |  0
 trace-msg.c => tracecmd/trace-msg.c                |  0
 trace-output.c => tracecmd/trace-output.c          |  0
 trace-profile.c => tracecmd/trace-profile.c        |  0
 trace-read.c => tracecmd/trace-read.c              |  0
 trace-record.c => tracecmd/trace-record.c          |  0
 trace-restore.c => tracecmd/trace-restore.c        |  0
 trace-show.c => tracecmd/trace-show.c              |  0
 trace-snapshot.c => tracecmd/trace-snapshot.c      |  0
 trace-split.c => tracecmd/trace-split.c            |  0
 trace-stack.c => tracecmd/trace-stack.c            |  0
 trace-stat.c => tracecmd/trace-stat.c              |  0
 trace-stream.c => tracecmd/trace-stream.c          |  0
 trace-usage.c => tracecmd/trace-usage.c            |  0
 22 files changed, 88 insertions(+), 62 deletions(-)
 create mode 100644 tracecmd/Makefile
 rename trace-check-events.c => tracecmd/trace-check-events.c (100%)
 rename trace-cmd.bash => tracecmd/trace-cmd.bash (100%)
 rename trace-cmd.c => tracecmd/trace-cmd.c (100%)
 rename trace-hist.c => tracecmd/trace-hist.c (100%)
 rename trace-list.c => tracecmd/trace-list.c (100%)
 rename trace-listen.c => tracecmd/trace-listen.c (100%)
 rename trace-mem.c => tracecmd/trace-mem.c (100%)
 rename trace-msg.c => tracecmd/trace-msg.c (100%)
 rename trace-output.c => tracecmd/trace-output.c (100%)
 rename trace-profile.c => tracecmd/trace-profile.c (100%)
 rename trace-read.c => tracecmd/trace-read.c (100%)
 rename trace-record.c => tracecmd/trace-record.c (100%)
 rename trace-restore.c => tracecmd/trace-restore.c (100%)
 rename trace-show.c => tracecmd/trace-show.c (100%)
 rename trace-snapshot.c => tracecmd/trace-snapshot.c (100%)
 rename trace-split.c => tracecmd/trace-split.c (100%)
 rename trace-stack.c => tracecmd/trace-stack.c (100%)
 rename trace-stat.c => tracecmd/trace-stat.c (100%)
 rename trace-stream.c => tracecmd/trace-stream.c (100%)
 rename trace-usage.c => tracecmd/trace-usage.c (100%)
Makefile +15 -62
index 4e604b4..cc96534 100644
@@ -3,6 +3,12 @@
 TC_VERSION = 2
 TC_PATCHLEVEL = 7
 TC_EXTRAVERSION =
+TRACECMD_VERSION = $(TC_VERSION).$(TC_PATCHLEVEL).$(TC_EXTRAVERSION)
+
+export TC_VERSION
+export TC_PATCHLEVEL
+export TC_EXTRAVERSION
+export TRACECMD_VERSION
 
 # file format version
 FILE_VERSION = 6
@@ -176,25 +182,14 @@ LIBTRACECMD_SHARED = $(LIBTRACECMD_DIR)/libtracecmd.so
 export LIBS
 export LIBTRACEEVENT_DIR LIBTRACECMD_DIR
 export LIBTRACECMD_STATIC LIBTRACECMD_SHARED
-
-CONFIG_INCLUDES = 
-CONFIG_LIBS	=
-CONFIG_FLAGS	=
-
-VERSION		= $(TC_VERSION)
-PATCHLEVEL	= $(TC_PATCHLEVEL)
-EXTRAVERSION	= $(TC_EXTRAVERSION)
-
-N		=
+export LIBTRACEEVENT_STATIC LIBTRACEEVENT_SHARED
 
 export Q VERBOSE EXT
 
 # Include the utils
 include scripts/utils.mk
 
-TRACECMD_VERSION = $(TC_VERSION).$(TC_PATCHLEVEL).$(TC_EXTRAVERSION)
-
-INCLUDES = -I$(src) -I $(src)/include -I $(srctree)/../../include $(CONFIG_INCLUDES)
+INCLUDES = -I$(src)/include -I$(src)/../../include
 INCLUDES += -I$(src)/include/traceevent
 INCLUDES += -I$(src)/include/trace-cmd
 INCLUDES += -I$(src)/lib/traceevent/include
@@ -243,27 +238,8 @@ endif
 override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ) $(VAR_DIR)
 override CFLAGS += $(udis86-flags) $(blk-flags)
 
-$(obj)/%.o: $(src)/%.c
-	$(Q)$(call do_compile)
 
-%.o: $(src)/%.c
-	$(Q)$(call do_compile)
-
-TRACE_CMD_OBJS = trace-cmd.o trace-record.o trace-read.o trace-split.o trace-listen.o \
-	 trace-stack.o trace-hist.o trace-mem.o trace-snapshot.o trace-stat.o \
-	 trace-profile.o trace-stream.o trace-record.o trace-restore.o \
-	 trace-check-events.o trace-show.o trace-list.o  \
-	 trace-output.o trace-usage.o trace-msg.o
-
-ALL_OBJS = $(TRACE_CMD_OBJS)
-
-CMD_TARGETS = tc_version.h trace-cmd $(BUILD_PYTHON)
-
-
-TARGETS = $(CMD_TARGETS)
-
-
-#	cpp $(INCLUDES)
+CMD_TARGETS = trace-cmd $(BUILD_PYTHON)
 
 ###
 #    Default we just build trace-cmd
@@ -279,10 +255,8 @@ gui: force $(CMD_TARGETS)
 	$(Q)$(MAKE) -C $(src)/kernel-shark; \
 	echo "gui build complete"
 
-trace-cmd: $(TRACE_CMD_OBJS)
-	$(Q)$(do_app_build)
-
-trace-cmd: $(LIBTRACECMD_STATIC) $(LIBTRACEEVENT_STATIC)
+trace-cmd: force $(LIBTRACEEVENT_STATIC) $(LIBTRACECMD_STATIC)
+	$(Q)$(MAKE) -C $(src)/tracecmd $@
 
 kernelshark: force $(CMD_TARGETS)
 	$(Q)$(MAKE) -C $(src)/kernel-shark $@
@@ -315,34 +289,12 @@ libs: $(LIBTRACECMD_SHARED) $(LIBTRACEEVENT_SHARED)
 plugins: force $(obj)/plugins/trace_plugin_dir $(obj)/plugins/trace_python_dir
 	$(Q)$(MAKE) -C $(src)/plugins
 
-tc_version.h: force
-	$(Q)$(N)$(call update_version.h)
-
 $(obj)/plugins/trace_plugin_dir: force
 	$(Q)$(MAKE) -C $(src)/plugins trace_plugin_dir
 
 $(obj)/plugins/trace_python_dir: force
 	$(Q)$(MAKE) -C $(src)/plugins trace_python_dir
 
-
-## make deps
-
-all_objs := $(sort $(ALL_OBJS))
-all_deps := $(all_objs:%.o=.%.d)
-
-$(all_deps): tc_version.h
-
-$(all_deps): .%.d: $(src)/%.c
-	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@;
-
-$(all_objs) : %.o : .%.d
-
-dep_includes := $(wildcard $(all_deps))
-
-ifneq ($(dep_includes),)
- include $(dep_includes)
-endif
-
 show_gui_make:
 	@echo "Note: to build the gui, type \"make gui\""
 	@echo "      to build man pages, type \"make doc\""
@@ -373,10 +325,10 @@ install_python: force
 	$(Q)$(MAKE) -C $(src)/python $@
 
 install_bash_completion: force
-	$(Q)$(call do_install_data,trace-cmd.bash,$(BASH_COMPLETE_DIR))
+	$(Q)$(call do_install_data,$(src)/tracecmd/trace-cmd.bash,$(BASH_COMPLETE_DIR))
 
 install_cmd: all_cmd install_plugins install_python install_bash_completion
-	$(Q)$(call do_install,trace-cmd,$(bindir_SQ))
+	$(Q)$(call do_install,$(obj)/tracecmd/trace-cmd,$(bindir_SQ))
 
 install: install_cmd
 	@echo "Note: to install the gui, type \"make install_gui\""
@@ -403,13 +355,14 @@ install_doc:
 	$(MAKE) -C $(src)/Documentation install
 
 clean:
-	$(RM) *.o *~ $(TARGETS) *.a *.so .*.d
+	$(RM) *.o *~ *.a *.so .*.d
 	$(RM) tags TAGS cscope*
 	$(MAKE) -C $(src)/lib/traceevent clean
 	$(MAKE) -C $(src)/lib/trace-cmd clean
 	$(MAKE) -C $(src)/kernel-shark clean
 	$(MAKE) -C $(src)/plugins clean
 	$(MAKE) -C $(src)/python clean
+	$(MAKE) -C $(src)/tracecmd clean
 
 
 ##### PYTHON STUFF #####
tracecmd/Makefile new file +73 -0

73 lines not on this page · raw message

tracecmd/trace-check-events.c renamed from trace-check-events.c +0 -0
similarity index 100%
rename from trace-check-events.c
rename to tracecmd/trace-check-events.c
tracecmd/trace-cmd.bash renamed from trace-cmd.bash +0 -0
similarity index 100%
rename from trace-cmd.bash
rename to tracecmd/trace-cmd.bash
tracecmd/trace-cmd.c renamed from trace-cmd.c +0 -0
similarity index 100%
rename from trace-cmd.c
rename to tracecmd/trace-cmd.c
tracecmd/trace-hist.c renamed from trace-hist.c +0 -0
similarity index 100%
rename from trace-hist.c
rename to tracecmd/trace-hist.c
tracecmd/trace-list.c renamed from trace-list.c +0 -0
similarity index 100%
rename from trace-list.c
rename to tracecmd/trace-list.c
tracecmd/trace-listen.c renamed from trace-listen.c +0 -0
similarity index 100%
rename from trace-listen.c
rename to tracecmd/trace-listen.c
tracecmd/trace-mem.c renamed from trace-mem.c +0 -0
similarity index 100%
rename from trace-mem.c
rename to tracecmd/trace-mem.c
tracecmd/trace-msg.c renamed from trace-msg.c +0 -0
similarity index 100%
rename from trace-msg.c
rename to tracecmd/trace-msg.c
tracecmd/trace-output.c renamed from trace-output.c +0 -0
similarity index 100%
rename from trace-output.c
rename to tracecmd/trace-output.c
tracecmd/trace-profile.c renamed from trace-profile.c +0 -0
similarity index 100%
rename from trace-profile.c
rename to tracecmd/trace-profile.c
tracecmd/trace-read.c renamed from trace-read.c +0 -0
similarity index 100%
rename from trace-read.c
rename to tracecmd/trace-read.c
tracecmd/trace-record.c renamed from trace-record.c +0 -0
similarity index 100%
rename from trace-record.c
rename to tracecmd/trace-record.c
tracecmd/trace-restore.c renamed from trace-restore.c +0 -0
similarity index 100%
rename from trace-restore.c
rename to tracecmd/trace-restore.c
tracecmd/trace-show.c renamed from trace-show.c +0 -0
similarity index 100%
rename from trace-show.c
rename to tracecmd/trace-show.c
tracecmd/trace-snapshot.c renamed from trace-snapshot.c +0 -0
similarity index 100%
rename from trace-snapshot.c
rename to tracecmd/trace-snapshot.c
tracecmd/trace-split.c renamed from trace-split.c +0 -0
similarity index 100%
rename from trace-split.c
rename to tracecmd/trace-split.c
tracecmd/trace-stack.c renamed from trace-stack.c +0 -0
similarity index 100%
rename from trace-stack.c
rename to tracecmd/trace-stack.c
tracecmd/trace-stat.c renamed from trace-stat.c +0 -0
similarity index 100%
rename from trace-stat.c
rename to tracecmd/trace-stat.c
tracecmd/trace-stream.c renamed from trace-stream.c +0 -0
similarity index 100%
rename from trace-stream.c
rename to tracecmd/trace-stream.c
tracecmd/trace-usage.c renamed from trace-usage.c +0 -0
similarity index 100%
rename from trace-usage.c
rename to tracecmd/trace-usage.c
Signature · 1 line
2.14.1
#22 lore raw

PATCH v2 17/24 trace-cmd: Fix the logic behind SWIG_DEFINED in the Makefile

In reply to Vladislav Valtchev (VMware)

At least on Ubuntu, the $(shell ...) command used in the master Makefile to test for the existence of the 'swig' command does not work in the negative case. That causes the build to report ugly errors in case 'swig' is not installed on the system.
This one-line patch, fixes the problem by using the POSIX 'comamnd -v {CMD}' in $(shell ...) to detect the presence of the swig and restores this way the fake report_noswig target.

---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
index cc96534..6016bec 100644
@@ -103,7 +103,7 @@ ifndef VERBOSE
   VERBOSE = 0
 endif
 
-SWIG_DEFINED := $(shell if swig -help &> /dev/null; then echo 1; else echo 0; fi)
+SWIG_DEFINED := $(shell if command -v swig; then echo 1; else echo 0; fi)
 ifeq ($(SWIG_DEFINED), 0)
 BUILD_PYTHON := report_noswig
 NO_PYTHON = 1
@@ -116,7 +116,7 @@ PYTHON_GUI	:= ctracecmd.so ctracecmdgui.so
 PYTHON_VERS ?= python
 
 # Can build python?
-ifeq ($(shell sh -c "pkg-config --cflags $(PYTHON_VERS) > /dev/null 2>&1 && which swig && echo y"), y)
+ifeq ($(shell sh -c "pkg-config --cflags $(PYTHON_VERS) > /dev/null 2>&1 && echo y"), y)
 	PYTHON_PLUGINS := plugin_python.so
 	BUILD_PYTHON := $(PYTHON) $(PYTHON_PLUGINS)
 	BUILD_PYTHON_WORKS := 1
Signature · 1 line
2.14.1
#23 lore raw

PATCH v2 18/24 trace-cmd: Make the build to tell when python-dev is missing

In reply to Vladislav Valtchev (VMware)

Currently, the build system will complain when swig is missing, since that will prevent it to build the python C modules, but in case swig is present but python-dev is not installed, the build will just silently skip them. This patch just makes the build to report a message when that happens.

---
 Makefile | 7 +++++++
 1 file changed, 7 insertions(+)
Makefile +7 -0
index 6016bec..4f17dd3 100644
@@ -120,6 +120,8 @@ ifeq ($(shell sh -c "pkg-config --cflags $(PYTHON_VERS) > /dev/null 2>&1 && echo
 	PYTHON_PLUGINS := plugin_python.so
 	BUILD_PYTHON := $(PYTHON) $(PYTHON_PLUGINS)
 	BUILD_PYTHON_WORKS := 1
+else
+	BUILD_PYTHON := report_nopythondev
 endif
 endif # NO_PYTHON
 
@@ -372,6 +374,11 @@ report_noswig: force
 	$(Q)echo "    NO_PYTHON forced: swig not installed, not compiling python plugins"
 	$(Q)echo
 
+report_nopythondev: force
+	$(Q)echo
+	$(Q)echo "    python-dev is not installed, not compiling python plugins"
+	$(Q)echo
+
 PYTHON_INCLUDES = `pkg-config --cflags $(PYTHON_VERS)`
 PYTHON_LDFLAGS = `pkg-config --libs $(PYTHON_VERS)` \
 		$(shell python2 -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LINKFORSHARED')")
Signature · 1 line
2.14.1
#24 lore raw

PATCH v2 19/24 trace-cmd: Make libtraceevent builable out-of-tree

In reply to Vladislav Valtchev (VMware)

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.

---
 Makefile                | 31 +++++++++++--------------------
 lib/traceevent/Makefile | 25 +++++++++++++++++--------
 2 files changed, 28 insertions(+), 28 deletions(-)
Makefile +11 -20
index 4f17dd3..6cd54d9 100644
@@ -145,27 +145,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)
 
@@ -270,10 +261,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
lib/traceevent/Makefile +17 -8
index f9c595c..60246aa 100644
@@ -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
Signature · 1 line
2.14.1
#25 lore raw

PATCH v2 20/24 trace-cmd: Make the plugins buildable out-of-tree

In reply to Vladislav Valtchev (VMware)

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.

---
 Makefile         | 10 +++++-----
 plugins/Makefile | 37 ++++++++++++++++++++++---------------
 scripts/utils.mk |  2 +-
 3 files changed, 28 insertions(+), 21 deletions(-)
Makefile +5 -5
index 6cd54d9..df20885 100644
@@ -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 \
plugins/Makefile +22 -15
index 7a09b82..cff71f1 100644
@@ -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
scripts/utils.mk +1 -1
index 043a68a..06e8dc3 100644
@@ -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)			\
Signature · 1 line
2.14.1
#26 lore raw

PATCH v2 21/24 trace-cmd: Make libtracecmd buildable out-of-tree

In reply to Vladislav Valtchev (VMware)

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.

---
 Makefile               |  4 ++--
 lib/trace-cmd/Makefile | 27 ++++++++++++++++++---------
 2 files changed, 20 insertions(+), 11 deletions(-)
Makefile +2 -2
index df20885..a40bf28 100644
@@ -267,10 +267,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)
lib/trace-cmd/Makefile +18 -9
index e8fb088..ee09099 100644
@@ -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
Signature · 1 line
2.14.1
#27 lore raw

PATCH v2 22/24 trace-cmd: Make the trace-cmd target buildable out-of-tree

In reply to Vladislav Valtchev (VMware)

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.

---
 Makefile          |  3 ++-
 tracecmd/Makefile | 33 ++++++++++++++++++++++-----------
 2 files changed, 24 insertions(+), 12 deletions(-)
Makefile +2 -1
index a40bf28..edb83c3 100644
@@ -189,6 +189,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
 
@@ -249,7 +250,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 $@
tracecmd/Makefile +22 -11
index 860dc89..3a11024 100644
@@ -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
Signature · 1 line
2.14.1
#28 lore raw

PATCH v2 23/24 trace-cmd: Make the python targets buildable out-of-tree

In reply to Vladislav Valtchev (VMware)

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.

---
 Makefile        |  4 ++--
 python/Makefile | 30 +++++++++++++++++-------------
 2 files changed, 19 insertions(+), 15 deletions(-)
Makefile +2 -2
index edb83c3..2f05cbb 100644
@@ -381,10 +381,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)
python/Makefile +17 -13
index b07c0d8..f8e7328 100644
@@ -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
Signature · 1 line
2.14.1
#29 lore raw

PATCH v2 24/24 trace-cmd: Make the GUI targets buildable out-of-tree

In reply to Vladislav Valtchev (VMware)

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.

---
 Makefile              |  9 +++++----
 kernel-shark/Makefile | 40 ++++++++++++++++++++++++++--------------
 2 files changed, 31 insertions(+), 18 deletions(-)
Makefile +5 -4
index 2f05cbb..dc512a1 100644
@@ -190,6 +190,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
 
@@ -229,7 +230,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)
 
 
@@ -253,13 +254,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 $@
kernel-shark/Makefile +26 -14
index 8e3ba8b..8576f3d 100644
@@ -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
Signature · 1 line
2.14.1
#30 lore raw
In reply to Vladislav Valtchev (VMware)
Quoted 8 lines · On Tue, 6 Feb 2018 10:48:42 +0200 "Vladislav Valtchev (VMware)"…

This series restructures trace-cmd's source tree in a way that each component inside the repo has its own directory. Now the two libraries, the GUI apps, the plugins, the python C modules, the trace-cmd's application and all of their headers are organized in dedicated directories. Almost all of the effort in this series has been spent on updating the build system to support the new structure. The side-effect of that is a simpler and easier to maintain build system.

Quoted 4 lines

NOTE: this rebased v2 series embeds now the previous mini-series called "trace-cmd: Make out-of-tree builds to work" which, as the title suggests, restores the out-of-tree build feature that is currently broken on the master branch.

Thanks Vladislav!

I applied them all. I'll be doing some more testing on them before pushing them to kernel.org, but I didn't see anything wrong with them.

-- Steve

#31 lore raw
Quoted 7 lines · Steven Rostedt

Thanks Vladislav!

I applied them all. I'll be doing some more testing on them before pushing them to kernel.org, but I didn't see anything wrong with them.

-- Steve

That's great! Thanks Steven!

Signature · 2 lines
Vladislav Valtchev
VMware Open Source Technology Center