Skip to content

Commit 1b038af

Browse files
jstancekkuba-moo
authored andcommitted
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 <[email protected]> Reviewed-by: Donald Hunter <[email protected]> Link: https://patch.msgid.link/645c68e3d201f1ef4276e3daddfe06262a0c2804.1736343575.git.jstancek@redhat.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent a12afef commit 1b038af

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

tools/net/ynl/generated/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*-user.c
22
*-user.h
3+
*.rst

tools/net/ynl/generated/Makefile

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,82 @@ ifeq ("$(DEBUG)","1")
77
CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
88
endif
99

10+
INSTALL ?= install
11+
prefix ?= /usr
12+
datarootdir ?= $(prefix)/share
13+
docdir ?= $(datarootdir)/doc
14+
includedir ?= $(prefix)/include
15+
1016
include ../Makefile.deps
1117

1218
YNL_GEN_ARG_ethtool:=--user-header linux/ethtool_netlink.h \
1319
--exclude-op stats-get
1420

1521
TOOL:=../pyynl/ynl_gen_c.py
22+
TOOL_RST:=../pyynl/ynl_gen_rst.py
1623

24+
SPECS_DIR:=../../../../Documentation/netlink/specs
1725
GENS_PATHS=$(shell grep -nrI --files-without-match \
1826
'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})
2129
SRCS=$(patsubst %,%-user.c,${GENS})
2230
HDRS=$(patsubst %,%-user.h,${GENS})
2331
OBJS=$(patsubst %,%-user.o,${GENS})
2432

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)
2638

2739
protos.a: $(OBJS)
2840
@echo -e "\tAR $@"
2941
@ar rcs $@ $(OBJS)
3042

31-
%-user.h: ../../../../Documentation/netlink/specs/%.yaml $(TOOL)
43+
%-user.h: $(SPECS_DIR)/%.yaml $(TOOL)
3244
@echo -e "\tGEN $@"
3345
@$(TOOL) --mode user --header --spec $< -o $@ $(YNL_GEN_ARG_$*)
3446

35-
%-user.c: ../../../../Documentation/netlink/specs/%.yaml $(TOOL)
47+
%-user.c: $(SPECS_DIR)/%.yaml $(TOOL)
3648
@echo -e "\tGEN $@"
3749
@$(TOOL) --mode user --source --spec $< -o $@ $(YNL_GEN_ARG_$*)
3850

3951
%-user.o: %-user.c %-user.h
4052
@echo -e "\tCC $@"
4153
@$(COMPILE.c) $(CFLAGS_$*) -o $@ $<
4254

55+
%.rst: $(SPECS_DIR)/%.yaml $(TOOL_RST)
56+
@echo -e "\tGEN_RST $@"
57+
@$(TOOL_RST) -o $@ -i $<
58+
4359
clean:
4460
rm -f *.o
4561

4662
distclean: clean
47-
rm -f *.c *.h *.a
63+
rm -f *.c *.h *.a *.rst
4864

4965
regen:
5066
@../ynl-regen.sh
5167

52-
.PHONY: all clean distclean regen
68+
install-headers: $(HDRS)
69+
@echo -e "\tINSTALL generated headers"
70+
@$(INSTALL) -d $(DESTDIR)$(includedir)/ynl
71+
@$(INSTALL) -m 0644 *.h $(DESTDIR)$(includedir)/ynl/
72+
73+
install-rsts: $(RSTS)
74+
@echo -e "\tINSTALL generated docs"
75+
@$(INSTALL) -d $(DESTDIR)$(docdir)/ynl
76+
@$(INSTALL) -m 0644 $(RSTS) $(DESTDIR)$(docdir)/ynl/
77+
78+
install-specs:
79+
@echo -e "\tINSTALL specs"
80+
@$(INSTALL) -d $(DESTDIR)$(datarootdir)/ynl
81+
@$(INSTALL) -m 0644 ../../../../Documentation/netlink/*.yaml $(DESTDIR)$(datarootdir)/ynl/
82+
@$(INSTALL) -d $(DESTDIR)$(datarootdir)/ynl/specs
83+
@$(INSTALL) -m 0644 $(SPECS_DIR)/*.yaml $(DESTDIR)$(datarootdir)/ynl/specs/
84+
85+
install: install-headers install-rsts install-specs
86+
87+
.PHONY: all clean distclean regen install install-headers install-rsts install-specs
5388
.DEFAULT_GOAL: all

0 commit comments

Comments
 (0)