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