Re: [PATCH v2 4/5] tools: ynl: add install target for specs and docs

From: Jakub Kicinski
Date: Tue Dec 10 2024 - 22:31:19 EST


On Mon, 9 Dec 2024 15:47:16 +0100 Jan Stancek wrote:
> +SPECS_PATHS=$(wildcard ../../../../Documentation/netlink/specs/*.yaml)

Maybe factor out:

SPECS_DIR := ../../../../Documentation/netlink/specs

? It's pretty long and we repeat it all over the place.

> +SPECS=$(patsubst ../../../../Documentation/netlink/specs/%.yaml,%,${SPECS_PATHS})
> +RSTS=$(patsubst %,%.rst,${SPECS})
> +
> +all: protos.a $(HDRS) $(SRCS) $(KHDRS) $(KSRCS) $(UAPI) $(RSTS)
>
> protos.a: $(OBJS)
> @echo -e "\tAR $@"
> @@ -40,8 +50,12 @@ protos.a: $(OBJS)
> @echo -e "\tCC $@"
> @$(COMPILE.c) $(CFLAGS_$*) -o $@ $<
>
> +%.rst: ../../../../Documentation/netlink/specs/%.yaml $(TOOL2)

TOOL2 -> TOOL_RST ?

> + @echo -e "\tGEN_RST $@"
> + @$(TOOL_RST) -o $@ -i $<
> +
> clean:
> - rm -f *.o
> + rm -f *.o *.rst

No strong preference but I'd count .rst as final artifacts so I'd clean
them up in distclean target only, not the clean target. The distinction
itself may be a local custom..

> distclean: clean
> rm -f *.c *.h *.a
> @@ -49,5 +63,19 @@ distclean: clean
> regen:
> @../ynl-regen.sh
>
> -.PHONY: all clean distclean regen
> +install-rsts:
> + @echo -e "\tINSTALL generated docs"
> + @$(INSTALL) -d $(DESTDIR)$(docdir)/ynl
> + @$(INSTALL) -m 0644 $(RSTS) $(DESTDIR)$(docdir)/ynl/
> +
> +install-specs:
> + @echo -e "\tINSTALL specs"
> + @$(INSTALL) -d $(DESTDIR)$(datarootdir)/ynl
> + @$(INSTALL) -m 0644 ../../../../Documentation/netlink/*.yaml $(DESTDIR)$(datarootdir)/ynl/
> + @$(INSTALL) -d $(DESTDIR)$(datarootdir)/ynl/specs
> + @$(INSTALL) -m 0644 ../../../../Documentation/netlink/specs/*.yaml $(DESTDIR)$(datarootdir)/ynl/specs/
> +
> +install: install-rsts install-specs
> +
> +.PHONY: all clean distclean regen install

I think .PHONY needs install-rsts install-specs, too?

> .DEFAULT_GOAL: all
--
pw-bot: cr