Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Hendrik Brueckner | 618e165 | 2017-12-04 10:56:48 +0100 | [diff] [blame] | 2 | |
Mickaël Salaün | d498f87 | 2017-02-11 23:20:23 +0100 | [diff] [blame] | 3 | LIBDIR := ../../../lib |
Zi Shen Lim | e8f1f34 | 2017-03-19 23:03:14 -0700 | [diff] [blame] | 4 | BPFDIR := $(LIBDIR)/bpf |
Daniel Borkmann | 02ea80b | 2017-03-31 02:24:04 +0200 | [diff] [blame] | 5 | APIDIR := ../../../include/uapi |
| 6 | GENDIR := ../../../../include/generated |
| 7 | GENHDR := $(GENDIR)/autoconf.h |
Mickaël Salaün | d498f87 | 2017-02-11 23:20:23 +0100 | [diff] [blame] | 8 | |
Daniel Borkmann | 02ea80b | 2017-03-31 02:24:04 +0200 | [diff] [blame] | 9 | ifneq ($(wildcard $(GENHDR)),) |
| 10 | GENFLAGS := -DHAVE_GENHDR |
| 11 | endif |
| 12 | |
Daniel Borkmann | 720f228 | 2017-12-12 02:25:32 +0100 | [diff] [blame] | 13 | CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include |
Yonghong Song | af32efe | 2018-01-26 15:06:08 -0800 | [diff] [blame] | 14 | LDLIBS += -lcap -lelf -lrt -lpthread |
Daniel Borkmann | 5aa5bd1 | 2016-10-17 14:28:36 +0200 | [diff] [blame] | 15 | |
Jesper Dangaard Brouer | f09b2e3 | 2018-02-08 12:48:27 +0100 | [diff] [blame] | 16 | # Order correspond to 'make run_tests' order |
David S. Miller | 18b3ad9 | 2017-05-10 11:43:51 -0700 | [diff] [blame] | 17 | TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \ |
Lawrence Brakmo | d6d4f60 | 2018-01-25 16:14:16 -0800 | [diff] [blame] | 18 | test_align test_verifier_log test_dev_cgroup test_tcpbpf_user |
Alexei Starovoitov | 6882804 | 2017-03-30 21:45:41 -0700 | [diff] [blame] | 19 | |
Yonghong Song | 18f3d6b | 2017-06-13 15:52:14 -0700 | [diff] [blame] | 20 | TEST_GEN_FILES = test_pkt_access.o test_xdp.o test_l4lb.o test_tcp_estats.o test_obj_id.o \ |
Daniel Borkmann | 22c8852 | 2017-09-25 02:25:53 +0200 | [diff] [blame] | 21 | test_pkt_md_access.o test_xdp_redirect.o test_xdp_meta.o sockmap_parse_prog.o \ |
Alexei Starovoitov | 3bc35c6 | 2017-12-14 17:55:11 -0800 | [diff] [blame] | 22 | sockmap_verdict_prog.o dev_cgroup.o sample_ret0.o test_tracepoint.o \ |
Jakub Kicinski | 7fedbb7c | 2018-01-17 19:13:31 -0800 | [diff] [blame] | 23 | test_l4lb_noinline.o test_xdp_noinline.o test_stacktrace_map.o \ |
Jesper Dangaard Brouer | f09b2e3 | 2018-02-08 12:48:27 +0100 | [diff] [blame] | 24 | sample_map_ret0.o test_tcpbpf_kern.o |
Daniel Borkmann | 5aa5bd1 | 2016-10-17 14:28:36 +0200 | [diff] [blame] | 25 | |
Jesper Dangaard Brouer | f09b2e3 | 2018-02-08 12:48:27 +0100 | [diff] [blame] | 26 | # Order correspond to 'make run_tests' order |
| 27 | TEST_PROGS := test_kmod.sh \ |
| 28 | test_libbpf.sh \ |
| 29 | test_xdp_redirect.sh \ |
| 30 | test_xdp_meta.sh \ |
Jakub Kicinski | 417ec26 | 2017-12-01 15:09:00 -0800 | [diff] [blame] | 31 | test_offload.py |
Daniel Borkmann | 5aa5bd1 | 2016-10-17 14:28:36 +0200 | [diff] [blame] | 32 | |
Jesper Dangaard Brouer | f09b2e3 | 2018-02-08 12:48:27 +0100 | [diff] [blame] | 33 | # Compile but not part of 'make run_tests' |
| 34 | TEST_GEN_PROGS_EXTENDED = test_libbpf_open |
| 35 | |
Zi Shen Lim | e8f1f34 | 2017-03-19 23:03:14 -0700 | [diff] [blame] | 36 | include ../lib.mk |
Alexei Starovoitov | 1da8ac7 | 2017-03-10 22:05:55 -0800 | [diff] [blame] | 37 | |
Jesper Dangaard Brouer | 41757dc | 2018-02-13 14:19:15 +0100 | [diff] [blame^] | 38 | BPFOBJ := $(OUTPUT)/libbpf.a |
Zi Shen Lim | e8f1f34 | 2017-03-19 23:03:14 -0700 | [diff] [blame] | 39 | |
| 40 | $(TEST_GEN_PROGS): $(BPFOBJ) |
| 41 | |
Jesper Dangaard Brouer | f09b2e3 | 2018-02-08 12:48:27 +0100 | [diff] [blame] | 42 | $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/libbpf.a |
| 43 | |
Jesper Dangaard Brouer | 41757dc | 2018-02-13 14:19:15 +0100 | [diff] [blame^] | 44 | $(OUTPUT)/test_dev_cgroup: cgroup_helpers.c |
| 45 | |
Zi Shen Lim | e8f1f34 | 2017-03-19 23:03:14 -0700 | [diff] [blame] | 46 | .PHONY: force |
Mickaël Salaün | d498f87 | 2017-02-11 23:20:23 +0100 | [diff] [blame] | 47 | |
Mickaël Salaün | d498f87 | 2017-02-11 23:20:23 +0100 | [diff] [blame] | 48 | # force a rebuild of BPFOBJ when its dependencies are updated |
| 49 | force: |
| 50 | |
| 51 | $(BPFOBJ): force |
Zi Shen Lim | e8f1f34 | 2017-03-19 23:03:14 -0700 | [diff] [blame] | 52 | $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ |
Alexei Starovoitov | 6882804 | 2017-03-30 21:45:41 -0700 | [diff] [blame] | 53 | |
| 54 | CLANG ?= clang |
Daniel Borkmann | 22c8852 | 2017-09-25 02:25:53 +0200 | [diff] [blame] | 55 | LLC ?= llc |
| 56 | |
Quentin Monnet | cd95a89 | 2017-12-21 08:52:50 -0800 | [diff] [blame] | 57 | PROBE := $(shell $(LLC) -march=bpf -mcpu=probe -filetype=null /dev/null 2>&1) |
Daniel Borkmann | 22c8852 | 2017-09-25 02:25:53 +0200 | [diff] [blame] | 58 | |
| 59 | # Let newer LLVM versions transparently probe the kernel for availability |
| 60 | # of full BPF instruction set. |
| 61 | ifeq ($(PROBE),) |
| 62 | CPU ?= probe |
| 63 | else |
| 64 | CPU ?= generic |
| 65 | endif |
Alexei Starovoitov | 6882804 | 2017-03-30 21:45:41 -0700 | [diff] [blame] | 66 | |
Alexei Starovoitov | 3bc35c6 | 2017-12-14 17:55:11 -0800 | [diff] [blame] | 67 | CLANG_FLAGS = -I. -I./include/uapi -I../../../include/uapi \ |
| 68 | -Wno-compare-distinct-pointer-types |
| 69 | |
| 70 | $(OUTPUT)/test_l4lb_noinline.o: CLANG_FLAGS += -fno-inline |
Alexei Starovoitov | b0b04fc | 2017-12-14 17:55:12 -0800 | [diff] [blame] | 71 | $(OUTPUT)/test_xdp_noinline.o: CLANG_FLAGS += -fno-inline |
Alexei Starovoitov | 3bc35c6 | 2017-12-14 17:55:11 -0800 | [diff] [blame] | 72 | |
Yonghong Song | 62a0699 | 2018-01-29 21:23:28 -0800 | [diff] [blame] | 73 | $(OUTPUT)/%.o: %.c |
Alexei Starovoitov | 3bc35c6 | 2017-12-14 17:55:11 -0800 | [diff] [blame] | 74 | $(CLANG) $(CLANG_FLAGS) \ |
Daniel Borkmann | 22c8852 | 2017-09-25 02:25:53 +0200 | [diff] [blame] | 75 | -O2 -target bpf -emit-llvm -c $< -o - | \ |
| 76 | $(LLC) -march=bpf -mcpu=$(CPU) -filetype=obj -o $@ |