Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Jakub Kicinski | 787360f | 2018-05-14 22:35:04 -0700 | [diff] [blame] | 2 | |
| 3 | BPF_SAMPLES_PATH ?= $(abspath $(srctree)/$(src)) |
| 4 | TOOLS_PATH := $(BPF_SAMPLES_PATH)/../../tools |
| 5 | |
Alexei Starovoitov | 3c731eb | 2014-09-26 00:17:07 -0700 | [diff] [blame] | 6 | # List of programs to build |
Martin KaFai Lau | 5db58fa | 2016-11-11 10:55:11 -0800 | [diff] [blame] | 7 | hostprogs-y := test_lru_dist |
Alexei Starovoitov | 03f4723 | 2014-12-01 15:06:36 -0800 | [diff] [blame] | 8 | hostprogs-y += sock_example |
Daniel Borkmann | 42984d7 | 2015-10-29 14:58:10 +0100 | [diff] [blame] | 9 | hostprogs-y += fds_example |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 10 | hostprogs-y += sockex1 |
Alexei Starovoitov | fbe3310 | 2014-12-01 15:06:39 -0800 | [diff] [blame] | 11 | hostprogs-y += sockex2 |
Alexei Starovoitov | 530b2c8 | 2015-05-19 16:59:06 -0700 | [diff] [blame] | 12 | hostprogs-y += sockex3 |
Alexei Starovoitov | b896c4f | 2015-03-25 12:49:23 -0700 | [diff] [blame] | 13 | hostprogs-y += tracex1 |
Alexei Starovoitov | d822a19 | 2015-03-25 12:49:24 -0700 | [diff] [blame] | 14 | hostprogs-y += tracex2 |
Alexei Starovoitov | 5c7fc2d | 2015-03-25 12:49:25 -0700 | [diff] [blame] | 15 | hostprogs-y += tracex3 |
Alexei Starovoitov | 9811e35 | 2015-03-25 12:49:26 -0700 | [diff] [blame] | 16 | hostprogs-y += tracex4 |
Alexei Starovoitov | 5bacd78 | 2015-05-19 16:59:05 -0700 | [diff] [blame] | 17 | hostprogs-y += tracex5 |
Kaixu Xia | 47efb30 | 2015-08-06 07:02:36 +0000 | [diff] [blame] | 18 | hostprogs-y += tracex6 |
Josef Bacik | 965de87 | 2017-12-11 11:36:49 -0500 | [diff] [blame] | 19 | hostprogs-y += tracex7 |
Sargun Dhillon | cf9b119 | 2016-07-25 05:55:02 -0700 | [diff] [blame] | 20 | hostprogs-y += test_probe_write_user |
Alexei Starovoitov | 3911169 | 2015-10-20 20:02:35 -0700 | [diff] [blame] | 21 | hostprogs-y += trace_output |
Daniel Wagner | 0fb1170 | 2015-06-19 16:00:44 +0200 | [diff] [blame] | 22 | hostprogs-y += lathist |
Alexei Starovoitov | a6ffe7b | 2016-02-17 19:58:59 -0800 | [diff] [blame] | 23 | hostprogs-y += offwaketime |
Alexei Starovoitov | 9d8b612 | 2016-03-08 15:07:52 -0800 | [diff] [blame] | 24 | hostprogs-y += spintest |
Alexei Starovoitov | 26e9093 | 2016-03-08 15:07:54 -0800 | [diff] [blame] | 25 | hostprogs-y += map_perf_test |
Alexei Starovoitov | e3edfde | 2016-04-06 18:43:31 -0700 | [diff] [blame] | 26 | hostprogs-y += test_overhead |
Martin KaFai Lau | a3f7461 | 2016-06-30 10:28:45 -0700 | [diff] [blame] | 27 | hostprogs-y += test_cgrp2_array_pin |
Daniel Mack | d8c5b17 | 2016-11-23 16:52:30 +0100 | [diff] [blame] | 28 | hostprogs-y += test_cgrp2_attach |
David Ahern | ad2805d | 2016-12-01 08:48:05 -0800 | [diff] [blame] | 29 | hostprogs-y += test_cgrp2_sock |
David Ahern | 554ae6e | 2016-12-01 08:48:08 -0800 | [diff] [blame] | 30 | hostprogs-y += test_cgrp2_sock2 |
Brenden Blanco | 86af8b4 | 2016-07-19 12:16:51 -0700 | [diff] [blame] | 31 | hostprogs-y += xdp1 |
Brenden Blanco | 764cbcce | 2016-07-19 12:16:57 -0700 | [diff] [blame] | 32 | hostprogs-y += xdp2 |
Christina Jacob | 3e29cd0 | 2017-11-05 08:52:30 +0530 | [diff] [blame] | 33 | hostprogs-y += xdp_router_ipv4 |
Sargun Dhillon | 9e6e60e | 2016-08-12 08:57:04 -0700 | [diff] [blame] | 34 | hostprogs-y += test_current_task_under_cgroup |
Alexei Starovoitov | 1c47910e | 2016-09-01 18:37:25 -0700 | [diff] [blame] | 35 | hostprogs-y += trace_event |
Brendan Gregg | 7287441 | 2016-09-01 18:37:26 -0700 | [diff] [blame] | 36 | hostprogs-y += sampleip |
Martin KaFai Lau | 90e0289 | 2016-11-09 15:36:34 -0800 | [diff] [blame] | 37 | hostprogs-y += tc_l2_redirect |
Thomas Graf | f74599f | 2016-11-30 17:10:11 +0100 | [diff] [blame] | 38 | hostprogs-y += lwt_len_hist |
Martin KaFai Lau | 12d8bb6 | 2016-12-07 15:53:14 -0800 | [diff] [blame] | 39 | hostprogs-y += xdp_tx_iptunnel |
Martin KaFai Lau | fb30d4b | 2017-03-22 10:00:35 -0700 | [diff] [blame] | 40 | hostprogs-y += test_map_in_map |
Chenbo Feng | 51570a5 | 2017-03-22 17:27:36 -0700 | [diff] [blame] | 41 | hostprogs-y += per_socket_stats_example |
John Fastabend | 832622e | 2017-07-17 09:27:28 -0700 | [diff] [blame] | 42 | hostprogs-y += xdp_redirect |
John Fastabend | 9d6e005 | 2017-07-17 09:30:25 -0700 | [diff] [blame] | 43 | hostprogs-y += xdp_redirect_map |
Jesper Dangaard Brouer | fad3917 | 2017-10-16 12:19:49 +0200 | [diff] [blame] | 44 | hostprogs-y += xdp_redirect_cpu |
Jesper Dangaard Brouer | 3ffab54 | 2017-08-29 16:38:11 +0200 | [diff] [blame] | 45 | hostprogs-y += xdp_monitor |
Jesper Dangaard Brouer | 0fca931 | 2018-01-03 11:26:19 +0100 | [diff] [blame] | 46 | hostprogs-y += xdp_rxq_info |
Yonghong Song | 1da236b6b | 2017-08-04 16:00:10 -0700 | [diff] [blame] | 47 | hostprogs-y += syscall_tp |
Leo Yan | c535077 | 2018-02-26 09:19:12 +0800 | [diff] [blame] | 48 | hostprogs-y += cpustat |
Nikita V. Shirokov | c6ffd1f | 2018-04-17 21:42:23 -0700 | [diff] [blame] | 49 | hostprogs-y += xdp_adjust_tail |
Magnus Karlsson | b4b8faa | 2018-05-02 13:01:36 +0200 | [diff] [blame] | 50 | hostprogs-y += xdpsock |
David Ahern | fe61605 | 2018-05-09 20:34:27 -0700 | [diff] [blame] | 51 | hostprogs-y += xdp_fwd |
Yonghong Song | ecb96f7 | 2018-05-24 11:21:56 -0700 | [diff] [blame] | 52 | hostprogs-y += task_fd_query |
Toke Høiland-Jørgensen | 1e54ad2 | 2018-06-25 14:25:02 +0200 | [diff] [blame] | 53 | hostprogs-y += xdp_sample_pkts |
Ira Weiny | 0ac01fe | 2019-03-19 14:11:49 -0700 | [diff] [blame] | 54 | hostprogs-y += ibumad |
brakmo | a1270fe | 2019-03-01 12:38:49 -0800 | [diff] [blame] | 55 | hostprogs-y += hbm |
Alexei Starovoitov | 3c731eb | 2014-09-26 00:17:07 -0700 | [diff] [blame] | 56 | |
Joe Stringer | 43371c8 | 2016-12-14 14:43:39 -0800 | [diff] [blame] | 57 | # Libbpf dependencies |
Jakub Kicinski | 787360f | 2018-05-14 22:35:04 -0700 | [diff] [blame] | 58 | LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a |
| 59 | |
Roman Gushchin | 9d1f159 | 2017-11-05 08:15:33 -0500 | [diff] [blame] | 60 | CGROUP_HELPERS := ../../tools/testing/selftests/bpf/cgroup_helpers.o |
Yonghong Song | 28dbf86 | 2018-04-28 22:28:13 -0700 | [diff] [blame] | 61 | TRACE_HELPERS := ../../tools/testing/selftests/bpf/trace_helpers.o |
Joe Stringer | 43371c8 | 2016-12-14 14:43:39 -0800 | [diff] [blame] | 62 | |
Jakub Kicinski | 1a9b268 | 2019-02-27 19:04:13 -0800 | [diff] [blame] | 63 | fds_example-objs := fds_example.o |
| 64 | sockex1-objs := sockex1_user.o |
| 65 | sockex2-objs := sockex2_user.o |
Jakub Kicinski | 0cc54db | 2018-05-14 22:35:05 -0700 | [diff] [blame] | 66 | sockex3-objs := bpf_load.o sockex3_user.o |
| 67 | tracex1-objs := bpf_load.o tracex1_user.o |
| 68 | tracex2-objs := bpf_load.o tracex2_user.o |
| 69 | tracex3-objs := bpf_load.o tracex3_user.o |
| 70 | tracex4-objs := bpf_load.o tracex4_user.o |
| 71 | tracex5-objs := bpf_load.o tracex5_user.o |
| 72 | tracex6-objs := bpf_load.o tracex6_user.o |
| 73 | tracex7-objs := bpf_load.o tracex7_user.o |
Jakub Kicinski | 0cc54db | 2018-05-14 22:35:05 -0700 | [diff] [blame] | 74 | test_probe_write_user-objs := bpf_load.o test_probe_write_user_user.o |
| 75 | trace_output-objs := bpf_load.o trace_output_user.o $(TRACE_HELPERS) |
| 76 | lathist-objs := bpf_load.o lathist_user.o |
| 77 | offwaketime-objs := bpf_load.o offwaketime_user.o $(TRACE_HELPERS) |
| 78 | spintest-objs := bpf_load.o spintest_user.o $(TRACE_HELPERS) |
| 79 | map_perf_test-objs := bpf_load.o map_perf_test_user.o |
| 80 | test_overhead-objs := bpf_load.o test_overhead_user.o |
| 81 | test_cgrp2_array_pin-objs := test_cgrp2_array_pin.o |
| 82 | test_cgrp2_attach-objs := test_cgrp2_attach.o |
Jakub Kicinski | 0cc54db | 2018-05-14 22:35:05 -0700 | [diff] [blame] | 83 | test_cgrp2_sock-objs := test_cgrp2_sock.o |
| 84 | test_cgrp2_sock2-objs := bpf_load.o test_cgrp2_sock2.o |
| 85 | xdp1-objs := xdp1_user.o |
Brenden Blanco | 764cbcce | 2016-07-19 12:16:57 -0700 | [diff] [blame] | 86 | # reuse xdp1 source intentionally |
Jakub Kicinski | 0cc54db | 2018-05-14 22:35:05 -0700 | [diff] [blame] | 87 | xdp2-objs := xdp1_user.o |
Maciej Fijalkowski | bbaf602 | 2019-02-01 22:42:25 +0100 | [diff] [blame] | 88 | xdp_router_ipv4-objs := xdp_router_ipv4_user.o |
Jakub Kicinski | 0cc54db | 2018-05-14 22:35:05 -0700 | [diff] [blame] | 89 | test_current_task_under_cgroup-objs := bpf_load.o $(CGROUP_HELPERS) \ |
Sargun Dhillon | 9e6e60e | 2016-08-12 08:57:04 -0700 | [diff] [blame] | 90 | test_current_task_under_cgroup_user.o |
Jakub Kicinski | 0cc54db | 2018-05-14 22:35:05 -0700 | [diff] [blame] | 91 | trace_event-objs := bpf_load.o trace_event_user.o $(TRACE_HELPERS) |
| 92 | sampleip-objs := bpf_load.o sampleip_user.o $(TRACE_HELPERS) |
| 93 | tc_l2_redirect-objs := bpf_load.o tc_l2_redirect_user.o |
| 94 | lwt_len_hist-objs := bpf_load.o lwt_len_hist_user.o |
Maciej Fijalkowski | bbaf602 | 2019-02-01 22:42:25 +0100 | [diff] [blame] | 95 | xdp_tx_iptunnel-objs := xdp_tx_iptunnel_user.o |
Jakub Kicinski | 0cc54db | 2018-05-14 22:35:05 -0700 | [diff] [blame] | 96 | test_map_in_map-objs := bpf_load.o test_map_in_map_user.o |
| 97 | per_socket_stats_example-objs := cookie_uid_helper_example.o |
Maciej Fijalkowski | bbaf602 | 2019-02-01 22:42:25 +0100 | [diff] [blame] | 98 | xdp_redirect-objs := xdp_redirect_user.o |
| 99 | xdp_redirect_map-objs := xdp_redirect_map_user.o |
Jakub Kicinski | 0cc54db | 2018-05-14 22:35:05 -0700 | [diff] [blame] | 100 | xdp_redirect_cpu-objs := bpf_load.o xdp_redirect_cpu_user.o |
| 101 | xdp_monitor-objs := bpf_load.o xdp_monitor_user.o |
| 102 | xdp_rxq_info-objs := xdp_rxq_info_user.o |
| 103 | syscall_tp-objs := bpf_load.o syscall_tp_user.o |
| 104 | cpustat-objs := bpf_load.o cpustat_user.o |
| 105 | xdp_adjust_tail-objs := xdp_adjust_tail_user.o |
Jakub Kicinski | 6748182 | 2018-07-26 14:32:21 -0700 | [diff] [blame] | 106 | xdpsock-objs := xdpsock_user.o |
Jakub Kicinski | e1a40ef | 2018-07-26 14:32:20 -0700 | [diff] [blame] | 107 | xdp_fwd-objs := xdp_fwd_user.o |
Yonghong Song | ecb96f7 | 2018-05-24 11:21:56 -0700 | [diff] [blame] | 108 | task_fd_query-objs := bpf_load.o task_fd_query_user.o $(TRACE_HELPERS) |
Toke Høiland-Jørgensen | 1e54ad2 | 2018-06-25 14:25:02 +0200 | [diff] [blame] | 109 | xdp_sample_pkts-objs := xdp_sample_pkts_user.o $(TRACE_HELPERS) |
Ira Weiny | 0ac01fe | 2019-03-19 14:11:49 -0700 | [diff] [blame] | 110 | ibumad-objs := bpf_load.o ibumad_user.o $(TRACE_HELPERS) |
brakmo | a1270fe | 2019-03-01 12:38:49 -0800 | [diff] [blame] | 111 | hbm-objs := bpf_load.o hbm.o $(CGROUP_HELPERS) |
Alexei Starovoitov | 3c731eb | 2014-09-26 00:17:07 -0700 | [diff] [blame] | 112 | |
| 113 | # Tell kbuild to always build the programs |
| 114 | always := $(hostprogs-y) |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 115 | always += sockex1_kern.o |
Alexei Starovoitov | fbe3310 | 2014-12-01 15:06:39 -0800 | [diff] [blame] | 116 | always += sockex2_kern.o |
Alexei Starovoitov | 530b2c8 | 2015-05-19 16:59:06 -0700 | [diff] [blame] | 117 | always += sockex3_kern.o |
Alexei Starovoitov | b896c4f | 2015-03-25 12:49:23 -0700 | [diff] [blame] | 118 | always += tracex1_kern.o |
Alexei Starovoitov | d822a19 | 2015-03-25 12:49:24 -0700 | [diff] [blame] | 119 | always += tracex2_kern.o |
Alexei Starovoitov | 5c7fc2d | 2015-03-25 12:49:25 -0700 | [diff] [blame] | 120 | always += tracex3_kern.o |
Alexei Starovoitov | 9811e35 | 2015-03-25 12:49:26 -0700 | [diff] [blame] | 121 | always += tracex4_kern.o |
Alexei Starovoitov | 5bacd78 | 2015-05-19 16:59:05 -0700 | [diff] [blame] | 122 | always += tracex5_kern.o |
Kaixu Xia | 47efb30 | 2015-08-06 07:02:36 +0000 | [diff] [blame] | 123 | always += tracex6_kern.o |
Josef Bacik | 965de87 | 2017-12-11 11:36:49 -0500 | [diff] [blame] | 124 | always += tracex7_kern.o |
David Ahern | 554ae6e | 2016-12-01 08:48:08 -0800 | [diff] [blame] | 125 | always += sock_flags_kern.o |
Sargun Dhillon | cf9b119 | 2016-07-25 05:55:02 -0700 | [diff] [blame] | 126 | always += test_probe_write_user_kern.o |
Alexei Starovoitov | 3911169 | 2015-10-20 20:02:35 -0700 | [diff] [blame] | 127 | always += trace_output_kern.o |
Alexei Starovoitov | 91bc4822 | 2015-04-01 17:12:13 -0700 | [diff] [blame] | 128 | always += tcbpf1_kern.o |
Martin KaFai Lau | 90e0289 | 2016-11-09 15:36:34 -0800 | [diff] [blame] | 129 | always += tc_l2_redirect_kern.o |
Daniel Wagner | 0fb1170 | 2015-06-19 16:00:44 +0200 | [diff] [blame] | 130 | always += lathist_kern.o |
Alexei Starovoitov | a6ffe7b | 2016-02-17 19:58:59 -0800 | [diff] [blame] | 131 | always += offwaketime_kern.o |
Alexei Starovoitov | 9d8b612 | 2016-03-08 15:07:52 -0800 | [diff] [blame] | 132 | always += spintest_kern.o |
Alexei Starovoitov | 26e9093 | 2016-03-08 15:07:54 -0800 | [diff] [blame] | 133 | always += map_perf_test_kern.o |
Alexei Starovoitov | e3edfde | 2016-04-06 18:43:31 -0700 | [diff] [blame] | 134 | always += test_overhead_tp_kern.o |
Alexei Starovoitov | 4662a4e | 2018-03-28 12:05:39 -0700 | [diff] [blame] | 135 | always += test_overhead_raw_tp_kern.o |
Alexei Starovoitov | e3edfde | 2016-04-06 18:43:31 -0700 | [diff] [blame] | 136 | always += test_overhead_kprobe_kern.o |
Alexei Starovoitov | 65d472f | 2016-05-05 19:49:14 -0700 | [diff] [blame] | 137 | always += parse_varlen.o parse_simple.o parse_ldabs.o |
Martin KaFai Lau | a3f7461 | 2016-06-30 10:28:45 -0700 | [diff] [blame] | 138 | always += test_cgrp2_tc_kern.o |
Brenden Blanco | 86af8b4 | 2016-07-19 12:16:51 -0700 | [diff] [blame] | 139 | always += xdp1_kern.o |
Brenden Blanco | 764cbcce | 2016-07-19 12:16:57 -0700 | [diff] [blame] | 140 | always += xdp2_kern.o |
Christina Jacob | 3e29cd0 | 2017-11-05 08:52:30 +0530 | [diff] [blame] | 141 | always += xdp_router_ipv4_kern.o |
Sargun Dhillon | 9e6e60e | 2016-08-12 08:57:04 -0700 | [diff] [blame] | 142 | always += test_current_task_under_cgroup_kern.o |
Alexei Starovoitov | 1c47910e | 2016-09-01 18:37:25 -0700 | [diff] [blame] | 143 | always += trace_event_kern.o |
Brendan Gregg | 7287441 | 2016-09-01 18:37:26 -0700 | [diff] [blame] | 144 | always += sampleip_kern.o |
Thomas Graf | f74599f | 2016-11-30 17:10:11 +0100 | [diff] [blame] | 145 | always += lwt_len_hist_kern.o |
Martin KaFai Lau | 12d8bb6 | 2016-12-07 15:53:14 -0800 | [diff] [blame] | 146 | always += xdp_tx_iptunnel_kern.o |
Martin KaFai Lau | fb30d4b | 2017-03-22 10:00:35 -0700 | [diff] [blame] | 147 | always += test_map_in_map_kern.o |
Chenbo Feng | 51570a5 | 2017-03-22 17:27:36 -0700 | [diff] [blame] | 148 | always += cookie_uid_helper_example.o |
Lawrence Brakmo | 61bc4d8 | 2017-06-30 20:02:43 -0700 | [diff] [blame] | 149 | always += tcp_synrto_kern.o |
Lawrence Brakmo | c400296 | 2017-06-30 20:02:45 -0700 | [diff] [blame] | 150 | always += tcp_rwnd_kern.o |
Lawrence Brakmo | d9925368 | 2017-06-30 20:02:48 -0700 | [diff] [blame] | 151 | always += tcp_bufs_kern.o |
Lawrence Brakmo | bb56d44 | 2017-06-30 20:02:50 -0700 | [diff] [blame] | 152 | always += tcp_cong_kern.o |
Lawrence Brakmo | 7bc62e2 | 2017-06-30 20:02:52 -0700 | [diff] [blame] | 153 | always += tcp_iw_kern.o |
Lawrence Brakmo | 6c4a01b | 2017-06-30 20:02:54 -0700 | [diff] [blame] | 154 | always += tcp_clamp_kern.o |
Lawrence Brakmo | c890063 | 2017-10-20 11:05:42 -0700 | [diff] [blame] | 155 | always += tcp_basertt_kern.o |
Nikita V. Shirokov | acb4ea9 | 2018-08-30 07:51:54 -0700 | [diff] [blame] | 156 | always += tcp_tos_reflect_kern.o |
Stanislav Fomichev | 3953388 | 2019-07-02 09:14:02 -0700 | [diff] [blame] | 157 | always += tcp_dumpstats_kern.o |
John Fastabend | 832622e | 2017-07-17 09:27:28 -0700 | [diff] [blame] | 158 | always += xdp_redirect_kern.o |
John Fastabend | 9d6e005 | 2017-07-17 09:30:25 -0700 | [diff] [blame] | 159 | always += xdp_redirect_map_kern.o |
Jesper Dangaard Brouer | fad3917 | 2017-10-16 12:19:49 +0200 | [diff] [blame] | 160 | always += xdp_redirect_cpu_kern.o |
Jesper Dangaard Brouer | 3ffab54 | 2017-08-29 16:38:11 +0200 | [diff] [blame] | 161 | always += xdp_monitor_kern.o |
Jesper Dangaard Brouer | 0fca931 | 2018-01-03 11:26:19 +0100 | [diff] [blame] | 162 | always += xdp_rxq_info_kern.o |
Jesper Dangaard Brouer | 36e04a2 | 2018-01-10 18:21:44 +0100 | [diff] [blame] | 163 | always += xdp2skb_meta_kern.o |
Yonghong Song | 1da236b6b | 2017-08-04 16:00:10 -0700 | [diff] [blame] | 164 | always += syscall_tp_kern.o |
Leo Yan | c535077 | 2018-02-26 09:19:12 +0800 | [diff] [blame] | 165 | always += cpustat_kern.o |
Nikita V. Shirokov | c6ffd1f | 2018-04-17 21:42:23 -0700 | [diff] [blame] | 166 | always += xdp_adjust_tail_kern.o |
David Ahern | fe61605 | 2018-05-09 20:34:27 -0700 | [diff] [blame] | 167 | always += xdp_fwd_kern.o |
Yonghong Song | ecb96f7 | 2018-05-24 11:21:56 -0700 | [diff] [blame] | 168 | always += task_fd_query_kern.o |
Toke Høiland-Jørgensen | 1e54ad2 | 2018-06-25 14:25:02 +0200 | [diff] [blame] | 169 | always += xdp_sample_pkts_kern.o |
Ira Weiny | 0ac01fe | 2019-03-19 14:11:49 -0700 | [diff] [blame] | 170 | always += ibumad_kern.o |
brakmo | 187d073 | 2019-03-01 12:38:48 -0800 | [diff] [blame] | 171 | always += hbm_out_kern.o |
brakmo | 71634d7 | 2019-07-02 15:09:52 -0700 | [diff] [blame] | 172 | always += hbm_edt_kern.o |
Alexei Starovoitov | 3c731eb | 2014-09-26 00:17:07 -0700 | [diff] [blame] | 173 | |
Laura Abbott | 96f14fe | 2018-07-09 17:45:58 -0700 | [diff] [blame] | 174 | KBUILD_HOSTCFLAGS += -I$(objtree)/usr/include |
Prashant Bhole | b552d33 | 2019-06-14 15:43:18 +0900 | [diff] [blame] | 175 | KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/bpf/ |
Laura Abbott | 96f14fe | 2018-07-09 17:45:58 -0700 | [diff] [blame] | 176 | KBUILD_HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/ |
| 177 | KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include |
| 178 | KBUILD_HOSTCFLAGS += -I$(srctree)/tools/perf |
Björn Töpel | 04ec044b | 2019-10-01 13:33:07 +0200 | [diff] [blame] | 179 | KBUILD_HOSTCFLAGS += -DHAVE_ATTR_TEST=0 |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 180 | |
| 181 | HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable |
Jakub Kicinski | d0cabbb | 2018-05-10 10:24:40 -0700 | [diff] [blame] | 182 | |
Laura Abbott | 8377bd2 | 2018-07-09 17:46:01 -0700 | [diff] [blame] | 183 | KBUILD_HOSTLDLIBS += $(LIBBPF) -lelf |
| 184 | HOSTLDLIBS_tracex4 += -lrt |
| 185 | HOSTLDLIBS_trace_output += -lrt |
| 186 | HOSTLDLIBS_map_perf_test += -lrt |
| 187 | HOSTLDLIBS_test_overhead += -lrt |
| 188 | HOSTLDLIBS_xdpsock += -pthread |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 189 | |
Jesper Dangaard Brouer | bdefbbf | 2016-04-28 14:21:14 +0200 | [diff] [blame] | 190 | # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline: |
| 191 | # make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang |
Jesper Dangaard Brouer | 6ccfba7 | 2016-04-28 14:20:53 +0200 | [diff] [blame] | 192 | LLC ?= llc |
Jesper Dangaard Brouer | bdefbbf | 2016-04-28 14:21:14 +0200 | [diff] [blame] | 193 | CLANG ?= clang |
Taeung Song | 9778cfd | 2018-07-26 19:13:44 +0900 | [diff] [blame] | 194 | LLVM_OBJCOPY ?= llvm-objcopy |
| 195 | BTF_PAHOLE ?= pahole |
Jesper Dangaard Brouer | 6ccfba7 | 2016-04-28 14:20:53 +0200 | [diff] [blame] | 196 | |
Joel Fernandes | 876e88e | 2017-09-20 09:11:57 -0700 | [diff] [blame] | 197 | # Detect that we're cross compiling and use the cross compiler |
| 198 | ifdef CROSS_COMPILE |
| 199 | HOSTCC = $(CROSS_COMPILE)gcc |
Abhijit Ayarekar | 9db9583 | 2017-10-13 12:24:06 -0700 | [diff] [blame] | 200 | CLANG_ARCH_ARGS = -target $(ARCH) |
Joel Fernandes | 876e88e | 2017-09-20 09:11:57 -0700 | [diff] [blame] | 201 | endif |
| 202 | |
Jakub Kicinski | 0ed3cc4 | 2019-06-07 10:11:16 -0700 | [diff] [blame] | 203 | # Don't evaluate probes and warnings if we need to run make recursively |
| 204 | ifneq ($(src),) |
Jakub Kicinski | 07c3bbd | 2019-06-05 16:47:22 -0700 | [diff] [blame] | 205 | HDR_PROBE := $(shell echo "\#include <linux/types.h>\n struct list_head { int a; }; int main() { return 0; }" | \ |
| 206 | $(HOSTCC) $(KBUILD_HOSTCFLAGS) -x c - -o /dev/null 2>/dev/null && \ |
| 207 | echo okay) |
| 208 | |
| 209 | ifeq ($(HDR_PROBE),) |
| 210 | $(warning WARNING: Detected possible issues with include path.) |
| 211 | $(warning WARNING: Please install kernel headers locally (make headers_install).) |
| 212 | endif |
| 213 | |
Taeung Song | 9778cfd | 2018-07-26 19:13:44 +0900 | [diff] [blame] | 214 | BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris) |
| 215 | BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF) |
| 216 | BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm') |
Yonghong Song | 9ce6ae2 | 2018-11-19 15:29:17 -0800 | [diff] [blame] | 217 | BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \ |
| 218 | $(CLANG) -target bpf -O2 -g -c -x c - -o ./llvm_btf_verify.o; \ |
| 219 | readelf -S ./llvm_btf_verify.o | grep BTF; \ |
| 220 | /bin/rm -f ./llvm_btf_verify.o) |
Taeung Song | 9778cfd | 2018-07-26 19:13:44 +0900 | [diff] [blame] | 221 | |
Yonghong Song | 9ce6ae2 | 2018-11-19 15:29:17 -0800 | [diff] [blame] | 222 | ifneq ($(BTF_LLVM_PROBE),) |
| 223 | EXTRA_CFLAGS += -g |
| 224 | else |
Taeung Song | 9778cfd | 2018-07-26 19:13:44 +0900 | [diff] [blame] | 225 | ifneq ($(and $(BTF_LLC_PROBE),$(BTF_PAHOLE_PROBE),$(BTF_OBJCOPY_PROBE)),) |
| 226 | EXTRA_CFLAGS += -g |
| 227 | LLC_FLAGS += -mattr=dwarfris |
| 228 | DWARF2BTF = y |
| 229 | endif |
Yonghong Song | 9ce6ae2 | 2018-11-19 15:29:17 -0800 | [diff] [blame] | 230 | endif |
Jakub Kicinski | 0ed3cc4 | 2019-06-07 10:11:16 -0700 | [diff] [blame] | 231 | endif |
Taeung Song | 9778cfd | 2018-07-26 19:13:44 +0900 | [diff] [blame] | 232 | |
Jesper Dangaard Brouer | b62a796 | 2016-04-28 14:21:09 +0200 | [diff] [blame] | 233 | # Trick to allow make to be run from this directory |
Jakub Kicinski | 787360f | 2018-05-14 22:35:04 -0700 | [diff] [blame] | 234 | all: |
| 235 | $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR) |
Jesper Dangaard Brouer | b62a796 | 2016-04-28 14:21:09 +0200 | [diff] [blame] | 236 | |
| 237 | clean: |
Uwe Kleine-König | e19b7ce | 2016-11-22 09:30:26 +0100 | [diff] [blame] | 238 | $(MAKE) -C ../../ M=$(CURDIR) clean |
Jesper Dangaard Brouer | b62a796 | 2016-04-28 14:21:09 +0200 | [diff] [blame] | 239 | @rm -f *~ |
| 240 | |
Mickaël Salaün | c25ef6a | 2018-01-26 01:39:30 +0100 | [diff] [blame] | 241 | $(LIBBPF): FORCE |
Jakub Kicinski | 787360f | 2018-05-14 22:35:04 -0700 | [diff] [blame] | 242 | # Fix up variables inherited from Kbuild that tools/ build system won't like |
| 243 | $(MAKE) -C $(dir $@) RM='rm -rf' LDFLAGS= srctree=$(BPF_SAMPLES_PATH)/../../ O= |
Mickaël Salaün | c25ef6a | 2018-01-26 01:39:30 +0100 | [diff] [blame] | 244 | |
David Daney | 4b7190e | 2017-06-13 16:49:38 -0700 | [diff] [blame] | 245 | $(obj)/syscall_nrs.h: $(obj)/syscall_nrs.s FORCE |
| 246 | $(call filechk,offsets,__SYSCALL_NRS_H__) |
| 247 | |
Masahiro Yamada | 2c667d7 | 2018-12-22 18:50:34 +0900 | [diff] [blame] | 248 | targets += syscall_nrs.s |
David Daney | 4b7190e | 2017-06-13 16:49:38 -0700 | [diff] [blame] | 249 | clean-files += syscall_nrs.h |
| 250 | |
| 251 | FORCE: |
| 252 | |
| 253 | |
Jesper Dangaard Brouer | bdefbbf | 2016-04-28 14:21:14 +0200 | [diff] [blame] | 254 | # Verify LLVM compiler tools are available and bpf target is supported by llc |
| 255 | .PHONY: verify_cmds verify_target_bpf $(CLANG) $(LLC) |
Jesper Dangaard Brouer | 7b01dd5 | 2016-04-28 14:20:58 +0200 | [diff] [blame] | 256 | |
Jesper Dangaard Brouer | bdefbbf | 2016-04-28 14:21:14 +0200 | [diff] [blame] | 257 | verify_cmds: $(CLANG) $(LLC) |
| 258 | @for TOOL in $^ ; do \ |
| 259 | if ! (which -- "$${TOOL}" > /dev/null 2>&1); then \ |
| 260 | echo "*** ERROR: Cannot find LLVM tool $${TOOL}" ;\ |
| 261 | exit 1; \ |
| 262 | else true; fi; \ |
| 263 | done |
Jesper Dangaard Brouer | 7b01dd5 | 2016-04-28 14:20:58 +0200 | [diff] [blame] | 264 | |
Jesper Dangaard Brouer | bdefbbf | 2016-04-28 14:21:14 +0200 | [diff] [blame] | 265 | verify_target_bpf: verify_cmds |
Jesper Dangaard Brouer | 7b01dd5 | 2016-04-28 14:20:58 +0200 | [diff] [blame] | 266 | @if ! (${LLC} -march=bpf -mattr=help > /dev/null 2>&1); then \ |
| 267 | echo "*** ERROR: LLVM (${LLC}) does not support 'bpf' target" ;\ |
| 268 | echo " NOTICE: LLVM version >= 3.7.1 required" ;\ |
| 269 | exit 2; \ |
| 270 | else true; fi |
| 271 | |
Jakub Kicinski | 787360f | 2018-05-14 22:35:04 -0700 | [diff] [blame] | 272 | $(BPF_SAMPLES_PATH)/*.c: verify_target_bpf $(LIBBPF) |
| 273 | $(src)/*.c: verify_target_bpf $(LIBBPF) |
Jesper Dangaard Brouer | 7b01dd5 | 2016-04-28 14:20:58 +0200 | [diff] [blame] | 274 | |
David Daney | 4b7190e | 2017-06-13 16:49:38 -0700 | [diff] [blame] | 275 | $(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h |
brakmo | 187d073 | 2019-03-01 12:38:48 -0800 | [diff] [blame] | 276 | $(obj)/hbm_out_kern.o: $(src)/hbm.h $(src)/hbm_kern.h |
brakmo | a1270fe | 2019-03-01 12:38:49 -0800 | [diff] [blame] | 277 | $(obj)/hbm.o: $(src)/hbm.h |
brakmo | 71634d7 | 2019-07-02 15:09:52 -0700 | [diff] [blame] | 278 | $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h |
David Daney | 4b7190e | 2017-06-13 16:49:38 -0700 | [diff] [blame] | 279 | |
Naveen N. Rao | 128d151 | 2016-04-04 22:31:33 +0530 | [diff] [blame] | 280 | # asm/sysreg.h - inline assembly used by it is incompatible with llvm. |
| 281 | # But, there is no easy way to fix it, so just exclude it since it is |
Yang Shi | 30b50aa | 2015-11-12 14:07:46 -0800 | [diff] [blame] | 282 | # useless for BPF samples. |
Brenden Blanco | b88c06e | 2015-05-11 21:25:51 -0700 | [diff] [blame] | 283 | $(obj)/%.o: $(src)/%.c |
Jakub Kicinski | 768759e | 2018-05-14 22:35:06 -0700 | [diff] [blame] | 284 | @echo " CLANG-bpf " $@ |
| 285 | $(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \ |
Yonghong Song | 5333502 | 2017-07-10 14:04:28 -0700 | [diff] [blame] | 286 | -I$(srctree)/tools/testing/selftests/bpf/ \ |
Alexei Starovoitov | b1ae32d | 2018-05-13 12:32:22 -0700 | [diff] [blame] | 287 | -D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \ |
Ilya Leoshkevich | 81f522f | 2019-07-15 11:11:03 +0200 | [diff] [blame] | 288 | -D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \ |
Alexei Starovoitov | 69a9d09 | 2016-12-01 18:31:12 -0800 | [diff] [blame] | 289 | -Wno-gnu-variable-sized-type-not-at-end \ |
| 290 | -Wno-address-of-packed-member -Wno-tautological-compare \ |
Abhijit Ayarekar | 9db9583 | 2017-10-13 12:24:06 -0700 | [diff] [blame] | 291 | -Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \ |
Yonghong Song | 6bf3bbe | 2019-01-12 15:04:30 -0800 | [diff] [blame] | 292 | -I$(srctree)/samples/bpf/ -include asm_goto_workaround.h \ |
Taeung Song | 9778cfd | 2018-07-26 19:13:44 +0900 | [diff] [blame] | 293 | -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $@ |
| 294 | ifeq ($(DWARF2BTF),y) |
| 295 | $(BTF_PAHOLE) -J $@ |
| 296 | endif |