diff mbox series

[v2,12/15] libtracefs: Have samples build in separate directory from bin

Message ID 20211217055041.19559-13-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 38d9b76f640a0a33a2a5e3eefae3cc38627507d3
Headers show
Series libtracefs: Updates to the Makefile | expand

Commit Message

Steven Rostedt Dec. 17, 2021, 5:50 a.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

The samples destination directory is bin/. Do not build in that directory.
Have it build in the default directory, and then it can be set to build in
the same directory as the source (or copy if it is a remote build).

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 samples/Makefile | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/samples/Makefile b/samples/Makefile
index 48c0e0e4160d..ace93448ff4e 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -24,9 +24,9 @@  TARGETS :=
 TARGETS += sqlhist
 TARGETS += $(EXAMPLES)
 
-bdir := $(obj)/bin
+sdir := $(obj)/bin
 
-TARGETS := $(patsubst %,$(bdir)/%,$(TARGETS))
+TARGETS := $(patsubst %,$(sdir)/%,$(TARGETS))
 
 all: $(TARGETS)
 
@@ -36,20 +36,21 @@  $(bdir)/sqlhist.c: $(src)/Documentation/libtracefs-sql.txt
 $(bdir)/%.c: ../Documentation/libtracefs-%.txt
 	$(call extract_example,$<,$@)
 
-$(bdir):
-	@mkdir -p $(bdir)
+$(sdir):
+	@mkdir -p $(sdir)
 
-sqlhist: $(bdir)/sqlhist.c
+sqlhist: $(sdir)/sqlhist
 
-$(TARGETS): $(bdir)
+$(TARGETS): $(sdir)
 
 # sqlhist is unique and stands on its own
-$(bdir)/sqlhist: $(bdir)/sqlhist.c
+$(sdir)/sqlhist: $(bdir)/sqlhist.c
+	$(call do_sample_build,$@,$<)
 
-$(bdir)/%: $(bdir)/%.o
+$(sdir)/%: $(bdir)/%.o
 	$(call do_sample_build,$@,$<)
 
-$(EXAMPLES): $(patsubst %,$(bdir)/%,$(TARGETS))
+$(EXAMPLES): $(patsubst %,$(sdir)/%,$(TARGETS))
 
 ## The intermediate files get removed by Make.
 ## To examine the .c files created by one of the man pages,
@@ -63,4 +64,4 @@  $(bdir)/%.o: $(bdir)/%.c
 	$(call do_sample_obj,$@,$^)
 
 clean:
-	$(Q)$(call do_clean,$(bdir)/*)
+	$(Q)$(call do_clean,$(sdir)/* $(bdir)/sqlhist.c $(bdir)/sqlhist.o)