[PATCH v3 18/22] libtracefs: Add Makefile rule to create sqlhist

From: Steven Rostedt
Date: Tue Aug 03 2021 - 13:06:55 EST


From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

Add a Makefile rule to extract the example from the man page and create a
sqlhist executable from it.

make sqlhist

Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
Makefile | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/Makefile b/Makefile
index 96d7f5528a56..7f382c304b9b 100644
--- a/Makefile
+++ b/Makefile
@@ -364,11 +364,21 @@ $(bdir)/libtracefs.so.$(TRACEFS_VERSION): force
$(Q)mkdir -p $(bdir)
$(Q)$(MAKE) -C $(src)/src libtracefs.so

+$(bdir)/sqlhist.c: Documentation/libtracefs-sql.txt
+ cat $< | sed -ne '/^EXAMPLE/,/FILES/ { /EXAMPLE/,+2d ; /^FILES/d ; /^--/d ; p}' > $@
+
+$(bdir)/sqlhist.o: $(bdir)/sqlhist.c
+ $(CC) -g -Wall -c -o $@ $^ -Iinclude/ $(LIBTRACEEVENT_INCLUDES)
+
+sqlhist: $(bdir)/sqlhist.o $(LIBTRACEFS_STATIC)
+ $(CC) -o $@ $^ $(LIBTRACEEVENT_LIBS)
+
clean:
$(MAKE) -C $(src)/utest clean
$(MAKE) -C $(src)/src clean
$(RM) $(TARGETS) $(bdir)/*.a $(bdir)/*.so $(bdir)/*.so.* $(bdir)/*.o $(bdir)/.*.d
$(RM) $(PKG_CONFIG_FILE)
$(RM) $(VERSION_FILE)
+ $(RM) $(bdir)/sqlhist.o $(bdir)/sqlhist.c sqlhist

.PHONY: clean
--
2.30.2