@@ -7,47 +7,82 @@ ifeq ("$(DEBUG)","1")
7
7
CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
8
8
endif
9
9
10
+ INSTALL ?= install
11
+ prefix ?= /usr
12
+ datarootdir ?= $(prefix ) /share
13
+ docdir ?= $(datarootdir ) /doc
14
+ includedir ?= $(prefix ) /include
15
+
10
16
include ../Makefile.deps
11
17
12
18
YNL_GEN_ARG_ethtool: =--user-header linux/ethtool_netlink.h \
13
19
--exclude-op stats-get
14
20
15
21
TOOL: =../pyynl/ynl_gen_c.py
22
+ TOOL_RST: =../pyynl/ynl_gen_rst.py
16
23
24
+ SPECS_DIR: =../../../../Documentation/netlink/specs
17
25
GENS_PATHS =$(shell grep -nrI --files-without-match \
18
26
'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})
21
29
SRCS =$(patsubst % ,% -user.c,${GENS})
22
30
HDRS =$(patsubst % ,% -user.h,${GENS})
23
31
OBJS =$(patsubst % ,% -user.o,${GENS})
24
32
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 )
26
38
27
39
protos.a : $(OBJS )
28
40
@echo -e " \tAR $@ "
29
41
@ar rcs $@ $(OBJS )
30
42
31
- % -user.h : ../../../../Documentation/netlink/specs /% .yaml $(TOOL )
43
+ % -user.h : $( SPECS_DIR ) /% .yaml $(TOOL )
32
44
@echo -e " \tGEN $@ "
33
45
@$(TOOL ) --mode user --header --spec $< -o $@ $(YNL_GEN_ARG_$* )
34
46
35
- % -user.c : ../../../../Documentation/netlink/specs /% .yaml $(TOOL )
47
+ % -user.c : $( SPECS_DIR ) /% .yaml $(TOOL )
36
48
@echo -e " \tGEN $@ "
37
49
@$(TOOL ) --mode user --source --spec $< -o $@ $(YNL_GEN_ARG_$* )
38
50
39
51
% -user.o : % -user.c % -user.h
40
52
@echo -e " \tCC $@ "
41
53
@$(COMPILE.c ) $(CFLAGS_$* ) -o $@ $<
42
54
55
+ % .rst : $(SPECS_DIR ) /% .yaml $(TOOL_RST )
56
+ @echo -e " \tGEN_RST $@ "
57
+ @$(TOOL_RST ) -o $@ -i $<
58
+
43
59
clean :
44
60
rm -f * .o
45
61
46
62
distclean : clean
47
- rm -f * .c * .h * .a
63
+ rm -f * .c * .h * .a * .rst
48
64
49
65
regen :
50
66
@../ynl-regen.sh
51
67
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
53
88
.DEFAULT_GOAL : all
0 commit comments