Debian Codegraph @

tools/net/ynl/generated/Makefile

raw
1 # SPDX-License-Identifier: GPL-2.0
2
3 CC=gcc
4 CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
5 -I../lib/ -idirafter $(UAPI_PATH)
6 ifeq ("$(DEBUG)","1")
7 CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
8 endif
9
10 INSTALL ?= install
11 prefix ?= /usr
12 datarootdir ?= $(prefix)/share
13 docdir ?= $(datarootdir)/doc
14 includedir ?= $(prefix)/include
15
16 include ../Makefile.deps
17
18 YNL_GEN_ARG_ethtool:=--user-header linux/ethtool_netlink.h \
19 --exclude-op stats-get
20
21 TOOL:=../pyynl/ynl_gen_c.py
22 TOOL_RST:=../pyynl/ynl_gen_rst.py
23
24 SPECS_DIR:=../../../../Documentation/netlink/specs
25 SPECS_PATHS=$(wildcard $(SPECS_DIR)/*.yaml)
26 GENS_UNSUP=conntrack nftables
27 GENS=$(filter-out ${GENS_UNSUP},$(patsubst $(SPECS_DIR)/%.yaml,%,${SPECS_PATHS}))
28 SRCS=$(patsubst %,%-user.c,${GENS})
29 HDRS=$(patsubst %,%-user.h,${GENS})
30 OBJS=$(patsubst %,%-user.o,${GENS})
31
32 SPECS_PATHS=$(wildcard $(SPECS_DIR)/*.yaml)
33 SPECS=$(patsubst $(SPECS_DIR)/%.yaml,%,${SPECS_PATHS})
34 RSTS=$(patsubst %,%.rst,${SPECS})
35
36 all: protos.a $(HDRS) $(SRCS) $(KHDRS) $(KSRCS) $(UAPI) $(RSTS)
37
38 protos.a: $(OBJS)
39 @echo -e "\tAR $@"
40 @ar rcs $@ $(OBJS)
41
42 %-user.h: $(SPECS_DIR)/%.yaml $(TOOL)
43 @echo -e "\tGEN $@"
44 @$(TOOL) --mode user --header --spec $< -o $@ $(YNL_GEN_ARG_$*)
45
46 %-user.c: $(SPECS_DIR)/%.yaml $(TOOL)
47 @echo -e "\tGEN $@"
48 @$(TOOL) --mode user --source --spec $< -o $@ $(YNL_GEN_ARG_$*)
49
50 %-user.o: %-user.c %-user.h
51 @echo -e "\tCC $@"
52 @$(COMPILE.c) $(CFLAGS_$*) -o $@ $<
53
54 %.rst: $(SPECS_DIR)/%.yaml $(TOOL_RST)
55 @echo -e "\tGEN_RST $@"
56 @$(TOOL_RST) -o $@ -i $<
57
58 clean:
59 rm -f *.o
60
61 distclean: clean
62 rm -f *.c *.h *.a *.rst
63
64 regen:
65 @../ynl-regen.sh
66
67 install-headers: $(HDRS)
68 @echo -e "\tINSTALL generated headers"
69 @$(INSTALL) -d $(DESTDIR)$(includedir)/ynl
70 @$(INSTALL) -m 0644 *.h $(DESTDIR)$(includedir)/ynl/
71
72 install-rsts: $(RSTS)
73 @echo -e "\tINSTALL generated docs"
74 @$(INSTALL) -d $(DESTDIR)$(docdir)/ynl
75 @$(INSTALL) -m 0644 $(RSTS) $(DESTDIR)$(docdir)/ynl/
76
77 install-specs:
78 @echo -e "\tINSTALL specs"
79 @$(INSTALL) -d $(DESTDIR)$(datarootdir)/ynl
80 @$(INSTALL) -m 0644 ../../../../Documentation/netlink/*.yaml $(DESTDIR)$(datarootdir)/ynl/
81 @$(INSTALL) -d $(DESTDIR)$(datarootdir)/ynl/specs
82 @$(INSTALL) -m 0644 $(SPECS_DIR)/*.yaml $(DESTDIR)$(datarootdir)/ynl/specs/
83
84 install: install-headers install-rsts install-specs
85
86 .PHONY: all clean distclean regen install install-headers install-rsts install-specs
87 .DEFAULT_GOAL: all