diff mbox series

[10/11] libtracefs: Add all working man page examples to samples

Message ID 20211122234956.788401-11-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit f83a898b1b71d20c3f459881a757dd251213f881
Headers show
Series libtracefs: Have all man page examples be executable | expand

Commit Message

Steven Rostedt Nov. 22, 2021, 11:49 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Parse out all the working examples in the man pages, and have

  make samples

build them.

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

Patch

diff --git a/samples/Makefile b/samples/Makefile
index 53b6630..6ee57fe 100644
--- a/samples/Makefile
+++ b/samples/Makefile
@@ -7,9 +7,22 @@ 
 
 include $(src)/scripts/utils.mk
 
+EXAMPLES :=
+EXAMPLES += dynevents
+EXAMPLES += kprobes
+EXAMPLES += eprobes
+EXAMPLES += synth
+EXAMPLES += error
+EXAMPLES += filter
+EXAMPLES += function-filter
+EXAMPLES += hist
+EXAMPLES += hist-cont
+EXAMPLES += tracer
+EXAMPLES += stream
+
 TARGETS :=
 TARGETS += sqlhist
-TARGETS += dynevent
+TARGETS += $(EXAMPLES)
 
 bdir := $(obj)/bin
 
@@ -21,7 +34,9 @@  extract_example = \
 $(bdir)/sqlhist.c: ../Documentation/libtracefs-sql.txt
 	$(call extract_example,$<,$@)
 
-$(bdir)/dynevent.c: ../Documentation/libtracefs-dynevents.txt
+EXAMPLE_C_CODE := $(patsubst %,$(bdir)/%.c,$(EXAMPLES))
+
+$(bdir)/%.c: ../Documentation/libtracefs-%.txt
 	$(call extract_example,$<,$@)
 
 $(bdir):
@@ -31,10 +46,21 @@  sqlhist: $(bdir) $(bdir) $(bdir)/sqlhist
 
 $(TARGETS): $(bdir)
 
+# sqlhist is unique and stands on its own
+sqlhist: $(bdir)/sqlhist
+
 $(bdir)/%: $(bdir)/%.o
 	$(CC) -o $@ $^ $(LIBTRACEFS_STATIC) $(LIBTRACEEVENT_LIBS)
 
-$(TARGETS): $(patsubst %,$(bdir)/%,$(TARGETS))
+$(EXAMPLES): $(patsubst %,$(bdir)/%,$(TARGETS))
+
+## The intermediate files get removed by Make.
+## To examine the .c files created by one of the man pages,
+## uncomment the below, and replace the XX with the exec example
+## name, and the file will not be discarded by make.
+#
+# $(bdir)/XX.o: $(bdir)/XX.c
+#	$(CC) -g -Wall -c -o $@ $^ -I../include/ $(LIBTRACEEVENT_INCLUDES)
 
 $(bdir)/%.o: %.c
 	$(CC) -g -Wall -c -o $@ $^ -I../include/ $(LIBTRACEEVENT_INCLUDES)