Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools: ynl: add install target for generated content

Generate docs using ynl_gen_rst and add install target for
headers, specs and generates rst files.

Factor out SPECS_DIR since it's repeated many times.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://patch.msgid.link/645c68e3d201f1ef4276e3daddfe06262a0c2804.1736343575.git.jstancek@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jan Stancek and committed by
Jakub Kicinski
1b038af9 a12afefa

+43 -7
+1
tools/net/ynl/generated/.gitignore
··· 1 1 *-user.c 2 2 *-user.h 3 + *.rst
+42 -7
tools/net/ynl/generated/Makefile
··· 7 7 CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan 8 8 endif 9 9 10 + INSTALL ?= install 11 + prefix ?= /usr 12 + datarootdir ?= $(prefix)/share 13 + docdir ?= $(datarootdir)/doc 14 + includedir ?= $(prefix)/include 15 + 10 16 include ../Makefile.deps 11 17 12 18 YNL_GEN_ARG_ethtool:=--user-header linux/ethtool_netlink.h \ 13 19 --exclude-op stats-get 14 20 15 21 TOOL:=../pyynl/ynl_gen_c.py 22 + TOOL_RST:=../pyynl/ynl_gen_rst.py 16 23 24 + SPECS_DIR:=../../../../Documentation/netlink/specs 17 25 GENS_PATHS=$(shell grep -nrI --files-without-match \ 18 26 'protocol: netlink' \ 19 - ../../../../Documentation/netlink/specs/) 20 - GENS=$(patsubst ../../../../Documentation/netlink/specs/%.yaml,%,${GENS_PATHS}) 27 + $(SPECS_DIR)) 28 + GENS=$(patsubst $(SPECS_DIR)/%.yaml,%,${GENS_PATHS}) 21 29 SRCS=$(patsubst %,%-user.c,${GENS}) 22 30 HDRS=$(patsubst %,%-user.h,${GENS}) 23 31 OBJS=$(patsubst %,%-user.o,${GENS}) 24 32 25 - all: protos.a $(HDRS) $(SRCS) $(KHDRS) $(KSRCS) $(UAPI) 33 + SPECS_PATHS=$(wildcard $(SPECS_DIR)/*.yaml) 34 + SPECS=$(patsubst $(SPECS_DIR)/%.yaml,%,${SPECS_PATHS}) 35 + RSTS=$(patsubst %,%.rst,${SPECS}) 36 + 37 + all: protos.a $(HDRS) $(SRCS) $(KHDRS) $(KSRCS) $(UAPI) $(RSTS) 26 38 27 39 protos.a: $(OBJS) 28 40 @echo -e "\tAR $@" 29 41 @ar rcs $@ $(OBJS) 30 42 31 - %-user.h: ../../../../Documentation/netlink/specs/%.yaml $(TOOL) 43 + %-user.h: $(SPECS_DIR)/%.yaml $(TOOL) 32 44 @echo -e "\tGEN $@" 33 45 @$(TOOL) --mode user --header --spec $< -o $@ $(YNL_GEN_ARG_$*) 34 46 35 - %-user.c: ../../../../Documentation/netlink/specs/%.yaml $(TOOL) 47 + %-user.c: $(SPECS_DIR)/%.yaml $(TOOL) 36 48 @echo -e "\tGEN $@" 37 49 @$(TOOL) --mode user --source --spec $< -o $@ $(YNL_GEN_ARG_$*) 38 50 ··· 52 40 @echo -e "\tCC $@" 53 41 @$(COMPILE.c) $(CFLAGS_$*) -o $@ $< 54 42 43 + %.rst: $(SPECS_DIR)/%.yaml $(TOOL_RST) 44 + @echo -e "\tGEN_RST $@" 45 + @$(TOOL_RST) -o $@ -i $< 46 + 55 47 clean: 56 48 rm -f *.o 57 49 58 50 distclean: clean 59 - rm -f *.c *.h *.a 51 + rm -f *.c *.h *.a *.rst 60 52 61 53 regen: 62 54 @../ynl-regen.sh 63 55 64 - .PHONY: all clean distclean regen 56 + install-headers: $(HDRS) 57 + @echo -e "\tINSTALL generated headers" 58 + @$(INSTALL) -d $(DESTDIR)$(includedir)/ynl 59 + @$(INSTALL) -m 0644 *.h $(DESTDIR)$(includedir)/ynl/ 60 + 61 + install-rsts: $(RSTS) 62 + @echo -e "\tINSTALL generated docs" 63 + @$(INSTALL) -d $(DESTDIR)$(docdir)/ynl 64 + @$(INSTALL) -m 0644 $(RSTS) $(DESTDIR)$(docdir)/ynl/ 65 + 66 + install-specs: 67 + @echo -e "\tINSTALL specs" 68 + @$(INSTALL) -d $(DESTDIR)$(datarootdir)/ynl 69 + @$(INSTALL) -m 0644 ../../../../Documentation/netlink/*.yaml $(DESTDIR)$(datarootdir)/ynl/ 70 + @$(INSTALL) -d $(DESTDIR)$(datarootdir)/ynl/specs 71 + @$(INSTALL) -m 0644 $(SPECS_DIR)/*.yaml $(DESTDIR)$(datarootdir)/ynl/specs/ 72 + 73 + install: install-headers install-rsts install-specs 74 + 75 + .PHONY: all clean distclean regen install install-headers install-rsts install-specs 65 76 .DEFAULT_GOAL: all