hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/tools/bpf/Makefile
....@@ -3,16 +3,26 @@
33
44 prefix ?= /usr/local
55
6
-CC = gcc
76 LEX = flex
87 YACC = bison
98 MAKE = make
109 INSTALL ?= install
1110
1211 CFLAGS += -Wall -O2
13
-CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include
12
+CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi \
13
+ -I$(srctree)/tools/include
1414
15
+# This will work when bpf is built in tools env. where srctree
16
+# isn't set and when invoked from selftests build, where srctree
17
+# is set to ".". building_out_of_srctree is undefined for in srctree
18
+# builds
1519 ifeq ($(srctree),)
20
+update_srctree := 1
21
+endif
22
+ifndef building_out_of_srctree
23
+update_srctree := 1
24
+endif
25
+ifeq ($(update_srctree),1)
1626 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
1727 srctree := $(patsubst %/,%,$(dir $(srctree)))
1828 endif
....@@ -28,7 +38,7 @@
2838 FEATURE_DISPLAY = libbfd disassembler-four-args
2939
3040 check_feat := 1
31
-NON_CHECK_FEAT_TARGETS := clean bpftool_clean
41
+NON_CHECK_FEAT_TARGETS := clean bpftool_clean runqslower_clean resolve_btfids_clean
3242 ifdef MAKECMDGOALS
3343 ifeq ($(filter-out $(NON_CHECK_FEAT_TARGETS),$(MAKECMDGOALS)),)
3444 check_feat := 0
....@@ -54,16 +64,16 @@
5464 $(QUIET_FLEX)$(LEX) -o $@ $<
5565
5666 $(OUTPUT)%.o: $(srctree)/tools/bpf/%.c
57
- $(QUIET_CC)$(COMPILE.c) -o $@ $<
67
+ $(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $<
5868
5969 $(OUTPUT)%.yacc.o: $(OUTPUT)%.yacc.c
60
- $(QUIET_CC)$(COMPILE.c) -o $@ $<
70
+ $(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $<
6171 $(OUTPUT)%.lex.o: $(OUTPUT)%.lex.c
62
- $(QUIET_CC)$(COMPILE.c) -o $@ $<
72
+ $(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $<
6373
6474 PROGS = $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg $(OUTPUT)bpf_asm
6575
66
-all: $(PROGS) bpftool
76
+all: $(PROGS) bpftool runqslower
6777
6878 $(OUTPUT)bpf_jit_disasm: CFLAGS += -DPACKAGE='bpf_jit_disasm'
6979 $(OUTPUT)bpf_jit_disasm: $(OUTPUT)bpf_jit_disasm.o
....@@ -79,12 +89,13 @@
7989 $(OUTPUT)bpf_exp.yacc.o: $(OUTPUT)bpf_exp.yacc.c
8090 $(OUTPUT)bpf_exp.lex.o: $(OUTPUT)bpf_exp.lex.c
8191
82
-clean: bpftool_clean
92
+clean: bpftool_clean runqslower_clean resolve_btfids_clean
8393 $(call QUIET_CLEAN, bpf-progs)
84
- $(Q)rm -rf $(OUTPUT)*.o $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg \
94
+ $(Q)$(RM) -r -- $(OUTPUT)*.o $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg \
8595 $(OUTPUT)bpf_asm $(OUTPUT)bpf_exp.yacc.* $(OUTPUT)bpf_exp.lex.*
8696 $(call QUIET_CLEAN, core-gen)
87
- $(Q)rm -f $(OUTPUT)FEATURE-DUMP.bpf
97
+ $(Q)$(RM) -- $(OUTPUT)FEATURE-DUMP.bpf
98
+ $(Q)$(RM) -r -- $(OUTPUT)feature
8899
89100 install: $(PROGS) bpftool_install
90101 $(call QUIET_INSTALL, bpf_jit_disasm)
....@@ -104,4 +115,18 @@
104115 bpftool_clean:
105116 $(call descend,bpftool,clean)
106117
107
-.PHONY: all install clean bpftool bpftool_install bpftool_clean
118
+runqslower:
119
+ $(call descend,runqslower)
120
+
121
+runqslower_clean:
122
+ $(call descend,runqslower,clean)
123
+
124
+resolve_btfids:
125
+ $(call descend,resolve_btfids)
126
+
127
+resolve_btfids_clean:
128
+ $(call descend,resolve_btfids,clean)
129
+
130
+.PHONY: all install clean bpftool bpftool_install bpftool_clean \
131
+ runqslower runqslower_clean \
132
+ resolve_btfids resolve_btfids_clean