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