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 |
David Miller | 19c832e | 2017-12-19 15:22:03 -0500 | [diff] [blame] | 14 | LDLIBS += -lcap -lelf -lrt |
Daniel Borkmann | 5aa5bd1 | 2016-10-17 14:28:36 +0200 | [diff] [blame] | 15 | |
David S. Miller | 18b3ad9 | 2017-05-10 11:43:51 -0700 | [diff] [blame] | 16 | TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \ |
Roman Gushchin | 37f1ba0 | 2017-11-05 08:15:34 -0500 | [diff] [blame] | 17 | test_align test_verifier_log test_dev_cgroup |
Alexei Starovoitov | 6882804 | 2017-03-30 21:45:41 -0700 | [diff] [blame] | 18 | |
Yonghong Song | 18f3d6b | 2017-06-13 15:52:14 -0700 | [diff] [blame] | 19 | 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] | 20 | test_pkt_md_access.o test_xdp_redirect.o test_xdp_meta.o sockmap_parse_prog.o \ |
Roman Gushchin | 37f1ba0 | 2017-11-05 08:15:34 -0500 | [diff] [blame] | 21 | sockmap_verdict_prog.o dev_cgroup.o |
Daniel Borkmann | 5aa5bd1 | 2016-10-17 14:28:36 +0200 | [diff] [blame] | 22 | |
Daniel Borkmann | 22c8852 | 2017-09-25 02:25:53 +0200 | [diff] [blame] | 23 | TEST_PROGS := test_kmod.sh test_xdp_redirect.sh test_xdp_meta.sh |
Daniel Borkmann | 5aa5bd1 | 2016-10-17 14:28:36 +0200 | [diff] [blame] | 24 | |
Zi Shen Lim | e8f1f34 | 2017-03-19 23:03:14 -0700 | [diff] [blame] | 25 | include ../lib.mk |
Alexei Starovoitov | 1da8ac7 | 2017-03-10 22:05:55 -0800 | [diff] [blame] | 26 | |
Roman Gushchin | 9d1f159 | 2017-11-05 08:15:33 -0500 | [diff] [blame] | 27 | BPFOBJ := $(OUTPUT)/libbpf.a $(OUTPUT)/cgroup_helpers.c |
Zi Shen Lim | e8f1f34 | 2017-03-19 23:03:14 -0700 | [diff] [blame] | 28 | |
| 29 | $(TEST_GEN_PROGS): $(BPFOBJ) |
| 30 | |
| 31 | .PHONY: force |
Mickaël Salaün | d498f87 | 2017-02-11 23:20:23 +0100 | [diff] [blame] | 32 | |
Mickaël Salaün | d498f87 | 2017-02-11 23:20:23 +0100 | [diff] [blame] | 33 | # force a rebuild of BPFOBJ when its dependencies are updated |
| 34 | force: |
| 35 | |
| 36 | $(BPFOBJ): force |
Zi Shen Lim | e8f1f34 | 2017-03-19 23:03:14 -0700 | [diff] [blame] | 37 | $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ |
Alexei Starovoitov | 6882804 | 2017-03-30 21:45:41 -0700 | [diff] [blame] | 38 | |
| 39 | CLANG ?= clang |
Daniel Borkmann | 22c8852 | 2017-09-25 02:25:53 +0200 | [diff] [blame] | 40 | LLC ?= llc |
| 41 | |
Quentin Monnet | cd95a89 | 2017-12-21 08:52:50 -0800 | [diff] [blame^] | 42 | 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] | 43 | |
| 44 | # Let newer LLVM versions transparently probe the kernel for availability |
| 45 | # of full BPF instruction set. |
| 46 | ifeq ($(PROBE),) |
| 47 | CPU ?= probe |
| 48 | else |
| 49 | CPU ?= generic |
| 50 | endif |
Alexei Starovoitov | 6882804 | 2017-03-30 21:45:41 -0700 | [diff] [blame] | 51 | |
| 52 | %.o: %.c |
David S. Miller | 0a5539f | 2017-05-11 12:00:50 -0700 | [diff] [blame] | 53 | $(CLANG) -I. -I./include/uapi -I../../../include/uapi \ |
Daniel Borkmann | 22c8852 | 2017-09-25 02:25:53 +0200 | [diff] [blame] | 54 | -Wno-compare-distinct-pointer-types \ |
| 55 | -O2 -target bpf -emit-llvm -c $< -o - | \ |
| 56 | $(LLC) -march=bpf -mcpu=$(CPU) -filetype=obj -o $@ |