blob: 3a7c02add70c3a9b096997b74d3697a732131649 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Ilya Leoshkevich9cae4ac2019-07-11 11:12:49 +02002include ../../../../scripts/Kbuild.include
Ilya Leoshkevich748e50c2019-07-11 16:29:27 +02003include ../../../scripts/Makefile.arch
Jean-Philippe Bruckerde11ae42021-01-13 17:33:16 +01004include ../../../scripts/Makefile.include
Hendrik Brueckner618e1652017-12-04 10:56:48 +01005
Ilya Leoshkeviche7ad28e2020-06-02 19:56:49 +02006CXX ?= $(CROSS_COMPILE)g++
7
Andrii Nakryiko74b5a592019-10-15 23:00:49 -07008CURDIR := $(abspath .)
Andrii Nakryikof3c926a2019-12-13 17:43:38 -08009TOOLSDIR := $(abspath ../../..)
10LIBDIR := $(TOOLSDIR)/lib
Zi Shen Lime8f1f342017-03-19 23:03:14 -070011BPFDIR := $(LIBDIR)/bpf
Andrii Nakryikof3c926a2019-12-13 17:43:38 -080012TOOLSINCDIR := $(TOOLSDIR)/include
13BPFTOOLDIR := $(TOOLSDIR)/bpf/bpftool
14APIDIR := $(TOOLSINCDIR)/uapi
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070015GENDIR := $(abspath ../../../../include/generated)
Daniel Borkmann02ea80b2017-03-31 02:24:04 +020016GENHDR := $(GENDIR)/autoconf.h
Mickaël Salaünd498f872017-02-11 23:20:23 +010017
Daniel Borkmann02ea80b2017-03-31 02:24:04 +020018ifneq ($(wildcard $(GENHDR)),)
19 GENFLAGS := -DHAVE_GENHDR
20endif
21
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +020022BPF_GCC ?= $(shell command -v bpf-gcc;)
Andrii Nakryiko02995dd2020-04-28 18:21:02 -070023SAN_CFLAGS ?=
Andrii Nakryiko252e3cb2021-03-13 13:09:20 -080024CFLAGS += -g -Og -rdynamic -Wall $(GENFLAGS) $(SAN_CFLAGS) \
Andrii Nakryiko02995dd2020-04-28 18:21:02 -070025 -I$(CURDIR) -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR) \
Jean-Philippe Brucker5837ced2021-01-13 17:33:17 +010026 -I$(TOOLSINCDIR) -I$(APIDIR) -I$(OUTPUT) \
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070027 -Dbpf_prog_load=bpf_prog_test_load \
Jiong Wang9d120b42019-05-24 23:25:21 +010028 -Dbpf_load_program=bpf_test_load_program
Andrii Nakryiko166750b2019-12-13 17:47:08 -080029LDLIBS += -lcap -lelf -lz -lrt -lpthread
Daniel Borkmann5aa5bd12016-10-17 14:28:36 +020030
Jesper Dangaard Brouerf09b2e32018-02-08 12:48:27 +010031# Order correspond to 'make run_tests' order
David S. Miller18b3ad92017-05-10 11:43:51 -070032TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
Alexander Duyckaaf376b2020-11-03 13:34:48 -080033 test_verifier_log test_dev_cgroup \
Florent Revest61f8c9c2021-02-10 12:14:04 +010034 test_sock test_sockmap get_cgroup_id_user \
Jakub Sitnicki415bb4e2019-12-12 11:22:58 +010035 test_cgroup_storage \
Martin KaFai Lau6f521a22020-09-24 17:04:27 -070036 test_netcnt test_tcpnotify_user test_sysctl \
Carlos Neira09c02d52021-01-14 11:10:36 -030037 test_progs-no_alu32
Jiong Wang3ef84342019-01-26 12:26:14 -050038
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070039# Also test bpf-gcc, if present
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +020040ifneq ($(BPF_GCC),)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070041TEST_GEN_PROGS += test_progs-bpf_gcc
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +020042endif
43
Jean-Philippe Bruckerd6ac8ca2021-01-13 17:33:18 +010044TEST_GEN_FILES = test_lwt_ip_encap.o \
45 test_tc_edt.o
Jean-Philippe Bruckerb8d1cbe2021-01-13 17:33:20 +010046TEST_FILES = xsk_prereqs.sh \
47 $(wildcard progs/btf_dump_test_case_*.c)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070048
Jesper Dangaard Brouerf09b2e32018-02-08 12:48:27 +010049# Order correspond to 'make run_tests' order
50TEST_PROGS := test_kmod.sh \
Jesper Dangaard Brouerf09b2e32018-02-08 12:48:27 +010051 test_xdp_redirect.sh \
52 test_xdp_meta.sh \
Toshiaki Makita88091ff2019-06-20 11:23:23 +090053 test_xdp_veth.sh \
Andrey Ignatov622adaf2018-03-30 15:08:06 -070054 test_offload.py \
William Tu933a7412018-04-26 14:01:39 -070055 test_sock_addr.sh \
Mathieu Xhonneuxc99a84e2018-05-20 14:58:17 +010056 test_tunnel.sh \
Sean Young6bdd5332018-05-27 12:24:10 +010057 test_lwt_seg6local.sh \
Andrey Ignatov5ecd8c22018-08-12 10:49:30 -070058 test_lirc_mode2.sh \
Petar Penkov50b3ed52018-09-14 07:46:22 -070059 test_skb_cgroup_id.sh \
Jesper Dangaard Brouer97396ff2018-10-09 12:04:53 +020060 test_flow_dissector.sh \
Jesper Dangaard Brouerd35661f2019-08-01 20:00:21 +020061 test_xdp_vlan_mode_generic.sh \
62 test_xdp_vlan_mode_native.sh \
Lorenz Bauerbafc0ba2019-03-22 09:54:06 +080063 test_lwt_ip_encap.sh \
Willem de Bruijn98cdabc2019-03-22 14:32:49 -040064 test_tcp_check_syncookie.sh \
Peter Oskolkov7df5e3d2019-03-22 16:40:19 -070065 test_tc_tunnel.sh \
Alan Maguirecd538502019-05-31 18:47:14 +010066 test_tc_edt.sh \
Quentin Monnet45c5589d2019-08-30 12:00:38 +010067 test_xdping.sh \
Michal Rostecki736332742020-02-26 17:59:39 +010068 test_bpftool_build.sh \
YiFei Zhud42d1cc2020-09-15 16:45:43 -070069 test_bpftool.sh \
70 test_bpftool_metadata.sh \
Jean-Philippe Bruckera0d73ac2021-03-08 19:28:31 +010071 test_doc_build.sh \
Weqaar Janjuaa8905252020-12-07 21:53:29 +000072 test_xsk.sh
Daniel Borkmann5aa5bd12016-10-17 14:28:36 +020073
Anders Roxellf98937c2019-01-08 10:23:03 +010074TEST_PROGS_EXTENDED := with_addr.sh \
Stanislav Fomichev1be72f22019-01-14 09:41:41 -080075 with_tunnels.sh \
Anders Roxell3035bb72019-08-20 15:41:21 +020076 test_xdp_vlan.sh
Anders Roxellef4ab842018-10-10 16:27:04 +020077
Jesper Dangaard Brouerf09b2e32018-02-08 12:48:27 +010078# Compile but not part of 'make run_tests'
Andrii Nakryikocb79a4e2019-10-15 23:00:51 -070079TEST_GEN_PROGS_EXTENDED = test_sock_addr test_skb_cgroup_id_user \
Hangbin Liu25a79912019-06-04 10:35:05 +080080 flow_dissector_load test_flow_dissector test_tcp_check_syncookie_user \
Weqaar Janjuafacb7cb2020-12-07 21:53:30 +000081 test_lirc_mode2_user xdping test_cpp runqslower bench bpf_testmod.ko \
82 xdpxceiver
Jesper Dangaard Brouerf09b2e32018-02-08 12:48:27 +010083
Jean-Philippe Bruckerca1e8462021-01-13 17:33:19 +010084TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070085
Andrii Nakryiko92f74402019-12-16 22:14:25 -080086# Emit succinct information message describing current building step
87# $1 - generic step name (e.g., CC, LINK, etc);
88# $2 - optional "flavor" specifier; if provided, will be emitted as [flavor];
89# $3 - target (assumed to be file); only file name will be emitted;
90# $4 - optional extra arg, emitted as-is, if provided.
91ifeq ($(V),1)
Andrii Nakryiko965b9fe2020-01-09 21:17:16 -080092Q =
Andrii Nakryiko92f74402019-12-16 22:14:25 -080093msg =
94else
Andrii Nakryiko965b9fe2020-01-09 21:17:16 -080095Q = @
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -080096msg = @printf ' %-8s%s %s%s\n' "$(1)" "$(if $(2), [$(2)])" "$(notdir $(3))" "$(if $(4), $(4))";
Andrii Nakryiko965b9fe2020-01-09 21:17:16 -080097MAKEFLAGS += --no-print-directory
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -080098submake_extras := feature_display=0
Andrii Nakryiko92f74402019-12-16 22:14:25 -080099endif
100
101# override lib.mk's default rules
102OVERRIDE_TARGETS := 1
103override define CLEAN
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800104 $(call msg,CLEAN)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700105 $(Q)$(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
Andrii Nakryiko9f7fa222020-12-03 12:46:26 -0800106 $(Q)$(MAKE) -C bpf_testmod clean
Joe Stringera01d9352021-03-02 09:19:43 -0800107 $(Q)$(MAKE) docs-clean
Andrii Nakryiko92f74402019-12-16 22:14:25 -0800108endef
109
Zi Shen Lime8f1f342017-03-19 23:03:14 -0700110include ../lib.mk
Alexei Starovoitov1da8ac72017-03-10 22:05:55 -0800111
Toke Høiland-Jørgensena2c96522020-01-20 14:06:52 +0100112SCRATCH_DIR := $(OUTPUT)/tools
113BUILD_DIR := $(SCRATCH_DIR)/build
114INCLUDE_DIR := $(SCRATCH_DIR)/include
115BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a
Jean-Philippe Bruckerde11ae42021-01-13 17:33:16 +0100116ifneq ($(CROSS_COMPILE),)
117HOST_BUILD_DIR := $(BUILD_DIR)/host
118HOST_SCRATCH_DIR := $(OUTPUT)/host-tools
119else
120HOST_BUILD_DIR := $(BUILD_DIR)
121HOST_SCRATCH_DIR := $(SCRATCH_DIR)
122endif
123HOST_BPFOBJ := $(HOST_BUILD_DIR)/libbpf/libbpf.a
124RESOLVE_BTFIDS := $(HOST_BUILD_DIR)/resolve_btfids/resolve_btfids
Toke Høiland-Jørgensena2c96522020-01-20 14:06:52 +0100125
Andrii Nakryikoa67079b2020-12-10 17:59:46 -0800126VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \
127 $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \
128 ../../../../vmlinux \
129 /sys/kernel/btf/vmlinux \
130 /boot/vmlinux-$(shell uname -r)
131VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
Kamal Mostafa1a3449c2020-12-15 10:20:10 -0800132ifeq ($(VMLINUX_BTF),)
133$(error Cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)")
134endif
Andrii Nakryikoa67079b2020-12-10 17:59:46 -0800135
Andrii Nakryiko03dcb782019-10-15 23:00:48 -0700136# Define simple and short `make test_progs`, `make test_sysctl`, etc targets
137# to build individual tests.
138# NOTE: Semicolon at the end is critical to override lib.mk's default static
139# rule for binaries.
140$(notdir $(TEST_GEN_PROGS) \
141 $(TEST_PROGS) \
142 $(TEST_PROGS_EXTENDED) \
143 $(TEST_GEN_PROGS_EXTENDED) \
144 $(TEST_CUSTOM_PROGS)): %: $(OUTPUT)/% ;
145
Jean-Philippe Bruckerde11ae42021-01-13 17:33:16 +0100146# sort removes libbpf duplicates when not cross-building
147MAKE_DIRS := $(sort $(BUILD_DIR)/libbpf $(HOST_BUILD_DIR)/libbpf \
148 $(HOST_BUILD_DIR)/bpftool $(HOST_BUILD_DIR)/resolve_btfids \
149 $(INCLUDE_DIR))
150$(MAKE_DIRS):
151 $(call msg,MKDIR,,$@)
152 $(Q)mkdir -p $@
153
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700154$(OUTPUT)/%.o: %.c
155 $(call msg,CC,,$@)
156 $(Q)$(CC) $(CFLAGS) -c $(filter %.c,$^) $(LDLIBS) -o $@
157
Andrii Nakryiko92f74402019-12-16 22:14:25 -0800158$(OUTPUT)/%:%.c
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800159 $(call msg,BINARY,,$@)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700160 $(Q)$(LINK.c) $^ $(LDLIBS) -o $@
Andrii Nakryiko92f74402019-12-16 22:14:25 -0800161
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700162$(OUTPUT)/urandom_read: urandom_read.c
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800163 $(call msg,BINARY,,$@)
Bill Wendlinga9684332020-09-22 16:21:40 -0700164 $(Q)$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS) -Wl,--build-id=sha1
Jiong Wang3ef84342019-01-26 12:26:14 -0500165
Andrii Nakryiko9f7fa222020-12-03 12:46:26 -0800166$(OUTPUT)/bpf_testmod.ko: $(VMLINUX_BTF) $(wildcard bpf_testmod/Makefile bpf_testmod/*.[ch])
167 $(call msg,MOD,,$@)
Andrii Nakryikoa67079b2020-12-10 17:59:46 -0800168 $(Q)$(RM) bpf_testmod/bpf_testmod.ko # force re-compilation
Andrii Nakryiko9f7fa222020-12-03 12:46:26 -0800169 $(Q)$(MAKE) $(submake_extras) -C bpf_testmod
170 $(Q)cp bpf_testmod/bpf_testmod.ko $@
171
Toke Høiland-Jørgensena2c96522020-01-20 14:06:52 +0100172$(OUTPUT)/test_stub.o: test_stub.c $(BPFOBJ)
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800173 $(call msg,CC,,$@)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700174 $(Q)$(CC) -c $(CFLAGS) -o $@ $<
Ilya Leoshkeviche93d9912019-10-28 11:21:10 +0100175
Jean-Philippe Bruckerde11ae42021-01-13 17:33:16 +0100176DEFAULT_BPFTOOL := $(HOST_SCRATCH_DIR)/sbin/bpftool
Andrii Nakryiko6bcaf412020-08-04 17:47:57 -0700177
178$(OUTPUT)/runqslower: $(BPFOBJ) | $(DEFAULT_BPFTOOL)
Toke Høiland-Jørgensenbfe42792020-01-20 14:06:43 +0100179 $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower \
Toke Høiland-Jørgensena2c96522020-01-20 14:06:52 +0100180 OUTPUT=$(SCRATCH_DIR)/ VMLINUX_BTF=$(VMLINUX_BTF) \
Veronika Kabatovab26d1e22020-04-28 19:37:42 +0200181 BPFOBJ=$(BPFOBJ) BPF_INCLUDE=$(INCLUDE_DIR) && \
182 cp $(SCRATCH_DIR)/runqslower $@
Zi Shen Lime8f1f342017-03-19 23:03:14 -0700183
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700184$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/test_stub.o $(BPFOBJ)
Joe Stringera01d9352021-03-02 09:19:43 -0800185$(TEST_GEN_FILES): docs
Jesper Dangaard Brouerf09b2e32018-02-08 12:48:27 +0100186
Jesper Dangaard Brouer41757dc2018-02-13 14:19:15 +0100187$(OUTPUT)/test_dev_cgroup: cgroup_helpers.c
Andrey Ignatov5ecd8c22018-08-12 10:49:30 -0700188$(OUTPUT)/test_skb_cgroup_id_user: cgroup_helpers.c
Andrey Ignatov1d436882018-03-30 15:08:08 -0700189$(OUTPUT)/test_sock: cgroup_helpers.c
Andrey Ignatove50b0a62018-03-30 15:08:03 -0700190$(OUTPUT)/test_sock_addr: cgroup_helpers.c
John Fastabend16962b22018-04-23 14:30:38 -0700191$(OUTPUT)/test_sockmap: cgroup_helpers.c
Sowmini Varadhan435f90a2018-11-07 16:12:02 -0800192$(OUTPUT)/test_tcpnotify_user: cgroup_helpers.c trace_helpers.c
Yonghong Songf2690992018-06-03 15:59:43 -0700193$(OUTPUT)/get_cgroup_id_user: cgroup_helpers.c
Roman Gushchin68cfa3a2018-08-02 14:27:29 -0700194$(OUTPUT)/test_cgroup_storage: cgroup_helpers.c
Roman Gushchin371e4fc2018-09-28 14:46:00 +0000195$(OUTPUT)/test_netcnt: cgroup_helpers.c
Martin KaFai Laue0b27b32019-02-09 23:22:28 -0800196$(OUTPUT)/test_sock_fields: cgroup_helpers.c
Andrey Ignatov1f5fa9a2019-03-08 15:08:21 -0800197$(OUTPUT)/test_sysctl: cgroup_helpers.c
Jesper Dangaard Brouer41757dc2018-02-13 14:19:15 +0100198
Andrii Nakryikof3c926a2019-12-13 17:43:38 -0800199BPFTOOL ?= $(DEFAULT_BPFTOOL)
Andrii Nakryiko03506292020-01-23 21:41:48 -0800200$(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \
Jean-Philippe Bruckerde11ae42021-01-13 17:33:16 +0100201 $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/bpftool
Andrii Nakryiko03506292020-01-23 21:41:48 -0800202 $(Q)$(MAKE) $(submake_extras) -C $(BPFTOOLDIR) \
Jean-Philippe Bruckerde11ae42021-01-13 17:33:16 +0100203 CC=$(HOSTCC) LD=$(HOSTLD) \
Andrii Nakryiko252e3cb2021-03-13 13:09:20 -0800204 EXTRA_CFLAGS='-g -Og' \
Jean-Philippe Bruckerde11ae42021-01-13 17:33:16 +0100205 OUTPUT=$(HOST_BUILD_DIR)/bpftool/ \
206 prefix= DESTDIR=$(HOST_SCRATCH_DIR)/ install
Joe Stringera01d9352021-03-02 09:19:43 -0800207
208docs:
209 $(Q)RST2MAN_OPTS="--exit-status=1" $(MAKE) $(submake_extras) \
210 -f Makefile.docs \
211 prefix= OUTPUT=$(OUTPUT)/ DESTDIR=$(OUTPUT)/ $@
212
213docs-clean:
214 $(Q)$(MAKE) $(submake_extras) \
215 -f Makefile.docs \
216 prefix= OUTPUT=$(OUTPUT)/ DESTDIR=$(OUTPUT)/ $@
Andrii Nakryikof3c926a2019-12-13 17:43:38 -0800217
Andrii Nakryiko03506292020-01-23 21:41:48 -0800218$(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \
Toke Høiland-Jørgensena2c96522020-01-20 14:06:52 +0100219 ../../../include/uapi/linux/bpf.h \
220 | $(INCLUDE_DIR) $(BUILD_DIR)/libbpf
221 $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/ \
Andrii Nakryiko252e3cb2021-03-13 13:09:20 -0800222 EXTRA_CFLAGS='-g -Og' \
Andrii Nakryiko03506292020-01-23 21:41:48 -0800223 DESTDIR=$(SCRATCH_DIR) prefix= all install_headers
Andrii Nakryikof3c926a2019-12-13 17:43:38 -0800224
Jean-Philippe Bruckerde11ae42021-01-13 17:33:16 +0100225ifneq ($(BPFOBJ),$(HOST_BPFOBJ))
226$(HOST_BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \
227 ../../../include/uapi/linux/bpf.h \
228 | $(INCLUDE_DIR) $(HOST_BUILD_DIR)/libbpf
229 $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) \
Andrii Nakryiko252e3cb2021-03-13 13:09:20 -0800230 EXTRA_CFLAGS='-g -Og' \
231 OUTPUT=$(HOST_BUILD_DIR)/libbpf/ CC=$(HOSTCC) LD=$(HOSTLD) \
Jean-Philippe Bruckerde11ae42021-01-13 17:33:16 +0100232 DESTDIR=$(HOST_SCRATCH_DIR)/ prefix= all install_headers
233endif
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700234
Andrii Nakryikocab62c32021-03-18 12:40:34 -0700235$(INCLUDE_DIR)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) | $(INCLUDE_DIR)
Andrii Nakryikoca4db632020-06-29 17:47:59 -0700236ifeq ($(VMLINUX_H),)
Andrii Nakryikoacbd0622020-03-13 10:23:36 -0700237 $(call msg,GEN,,$@)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700238 $(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@
Andrii Nakryikoca4db632020-06-29 17:47:59 -0700239else
240 $(call msg,CP,,$@)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700241 $(Q)cp "$(VMLINUX_H)" $@
Andrii Nakryikoca4db632020-06-29 17:47:59 -0700242endif
Andrii Nakryikoacbd0622020-03-13 10:23:36 -0700243
Jean-Philippe Bruckerde11ae42021-01-13 17:33:16 +0100244$(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids \
Jiri Olsacc15a202020-07-11 23:53:29 +0200245 $(TOOLSDIR)/bpf/resolve_btfids/main.c \
246 $(TOOLSDIR)/lib/rbtree.c \
247 $(TOOLSDIR)/lib/zalloc.c \
248 $(TOOLSDIR)/lib/string.c \
249 $(TOOLSDIR)/lib/ctype.c \
250 $(TOOLSDIR)/lib/str_error_r.c
251 $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/resolve_btfids \
Jean-Philippe Bruckerde11ae42021-01-13 17:33:16 +0100252 CC=$(HOSTCC) LD=$(HOSTLD) AR=$(HOSTAR) \
253 OUTPUT=$(HOST_BUILD_DIR)/resolve_btfids/ BPFOBJ=$(HOST_BPFOBJ)
Jiri Olsacc15a202020-07-11 23:53:29 +0200254
Sirio Balmelli167381f2018-05-21 09:00:03 +0200255# Get Clang's default includes on this system, as opposed to those seen by
256# '-target bpf'. This fixes "missing" files on some architectures/distros,
257# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc.
258#
259# Use '-idirafter': Don't interfere with include mechanics except where the
260# build would have failed anyways.
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200261define get_sys_includes
262$(shell $(1) -v -E - </dev/null 2>&1 \
Björn Töpel6016df82020-11-18 08:16:38 +0100263 | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
264$(shell $(1) -dM -E - </dev/null | grep '#define __riscv_xlen ' | sed 's/#define /-D/' | sed 's/ /=/')
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200265endef
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700266
Ilya Leoshkevich313e7f62019-10-28 11:20:49 +0100267# Determine target endianness.
268IS_LITTLE_ENDIAN = $(shell $(CC) -dM -E - </dev/null | \
269 grep 'define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__')
270MENDIAN=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)
271
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200272CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG))
Ilya Leoshkevich313e7f62019-10-28 11:20:49 +0100273BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) \
Tobias Klauserbcd66b12020-03-13 12:31:05 +0100274 -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR) \
275 -I$(abspath $(OUTPUT)/../usr/include)
Sirio Balmelli167381f2018-05-21 09:00:03 +0200276
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200277CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
278 -Wno-compare-distinct-pointer-types
Alexei Starovoitov3bc35c62017-12-14 17:55:11 -0800279
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200280$(OUTPUT)/test_l4lb_noinline.o: BPF_CFLAGS += -fno-inline
281$(OUTPUT)/test_xdp_noinline.o: BPF_CFLAGS += -fno-inline
Alexei Starovoitov3bc35c62017-12-14 17:55:11 -0800282
Stanislav Fomichevbf0f0fd2019-01-28 08:53:55 -0800283$(OUTPUT)/flow_dissector_load.o: flow_dissector_load.h
Stanislav Fomichevbf0f0fd2019-01-28 08:53:55 -0800284
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700285# Build BPF object using Clang
286# $1 - input .c file
287# $2 - output .o file
288# $3 - CFLAGS
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700289define CLANG_BPF_BUILD_RULE
Andrew Delgadillo89ad7422020-12-11 00:43:44 +0000290 $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
291 $(Q)$(CLANG) $3 -O2 -target bpf -c $1 -o $2 -mcpu=v3
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700292endef
Andrii Nakryiko24f65052019-11-19 16:25:10 -0800293# Similar to CLANG_BPF_BUILD_RULE, but with disabled alu32
294define CLANG_NOALU32_BPF_BUILD_RULE
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800295 $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
Andrew Delgadillo89ad7422020-12-11 00:43:44 +0000296 $(Q)$(CLANG) $3 -O2 -target bpf -c $1 -o $2 -mcpu=v2
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700297endef
298# Build BPF object using GCC
299define GCC_BPF_BUILD_RULE
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800300 $(call msg,GCC-BPF,$(TRUNNER_BINARY),$2)
Andrew Delgadillo89ad7422020-12-11 00:43:44 +0000301 $(Q)$(BPF_GCC) $3 -O2 -c $1 -o $2
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700302endef
Stanislav Fomicheve78e00b2019-03-06 11:59:26 -0800303
Jakub Sitnicki0b9ad562020-04-29 20:11:54 +0200304SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c
Andrii Nakryikof3c926a2019-12-13 17:43:38 -0800305
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700306# Set up extra TRUNNER_XXX "temporary" variables in the environment (relies on
307# $eval()) and pass control to DEFINE_TEST_RUNNER_RULES.
308# Parameters:
309# $1 - test runner base binary name (e.g., test_progs)
Yonghong Songe13a2fe2019-10-21 21:31:19 -0700310# $2 - test runner extra "flavor" (e.g., no_alu32, gcc-bpf, etc)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700311define DEFINE_TEST_RUNNER
Jiong Wang3ef84342019-01-26 12:26:14 -0500312
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700313TRUNNER_OUTPUT := $(OUTPUT)$(if $2,/)$2
314TRUNNER_BINARY := $1$(if $2,-)$2
315TRUNNER_TEST_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.test.o, \
316 $$(notdir $$(wildcard $(TRUNNER_TESTS_DIR)/*.c)))
317TRUNNER_EXTRA_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.o, \
318 $$(filter %.c,$(TRUNNER_EXTRA_SOURCES)))
319TRUNNER_EXTRA_HDRS := $$(filter %.h,$(TRUNNER_EXTRA_SOURCES))
320TRUNNER_TESTS_HDR := $(TRUNNER_TESTS_DIR)/tests.h
Andrii Nakryikof3c926a2019-12-13 17:43:38 -0800321TRUNNER_BPF_SRCS := $$(notdir $$(wildcard $(TRUNNER_BPF_PROGS_DIR)/*.c))
322TRUNNER_BPF_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.o, $$(TRUNNER_BPF_SRCS))
323TRUNNER_BPF_SKELS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.skel.h, \
324 $$(filter-out $(SKEL_BLACKLIST), \
325 $$(TRUNNER_BPF_SRCS)))
Yauheni Kaliuta309b81f2020-05-13 05:17:22 +0300326TEST_GEN_FILES += $$(TRUNNER_BPF_OBJS)
Jiong Wang3ef84342019-01-26 12:26:14 -0500327
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700328# Evaluate rules now with extra TRUNNER_XXX variables above already defined
329$$(eval $$(call DEFINE_TEST_RUNNER_RULES,$1,$2))
Stanislav Fomichev3f306582019-03-01 19:42:13 -0800330
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700331endef
Jiong Wang3ef84342019-01-26 12:26:14 -0500332
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700333# Using TRUNNER_XXX variables, provided by callers of DEFINE_TEST_RUNNER and
334# set up by DEFINE_TEST_RUNNER itself, create test runner build rules with:
335# $1 - test runner base binary name (e.g., test_progs)
Yonghong Songe13a2fe2019-10-21 21:31:19 -0700336# $2 - test runner extra "flavor" (e.g., no_alu32, gcc-bpf, etc)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700337define DEFINE_TEST_RUNNER_RULES
338
339ifeq ($($(TRUNNER_OUTPUT)-dir),)
340$(TRUNNER_OUTPUT)-dir := y
341$(TRUNNER_OUTPUT):
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800342 $$(call msg,MKDIR,,$$@)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700343 $(Q)mkdir -p $$@
Jiong Wang3ef84342019-01-26 12:26:14 -0500344endif
345
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700346# ensure we set up BPF objects generation rule just once for a given
347# input/output directory combination
348ifeq ($($(TRUNNER_BPF_PROGS_DIR)$(if $2,-)$2-bpfobjs),)
349$(TRUNNER_BPF_PROGS_DIR)$(if $2,-)$2-bpfobjs := y
350$(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.o: \
351 $(TRUNNER_BPF_PROGS_DIR)/%.c \
352 $(TRUNNER_BPF_PROGS_DIR)/*.h \
Andrii Nakryikoacbd0622020-03-13 10:23:36 -0700353 $$(INCLUDE_DIR)/vmlinux.h \
Andrii Nakryiko3ac2e202020-08-20 16:12:35 -0700354 $(wildcard $(BPFDIR)/bpf_*.h) | $(TRUNNER_OUTPUT)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700355 $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \
Andrew Delgadillo89ad7422020-12-11 00:43:44 +0000356 $(TRUNNER_BPF_CFLAGS))
Andrii Nakryikof3c926a2019-12-13 17:43:38 -0800357
Andrii Nakryiko14137f32021-03-18 12:40:35 -0700358$(TRUNNER_BPF_SKELS): %.skel.h: %.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800359 $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
Andrii Nakryiko14137f32021-03-18 12:40:35 -0700360 $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked.o) $$<
361 $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked2.o) $$(<:.o=.linked.o)
362 $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked3.o) $$(<:.o=.linked2.o)
363 $(Q)diff $$(<:.o=.linked2.o) $$(<:.o=.linked3.o)
364 $(Q)$$(BPFTOOL) gen skeleton $$(<:.o=.linked.o) name $$(notdir $$(<:.o=)) > $$@
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700365endif
366
367# ensure we set up tests.h header generation rule just once
368ifeq ($($(TRUNNER_TESTS_DIR)-tests-hdr),)
369$(TRUNNER_TESTS_DIR)-tests-hdr := y
370$(TRUNNER_TESTS_HDR): $(TRUNNER_TESTS_DIR)/*.c
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800371 $$(call msg,TEST-HDR,$(TRUNNER_BINARY),$$@)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700372 $$(shell ( cd $(TRUNNER_TESTS_DIR); \
373 echo '/* Generated header, do not edit */'; \
374 ls *.c 2> /dev/null | \
375 sed -e 's@\([^\.]*\)\.c@DEFINE_TEST(\1)@'; \
376 ) > $$@)
377endif
378
379# compile individual test files
380# Note: we cd into output directory to ensure embedded BPF object is found
381$(TRUNNER_TEST_OBJS): $(TRUNNER_OUTPUT)/%.test.o: \
382 $(TRUNNER_TESTS_DIR)/%.c \
383 $(TRUNNER_EXTRA_HDRS) \
384 $(TRUNNER_BPF_OBJS) \
Andrii Nakryikof3c926a2019-12-13 17:43:38 -0800385 $(TRUNNER_BPF_SKELS) \
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700386 $$(BPFOBJ) | $(TRUNNER_OUTPUT)
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800387 $$(call msg,TEST-OBJ,$(TRUNNER_BINARY),$$@)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700388 $(Q)cd $$(@D) && $$(CC) -I. $$(CFLAGS) -c $(CURDIR)/$$< $$(LDLIBS) -o $$(@F)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700389
390$(TRUNNER_EXTRA_OBJS): $(TRUNNER_OUTPUT)/%.o: \
391 %.c \
392 $(TRUNNER_EXTRA_HDRS) \
393 $(TRUNNER_TESTS_HDR) \
394 $$(BPFOBJ) | $(TRUNNER_OUTPUT)
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800395 $$(call msg,EXT-OBJ,$(TRUNNER_BINARY),$$@)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700396 $(Q)$$(CC) $$(CFLAGS) -c $$< $$(LDLIBS) -o $$@
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700397
Ilya Leoshkevich86fd1662021-02-24 12:14:45 +0100398# non-flavored in-srctree builds receive special treatment, in particular, we
399# do not need to copy extra resources (see e.g. test_btf_dump_case())
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700400$(TRUNNER_BINARY)-extras: $(TRUNNER_EXTRA_FILES) | $(TRUNNER_OUTPUT)
Ilya Leoshkevich86fd1662021-02-24 12:14:45 +0100401ifneq ($2:$(OUTPUT),:$(shell pwd))
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800402 $$(call msg,EXT-COPY,$(TRUNNER_BINARY),$(TRUNNER_EXTRA_FILES))
Ilya Leoshkevich86fd1662021-02-24 12:14:45 +0100403 $(Q)rsync -aq $$^ $(TRUNNER_OUTPUT)/
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700404endif
405
406$(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS) \
407 $(TRUNNER_EXTRA_OBJS) $$(BPFOBJ) \
Jiri Olsacc15a202020-07-11 23:53:29 +0200408 $(RESOLVE_BTFIDS) \
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700409 | $(TRUNNER_BINARY)-extras
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800410 $$(call msg,BINARY,,$$@)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700411 $(Q)$$(CC) $$(CFLAGS) $$(filter %.a %.o,$$^) $$(LDLIBS) -o $$@
Brendan Jackman58c185b2020-12-03 12:08:50 +0000412 $(Q)$(RESOLVE_BTFIDS) --no-fail --btf $(TRUNNER_OUTPUT)/btf_data.o $$@
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700413
414endef
415
416# Define test_progs test runner.
417TRUNNER_TESTS_DIR := prog_tests
418TRUNNER_BPF_PROGS_DIR := progs
419TRUNNER_EXTRA_SOURCES := test_progs.c cgroup_helpers.c trace_helpers.c \
Andrii Nakryikocd492912020-05-12 12:24:42 -0700420 network_helpers.c testing_helpers.c \
Andrii Nakryiko1306c982020-11-04 20:33:56 -0800421 btf_helpers.c flow_dissector_load.h
Andrii Nakryiko9f7fa222020-12-03 12:46:26 -0800422TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \
KP Singh854055c2020-11-26 18:49:46 +0000423 ima_setup.sh \
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700424 $(wildcard progs/btf_dump_test_case_*.c)
425TRUNNER_BPF_BUILD_RULE := CLANG_BPF_BUILD_RULE
Andrii Nakryiko6910d7d2020-01-09 21:17:15 -0800426TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS)
Brendan Jackman98d666d2021-01-14 18:17:50 +0000427TRUNNER_BPF_CFLAGS += -DENABLE_ATOMICS_TESTS
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700428$(eval $(call DEFINE_TEST_RUNNER,test_progs))
429
Yonghong Songe13a2fe2019-10-21 21:31:19 -0700430# Define test_progs-no_alu32 test runner.
Andrii Nakryiko24f65052019-11-19 16:25:10 -0800431TRUNNER_BPF_BUILD_RULE := CLANG_NOALU32_BPF_BUILD_RULE
Brendan Jackman98d666d2021-01-14 18:17:50 +0000432TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS)
Yonghong Songe13a2fe2019-10-21 21:31:19 -0700433$(eval $(call DEFINE_TEST_RUNNER,test_progs,no_alu32))
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700434
435# Define test_progs BPF-GCC-flavored test runner.
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200436ifneq ($(BPF_GCC),)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700437TRUNNER_BPF_BUILD_RULE := GCC_BPF_BUILD_RULE
Ilya Leoshkevich313e7f62019-10-28 11:20:49 +0100438TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(call get_sys_includes,gcc)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700439$(eval $(call DEFINE_TEST_RUNNER,test_progs,bpf_gcc))
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200440endif
441
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700442# Define test_maps test runner.
443TRUNNER_TESTS_DIR := map_tests
444TRUNNER_BPF_PROGS_DIR := progs
445TRUNNER_EXTRA_SOURCES := test_maps.c
446TRUNNER_EXTRA_FILES :=
447TRUNNER_BPF_BUILD_RULE := $$(error no BPF objects should be built)
448TRUNNER_BPF_CFLAGS :=
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700449$(eval $(call DEFINE_TEST_RUNNER,test_maps))
Martin KaFai Lauc0fa1b62018-04-18 15:56:06 -0700450
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700451# Define test_verifier test runner.
452# It is much simpler than test_maps/test_progs and sufficiently different from
453# them (e.g., test.h is using completely pattern), that it's worth just
454# explicitly defining all the rules explicitly.
455verifier/tests.h: verifier/*.c
Stanislav Fomicheve78e00b2019-03-06 11:59:26 -0800456 $(shell ( cd verifier/; \
Jakub Kicinski2dfb4012019-01-25 15:24:42 -0800457 echo '/* Generated header, do not edit */'; \
458 echo '#ifdef FILL_ARRAY'; \
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700459 ls *.c 2> /dev/null | sed -e 's@\(.*\)@#include \"\1\"@'; \
Jakub Kicinski2dfb4012019-01-25 15:24:42 -0800460 echo '#endif' \
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700461 ) > verifier/tests.h)
462$(OUTPUT)/test_verifier: test_verifier.c verifier/tests.h $(BPFOBJ) | $(OUTPUT)
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800463 $(call msg,BINARY,,$@)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700464 $(Q)$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@
Jakub Kicinski2dfb4012019-01-25 15:24:42 -0800465
Stanislav Fomichev6bf6aff2019-12-02 13:59:31 -0800466# Make sure we are able to include and link libbpf against c++.
Andrii Nakryiko7c8dce42019-12-26 13:02:53 -0800467$(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ)
Andrii Nakryiko2cc51d32020-01-12 23:31:40 -0800468 $(call msg,CXX,,$@)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700469 $(Q)$(CXX) $(CFLAGS) $^ $(LDLIBS) -o $@
Stanislav Fomichev6bf6aff2019-12-02 13:59:31 -0800470
Andrii Nakryiko8e7c2a02020-05-12 12:24:43 -0700471# Benchmark runner
472$(OUTPUT)/bench_%.o: benchs/bench_%.c bench.h
473 $(call msg,CC,,$@)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700474 $(Q)$(CC) $(CFLAGS) -c $(filter %.c,$^) $(LDLIBS) -o $@
Andrii Nakryiko4eaf0b52020-05-12 12:24:44 -0700475$(OUTPUT)/bench_rename.o: $(OUTPUT)/test_overhead.skel.h
Andrii Nakryikoc5d420c2020-05-12 12:24:45 -0700476$(OUTPUT)/bench_trigger.o: $(OUTPUT)/trigger_bench.skel.h
Andrii Nakryikoc97099b2020-05-29 00:54:23 -0700477$(OUTPUT)/bench_ringbufs.o: $(OUTPUT)/ringbuf_bench.skel.h \
478 $(OUTPUT)/perfbuf_bench.skel.h
Andrii Nakryiko8e7c2a02020-05-12 12:24:43 -0700479$(OUTPUT)/bench.o: bench.h testing_helpers.h
480$(OUTPUT)/bench: LDLIBS += -lm
481$(OUTPUT)/bench: $(OUTPUT)/bench.o $(OUTPUT)/testing_helpers.o \
Andrii Nakryiko4eaf0b52020-05-12 12:24:44 -0700482 $(OUTPUT)/bench_count.o \
Andrii Nakryikoc5d420c2020-05-12 12:24:45 -0700483 $(OUTPUT)/bench_rename.o \
Andrii Nakryikoc97099b2020-05-29 00:54:23 -0700484 $(OUTPUT)/bench_trigger.o \
485 $(OUTPUT)/bench_ringbufs.o
Andrii Nakryiko8e7c2a02020-05-12 12:24:43 -0700486 $(call msg,BINARY,,$@)
Andrii Nakryikod5ca5902020-08-06 20:30:57 -0700487 $(Q)$(CC) $(LDFLAGS) -o $@ $(filter %.a %.o,$^) $(LDLIBS)
Andrii Nakryiko8e7c2a02020-05-12 12:24:43 -0700488
Jean-Philippe Bruckerde11ae42021-01-13 17:33:16 +0100489EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(SCRATCH_DIR) $(HOST_SCRATCH_DIR) \
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700490 prog_tests/tests.h map_tests/tests.h verifier/tests.h \
Andrii Nakryiko2031af22020-01-09 21:17:14 -0800491 feature \
Andrii Nakryiko9f7fa222020-12-03 12:46:26 -0800492 $(addprefix $(OUTPUT)/,*.o *.skel.h no_alu32 bpf_gcc bpf_testmod.ko)
Joe Stringera01d9352021-03-02 09:19:43 -0800493
494.PHONY: docs docs-clean