]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - samples/bpf/Makefile
Merge remote-tracking branches 'asoc/topic/inntel', 'asoc/topic/input', 'asoc/topic...
[mirror_ubuntu-bionic-kernel.git] / samples / bpf / Makefile
CommitLineData
3c731eba
AS
1# kbuild trick to avoid linker error. Can be omitted if a module is built.
2obj- := dummy.o
3
4# List of programs to build
ffb65f27 5hostprogs-y := test_verifier test_maps
03f4723e 6hostprogs-y += sock_example
42984d7c 7hostprogs-y += fds_example
a8085782 8hostprogs-y += sockex1
fbe33108 9hostprogs-y += sockex2
530b2c86 10hostprogs-y += sockex3
b896c4f9 11hostprogs-y += tracex1
d822a192 12hostprogs-y += tracex2
5c7fc2d2 13hostprogs-y += tracex3
9811e353 14hostprogs-y += tracex4
5bacd780 15hostprogs-y += tracex5
47efb302 16hostprogs-y += tracex6
cf9b1199 17hostprogs-y += test_probe_write_user
39111695 18hostprogs-y += trace_output
0fb1170e 19hostprogs-y += lathist
a6ffe7b9 20hostprogs-y += offwaketime
9d8b612d 21hostprogs-y += spintest
26e90931 22hostprogs-y += map_perf_test
e3edfdec 23hostprogs-y += test_overhead
a3f74617 24hostprogs-y += test_cgrp2_array_pin
86af8b41 25hostprogs-y += xdp1
764cbcce 26hostprogs-y += xdp2
9e6e60ec 27hostprogs-y += test_current_task_under_cgroup
1c47910e 28hostprogs-y += trace_event
72874418 29hostprogs-y += sampleip
90e02896 30hostprogs-y += tc_l2_redirect
3c731eba
AS
31
32test_verifier-objs := test_verifier.o libbpf.o
ffb65f27 33test_maps-objs := test_maps.o libbpf.o
03f4723e 34sock_example-objs := sock_example.o libbpf.o
42984d7c 35fds_example-objs := bpf_load.o libbpf.o fds_example.o
a8085782 36sockex1-objs := bpf_load.o libbpf.o sockex1_user.o
fbe33108 37sockex2-objs := bpf_load.o libbpf.o sockex2_user.o
530b2c86 38sockex3-objs := bpf_load.o libbpf.o sockex3_user.o
b896c4f9 39tracex1-objs := bpf_load.o libbpf.o tracex1_user.o
d822a192 40tracex2-objs := bpf_load.o libbpf.o tracex2_user.o
5c7fc2d2 41tracex3-objs := bpf_load.o libbpf.o tracex3_user.o
9811e353 42tracex4-objs := bpf_load.o libbpf.o tracex4_user.o
5bacd780 43tracex5-objs := bpf_load.o libbpf.o tracex5_user.o
47efb302 44tracex6-objs := bpf_load.o libbpf.o tracex6_user.o
cf9b1199 45test_probe_write_user-objs := bpf_load.o libbpf.o test_probe_write_user_user.o
39111695 46trace_output-objs := bpf_load.o libbpf.o trace_output_user.o
0fb1170e 47lathist-objs := bpf_load.o libbpf.o lathist_user.o
a6ffe7b9 48offwaketime-objs := bpf_load.o libbpf.o offwaketime_user.o
9d8b612d 49spintest-objs := bpf_load.o libbpf.o spintest_user.o
26e90931 50map_perf_test-objs := bpf_load.o libbpf.o map_perf_test_user.o
e3edfdec 51test_overhead-objs := bpf_load.o libbpf.o test_overhead_user.o
a3f74617 52test_cgrp2_array_pin-objs := libbpf.o test_cgrp2_array_pin.o
86af8b41 53xdp1-objs := bpf_load.o libbpf.o xdp1_user.o
764cbcce
BB
54# reuse xdp1 source intentionally
55xdp2-objs := bpf_load.o libbpf.o xdp1_user.o
9e6e60ec
SD
56test_current_task_under_cgroup-objs := bpf_load.o libbpf.o \
57 test_current_task_under_cgroup_user.o
1c47910e 58trace_event-objs := bpf_load.o libbpf.o trace_event_user.o
72874418 59sampleip-objs := bpf_load.o libbpf.o sampleip_user.o
90e02896 60tc_l2_redirect-objs := bpf_load.o libbpf.o tc_l2_redirect_user.o
3c731eba
AS
61
62# Tell kbuild to always build the programs
63always := $(hostprogs-y)
a8085782 64always += sockex1_kern.o
fbe33108 65always += sockex2_kern.o
530b2c86 66always += sockex3_kern.o
b896c4f9 67always += tracex1_kern.o
d822a192 68always += tracex2_kern.o
5c7fc2d2 69always += tracex3_kern.o
9811e353 70always += tracex4_kern.o
5bacd780 71always += tracex5_kern.o
47efb302 72always += tracex6_kern.o
cf9b1199 73always += test_probe_write_user_kern.o
39111695 74always += trace_output_kern.o
91bc4822 75always += tcbpf1_kern.o
6afb1e28 76always += tcbpf2_kern.o
90e02896 77always += tc_l2_redirect_kern.o
0fb1170e 78always += lathist_kern.o
a6ffe7b9 79always += offwaketime_kern.o
9d8b612d 80always += spintest_kern.o
26e90931 81always += map_perf_test_kern.o
e3edfdec
AS
82always += test_overhead_tp_kern.o
83always += test_overhead_kprobe_kern.o
65d472fb 84always += parse_varlen.o parse_simple.o parse_ldabs.o
a3f74617 85always += test_cgrp2_tc_kern.o
86af8b41 86always += xdp1_kern.o
764cbcce 87always += xdp2_kern.o
9e6e60ec 88always += test_current_task_under_cgroup_kern.o
1c47910e 89always += trace_event_kern.o
72874418 90always += sampleip_kern.o
3c731eba
AS
91
92HOSTCFLAGS += -I$(objtree)/usr/include
a8085782
AS
93
94HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
42984d7c 95HOSTLOADLIBES_fds_example += -lelf
a8085782 96HOSTLOADLIBES_sockex1 += -lelf
fbe33108 97HOSTLOADLIBES_sockex2 += -lelf
530b2c86 98HOSTLOADLIBES_sockex3 += -lelf
b896c4f9 99HOSTLOADLIBES_tracex1 += -lelf
d822a192 100HOSTLOADLIBES_tracex2 += -lelf
5c7fc2d2 101HOSTLOADLIBES_tracex3 += -lelf
9811e353 102HOSTLOADLIBES_tracex4 += -lelf -lrt
5bacd780 103HOSTLOADLIBES_tracex5 += -lelf
47efb302 104HOSTLOADLIBES_tracex6 += -lelf
cf9b1199 105HOSTLOADLIBES_test_probe_write_user += -lelf
39111695 106HOSTLOADLIBES_trace_output += -lelf -lrt
0fb1170e 107HOSTLOADLIBES_lathist += -lelf
a6ffe7b9 108HOSTLOADLIBES_offwaketime += -lelf
9d8b612d 109HOSTLOADLIBES_spintest += -lelf
26e90931 110HOSTLOADLIBES_map_perf_test += -lelf -lrt
e3edfdec 111HOSTLOADLIBES_test_overhead += -lelf -lrt
86af8b41 112HOSTLOADLIBES_xdp1 += -lelf
764cbcce 113HOSTLOADLIBES_xdp2 += -lelf
9e6e60ec 114HOSTLOADLIBES_test_current_task_under_cgroup += -lelf
1c47910e 115HOSTLOADLIBES_trace_event += -lelf
72874418 116HOSTLOADLIBES_sampleip += -lelf
90e02896 117HOSTLOADLIBES_tc_l2_redirect += -l elf
a8085782 118
bdefbbf2
JDB
119# Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
120# make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
6ccfba75 121LLC ?= llc
bdefbbf2 122CLANG ?= clang
6ccfba75 123
b62a796c
JDB
124# Trick to allow make to be run from this directory
125all:
126 $(MAKE) -C ../../ $$PWD/
127
128clean:
129 $(MAKE) -C ../../ M=$$PWD clean
130 @rm -f *~
131
bdefbbf2
JDB
132# Verify LLVM compiler tools are available and bpf target is supported by llc
133.PHONY: verify_cmds verify_target_bpf $(CLANG) $(LLC)
7b01dd57 134
bdefbbf2
JDB
135verify_cmds: $(CLANG) $(LLC)
136 @for TOOL in $^ ; do \
137 if ! (which -- "$${TOOL}" > /dev/null 2>&1); then \
138 echo "*** ERROR: Cannot find LLVM tool $${TOOL}" ;\
139 exit 1; \
140 else true; fi; \
141 done
7b01dd57 142
bdefbbf2 143verify_target_bpf: verify_cmds
7b01dd57
JDB
144 @if ! (${LLC} -march=bpf -mattr=help > /dev/null 2>&1); then \
145 echo "*** ERROR: LLVM (${LLC}) does not support 'bpf' target" ;\
146 echo " NOTICE: LLVM version >= 3.7.1 required" ;\
147 exit 2; \
148 else true; fi
149
150$(src)/*.c: verify_target_bpf
151
128d1514
NR
152# asm/sysreg.h - inline assembly used by it is incompatible with llvm.
153# But, there is no easy way to fix it, so just exclude it since it is
30b50aa6 154# useless for BPF samples.
b88c06e3 155$(obj)/%.o: $(src)/%.c
bdefbbf2 156 $(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
30b50aa6 157 -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
65d472fb 158 -Wno-compare-distinct-pointer-types \
6ccfba75 159 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@