diff mbox series

[v2,11/15] libtracefs: Have sample build look cleaner

Message ID 20211217055041.19559-12-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 08de3485ebf12389f98fc23b610769976fb2492a
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 build of the samples directory just showed the raw commands. This is
inconsistent with the rest of the build system. Make it cleaner by showing
EXTRACT, COMPILE SAMPLE OBJ and COMPILE SAMPLE for the samples being
extracted and built.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 samples/Makefile |  7 ++-----
 scripts/utils.mk | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/samples/Makefile b/samples/Makefile
index 033f1ca735f4..48c0e0e4160d 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -30,9 +30,6 @@  TARGETS := $(patsubst %,$(bdir)/%,$(TARGETS))
 
 all: $(TARGETS)
 
-extract_example = \
-	cat $1 | sed -ne '/^EXAMPLE/,/FILES/ { /EXAMPLE/,+2d ; /^FILES/d ;  /^--/d ; p}' > $2
-
 $(bdir)/sqlhist.c: $(src)/Documentation/libtracefs-sql.txt
 	$(call extract_example,$<,$@)
 
@@ -50,7 +47,7 @@  $(TARGETS): $(bdir)
 $(bdir)/sqlhist: $(bdir)/sqlhist.c
 
 $(bdir)/%: $(bdir)/%.o
-	$(CC) -o $@ $< $(CFLAGS) $(LIBTRACEFS_STATIC) $(LIBTRACEEVENT_LIBS)
+	$(call do_sample_build,$@,$<)
 
 $(EXAMPLES): $(patsubst %,$(bdir)/%,$(TARGETS))
 
@@ -63,7 +60,7 @@  $(EXAMPLES): $(patsubst %,$(bdir)/%,$(TARGETS))
 #	$(CC) -g -Wall $(CFLAGS) -c -o $@ $^ -I../include/ $(LIBTRACEEVENT_INCLUDES)
 
 $(bdir)/%.o: $(bdir)/%.c
-	$(CC) -g -Wall -c $(CFLAGS) -o $@ $^ -I../include/ $(LIBTRACEEVENT_INCLUDES)
+	$(call do_sample_obj,$@,$^)
 
 clean:
 	$(Q)$(call do_clean,$(bdir)/*)
diff --git a/scripts/utils.mk b/scripts/utils.mk
index af0f14fcbfa7..0f6225d3ee68 100644
--- a/scripts/utils.mk
+++ b/scripts/utils.mk
@@ -30,6 +30,9 @@  ifeq ($(findstring 1,$(SILENT)$(VERBOSE)),1)
   print_update =
   print_descend =
   print_clean =
+  print_extract =
+  print_sample_build =
+  print_sample_obj =
 else
   print_compile =		echo '  COMPILE            '$(GOBJ);
   print_app_build =		echo '  BUILD              '$(GOBJ);
@@ -43,6 +46,9 @@  else
   print_update =		echo '  UPDATE             '$(GOBJ);
   print_descend =		echo '  DESCEND            '$(BASE1) $(BASE2);
   print_clean =			echo '  CLEAN              '$(BASEPWD);
+  print_extract =		echo '  EXTRACT            '$(GOBJ);
+  print_sample_build =		echo '  COMPILE SAMPLE     '$(GOBJ);
+  print_sample_obj =		echo '  COMPILE SAMPLE OBJ '$(GOBJ);
 endif
 
 do_fpic_compile =					\
@@ -89,6 +95,18 @@  do_clean =					\
 	($(print_clean)				\
 	$(RM) $1)
 
+extract_example =				\
+	$(Q)($(print_extract)			\
+	cat $1 | sed -ne '/^EXAMPLE/,/FILES/ { /EXAMPLE/,+2d ; /^FILES/d ;  /^--/d ; p}' > $2)
+
+do_sample_build =							\
+	$(Q)($(print_sample_build)					\
+	$(CC) -o $1 $2 $(CFLAGS) $(LIBTRACEFS_STATIC) $(LIBTRACEEVENT_LIBS))
+
+do_sample_obj =									\
+	$(Q)($(print_sample_obj)						\
+	$(CC) -g -Wall -c $(CFLAGS) -o $1 $2 -I../include/ $(LIBTRACEEVENT_INCLUDES))
+
 ifneq ($(findstring $(MAKEFLAGS), w),w)
 PRINT_DIR = --no-print-directory
 else