diff mbox series

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

Message ID 20210803170606.694085-19-rostedt@goodmis.org (mailing list archive)
State Accepted
Headers show
Series [v3,01/22] libtracefs: Added new API tracefs_sql() | expand

Commit Message

Steven Rostedt Aug. 3, 2021, 5:06 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

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@goodmis.org>
---
 Makefile | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

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