@@ -20,8 +20,8 @@ CLANG ?= clang
20
20
LLC ?= llc
21
21
LLVM_OBJCOPY ?= llvm-objcopy
22
22
BPF_GCC ?= $(shell command -v bpf-gcc;)
23
- CFLAGS += -g -Wall -O2 $(GENFLAGS ) -I$(APIDIR ) -I$(LIBDIR ) -I$(BPFDIR ) \
24
- -I$(GENDIR ) -I$(TOOLSINCDIR ) -I$(CURDIR ) \
23
+ CFLAGS += -g -Wall -O2 $(GENFLAGS ) -I$(CURDIR ) -I$(APIDIR ) -I$(LIBDIR ) \
24
+ -I$(BPFDIR ) -I$(GENDIR ) -I$(TOOLSINCDIR ) \
25
25
-Dbpf_prog_load=bpf_prog_test_load \
26
26
-Dbpf_load_program=bpf_test_load_program
27
27
LDLIBS += -lcap -lelf -lz -lrt -lpthread
@@ -83,16 +83,20 @@ TEST_CUSTOM_PROGS = urandom_read
83
83
# $3 - target (assumed to be file); only file name will be emitted;
84
84
# $4 - optional extra arg, emitted as-is, if provided.
85
85
ifeq ($(V ) ,1)
86
+ Q =
86
87
msg =
87
88
else
89
+ Q = @
88
90
msg = @$(info $(1 )$(if $(2 ) , [$(2 ) ]) $(notdir $(3 ) ) )$(if $(4 ) , $(4 ) )
91
+ MAKEFLAGS += --no-print-directory
89
92
endif
90
93
91
94
# override lib.mk's default rules
92
95
OVERRIDE_TARGETS := 1
93
96
override define CLEAN
94
97
$(call msg, CLEAN)
95
98
$(RM ) -r $(TEST_GEN_PROGS ) $(TEST_GEN_PROGS_EXTENDED ) $(TEST_GEN_FILES ) $(EXTRA_CLEAN )
99
+ $(MAKE ) -C $(BPFDIR ) OUTPUT=$(OUTPUT ) / clean
96
100
endef
97
101
98
102
include ../lib.mk
@@ -146,14 +150,14 @@ DEFAULT_BPFTOOL := $(OUTPUT)/tools/usr/local/sbin/bpftool
146
150
BPFTOOL ?= $(DEFAULT_BPFTOOL )
147
151
148
152
$(DEFAULT_BPFTOOL ) : force
149
- $(MAKE ) -C $(BPFTOOLDIR ) DESTDIR=$(OUTPUT ) /tools install
153
+ $(Q )$( MAKE ) -C $(BPFTOOLDIR ) DESTDIR=$(OUTPUT ) /tools install
150
154
151
155
$(BPFOBJ ) : force
152
- $(MAKE ) -C $(BPFDIR ) OUTPUT=$(OUTPUT ) /
156
+ $(Q )$( MAKE ) -C $(BPFDIR ) OUTPUT=$(OUTPUT ) /
153
157
154
158
BPF_HELPERS := $(OUTPUT ) /bpf_helper_defs.h $(wildcard $(BPFDIR ) /bpf_* .h)
155
- $(OUTPUT ) /bpf_helper_defs.h :
156
- $(MAKE ) -C $(BPFDIR ) OUTPUT=$(OUTPUT ) / $(OUTPUT ) /bpf_helper_defs.h
159
+ $(OUTPUT ) /bpf_helper_defs.h : $( BPFOBJ )
160
+ $(Q )$( MAKE ) -C $(BPFDIR ) OUTPUT=$(OUTPUT ) / $(OUTPUT ) /bpf_helper_defs.h
157
161
158
162
# Get Clang's default includes on this system, as opposed to those seen by
159
163
# '-target bpf'. This fixes "missing" files on some architectures/distros,
@@ -173,8 +177,8 @@ MENDIAN=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)
173
177
174
178
CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG ) )
175
179
BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH ) $(MENDIAN ) \
176
- -I. -I./include/uapi -I$(APIDIR ) \
177
- -I$(BPFDIR ) -I$(abspath $(OUTPUT ) /../usr/include)
180
+ -I$( OUTPUT ) -I$( CURDIR ) -I$(CURDIR ) /include/uapi \
181
+ -I$(APIDIR ) -I $( BPFDIR ) -I$(abspath $(OUTPUT ) /../usr/include)
178
182
179
183
CLANG_CFLAGS = $(CLANG_SYS_INCLUDES ) \
180
184
-Wno-compare-distinct-pointer-types
@@ -252,6 +256,7 @@ define DEFINE_TEST_RUNNER_RULES
252
256
ifeq ($($(TRUNNER_OUTPUT ) -dir) ,)
253
257
$(TRUNNER_OUTPUT)-dir := y
254
258
$(TRUNNER_OUTPUT ) :
259
+ $$(call msg, MKDIR,,$$@ )
255
260
mkdir -p $$@
256
261
endif
257
262
@@ -328,7 +333,7 @@ TRUNNER_EXTRA_SOURCES := test_progs.c cgroup_helpers.c trace_helpers.c \
328
333
TRUNNER_EXTRA_FILES := $(OUTPUT ) /urandom_read \
329
334
$(wildcard progs/btf_dump_test_case_* .c)
330
335
TRUNNER_BPF_BUILD_RULE := CLANG_BPF_BUILD_RULE
331
- TRUNNER_BPF_CFLAGS := -I. -I $( OUTPUT ) $(BPF_CFLAGS ) $(CLANG_CFLAGS )
336
+ TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS ) $(CLANG_CFLAGS )
332
337
TRUNNER_BPF_LDFLAGS := -mattr=+alu32
333
338
$(eval $(call DEFINE_TEST_RUNNER,test_progs))
334
339
@@ -377,5 +382,5 @@ $(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ)
377
382
378
383
EXTRA_CLEAN := $(TEST_CUSTOM_PROGS ) \
379
384
prog_tests/tests.h map_tests/tests.h verifier/tests.h \
380
- feature $( OUTPUT ) /*.o $( OUTPUT ) /no_alu32 $( OUTPUT ) /bpf_gcc \
381
- tools *. skel.h
385
+ feature \
386
+ $( addprefix $( OUTPUT ) /, * .o * . skel.h no_alu32 bpf_gcc tools)
0 commit comments