Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Masahiro Yamada | b61442d | 2021-04-16 22:00:51 +0900 | [diff] [blame] | 2 | include ../../../build/Build.include |
Ilya Leoshkevich | 748e50c | 2019-07-11 16:29:27 +0200 | [diff] [blame] | 3 | include ../../../scripts/Makefile.arch |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 4 | include ../../../scripts/Makefile.include |
Hendrik Brueckner | 618e165 | 2017-12-04 10:56:48 +0100 | [diff] [blame] | 5 | |
Ilya Leoshkevich | e7ad28e | 2020-06-02 19:56:49 +0200 | [diff] [blame] | 6 | CXX ?= $(CROSS_COMPILE)g++ |
| 7 | |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 8 | CURDIR := $(abspath .) |
Andrii Nakryiko | f3c926a | 2019-12-13 17:43:38 -0800 | [diff] [blame] | 9 | TOOLSDIR := $(abspath ../../..) |
| 10 | LIBDIR := $(TOOLSDIR)/lib |
Zi Shen Lim | e8f1f34 | 2017-03-19 23:03:14 -0700 | [diff] [blame] | 11 | BPFDIR := $(LIBDIR)/bpf |
Andrii Nakryiko | f3c926a | 2019-12-13 17:43:38 -0800 | [diff] [blame] | 12 | TOOLSINCDIR := $(TOOLSDIR)/include |
| 13 | BPFTOOLDIR := $(TOOLSDIR)/bpf/bpftool |
| 14 | APIDIR := $(TOOLSINCDIR)/uapi |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 15 | GENDIR := $(abspath ../../../../include/generated) |
Daniel Borkmann | 02ea80b | 2017-03-31 02:24:04 +0200 | [diff] [blame] | 16 | GENHDR := $(GENDIR)/autoconf.h |
Mickaël Salaün | d498f87 | 2017-02-11 23:20:23 +0100 | [diff] [blame] | 17 | |
Daniel Borkmann | 02ea80b | 2017-03-31 02:24:04 +0200 | [diff] [blame] | 18 | ifneq ($(wildcard $(GENHDR)),) |
| 19 | GENFLAGS := -DHAVE_GENHDR |
| 20 | endif |
| 21 | |
Ilya Leoshkevich | 4ce150b | 2019-09-12 18:05:43 +0200 | [diff] [blame] | 22 | BPF_GCC ?= $(shell command -v bpf-gcc;) |
Andrii Nakryiko | 02995dd | 2020-04-28 18:21:02 -0700 | [diff] [blame] | 23 | SAN_CFLAGS ?= |
Andrii Nakryiko | 41c472e | 2021-04-23 11:13:43 -0700 | [diff] [blame] | 24 | CFLAGS += -g -O0 -rdynamic -Wall $(GENFLAGS) $(SAN_CFLAGS) \ |
Andrii Nakryiko | 02995dd | 2020-04-28 18:21:02 -0700 | [diff] [blame] | 25 | -I$(CURDIR) -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR) \ |
Andrii Nakryiko | f19ddfe | 2021-11-03 15:08:45 -0700 | [diff] [blame] | 26 | -I$(TOOLSINCDIR) -I$(APIDIR) -I$(OUTPUT) |
Andrii Nakryiko | 2a2cb45 | 2021-11-07 08:55:13 -0800 | [diff] [blame] | 27 | LDFLAGS += $(SAN_CFLAGS) |
Andrii Nakryiko | 166750b | 2019-12-13 17:47:08 -0800 | [diff] [blame] | 28 | LDLIBS += -lcap -lelf -lz -lrt -lpthread |
Daniel Borkmann | 5aa5bd1 | 2016-10-17 14:28:36 +0200 | [diff] [blame] | 29 | |
Yonghong Song | ef99858 | 2021-04-13 08:34:29 -0700 | [diff] [blame] | 30 | # Silence some warnings when compiled with clang |
| 31 | ifneq ($(LLVM),) |
| 32 | CFLAGS += -Wno-unused-command-line-argument |
| 33 | endif |
| 34 | |
Jesper Dangaard Brouer | f09b2e3 | 2018-02-08 12:48:27 +0100 | [diff] [blame] | 35 | # Order correspond to 'make run_tests' order |
David S. Miller | 18b3ad9 | 2017-05-10 11:43:51 -0700 | [diff] [blame] | 36 | TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \ |
Alexander Duyck | aaf376b | 2020-11-03 13:34:48 -0800 | [diff] [blame] | 37 | test_verifier_log test_dev_cgroup \ |
Florent Revest | 61f8c9c | 2021-02-10 12:14:04 +0100 | [diff] [blame] | 38 | test_sock test_sockmap get_cgroup_id_user \ |
Jakub Sitnicki | 415bb4e | 2019-12-12 11:22:58 +0100 | [diff] [blame] | 39 | test_cgroup_storage \ |
Stanislav Fomichev | 372642e | 2021-08-04 13:55:24 -0700 | [diff] [blame] | 40 | test_tcpnotify_user test_sysctl \ |
Carlos Neira | 09c02d5 | 2021-01-14 11:10:36 -0300 | [diff] [blame] | 41 | test_progs-no_alu32 |
Jiong Wang | 3ef8434 | 2019-01-26 12:26:14 -0500 | [diff] [blame] | 42 | |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 43 | # Also test bpf-gcc, if present |
Ilya Leoshkevich | 4ce150b | 2019-09-12 18:05:43 +0200 | [diff] [blame] | 44 | ifneq ($(BPF_GCC),) |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 45 | TEST_GEN_PROGS += test_progs-bpf_gcc |
Ilya Leoshkevich | 4ce150b | 2019-09-12 18:05:43 +0200 | [diff] [blame] | 46 | endif |
| 47 | |
Andrii Nakryiko | de29e6b | 2021-11-10 21:36:17 -0800 | [diff] [blame] | 48 | TEST_GEN_FILES = test_lwt_ip_encap.o test_tc_edt.o |
| 49 | TEST_FILES = xsk_prereqs.sh $(wildcard progs/btf_dump_test_case_*.c) |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 50 | |
Jesper Dangaard Brouer | f09b2e3 | 2018-02-08 12:48:27 +0100 | [diff] [blame] | 51 | # Order correspond to 'make run_tests' order |
| 52 | TEST_PROGS := test_kmod.sh \ |
Jesper Dangaard Brouer | f09b2e3 | 2018-02-08 12:48:27 +0100 | [diff] [blame] | 53 | test_xdp_redirect.sh \ |
Hangbin Liu | d232924 | 2021-05-19 17:07:47 +0800 | [diff] [blame] | 54 | test_xdp_redirect_multi.sh \ |
Jesper Dangaard Brouer | f09b2e3 | 2018-02-08 12:48:27 +0100 | [diff] [blame] | 55 | test_xdp_meta.sh \ |
Toshiaki Makita | 88091ff | 2019-06-20 11:23:23 +0900 | [diff] [blame] | 56 | test_xdp_veth.sh \ |
Andrey Ignatov | 622adaf | 2018-03-30 15:08:06 -0700 | [diff] [blame] | 57 | test_offload.py \ |
William Tu | 933a741 | 2018-04-26 14:01:39 -0700 | [diff] [blame] | 58 | test_sock_addr.sh \ |
Mathieu Xhonneux | c99a84e | 2018-05-20 14:58:17 +0100 | [diff] [blame] | 59 | test_tunnel.sh \ |
Sean Young | 6bdd533 | 2018-05-27 12:24:10 +0100 | [diff] [blame] | 60 | test_lwt_seg6local.sh \ |
Andrey Ignatov | 5ecd8c2 | 2018-08-12 10:49:30 -0700 | [diff] [blame] | 61 | test_lirc_mode2.sh \ |
Petar Penkov | 50b3ed5 | 2018-09-14 07:46:22 -0700 | [diff] [blame] | 62 | test_skb_cgroup_id.sh \ |
Jesper Dangaard Brouer | 97396ff | 2018-10-09 12:04:53 +0200 | [diff] [blame] | 63 | test_flow_dissector.sh \ |
Jesper Dangaard Brouer | d35661f | 2019-08-01 20:00:21 +0200 | [diff] [blame] | 64 | test_xdp_vlan_mode_generic.sh \ |
| 65 | test_xdp_vlan_mode_native.sh \ |
Lorenz Bauer | bafc0ba | 2019-03-22 09:54:06 +0800 | [diff] [blame] | 66 | test_lwt_ip_encap.sh \ |
Willem de Bruijn | 98cdabc | 2019-03-22 14:32:49 -0400 | [diff] [blame] | 67 | test_tcp_check_syncookie.sh \ |
Peter Oskolkov | 7df5e3d | 2019-03-22 16:40:19 -0700 | [diff] [blame] | 68 | test_tc_tunnel.sh \ |
Alan Maguire | cd53850 | 2019-05-31 18:47:14 +0100 | [diff] [blame] | 69 | test_tc_edt.sh \ |
Quentin Monnet | 45c5589d | 2019-08-30 12:00:38 +0100 | [diff] [blame] | 70 | test_xdping.sh \ |
Michal Rostecki | 73633274 | 2020-02-26 17:59:39 +0100 | [diff] [blame] | 71 | test_bpftool_build.sh \ |
YiFei Zhu | d42d1cc | 2020-09-15 16:45:43 -0700 | [diff] [blame] | 72 | test_bpftool.sh \ |
| 73 | test_bpftool_metadata.sh \ |
Jean-Philippe Brucker | a0d73ac | 2021-03-08 19:28:31 +0100 | [diff] [blame] | 74 | test_doc_build.sh \ |
Weqaar Janjua | a890525 | 2020-12-07 21:53:29 +0000 | [diff] [blame] | 75 | test_xsk.sh |
Daniel Borkmann | 5aa5bd1 | 2016-10-17 14:28:36 +0200 | [diff] [blame] | 76 | |
Anders Roxell | f98937c | 2019-01-08 10:23:03 +0100 | [diff] [blame] | 77 | TEST_PROGS_EXTENDED := with_addr.sh \ |
Stanislav Fomichev | 1be72f2 | 2019-01-14 09:41:41 -0800 | [diff] [blame] | 78 | with_tunnels.sh \ |
Li Zhijian | 404bd9f | 2021-08-20 09:55:56 +0800 | [diff] [blame] | 79 | test_xdp_vlan.sh test_bpftool.py |
Anders Roxell | ef4ab84 | 2018-10-10 16:27:04 +0200 | [diff] [blame] | 80 | |
Jesper Dangaard Brouer | f09b2e3 | 2018-02-08 12:48:27 +0100 | [diff] [blame] | 81 | # Compile but not part of 'make run_tests' |
Andrii Nakryiko | cb79a4e | 2019-10-15 23:00:51 -0700 | [diff] [blame] | 82 | TEST_GEN_PROGS_EXTENDED = test_sock_addr test_skb_cgroup_id_user \ |
Hangbin Liu | 25a7991 | 2019-06-04 10:35:05 +0800 | [diff] [blame] | 83 | flow_dissector_load test_flow_dissector test_tcp_check_syncookie_user \ |
Weqaar Janjua | facb7cb | 2020-12-07 21:53:30 +0000 | [diff] [blame] | 84 | test_lirc_mode2_user xdping test_cpp runqslower bench bpf_testmod.ko \ |
Hangbin Liu | d232924 | 2021-05-19 17:07:47 +0800 | [diff] [blame] | 85 | xdpxceiver xdp_redirect_multi |
Jesper Dangaard Brouer | f09b2e3 | 2018-02-08 12:48:27 +0100 | [diff] [blame] | 86 | |
Jean-Philippe Brucker | ca1e846 | 2021-01-13 17:33:19 +0100 | [diff] [blame] | 87 | TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 88 | |
Andrii Nakryiko | 92f7440 | 2019-12-16 22:14:25 -0800 | [diff] [blame] | 89 | # Emit succinct information message describing current building step |
| 90 | # $1 - generic step name (e.g., CC, LINK, etc); |
| 91 | # $2 - optional "flavor" specifier; if provided, will be emitted as [flavor]; |
| 92 | # $3 - target (assumed to be file); only file name will be emitted; |
| 93 | # $4 - optional extra arg, emitted as-is, if provided. |
| 94 | ifeq ($(V),1) |
Andrii Nakryiko | 965b9fe | 2020-01-09 21:17:16 -0800 | [diff] [blame] | 95 | Q = |
Andrii Nakryiko | 92f7440 | 2019-12-16 22:14:25 -0800 | [diff] [blame] | 96 | msg = |
| 97 | else |
Andrii Nakryiko | 965b9fe | 2020-01-09 21:17:16 -0800 | [diff] [blame] | 98 | Q = @ |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 99 | msg = @printf ' %-8s%s %s%s\n' "$(1)" "$(if $(2), [$(2)])" "$(notdir $(3))" "$(if $(4), $(4))"; |
Andrii Nakryiko | 965b9fe | 2020-01-09 21:17:16 -0800 | [diff] [blame] | 100 | MAKEFLAGS += --no-print-directory |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 101 | submake_extras := feature_display=0 |
Andrii Nakryiko | 92f7440 | 2019-12-16 22:14:25 -0800 | [diff] [blame] | 102 | endif |
| 103 | |
| 104 | # override lib.mk's default rules |
| 105 | OVERRIDE_TARGETS := 1 |
| 106 | override define CLEAN |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 107 | $(call msg,CLEAN) |
Andrii Nakryiko | de29e6b | 2021-11-10 21:36:17 -0800 | [diff] [blame] | 108 | $(Q)$(RM) -r $(TEST_GEN_PROGS) |
| 109 | $(Q)$(RM) -r $(TEST_GEN_PROGS_EXTENDED) |
| 110 | $(Q)$(RM) -r $(TEST_GEN_FILES) |
| 111 | $(Q)$(RM) -r $(EXTRA_CLEAN) |
Andrii Nakryiko | 9f7fa22 | 2020-12-03 12:46:26 -0800 | [diff] [blame] | 112 | $(Q)$(MAKE) -C bpf_testmod clean |
Joe Stringer | a01d935 | 2021-03-02 09:19:43 -0800 | [diff] [blame] | 113 | $(Q)$(MAKE) docs-clean |
Andrii Nakryiko | 92f7440 | 2019-12-16 22:14:25 -0800 | [diff] [blame] | 114 | endef |
| 115 | |
Zi Shen Lim | e8f1f34 | 2017-03-19 23:03:14 -0700 | [diff] [blame] | 116 | include ../lib.mk |
Alexei Starovoitov | 1da8ac7 | 2017-03-10 22:05:55 -0800 | [diff] [blame] | 117 | |
Toke Høiland-Jørgensen | a2c9652 | 2020-01-20 14:06:52 +0100 | [diff] [blame] | 118 | SCRATCH_DIR := $(OUTPUT)/tools |
| 119 | BUILD_DIR := $(SCRATCH_DIR)/build |
| 120 | INCLUDE_DIR := $(SCRATCH_DIR)/include |
| 121 | BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 122 | ifneq ($(CROSS_COMPILE),) |
| 123 | HOST_BUILD_DIR := $(BUILD_DIR)/host |
| 124 | HOST_SCRATCH_DIR := $(OUTPUT)/host-tools |
Quentin Monnet | 1478994 | 2021-10-07 20:44:30 +0100 | [diff] [blame] | 125 | HOST_INCLUDE_DIR := $(HOST_SCRATCH_DIR)/include |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 126 | else |
| 127 | HOST_BUILD_DIR := $(BUILD_DIR) |
| 128 | HOST_SCRATCH_DIR := $(SCRATCH_DIR) |
Quentin Monnet | 1478994 | 2021-10-07 20:44:30 +0100 | [diff] [blame] | 129 | HOST_INCLUDE_DIR := $(INCLUDE_DIR) |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 130 | endif |
| 131 | HOST_BPFOBJ := $(HOST_BUILD_DIR)/libbpf/libbpf.a |
| 132 | RESOLVE_BTFIDS := $(HOST_BUILD_DIR)/resolve_btfids/resolve_btfids |
Quentin Monnet | be79505 | 2021-10-07 20:44:31 +0100 | [diff] [blame] | 133 | RUNQSLOWER_OUTPUT := $(BUILD_DIR)/runqslower/ |
Toke Høiland-Jørgensen | a2c9652 | 2020-01-20 14:06:52 +0100 | [diff] [blame] | 134 | |
Andrii Nakryiko | a67079b | 2020-12-10 17:59:46 -0800 | [diff] [blame] | 135 | VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \ |
| 136 | $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ |
| 137 | ../../../../vmlinux \ |
| 138 | /sys/kernel/btf/vmlinux \ |
| 139 | /boot/vmlinux-$(shell uname -r) |
| 140 | VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS)))) |
Kamal Mostafa | 1a3449c | 2020-12-15 10:20:10 -0800 | [diff] [blame] | 141 | ifeq ($(VMLINUX_BTF),) |
| 142 | $(error Cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)") |
| 143 | endif |
Andrii Nakryiko | a67079b | 2020-12-10 17:59:46 -0800 | [diff] [blame] | 144 | |
Andrii Nakryiko | 03dcb78 | 2019-10-15 23:00:48 -0700 | [diff] [blame] | 145 | # Define simple and short `make test_progs`, `make test_sysctl`, etc targets |
| 146 | # to build individual tests. |
| 147 | # NOTE: Semicolon at the end is critical to override lib.mk's default static |
| 148 | # rule for binaries. |
| 149 | $(notdir $(TEST_GEN_PROGS) \ |
| 150 | $(TEST_PROGS) \ |
| 151 | $(TEST_PROGS_EXTENDED) \ |
| 152 | $(TEST_GEN_PROGS_EXTENDED) \ |
| 153 | $(TEST_CUSTOM_PROGS)): %: $(OUTPUT)/% ; |
| 154 | |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 155 | # sort removes libbpf duplicates when not cross-building |
| 156 | MAKE_DIRS := $(sort $(BUILD_DIR)/libbpf $(HOST_BUILD_DIR)/libbpf \ |
| 157 | $(HOST_BUILD_DIR)/bpftool $(HOST_BUILD_DIR)/resolve_btfids \ |
Quentin Monnet | be79505 | 2021-10-07 20:44:31 +0100 | [diff] [blame] | 158 | $(RUNQSLOWER_OUTPUT) $(INCLUDE_DIR)) |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 159 | $(MAKE_DIRS): |
| 160 | $(call msg,MKDIR,,$@) |
| 161 | $(Q)mkdir -p $@ |
| 162 | |
Andrii Nakryiko | d5ca590 | 2020-08-06 20:30:57 -0700 | [diff] [blame] | 163 | $(OUTPUT)/%.o: %.c |
| 164 | $(call msg,CC,,$@) |
| 165 | $(Q)$(CC) $(CFLAGS) -c $(filter %.c,$^) $(LDLIBS) -o $@ |
| 166 | |
Andrii Nakryiko | 92f7440 | 2019-12-16 22:14:25 -0800 | [diff] [blame] | 167 | $(OUTPUT)/%:%.c |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 168 | $(call msg,BINARY,,$@) |
Andrii Nakryiko | d5ca590 | 2020-08-06 20:30:57 -0700 | [diff] [blame] | 169 | $(Q)$(LINK.c) $^ $(LDLIBS) -o $@ |
Andrii Nakryiko | 92f7440 | 2019-12-16 22:14:25 -0800 | [diff] [blame] | 170 | |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 171 | $(OUTPUT)/urandom_read: urandom_read.c |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 172 | $(call msg,BINARY,,$@) |
Jean-Philippe Brucker | ea79020 | 2021-12-16 16:38:43 +0000 | [diff] [blame] | 173 | $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $< $(LDLIBS) -Wl,--build-id=sha1 -o $@ |
Jiong Wang | 3ef8434 | 2019-01-26 12:26:14 -0500 | [diff] [blame] | 174 | |
Andrii Nakryiko | 9f7fa22 | 2020-12-03 12:46:26 -0800 | [diff] [blame] | 175 | $(OUTPUT)/bpf_testmod.ko: $(VMLINUX_BTF) $(wildcard bpf_testmod/Makefile bpf_testmod/*.[ch]) |
| 176 | $(call msg,MOD,,$@) |
Andrii Nakryiko | a67079b | 2020-12-10 17:59:46 -0800 | [diff] [blame] | 177 | $(Q)$(RM) bpf_testmod/bpf_testmod.ko # force re-compilation |
Andrii Nakryiko | 9f7fa22 | 2020-12-03 12:46:26 -0800 | [diff] [blame] | 178 | $(Q)$(MAKE) $(submake_extras) -C bpf_testmod |
| 179 | $(Q)cp bpf_testmod/bpf_testmod.ko $@ |
| 180 | |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 181 | DEFAULT_BPFTOOL := $(HOST_SCRATCH_DIR)/sbin/bpftool |
Andrii Nakryiko | 6bcaf41 | 2020-08-04 17:47:57 -0700 | [diff] [blame] | 182 | |
Quentin Monnet | be79505 | 2021-10-07 20:44:31 +0100 | [diff] [blame] | 183 | $(OUTPUT)/runqslower: $(BPFOBJ) | $(DEFAULT_BPFTOOL) $(RUNQSLOWER_OUTPUT) |
| 184 | $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower \ |
| 185 | OUTPUT=$(RUNQSLOWER_OUTPUT) VMLINUX_BTF=$(VMLINUX_BTF) \ |
Jean-Philippe Brucker | e4ac80e | 2021-11-12 15:51:30 +0000 | [diff] [blame] | 186 | BPFTOOL_OUTPUT=$(HOST_BUILD_DIR)/bpftool/ \ |
Quentin Monnet | be79505 | 2021-10-07 20:44:31 +0100 | [diff] [blame] | 187 | BPFOBJ_OUTPUT=$(BUILD_DIR)/libbpf \ |
| 188 | BPFOBJ=$(BPFOBJ) BPF_INCLUDE=$(INCLUDE_DIR) && \ |
| 189 | cp $(RUNQSLOWER_OUTPUT)runqslower $@ |
Zi Shen Lim | e8f1f34 | 2017-03-19 23:03:14 -0700 | [diff] [blame] | 190 | |
Li Zhijian | 404bd9f | 2021-08-20 09:55:56 +0800 | [diff] [blame] | 191 | TEST_GEN_PROGS_EXTENDED += $(DEFAULT_BPFTOOL) |
| 192 | |
Andrii Nakryiko | f87c193 | 2021-11-03 15:08:43 -0700 | [diff] [blame] | 193 | $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(BPFOBJ) |
Jesper Dangaard Brouer | f09b2e3 | 2018-02-08 12:48:27 +0100 | [diff] [blame] | 194 | |
Jean-Philippe Brucker | eee9a6d | 2021-12-01 14:51:02 +0000 | [diff] [blame] | 195 | CGROUP_HELPERS := $(OUTPUT)/cgroup_helpers.o |
| 196 | TESTING_HELPERS := $(OUTPUT)/testing_helpers.o |
| 197 | TRACE_HELPERS := $(OUTPUT)/trace_helpers.o |
| 198 | |
| 199 | $(OUTPUT)/test_dev_cgroup: $(CGROUP_HELPERS) $(TESTING_HELPERS) |
| 200 | $(OUTPUT)/test_skb_cgroup_id_user: $(CGROUP_HELPERS) $(TESTING_HELPERS) |
| 201 | $(OUTPUT)/test_sock: $(CGROUP_HELPERS) $(TESTING_HELPERS) |
| 202 | $(OUTPUT)/test_sock_addr: $(CGROUP_HELPERS) $(TESTING_HELPERS) |
| 203 | $(OUTPUT)/test_sockmap: $(CGROUP_HELPERS) $(TESTING_HELPERS) |
| 204 | $(OUTPUT)/test_tcpnotify_user: $(CGROUP_HELPERS) $(TESTING_HELPERS) $(TRACE_HELPERS) |
| 205 | $(OUTPUT)/get_cgroup_id_user: $(CGROUP_HELPERS) $(TESTING_HELPERS) |
| 206 | $(OUTPUT)/test_cgroup_storage: $(CGROUP_HELPERS) $(TESTING_HELPERS) |
| 207 | $(OUTPUT)/test_sock_fields: $(CGROUP_HELPERS) $(TESTING_HELPERS) |
| 208 | $(OUTPUT)/test_sysctl: $(CGROUP_HELPERS) $(TESTING_HELPERS) |
| 209 | $(OUTPUT)/test_tag: $(TESTING_HELPERS) |
| 210 | $(OUTPUT)/test_lirc_mode2_user: $(TESTING_HELPERS) |
| 211 | $(OUTPUT)/xdping: $(TESTING_HELPERS) |
| 212 | $(OUTPUT)/flow_dissector_load: $(TESTING_HELPERS) |
| 213 | $(OUTPUT)/test_maps: $(TESTING_HELPERS) |
| 214 | $(OUTPUT)/test_verifier: $(TESTING_HELPERS) |
Jesper Dangaard Brouer | 41757dc | 2018-02-13 14:19:15 +0100 | [diff] [blame] | 215 | |
Andrii Nakryiko | f3c926a | 2019-12-13 17:43:38 -0800 | [diff] [blame] | 216 | BPFTOOL ?= $(DEFAULT_BPFTOOL) |
Andrii Nakryiko | 0350629 | 2020-01-23 21:41:48 -0800 | [diff] [blame] | 217 | $(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \ |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 218 | $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/bpftool |
Andrii Nakryiko | 0350629 | 2020-01-23 21:41:48 -0800 | [diff] [blame] | 219 | $(Q)$(MAKE) $(submake_extras) -C $(BPFTOOLDIR) \ |
Jean-Philippe Brucker | ea79020 | 2021-12-16 16:38:43 +0000 | [diff] [blame] | 220 | ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) \ |
Andrii Nakryiko | 41c472e | 2021-04-23 11:13:43 -0700 | [diff] [blame] | 221 | EXTRA_CFLAGS='-g -O0' \ |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 222 | OUTPUT=$(HOST_BUILD_DIR)/bpftool/ \ |
Quentin Monnet | f012ade1 | 2021-10-07 20:44:29 +0100 | [diff] [blame] | 223 | LIBBPF_OUTPUT=$(HOST_BUILD_DIR)/libbpf/ \ |
| 224 | LIBBPF_DESTDIR=$(HOST_SCRATCH_DIR)/ \ |
Quentin Monnet | d7db0a4 | 2021-10-07 20:44:38 +0100 | [diff] [blame] | 225 | prefix= DESTDIR=$(HOST_SCRATCH_DIR)/ install-bin |
Joe Stringer | a01d935 | 2021-03-02 09:19:43 -0800 | [diff] [blame] | 226 | |
Jiri Olsa | d044d9f | 2021-04-20 15:24:28 +0200 | [diff] [blame] | 227 | all: docs |
| 228 | |
Joe Stringer | a01d935 | 2021-03-02 09:19:43 -0800 | [diff] [blame] | 229 | docs: |
| 230 | $(Q)RST2MAN_OPTS="--exit-status=1" $(MAKE) $(submake_extras) \ |
| 231 | -f Makefile.docs \ |
| 232 | prefix= OUTPUT=$(OUTPUT)/ DESTDIR=$(OUTPUT)/ $@ |
| 233 | |
| 234 | docs-clean: |
| 235 | $(Q)$(MAKE) $(submake_extras) \ |
| 236 | -f Makefile.docs \ |
| 237 | prefix= OUTPUT=$(OUTPUT)/ DESTDIR=$(OUTPUT)/ $@ |
Andrii Nakryiko | f3c926a | 2019-12-13 17:43:38 -0800 | [diff] [blame] | 238 | |
Andrii Nakryiko | 0350629 | 2020-01-23 21:41:48 -0800 | [diff] [blame] | 239 | $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ |
Andrii Nakryiko | de29e6b | 2021-11-10 21:36:17 -0800 | [diff] [blame] | 240 | $(APIDIR)/linux/bpf.h \ |
Quentin Monnet | 1478994 | 2021-10-07 20:44:30 +0100 | [diff] [blame] | 241 | | $(BUILD_DIR)/libbpf |
Toke Høiland-Jørgensen | a2c9652 | 2020-01-20 14:06:52 +0100 | [diff] [blame] | 242 | $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/ \ |
Andrii Nakryiko | 41c472e | 2021-04-23 11:13:43 -0700 | [diff] [blame] | 243 | EXTRA_CFLAGS='-g -O0' \ |
Andrii Nakryiko | 0350629 | 2020-01-23 21:41:48 -0800 | [diff] [blame] | 244 | DESTDIR=$(SCRATCH_DIR) prefix= all install_headers |
Andrii Nakryiko | f3c926a | 2019-12-13 17:43:38 -0800 | [diff] [blame] | 245 | |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 246 | ifneq ($(BPFOBJ),$(HOST_BPFOBJ)) |
Andrii Nakryiko | de29e6b | 2021-11-10 21:36:17 -0800 | [diff] [blame] | 247 | $(HOST_BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ |
| 248 | $(APIDIR)/linux/bpf.h \ |
| 249 | | $(HOST_BUILD_DIR)/libbpf |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 250 | $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) \ |
Jean-Philippe Brucker | ea79020 | 2021-12-16 16:38:43 +0000 | [diff] [blame] | 251 | EXTRA_CFLAGS='-g -O0' ARCH= CROSS_COMPILE= \ |
Andrii Nakryiko | 252e3cb | 2021-03-13 13:09:20 -0800 | [diff] [blame] | 252 | OUTPUT=$(HOST_BUILD_DIR)/libbpf/ CC=$(HOSTCC) LD=$(HOSTLD) \ |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 253 | DESTDIR=$(HOST_SCRATCH_DIR)/ prefix= all install_headers |
| 254 | endif |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 255 | |
Andrii Nakryiko | cab62c3 | 2021-03-18 12:40:34 -0700 | [diff] [blame] | 256 | $(INCLUDE_DIR)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) | $(INCLUDE_DIR) |
Andrii Nakryiko | ca4db63 | 2020-06-29 17:47:59 -0700 | [diff] [blame] | 257 | ifeq ($(VMLINUX_H),) |
Andrii Nakryiko | acbd062 | 2020-03-13 10:23:36 -0700 | [diff] [blame] | 258 | $(call msg,GEN,,$@) |
Andrii Nakryiko | d5ca590 | 2020-08-06 20:30:57 -0700 | [diff] [blame] | 259 | $(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@ |
Andrii Nakryiko | ca4db63 | 2020-06-29 17:47:59 -0700 | [diff] [blame] | 260 | else |
| 261 | $(call msg,CP,,$@) |
Andrii Nakryiko | d5ca590 | 2020-08-06 20:30:57 -0700 | [diff] [blame] | 262 | $(Q)cp "$(VMLINUX_H)" $@ |
Andrii Nakryiko | ca4db63 | 2020-06-29 17:47:59 -0700 | [diff] [blame] | 263 | endif |
Andrii Nakryiko | acbd062 | 2020-03-13 10:23:36 -0700 | [diff] [blame] | 264 | |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 265 | $(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids \ |
Jiri Olsa | cc15a20 | 2020-07-11 23:53:29 +0200 | [diff] [blame] | 266 | $(TOOLSDIR)/bpf/resolve_btfids/main.c \ |
| 267 | $(TOOLSDIR)/lib/rbtree.c \ |
| 268 | $(TOOLSDIR)/lib/zalloc.c \ |
| 269 | $(TOOLSDIR)/lib/string.c \ |
| 270 | $(TOOLSDIR)/lib/ctype.c \ |
| 271 | $(TOOLSDIR)/lib/str_error_r.c |
| 272 | $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/resolve_btfids \ |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 273 | CC=$(HOSTCC) LD=$(HOSTLD) AR=$(HOSTAR) \ |
Quentin Monnet | 1478994 | 2021-10-07 20:44:30 +0100 | [diff] [blame] | 274 | LIBBPF_INCLUDE=$(HOST_INCLUDE_DIR) \ |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 275 | OUTPUT=$(HOST_BUILD_DIR)/resolve_btfids/ BPFOBJ=$(HOST_BPFOBJ) |
Jiri Olsa | cc15a20 | 2020-07-11 23:53:29 +0200 | [diff] [blame] | 276 | |
Sirio Balmelli | 167381f | 2018-05-21 09:00:03 +0200 | [diff] [blame] | 277 | # Get Clang's default includes on this system, as opposed to those seen by |
| 278 | # '-target bpf'. This fixes "missing" files on some architectures/distros, |
| 279 | # such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc. |
| 280 | # |
| 281 | # Use '-idirafter': Don't interfere with include mechanics except where the |
| 282 | # build would have failed anyways. |
Ilya Leoshkevich | 4ce150b | 2019-09-12 18:05:43 +0200 | [diff] [blame] | 283 | define get_sys_includes |
| 284 | $(shell $(1) -v -E - </dev/null 2>&1 \ |
Björn Töpel | 6016df8 | 2020-11-18 08:16:38 +0100 | [diff] [blame] | 285 | | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ |
Björn Töpel | 36e70b9 | 2021-10-28 18:10:57 +0200 | [diff] [blame] | 286 | $(shell $(1) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') |
Ilya Leoshkevich | 4ce150b | 2019-09-12 18:05:43 +0200 | [diff] [blame] | 287 | endef |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 288 | |
Ilya Leoshkevich | 313e7f6 | 2019-10-28 11:20:49 +0100 | [diff] [blame] | 289 | # Determine target endianness. |
| 290 | IS_LITTLE_ENDIAN = $(shell $(CC) -dM -E - </dev/null | \ |
| 291 | grep 'define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__') |
| 292 | MENDIAN=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian) |
| 293 | |
Ilya Leoshkevich | 4ce150b | 2019-09-12 18:05:43 +0200 | [diff] [blame] | 294 | CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG)) |
Ilya Leoshkevich | 313e7f6 | 2019-10-28 11:20:49 +0100 | [diff] [blame] | 295 | BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) \ |
Tobias Klauser | bcd66b1 | 2020-03-13 12:31:05 +0100 | [diff] [blame] | 296 | -I$(INCLUDE_DIR) -I$(CURDIR) -I$(APIDIR) \ |
| 297 | -I$(abspath $(OUTPUT)/../usr/include) |
Sirio Balmelli | 167381f | 2018-05-21 09:00:03 +0200 | [diff] [blame] | 298 | |
Ilya Leoshkevich | 4ce150b | 2019-09-12 18:05:43 +0200 | [diff] [blame] | 299 | CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \ |
| 300 | -Wno-compare-distinct-pointer-types |
Alexei Starovoitov | 3bc35c6 | 2017-12-14 17:55:11 -0800 | [diff] [blame] | 301 | |
Ilya Leoshkevich | 4ce150b | 2019-09-12 18:05:43 +0200 | [diff] [blame] | 302 | $(OUTPUT)/test_l4lb_noinline.o: BPF_CFLAGS += -fno-inline |
| 303 | $(OUTPUT)/test_xdp_noinline.o: BPF_CFLAGS += -fno-inline |
Alexei Starovoitov | 3bc35c6 | 2017-12-14 17:55:11 -0800 | [diff] [blame] | 304 | |
Stanislav Fomichev | bf0f0fd | 2019-01-28 08:53:55 -0800 | [diff] [blame] | 305 | $(OUTPUT)/flow_dissector_load.o: flow_dissector_load.h |
Stanislav Fomichev | bf0f0fd | 2019-01-28 08:53:55 -0800 | [diff] [blame] | 306 | |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 307 | # Build BPF object using Clang |
| 308 | # $1 - input .c file |
| 309 | # $2 - output .o file |
| 310 | # $3 - CFLAGS |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 311 | define CLANG_BPF_BUILD_RULE |
Andrew Delgadillo | 89ad742 | 2020-12-11 00:43:44 +0000 | [diff] [blame] | 312 | $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2) |
Andrii Nakryiko | de29e6b | 2021-11-10 21:36:17 -0800 | [diff] [blame] | 313 | $(Q)$(CLANG) $3 -O2 -target bpf -c $1 -mcpu=v3 -o $2 |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 314 | endef |
Andrii Nakryiko | 24f6505 | 2019-11-19 16:25:10 -0800 | [diff] [blame] | 315 | # Similar to CLANG_BPF_BUILD_RULE, but with disabled alu32 |
| 316 | define CLANG_NOALU32_BPF_BUILD_RULE |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 317 | $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2) |
Andrii Nakryiko | de29e6b | 2021-11-10 21:36:17 -0800 | [diff] [blame] | 318 | $(Q)$(CLANG) $3 -O2 -target bpf -c $1 -mcpu=v2 -o $2 |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 319 | endef |
| 320 | # Build BPF object using GCC |
| 321 | define GCC_BPF_BUILD_RULE |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 322 | $(call msg,GCC-BPF,$(TRUNNER_BINARY),$2) |
Andrew Delgadillo | 89ad742 | 2020-12-11 00:43:44 +0000 | [diff] [blame] | 323 | $(Q)$(BPF_GCC) $3 -O2 -c $1 -o $2 |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 324 | endef |
Stanislav Fomichev | e78e00b | 2019-03-06 11:59:26 -0800 | [diff] [blame] | 325 | |
Jakub Sitnicki | 0b9ad56 | 2020-04-29 20:11:54 +0200 | [diff] [blame] | 326 | SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c |
Andrii Nakryiko | f3c926a | 2019-12-13 17:43:38 -0800 | [diff] [blame] | 327 | |
Andrii Nakryiko | 3b2ad50 | 2021-04-23 11:13:47 -0700 | [diff] [blame] | 328 | LINKED_SKELS := test_static_linked.skel.h linked_funcs.skel.h \ |
| 329 | linked_vars.skel.h linked_maps.skel.h |
Andrii Nakryiko | a0964f5 | 2021-03-18 12:40:36 -0700 | [diff] [blame] | 330 | |
Alexei Starovoitov | 4d1b629 | 2021-05-13 17:36:20 -0700 | [diff] [blame] | 331 | LSKELS := kfunc_call_test.c fentry_test.c fexit_test.c fexit_sleep.c \ |
Alexei Starovoitov | 650c9db | 2021-12-01 10:10:37 -0800 | [diff] [blame] | 332 | test_ringbuf.c atomics.c trace_printk.c trace_vprintk.c \ |
Alexei Starovoitov | 26b367e | 2021-12-01 10:10:38 -0800 | [diff] [blame] | 333 | map_ptr_kern.c core_kern.c |
Kumar Kartikeya Dwivedi | c48e51c | 2021-10-02 06:47:57 +0530 | [diff] [blame] | 334 | # Generate both light skeleton and libbpf skeleton for these |
Alexei Starovoitov | bc5f75d | 2021-12-01 10:10:35 -0800 | [diff] [blame] | 335 | LSKELS_EXTRA := test_ksyms_module.c test_ksyms_weak.c kfunc_call_test_subprog.c |
Alexei Starovoitov | 4d1b629 | 2021-05-13 17:36:20 -0700 | [diff] [blame] | 336 | SKEL_BLACKLIST += $$(LSKELS) |
| 337 | |
Andrii Nakryiko | a0964f5 | 2021-03-18 12:40:36 -0700 | [diff] [blame] | 338 | test_static_linked.skel.h-deps := test_static_linked1.o test_static_linked2.o |
Andrii Nakryiko | f2644fb | 2021-04-23 11:13:45 -0700 | [diff] [blame] | 339 | linked_funcs.skel.h-deps := linked_funcs1.o linked_funcs2.o |
Andrii Nakryiko | 14f1aae | 2021-04-23 11:13:46 -0700 | [diff] [blame] | 340 | linked_vars.skel.h-deps := linked_vars1.o linked_vars2.o |
Andrii Nakryiko | 3b2ad50 | 2021-04-23 11:13:47 -0700 | [diff] [blame] | 341 | linked_maps.skel.h-deps := linked_maps1.o linked_maps2.o |
Andrii Nakryiko | a0964f5 | 2021-03-18 12:40:36 -0700 | [diff] [blame] | 342 | |
Andrii Nakryiko | b131aed | 2021-04-23 11:13:44 -0700 | [diff] [blame] | 343 | LINKED_BPF_SRCS := $(patsubst %.o,%.c,$(foreach skel,$(LINKED_SKELS),$($(skel)-deps))) |
| 344 | |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 345 | # Set up extra TRUNNER_XXX "temporary" variables in the environment (relies on |
| 346 | # $eval()) and pass control to DEFINE_TEST_RUNNER_RULES. |
| 347 | # Parameters: |
| 348 | # $1 - test runner base binary name (e.g., test_progs) |
Yonghong Song | e13a2fe | 2019-10-21 21:31:19 -0700 | [diff] [blame] | 349 | # $2 - test runner extra "flavor" (e.g., no_alu32, gcc-bpf, etc) |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 350 | define DEFINE_TEST_RUNNER |
Jiong Wang | 3ef8434 | 2019-01-26 12:26:14 -0500 | [diff] [blame] | 351 | |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 352 | TRUNNER_OUTPUT := $(OUTPUT)$(if $2,/)$2 |
| 353 | TRUNNER_BINARY := $1$(if $2,-)$2 |
| 354 | TRUNNER_TEST_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.test.o, \ |
| 355 | $$(notdir $$(wildcard $(TRUNNER_TESTS_DIR)/*.c))) |
| 356 | TRUNNER_EXTRA_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.o, \ |
| 357 | $$(filter %.c,$(TRUNNER_EXTRA_SOURCES))) |
| 358 | TRUNNER_EXTRA_HDRS := $$(filter %.h,$(TRUNNER_EXTRA_SOURCES)) |
| 359 | TRUNNER_TESTS_HDR := $(TRUNNER_TESTS_DIR)/tests.h |
Andrii Nakryiko | f3c926a | 2019-12-13 17:43:38 -0800 | [diff] [blame] | 360 | TRUNNER_BPF_SRCS := $$(notdir $$(wildcard $(TRUNNER_BPF_PROGS_DIR)/*.c)) |
| 361 | TRUNNER_BPF_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.o, $$(TRUNNER_BPF_SRCS)) |
| 362 | TRUNNER_BPF_SKELS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.skel.h, \ |
Andrii Nakryiko | b131aed | 2021-04-23 11:13:44 -0700 | [diff] [blame] | 363 | $$(filter-out $(SKEL_BLACKLIST) $(LINKED_BPF_SRCS),\ |
Andrii Nakryiko | f3c926a | 2019-12-13 17:43:38 -0800 | [diff] [blame] | 364 | $$(TRUNNER_BPF_SRCS))) |
Kumar Kartikeya Dwivedi | c48e51c | 2021-10-02 06:47:57 +0530 | [diff] [blame] | 365 | TRUNNER_BPF_LSKELS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.lskel.h, $$(LSKELS) $$(LSKELS_EXTRA)) |
Andrii Nakryiko | a0964f5 | 2021-03-18 12:40:36 -0700 | [diff] [blame] | 366 | TRUNNER_BPF_SKELS_LINKED := $$(addprefix $$(TRUNNER_OUTPUT)/,$(LINKED_SKELS)) |
Yauheni Kaliuta | 309b81f | 2020-05-13 05:17:22 +0300 | [diff] [blame] | 367 | TEST_GEN_FILES += $$(TRUNNER_BPF_OBJS) |
Jiong Wang | 3ef8434 | 2019-01-26 12:26:14 -0500 | [diff] [blame] | 368 | |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 369 | # Evaluate rules now with extra TRUNNER_XXX variables above already defined |
| 370 | $$(eval $$(call DEFINE_TEST_RUNNER_RULES,$1,$2)) |
Stanislav Fomichev | 3f30658 | 2019-03-01 19:42:13 -0800 | [diff] [blame] | 371 | |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 372 | endef |
Jiong Wang | 3ef8434 | 2019-01-26 12:26:14 -0500 | [diff] [blame] | 373 | |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 374 | # Using TRUNNER_XXX variables, provided by callers of DEFINE_TEST_RUNNER and |
| 375 | # set up by DEFINE_TEST_RUNNER itself, create test runner build rules with: |
| 376 | # $1 - test runner base binary name (e.g., test_progs) |
Yonghong Song | e13a2fe | 2019-10-21 21:31:19 -0700 | [diff] [blame] | 377 | # $2 - test runner extra "flavor" (e.g., no_alu32, gcc-bpf, etc) |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 378 | define DEFINE_TEST_RUNNER_RULES |
| 379 | |
| 380 | ifeq ($($(TRUNNER_OUTPUT)-dir),) |
| 381 | $(TRUNNER_OUTPUT)-dir := y |
| 382 | $(TRUNNER_OUTPUT): |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 383 | $$(call msg,MKDIR,,$$@) |
Andrii Nakryiko | d5ca590 | 2020-08-06 20:30:57 -0700 | [diff] [blame] | 384 | $(Q)mkdir -p $$@ |
Jiong Wang | 3ef8434 | 2019-01-26 12:26:14 -0500 | [diff] [blame] | 385 | endif |
| 386 | |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 387 | # ensure we set up BPF objects generation rule just once for a given |
| 388 | # input/output directory combination |
| 389 | ifeq ($($(TRUNNER_BPF_PROGS_DIR)$(if $2,-)$2-bpfobjs),) |
| 390 | $(TRUNNER_BPF_PROGS_DIR)$(if $2,-)$2-bpfobjs := y |
| 391 | $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.o: \ |
| 392 | $(TRUNNER_BPF_PROGS_DIR)/%.c \ |
| 393 | $(TRUNNER_BPF_PROGS_DIR)/*.h \ |
Andrii Nakryiko | acbd062 | 2020-03-13 10:23:36 -0700 | [diff] [blame] | 394 | $$(INCLUDE_DIR)/vmlinux.h \ |
Jiri Benc | d888eaa | 2021-09-27 18:01:36 +0200 | [diff] [blame] | 395 | $(wildcard $(BPFDIR)/bpf_*.h) \ |
| 396 | | $(TRUNNER_OUTPUT) $$(BPFOBJ) |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 397 | $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \ |
Andrew Delgadillo | 89ad742 | 2020-12-11 00:43:44 +0000 | [diff] [blame] | 398 | $(TRUNNER_BPF_CFLAGS)) |
Andrii Nakryiko | f3c926a | 2019-12-13 17:43:38 -0800 | [diff] [blame] | 399 | |
Andrii Nakryiko | 14137f3 | 2021-03-18 12:40:35 -0700 | [diff] [blame] | 400 | $(TRUNNER_BPF_SKELS): %.skel.h: %.o $(BPFTOOL) | $(TRUNNER_OUTPUT) |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 401 | $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@) |
Andrii Nakryiko | a0964f5 | 2021-03-18 12:40:36 -0700 | [diff] [blame] | 402 | $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked1.o) $$< |
| 403 | $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked2.o) $$(<:.o=.linked1.o) |
Andrii Nakryiko | 14137f3 | 2021-03-18 12:40:35 -0700 | [diff] [blame] | 404 | $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked3.o) $$(<:.o=.linked2.o) |
| 405 | $(Q)diff $$(<:.o=.linked2.o) $$(<:.o=.linked3.o) |
Andrii Nakryiko | a0964f5 | 2021-03-18 12:40:36 -0700 | [diff] [blame] | 406 | $(Q)$$(BPFTOOL) gen skeleton $$(<:.o=.linked3.o) name $$(notdir $$(<:.o=)) > $$@ |
| 407 | |
Alexei Starovoitov | 4d1b629 | 2021-05-13 17:36:20 -0700 | [diff] [blame] | 408 | $(TRUNNER_BPF_LSKELS): %.lskel.h: %.o $(BPFTOOL) | $(TRUNNER_OUTPUT) |
| 409 | $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@) |
| 410 | $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked1.o) $$< |
| 411 | $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked2.o) $$(<:.o=.linked1.o) |
| 412 | $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked3.o) $$(<:.o=.linked2.o) |
| 413 | $(Q)diff $$(<:.o=.linked2.o) $$(<:.o=.linked3.o) |
Kumar Kartikeya Dwivedi | 087cba7 | 2021-10-28 12:04:59 +0530 | [diff] [blame] | 414 | $(Q)$$(BPFTOOL) gen skeleton -L $$(<:.o=.linked3.o) name $$(notdir $$(<:.o=_lskel)) > $$@ |
Alexei Starovoitov | 4d1b629 | 2021-05-13 17:36:20 -0700 | [diff] [blame] | 415 | |
Andrii Nakryiko | a0964f5 | 2021-03-18 12:40:36 -0700 | [diff] [blame] | 416 | $(TRUNNER_BPF_SKELS_LINKED): $(TRUNNER_BPF_OBJS) $(BPFTOOL) | $(TRUNNER_OUTPUT) |
| 417 | $$(call msg,LINK-BPF,$(TRUNNER_BINARY),$$(@:.skel.h=.o)) |
| 418 | $(Q)$$(BPFTOOL) gen object $$(@:.skel.h=.linked1.o) $$(addprefix $(TRUNNER_OUTPUT)/,$$($$(@F)-deps)) |
| 419 | $(Q)$$(BPFTOOL) gen object $$(@:.skel.h=.linked2.o) $$(@:.skel.h=.linked1.o) |
| 420 | $(Q)$$(BPFTOOL) gen object $$(@:.skel.h=.linked3.o) $$(@:.skel.h=.linked2.o) |
| 421 | $(Q)diff $$(@:.skel.h=.linked2.o) $$(@:.skel.h=.linked3.o) |
| 422 | $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@) |
| 423 | $(Q)$$(BPFTOOL) gen skeleton $$(@:.skel.h=.linked3.o) name $$(notdir $$(@:.skel.h=)) > $$@ |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 424 | endif |
| 425 | |
| 426 | # ensure we set up tests.h header generation rule just once |
| 427 | ifeq ($($(TRUNNER_TESTS_DIR)-tests-hdr),) |
| 428 | $(TRUNNER_TESTS_DIR)-tests-hdr := y |
| 429 | $(TRUNNER_TESTS_HDR): $(TRUNNER_TESTS_DIR)/*.c |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 430 | $$(call msg,TEST-HDR,$(TRUNNER_BINARY),$$@) |
Andrii Nakryiko | 8ea688e | 2021-10-22 15:32:26 -0700 | [diff] [blame] | 431 | $$(shell (echo '/* Generated header, do not edit */'; \ |
| 432 | sed -n -E 's/^void (serial_)?test_([a-zA-Z0-9_]+)\((void)?\).*/DEFINE_TEST(\2)/p' \ |
| 433 | $(TRUNNER_TESTS_DIR)/*.c | sort ; \ |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 434 | ) > $$@) |
| 435 | endif |
| 436 | |
| 437 | # compile individual test files |
| 438 | # Note: we cd into output directory to ensure embedded BPF object is found |
| 439 | $(TRUNNER_TEST_OBJS): $(TRUNNER_OUTPUT)/%.test.o: \ |
| 440 | $(TRUNNER_TESTS_DIR)/%.c \ |
| 441 | $(TRUNNER_EXTRA_HDRS) \ |
| 442 | $(TRUNNER_BPF_OBJS) \ |
Andrii Nakryiko | f3c926a | 2019-12-13 17:43:38 -0800 | [diff] [blame] | 443 | $(TRUNNER_BPF_SKELS) \ |
Alexei Starovoitov | 4d1b629 | 2021-05-13 17:36:20 -0700 | [diff] [blame] | 444 | $(TRUNNER_BPF_LSKELS) \ |
Andrii Nakryiko | a0964f5 | 2021-03-18 12:40:36 -0700 | [diff] [blame] | 445 | $(TRUNNER_BPF_SKELS_LINKED) \ |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 446 | $$(BPFOBJ) | $(TRUNNER_OUTPUT) |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 447 | $$(call msg,TEST-OBJ,$(TRUNNER_BINARY),$$@) |
Andrii Nakryiko | d5ca590 | 2020-08-06 20:30:57 -0700 | [diff] [blame] | 448 | $(Q)cd $$(@D) && $$(CC) -I. $$(CFLAGS) -c $(CURDIR)/$$< $$(LDLIBS) -o $$(@F) |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 449 | |
| 450 | $(TRUNNER_EXTRA_OBJS): $(TRUNNER_OUTPUT)/%.o: \ |
| 451 | %.c \ |
| 452 | $(TRUNNER_EXTRA_HDRS) \ |
| 453 | $(TRUNNER_TESTS_HDR) \ |
| 454 | $$(BPFOBJ) | $(TRUNNER_OUTPUT) |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 455 | $$(call msg,EXT-OBJ,$(TRUNNER_BINARY),$$@) |
Andrii Nakryiko | d5ca590 | 2020-08-06 20:30:57 -0700 | [diff] [blame] | 456 | $(Q)$$(CC) $$(CFLAGS) -c $$< $$(LDLIBS) -o $$@ |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 457 | |
Ilya Leoshkevich | 86fd166 | 2021-02-24 12:14:45 +0100 | [diff] [blame] | 458 | # non-flavored in-srctree builds receive special treatment, in particular, we |
| 459 | # do not need to copy extra resources (see e.g. test_btf_dump_case()) |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 460 | $(TRUNNER_BINARY)-extras: $(TRUNNER_EXTRA_FILES) | $(TRUNNER_OUTPUT) |
Ilya Leoshkevich | 86fd166 | 2021-02-24 12:14:45 +0100 | [diff] [blame] | 461 | ifneq ($2:$(OUTPUT),:$(shell pwd)) |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 462 | $$(call msg,EXT-COPY,$(TRUNNER_BINARY),$(TRUNNER_EXTRA_FILES)) |
Ilya Leoshkevich | 86fd166 | 2021-02-24 12:14:45 +0100 | [diff] [blame] | 463 | $(Q)rsync -aq $$^ $(TRUNNER_OUTPUT)/ |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 464 | endif |
| 465 | |
| 466 | $(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS) \ |
| 467 | $(TRUNNER_EXTRA_OBJS) $$(BPFOBJ) \ |
Jiri Olsa | cc15a20 | 2020-07-11 23:53:29 +0200 | [diff] [blame] | 468 | $(RESOLVE_BTFIDS) \ |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 469 | | $(TRUNNER_BINARY)-extras |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 470 | $$(call msg,BINARY,,$$@) |
Andrii Nakryiko | d5ca590 | 2020-08-06 20:30:57 -0700 | [diff] [blame] | 471 | $(Q)$$(CC) $$(CFLAGS) $$(filter %.a %.o,$$^) $$(LDLIBS) -o $$@ |
Kumar Kartikeya Dwivedi | f614f2c | 2021-10-02 06:47:52 +0530 | [diff] [blame] | 472 | $(Q)$(RESOLVE_BTFIDS) --btf $(TRUNNER_OUTPUT)/btf_data.o $$@ |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 473 | |
| 474 | endef |
| 475 | |
| 476 | # Define test_progs test runner. |
| 477 | TRUNNER_TESTS_DIR := prog_tests |
| 478 | TRUNNER_BPF_PROGS_DIR := progs |
| 479 | TRUNNER_EXTRA_SOURCES := test_progs.c cgroup_helpers.c trace_helpers.c \ |
Andrii Nakryiko | cd49291 | 2020-05-12 12:24:42 -0700 | [diff] [blame] | 480 | network_helpers.c testing_helpers.c \ |
Andrii Nakryiko | de29e6b | 2021-11-10 21:36:17 -0800 | [diff] [blame] | 481 | btf_helpers.c flow_dissector_load.h |
Andrii Nakryiko | 9f7fa22 | 2020-12-03 12:46:26 -0800 | [diff] [blame] | 482 | TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \ |
KP Singh | 854055c | 2020-11-26 18:49:46 +0000 | [diff] [blame] | 483 | ima_setup.sh \ |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 484 | $(wildcard progs/btf_dump_test_case_*.c) |
| 485 | TRUNNER_BPF_BUILD_RULE := CLANG_BPF_BUILD_RULE |
Andrii Nakryiko | de29e6b | 2021-11-10 21:36:17 -0800 | [diff] [blame] | 486 | TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS) -DENABLE_ATOMICS_TESTS |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 487 | $(eval $(call DEFINE_TEST_RUNNER,test_progs)) |
| 488 | |
Yonghong Song | e13a2fe | 2019-10-21 21:31:19 -0700 | [diff] [blame] | 489 | # Define test_progs-no_alu32 test runner. |
Andrii Nakryiko | 24f6505 | 2019-11-19 16:25:10 -0800 | [diff] [blame] | 490 | TRUNNER_BPF_BUILD_RULE := CLANG_NOALU32_BPF_BUILD_RULE |
Brendan Jackman | 98d666d | 2021-01-14 18:17:50 +0000 | [diff] [blame] | 491 | TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS) |
Yonghong Song | e13a2fe | 2019-10-21 21:31:19 -0700 | [diff] [blame] | 492 | $(eval $(call DEFINE_TEST_RUNNER,test_progs,no_alu32)) |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 493 | |
| 494 | # Define test_progs BPF-GCC-flavored test runner. |
Ilya Leoshkevich | 4ce150b | 2019-09-12 18:05:43 +0200 | [diff] [blame] | 495 | ifneq ($(BPF_GCC),) |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 496 | TRUNNER_BPF_BUILD_RULE := GCC_BPF_BUILD_RULE |
Ilya Leoshkevich | 313e7f6 | 2019-10-28 11:20:49 +0100 | [diff] [blame] | 497 | TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(call get_sys_includes,gcc) |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 498 | $(eval $(call DEFINE_TEST_RUNNER,test_progs,bpf_gcc)) |
Ilya Leoshkevich | 4ce150b | 2019-09-12 18:05:43 +0200 | [diff] [blame] | 499 | endif |
| 500 | |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 501 | # Define test_maps test runner. |
| 502 | TRUNNER_TESTS_DIR := map_tests |
| 503 | TRUNNER_BPF_PROGS_DIR := progs |
| 504 | TRUNNER_EXTRA_SOURCES := test_maps.c |
| 505 | TRUNNER_EXTRA_FILES := |
| 506 | TRUNNER_BPF_BUILD_RULE := $$(error no BPF objects should be built) |
| 507 | TRUNNER_BPF_CFLAGS := |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 508 | $(eval $(call DEFINE_TEST_RUNNER,test_maps)) |
Martin KaFai Lau | c0fa1b6 | 2018-04-18 15:56:06 -0700 | [diff] [blame] | 509 | |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 510 | # Define test_verifier test runner. |
| 511 | # It is much simpler than test_maps/test_progs and sufficiently different from |
| 512 | # them (e.g., test.h is using completely pattern), that it's worth just |
| 513 | # explicitly defining all the rules explicitly. |
| 514 | verifier/tests.h: verifier/*.c |
Stanislav Fomichev | e78e00b | 2019-03-06 11:59:26 -0800 | [diff] [blame] | 515 | $(shell ( cd verifier/; \ |
Jakub Kicinski | 2dfb401 | 2019-01-25 15:24:42 -0800 | [diff] [blame] | 516 | echo '/* Generated header, do not edit */'; \ |
| 517 | echo '#ifdef FILL_ARRAY'; \ |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 518 | ls *.c 2> /dev/null | sed -e 's@\(.*\)@#include \"\1\"@'; \ |
Jakub Kicinski | 2dfb401 | 2019-01-25 15:24:42 -0800 | [diff] [blame] | 519 | echo '#endif' \ |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 520 | ) > verifier/tests.h) |
| 521 | $(OUTPUT)/test_verifier: test_verifier.c verifier/tests.h $(BPFOBJ) | $(OUTPUT) |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 522 | $(call msg,BINARY,,$@) |
Andrii Nakryiko | d5ca590 | 2020-08-06 20:30:57 -0700 | [diff] [blame] | 523 | $(Q)$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@ |
Jakub Kicinski | 2dfb401 | 2019-01-25 15:24:42 -0800 | [diff] [blame] | 524 | |
Stanislav Fomichev | 6bf6aff | 2019-12-02 13:59:31 -0800 | [diff] [blame] | 525 | # Make sure we are able to include and link libbpf against c++. |
Andrii Nakryiko | 7c8dce4 | 2019-12-26 13:02:53 -0800 | [diff] [blame] | 526 | $(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ) |
Andrii Nakryiko | 2cc51d3 | 2020-01-12 23:31:40 -0800 | [diff] [blame] | 527 | $(call msg,CXX,,$@) |
Yonghong Song | a22c0c8 | 2021-04-13 08:34:24 -0700 | [diff] [blame] | 528 | $(Q)$(CXX) $(CFLAGS) $(filter %.a %.o %.cpp,$^) $(LDLIBS) -o $@ |
Stanislav Fomichev | 6bf6aff | 2019-12-02 13:59:31 -0800 | [diff] [blame] | 529 | |
Andrii Nakryiko | 8e7c2a0 | 2020-05-12 12:24:43 -0700 | [diff] [blame] | 530 | # Benchmark runner |
Quentin Monnet | 0b46b75 | 2021-09-08 14:32:26 -0700 | [diff] [blame] | 531 | $(OUTPUT)/bench_%.o: benchs/bench_%.c bench.h $(BPFOBJ) |
Andrii Nakryiko | 8e7c2a0 | 2020-05-12 12:24:43 -0700 | [diff] [blame] | 532 | $(call msg,CC,,$@) |
Joanne Koong | 57fd1c6 | 2021-10-27 16:45:03 -0700 | [diff] [blame] | 533 | $(Q)$(CC) $(CFLAGS) -O2 -c $(filter %.c,$^) $(LDLIBS) -o $@ |
Andrii Nakryiko | 4eaf0b5 | 2020-05-12 12:24:44 -0700 | [diff] [blame] | 534 | $(OUTPUT)/bench_rename.o: $(OUTPUT)/test_overhead.skel.h |
Andrii Nakryiko | c5d420c | 2020-05-12 12:24:45 -0700 | [diff] [blame] | 535 | $(OUTPUT)/bench_trigger.o: $(OUTPUT)/trigger_bench.skel.h |
Andrii Nakryiko | c97099b | 2020-05-29 00:54:23 -0700 | [diff] [blame] | 536 | $(OUTPUT)/bench_ringbufs.o: $(OUTPUT)/ringbuf_bench.skel.h \ |
| 537 | $(OUTPUT)/perfbuf_bench.skel.h |
Joanne Koong | 57fd1c6 | 2021-10-27 16:45:03 -0700 | [diff] [blame] | 538 | $(OUTPUT)/bench_bloom_filter_map.o: $(OUTPUT)/bloom_filter_bench.skel.h |
Joanne Koong | ec15103 | 2021-11-29 19:06:22 -0800 | [diff] [blame] | 539 | $(OUTPUT)/bench_bpf_loop.o: $(OUTPUT)/bpf_loop_bench.skel.h |
Hou Tao | 9c42652 | 2021-12-10 22:16:51 +0800 | [diff] [blame] | 540 | $(OUTPUT)/bench_strncmp.o: $(OUTPUT)/strncmp_bench.skel.h |
Quentin Monnet | 0b46b75 | 2021-09-08 14:32:26 -0700 | [diff] [blame] | 541 | $(OUTPUT)/bench.o: bench.h testing_helpers.h $(BPFOBJ) |
Andrii Nakryiko | 8e7c2a0 | 2020-05-12 12:24:43 -0700 | [diff] [blame] | 542 | $(OUTPUT)/bench: LDLIBS += -lm |
Andrii Nakryiko | d41bc48 | 2021-11-15 17:30:41 -0800 | [diff] [blame] | 543 | $(OUTPUT)/bench: $(OUTPUT)/bench.o \ |
Jean-Philippe Brucker | eee9a6d | 2021-12-01 14:51:02 +0000 | [diff] [blame] | 544 | $(TESTING_HELPERS) \ |
| 545 | $(TRACE_HELPERS) \ |
Andrii Nakryiko | 4eaf0b5 | 2020-05-12 12:24:44 -0700 | [diff] [blame] | 546 | $(OUTPUT)/bench_count.o \ |
Andrii Nakryiko | c5d420c | 2020-05-12 12:24:45 -0700 | [diff] [blame] | 547 | $(OUTPUT)/bench_rename.o \ |
Andrii Nakryiko | c97099b | 2020-05-29 00:54:23 -0700 | [diff] [blame] | 548 | $(OUTPUT)/bench_trigger.o \ |
Joanne Koong | 57fd1c6 | 2021-10-27 16:45:03 -0700 | [diff] [blame] | 549 | $(OUTPUT)/bench_ringbufs.o \ |
Joanne Koong | ec15103 | 2021-11-29 19:06:22 -0800 | [diff] [blame] | 550 | $(OUTPUT)/bench_bloom_filter_map.o \ |
Hou Tao | 9c42652 | 2021-12-10 22:16:51 +0800 | [diff] [blame] | 551 | $(OUTPUT)/bench_bpf_loop.o \ |
| 552 | $(OUTPUT)/bench_strncmp.o |
Andrii Nakryiko | 8e7c2a0 | 2020-05-12 12:24:43 -0700 | [diff] [blame] | 553 | $(call msg,BINARY,,$@) |
Jean-Philippe Brucker | ea79020 | 2021-12-16 16:38:43 +0000 | [diff] [blame] | 554 | $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.a %.o,$^) $(LDLIBS) -o $@ |
Andrii Nakryiko | 8e7c2a0 | 2020-05-12 12:24:43 -0700 | [diff] [blame] | 555 | |
Jean-Philippe Brucker | de11ae4 | 2021-01-13 17:33:16 +0100 | [diff] [blame] | 556 | EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(SCRATCH_DIR) $(HOST_SCRATCH_DIR) \ |
Andrii Nakryiko | 74b5a59 | 2019-10-15 23:00:49 -0700 | [diff] [blame] | 557 | prog_tests/tests.h map_tests/tests.h verifier/tests.h \ |
Andrii Nakryiko | 2031af2 | 2020-01-09 21:17:14 -0800 | [diff] [blame] | 558 | feature \ |
Alexei Starovoitov | 4d1b629 | 2021-05-13 17:36:20 -0700 | [diff] [blame] | 559 | $(addprefix $(OUTPUT)/,*.o *.skel.h *.lskel.h no_alu32 bpf_gcc bpf_testmod.ko) |
Joe Stringer | a01d935 | 2021-03-02 09:19:43 -0800 | [diff] [blame] | 560 | |
| 561 | .PHONY: docs docs-clean |