]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - samples/bpf/Makefile
macvtap: replace printk with netdev_err
[mirror_ubuntu-artful-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
5db58faf 5hostprogs-y := test_lru_dist
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
d8c5b17f 25hostprogs-y += test_cgrp2_attach
86af8b41 26hostprogs-y += xdp1
764cbcce 27hostprogs-y += xdp2
9e6e60ec 28hostprogs-y += test_current_task_under_cgroup
1c47910e 29hostprogs-y += trace_event
72874418 30hostprogs-y += sampleip
90e02896 31hostprogs-y += tc_l2_redirect
3c731eba 32
5db58faf 33test_lru_dist-objs := test_lru_dist.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
d8c5b17f 53test_cgrp2_attach-objs := libbpf.o test_cgrp2_attach.o
86af8b41 54xdp1-objs := bpf_load.o libbpf.o xdp1_user.o
764cbcce
BB
55# reuse xdp1 source intentionally
56xdp2-objs := bpf_load.o libbpf.o xdp1_user.o
9e6e60ec
SD
57test_current_task_under_cgroup-objs := bpf_load.o libbpf.o \
58 test_current_task_under_cgroup_user.o
1c47910e 59trace_event-objs := bpf_load.o libbpf.o trace_event_user.o
72874418 60sampleip-objs := bpf_load.o libbpf.o sampleip_user.o
90e02896 61tc_l2_redirect-objs := bpf_load.o libbpf.o tc_l2_redirect_user.o
3c731eba
AS
62
63# Tell kbuild to always build the programs
64always := $(hostprogs-y)
a8085782 65always += sockex1_kern.o
fbe33108 66always += sockex2_kern.o
530b2c86 67always += sockex3_kern.o
b896c4f9 68always += tracex1_kern.o
d822a192 69always += tracex2_kern.o
5c7fc2d2 70always += tracex3_kern.o
9811e353 71always += tracex4_kern.o
5bacd780 72always += tracex5_kern.o
47efb302 73always += tracex6_kern.o
cf9b1199 74always += test_probe_write_user_kern.o
39111695 75always += trace_output_kern.o
91bc4822 76always += tcbpf1_kern.o
6afb1e28 77always += tcbpf2_kern.o
90e02896 78always += tc_l2_redirect_kern.o
0fb1170e 79always += lathist_kern.o
a6ffe7b9 80always += offwaketime_kern.o
9d8b612d 81always += spintest_kern.o
26e90931 82always += map_perf_test_kern.o
e3edfdec
AS
83always += test_overhead_tp_kern.o
84always += test_overhead_kprobe_kern.o
65d472fb 85always += parse_varlen.o parse_simple.o parse_ldabs.o
a3f74617 86always += test_cgrp2_tc_kern.o
86af8b41 87always += xdp1_kern.o
764cbcce 88always += xdp2_kern.o
9e6e60ec 89always += test_current_task_under_cgroup_kern.o
1c47910e 90always += trace_event_kern.o
72874418 91always += sampleip_kern.o
3c731eba
AS
92
93HOSTCFLAGS += -I$(objtree)/usr/include
e00c7b21 94HOSTCFLAGS += -I$(objtree)/tools/testing/selftests/bpf/
a8085782
AS
95
96HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
42984d7c 97HOSTLOADLIBES_fds_example += -lelf
a8085782 98HOSTLOADLIBES_sockex1 += -lelf
fbe33108 99HOSTLOADLIBES_sockex2 += -lelf
530b2c86 100HOSTLOADLIBES_sockex3 += -lelf
b896c4f9 101HOSTLOADLIBES_tracex1 += -lelf
d822a192 102HOSTLOADLIBES_tracex2 += -lelf
5c7fc2d2 103HOSTLOADLIBES_tracex3 += -lelf
9811e353 104HOSTLOADLIBES_tracex4 += -lelf -lrt
5bacd780 105HOSTLOADLIBES_tracex5 += -lelf
47efb302 106HOSTLOADLIBES_tracex6 += -lelf
cf9b1199 107HOSTLOADLIBES_test_probe_write_user += -lelf
39111695 108HOSTLOADLIBES_trace_output += -lelf -lrt
0fb1170e 109HOSTLOADLIBES_lathist += -lelf
a6ffe7b9 110HOSTLOADLIBES_offwaketime += -lelf
9d8b612d 111HOSTLOADLIBES_spintest += -lelf
26e90931 112HOSTLOADLIBES_map_perf_test += -lelf -lrt
e3edfdec 113HOSTLOADLIBES_test_overhead += -lelf -lrt
86af8b41 114HOSTLOADLIBES_xdp1 += -lelf
764cbcce 115HOSTLOADLIBES_xdp2 += -lelf
9e6e60ec 116HOSTLOADLIBES_test_current_task_under_cgroup += -lelf
1c47910e 117HOSTLOADLIBES_trace_event += -lelf
72874418 118HOSTLOADLIBES_sampleip += -lelf
90e02896 119HOSTLOADLIBES_tc_l2_redirect += -l elf
a8085782 120
bdefbbf2
JDB
121# Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
122# make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
6ccfba75 123LLC ?= llc
bdefbbf2 124CLANG ?= clang
6ccfba75 125
b62a796c
JDB
126# Trick to allow make to be run from this directory
127all:
128 $(MAKE) -C ../../ $$PWD/
129
130clean:
131 $(MAKE) -C ../../ M=$$PWD clean
132 @rm -f *~
133
bdefbbf2
JDB
134# Verify LLVM compiler tools are available and bpf target is supported by llc
135.PHONY: verify_cmds verify_target_bpf $(CLANG) $(LLC)
7b01dd57 136
bdefbbf2
JDB
137verify_cmds: $(CLANG) $(LLC)
138 @for TOOL in $^ ; do \
139 if ! (which -- "$${TOOL}" > /dev/null 2>&1); then \
140 echo "*** ERROR: Cannot find LLVM tool $${TOOL}" ;\
141 exit 1; \
142 else true; fi; \
143 done
7b01dd57 144
bdefbbf2 145verify_target_bpf: verify_cmds
7b01dd57
JDB
146 @if ! (${LLC} -march=bpf -mattr=help > /dev/null 2>&1); then \
147 echo "*** ERROR: LLVM (${LLC}) does not support 'bpf' target" ;\
148 echo " NOTICE: LLVM version >= 3.7.1 required" ;\
149 exit 2; \
150 else true; fi
151
152$(src)/*.c: verify_target_bpf
153
128d1514
NR
154# asm/sysreg.h - inline assembly used by it is incompatible with llvm.
155# But, there is no easy way to fix it, so just exclude it since it is
30b50aa6 156# useless for BPF samples.
b88c06e3 157$(obj)/%.o: $(src)/%.c
bdefbbf2 158 $(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
30b50aa6 159 -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
65d472fb 160 -Wno-compare-distinct-pointer-types \
6ccfba75 161 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@