Skip to contentSkip to conversation

trace-cmd: Fix build dependencies

PATCH New Steven Rostedt 1 participant 1 message Jun 2, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace-cmd: Fix build dependencies

From: "Steven Rostedt (VMware)" <[email protected]>

After having trace-cmd break because not all proper files are being compiled when needed, I looked into why the dependencies were not working. I found that the .foo.d files that were being created required having the full path of the object file in them. Without that, the dependencies were being ignored.

By adding "-MT $(bdir)/$*.o", to the dependency creating rules, the full path would be added to targets for the object files, and this makes the depencies work again.

Fixes 60f0a40bb ("trace-cmd: Make libtraceevent buildable out-of-tree")
---
 lib/trace-cmd/Makefile          | 2 +-
 lib/trace-cmd/plugins/Makefile  | 2 +-
 lib/traceevent/Makefile         | 2 +-
 lib/traceevent/plugins/Makefile | 2 +-
 lib/tracefs/Makefile            | 2 +-
 tracecmd/Makefile               | 2 +-
 utest/Makefile                  | 1 +
 7 files changed, 7 insertions(+), 6 deletions(-)
lib/trace-cmd/Makefile +1 -1
index ab7440ac..994ae94d 100644
@@ -45,7 +45,7 @@ $(bdir)/%.o: %.c
 	$(Q)$(call do_fpic_compile)
 
 $(DEPS): $(bdir)/.%.d: %.c
-	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@
+	$(Q)$(CC) -M -MT $(bdir)/$*.o $(CPPFLAGS) $(CFLAGS) $< > $@
 
 $(OBJS): $(bdir)/%.o : $(bdir)/.%.d
 
lib/trace-cmd/plugins/Makefile +1 -1
index 240e6be3..ed5a9cea 100644
@@ -26,7 +26,7 @@ $(PLUGIN_BUILD): $(bdir)/%.so: $(bdir)/%.o
 	$(Q)$(do_plugin_build)
 
 $(DEPS): $(bdir)/.%.d: %.c
-	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@
+	$(Q)$(CC) -M -MT $(bdir)/$*.o $(CPPFLAGS) $(CFLAGS) $< > $@
 
 $(PLUGIN_OBJS): $(bdir)/%.o : $(bdir)/.%.d
 
lib/traceevent/Makefile +1 -1
index c3f09572..d0666911 100644
@@ -37,7 +37,7 @@ $(bdir)/%.o: %.c
 	$(Q)$(call do_fpic_compile)
 
 $(DEPS): $(bdir)/.%.d: %.c
-	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@
+	$(Q)$(CC) -M -MT $(bdir)/$*.o $(CPPFLAGS) $(CFLAGS) $< > $@
 
 $(OBJS): $(bdir)/%.o : $(bdir)/.%.d
 
lib/traceevent/plugins/Makefile +1 -1
index 40500194..21e933af 100644
@@ -40,7 +40,7 @@ $(PLUGIN_BUILD): $(bdir)/%.so: $(bdir)/%.o
 	$(Q)$(do_plugin_build)
 
 $(DEPS): $(bdir)/.%.d: %.c
-	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@
+	$(Q)$(CC) -M -MT $(bdir)/$*.o $(CPPFLAGS) $(CFLAGS) $< > $@
 
 $(PLUGIN_OBJS): $(bdir)/%.o : $(bdir)/.%.d
 
lib/tracefs/Makefile +1 -1
index f6d93ec8..b810bbf4 100644
@@ -34,7 +34,7 @@ $(bdir)/%.o: %.c
 	$(Q)$(call do_fpic_compile)
 
 $(DEPS): $(bdir)/.%.d: %.c
-	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@
+	$(Q)$(CC) -M -MT $(bdir)/$*.o $(CPPFLAGS) $(CFLAGS) $< > $@
 
 $(OBJS): $(bdir)/%.o : $(bdir)/.%.d
 
tracecmd/Makefile +1 -1
index 17e67600..5a7f7d2b 100644
@@ -70,7 +70,7 @@ $(bdir)/%.o: %.c
 	$(Q)$(call do_compile)
 
 $(all_deps): $(bdir)/.%.d: %.c
-	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@
+	$(Q)$(CC) -M -MT $(bdir)/$*.o $(CPPFLAGS) $(CFLAGS) $< > $@
 
 $(all_deps): $(TC_VERSION)
 
utest/Makefile +1 -0
index 55aa46ab..d635650d 100644
@@ -30,6 +30,7 @@ $(bdir)/%.o: %.c
 
 $(DEPS): $(bdir)/.%.d: %.c
 	$(Q)$(CC) -M $(CPPFLAGS) $(CFLAGS) $< > $@
+	$(Q)$(CC) -M -MT $(bdir)/$*.o $(CPPFLAGS) $(CFLAGS) $< > $@
 
 $(OBJS): $(bdir)/%.o : $(bdir)/.%.d
 
Signature · 1 line
2.25.4