]>
Commit | Line | Data |
---|---|---|
3c731eba AS |
1 | # kbuild trick to avoid linker error. Can be omitted if a module is built. |
2 | obj- := dummy.o | |
3 | ||
4 | # List of programs to build | |
ffb65f27 | 5 | hostprogs-y := test_verifier test_maps |
03f4723e | 6 | hostprogs-y += sock_example |
42984d7c | 7 | hostprogs-y += fds_example |
a8085782 | 8 | hostprogs-y += sockex1 |
fbe33108 | 9 | hostprogs-y += sockex2 |
530b2c86 | 10 | hostprogs-y += sockex3 |
b896c4f9 | 11 | hostprogs-y += tracex1 |
d822a192 | 12 | hostprogs-y += tracex2 |
5c7fc2d2 | 13 | hostprogs-y += tracex3 |
9811e353 | 14 | hostprogs-y += tracex4 |
5bacd780 | 15 | hostprogs-y += tracex5 |
47efb302 | 16 | hostprogs-y += tracex6 |
cf9b1199 | 17 | hostprogs-y += test_probe_write_user |
39111695 | 18 | hostprogs-y += trace_output |
0fb1170e | 19 | hostprogs-y += lathist |
a6ffe7b9 | 20 | hostprogs-y += offwaketime |
9d8b612d | 21 | hostprogs-y += spintest |
26e90931 | 22 | hostprogs-y += map_perf_test |
e3edfdec | 23 | hostprogs-y += test_overhead |
a3f74617 | 24 | hostprogs-y += test_cgrp2_array_pin |
86af8b41 | 25 | hostprogs-y += xdp1 |
764cbcce | 26 | hostprogs-y += xdp2 |
9e6e60ec | 27 | hostprogs-y += test_current_task_under_cgroup |
1c47910e | 28 | hostprogs-y += trace_event |
72874418 | 29 | hostprogs-y += sampleip |
90e02896 | 30 | hostprogs-y += tc_l2_redirect |
3c731eba AS |
31 | |
32 | test_verifier-objs := test_verifier.o libbpf.o | |
ffb65f27 | 33 | test_maps-objs := test_maps.o libbpf.o |
03f4723e | 34 | sock_example-objs := sock_example.o libbpf.o |
42984d7c | 35 | fds_example-objs := bpf_load.o libbpf.o fds_example.o |
a8085782 | 36 | sockex1-objs := bpf_load.o libbpf.o sockex1_user.o |
fbe33108 | 37 | sockex2-objs := bpf_load.o libbpf.o sockex2_user.o |
530b2c86 | 38 | sockex3-objs := bpf_load.o libbpf.o sockex3_user.o |
b896c4f9 | 39 | tracex1-objs := bpf_load.o libbpf.o tracex1_user.o |
d822a192 | 40 | tracex2-objs := bpf_load.o libbpf.o tracex2_user.o |
5c7fc2d2 | 41 | tracex3-objs := bpf_load.o libbpf.o tracex3_user.o |
9811e353 | 42 | tracex4-objs := bpf_load.o libbpf.o tracex4_user.o |
5bacd780 | 43 | tracex5-objs := bpf_load.o libbpf.o tracex5_user.o |
47efb302 | 44 | tracex6-objs := bpf_load.o libbpf.o tracex6_user.o |
cf9b1199 | 45 | test_probe_write_user-objs := bpf_load.o libbpf.o test_probe_write_user_user.o |
39111695 | 46 | trace_output-objs := bpf_load.o libbpf.o trace_output_user.o |
0fb1170e | 47 | lathist-objs := bpf_load.o libbpf.o lathist_user.o |
a6ffe7b9 | 48 | offwaketime-objs := bpf_load.o libbpf.o offwaketime_user.o |
9d8b612d | 49 | spintest-objs := bpf_load.o libbpf.o spintest_user.o |
26e90931 | 50 | map_perf_test-objs := bpf_load.o libbpf.o map_perf_test_user.o |
e3edfdec | 51 | test_overhead-objs := bpf_load.o libbpf.o test_overhead_user.o |
a3f74617 | 52 | test_cgrp2_array_pin-objs := libbpf.o test_cgrp2_array_pin.o |
86af8b41 | 53 | xdp1-objs := bpf_load.o libbpf.o xdp1_user.o |
764cbcce BB |
54 | # reuse xdp1 source intentionally |
55 | xdp2-objs := bpf_load.o libbpf.o xdp1_user.o | |
9e6e60ec SD |
56 | test_current_task_under_cgroup-objs := bpf_load.o libbpf.o \ |
57 | test_current_task_under_cgroup_user.o | |
1c47910e | 58 | trace_event-objs := bpf_load.o libbpf.o trace_event_user.o |
72874418 | 59 | sampleip-objs := bpf_load.o libbpf.o sampleip_user.o |
90e02896 | 60 | tc_l2_redirect-objs := bpf_load.o libbpf.o tc_l2_redirect_user.o |
3c731eba AS |
61 | |
62 | # Tell kbuild to always build the programs | |
63 | always := $(hostprogs-y) | |
a8085782 | 64 | always += sockex1_kern.o |
fbe33108 | 65 | always += sockex2_kern.o |
530b2c86 | 66 | always += sockex3_kern.o |
b896c4f9 | 67 | always += tracex1_kern.o |
d822a192 | 68 | always += tracex2_kern.o |
5c7fc2d2 | 69 | always += tracex3_kern.o |
9811e353 | 70 | always += tracex4_kern.o |
5bacd780 | 71 | always += tracex5_kern.o |
47efb302 | 72 | always += tracex6_kern.o |
cf9b1199 | 73 | always += test_probe_write_user_kern.o |
39111695 | 74 | always += trace_output_kern.o |
91bc4822 | 75 | always += tcbpf1_kern.o |
6afb1e28 | 76 | always += tcbpf2_kern.o |
90e02896 | 77 | always += tc_l2_redirect_kern.o |
0fb1170e | 78 | always += lathist_kern.o |
a6ffe7b9 | 79 | always += offwaketime_kern.o |
9d8b612d | 80 | always += spintest_kern.o |
26e90931 | 81 | always += map_perf_test_kern.o |
e3edfdec AS |
82 | always += test_overhead_tp_kern.o |
83 | always += test_overhead_kprobe_kern.o | |
65d472fb | 84 | always += parse_varlen.o parse_simple.o parse_ldabs.o |
a3f74617 | 85 | always += test_cgrp2_tc_kern.o |
86af8b41 | 86 | always += xdp1_kern.o |
764cbcce | 87 | always += xdp2_kern.o |
9e6e60ec | 88 | always += test_current_task_under_cgroup_kern.o |
1c47910e | 89 | always += trace_event_kern.o |
72874418 | 90 | always += sampleip_kern.o |
3c731eba AS |
91 | |
92 | HOSTCFLAGS += -I$(objtree)/usr/include | |
a8085782 AS |
93 | |
94 | HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable | |
42984d7c | 95 | HOSTLOADLIBES_fds_example += -lelf |
a8085782 | 96 | HOSTLOADLIBES_sockex1 += -lelf |
fbe33108 | 97 | HOSTLOADLIBES_sockex2 += -lelf |
530b2c86 | 98 | HOSTLOADLIBES_sockex3 += -lelf |
b896c4f9 | 99 | HOSTLOADLIBES_tracex1 += -lelf |
d822a192 | 100 | HOSTLOADLIBES_tracex2 += -lelf |
5c7fc2d2 | 101 | HOSTLOADLIBES_tracex3 += -lelf |
9811e353 | 102 | HOSTLOADLIBES_tracex4 += -lelf -lrt |
5bacd780 | 103 | HOSTLOADLIBES_tracex5 += -lelf |
47efb302 | 104 | HOSTLOADLIBES_tracex6 += -lelf |
cf9b1199 | 105 | HOSTLOADLIBES_test_probe_write_user += -lelf |
39111695 | 106 | HOSTLOADLIBES_trace_output += -lelf -lrt |
0fb1170e | 107 | HOSTLOADLIBES_lathist += -lelf |
a6ffe7b9 | 108 | HOSTLOADLIBES_offwaketime += -lelf |
9d8b612d | 109 | HOSTLOADLIBES_spintest += -lelf |
26e90931 | 110 | HOSTLOADLIBES_map_perf_test += -lelf -lrt |
e3edfdec | 111 | HOSTLOADLIBES_test_overhead += -lelf -lrt |
86af8b41 | 112 | HOSTLOADLIBES_xdp1 += -lelf |
764cbcce | 113 | HOSTLOADLIBES_xdp2 += -lelf |
9e6e60ec | 114 | HOSTLOADLIBES_test_current_task_under_cgroup += -lelf |
1c47910e | 115 | HOSTLOADLIBES_trace_event += -lelf |
72874418 | 116 | HOSTLOADLIBES_sampleip += -lelf |
90e02896 | 117 | HOSTLOADLIBES_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 | 121 | LLC ?= llc |
bdefbbf2 | 122 | CLANG ?= clang |
6ccfba75 | 123 | |
b62a796c JDB |
124 | # Trick to allow make to be run from this directory |
125 | all: | |
126 | $(MAKE) -C ../../ $$PWD/ | |
127 | ||
128 | clean: | |
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 |
135 | verify_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 | 143 | verify_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 $@ |