[PATCH 12/18] trace-cmd: Fix the broken target ctracecmdgui.so

From: Vladislav Valtchev (VMware)
Date: Wed Dec 20 2017 - 13:10:52 EST


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.

Signed-off-by: Vladislav Valtchev (VMware) <vladislav.valtchev@xxxxxxxxx>
---
kernel-shark/Makefile | 10 +++++++---
scripts/utils.mk | 10 +++++-----
2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/kernel-shark/Makefile b/kernel-shark/Makefile
index 247f4d1..8e3ba8b 100644
--- a/kernel-shark/Makefile
+++ b/kernel-shark/Makefile
@@ -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))

diff --git a/scripts/utils.mk b/scripts/utils.mk
index 31fc9e9..043a68a 100644
--- a/scripts/utils.mk
+++ b/scripts/utils.mk
@@ -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))
--
2.14.1