Alexei Starovoitov | 3c731eb | 2014-09-26 00:17:07 -0700 | [diff] [blame] | 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 |
Alexei Starovoitov | ffb65f2 | 2014-11-13 17:36:48 -0800 | [diff] [blame] | 5 | hostprogs-y := test_verifier test_maps |
Alexei Starovoitov | 03f4723 | 2014-12-01 15:06:36 -0800 | [diff] [blame] | 6 | hostprogs-y += sock_example |
Daniel Borkmann | 42984d7 | 2015-10-29 14:58:10 +0100 | [diff] [blame] | 7 | hostprogs-y += fds_example |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 8 | hostprogs-y += sockex1 |
Alexei Starovoitov | fbe3310 | 2014-12-01 15:06:39 -0800 | [diff] [blame] | 9 | hostprogs-y += sockex2 |
Alexei Starovoitov | 530b2c8 | 2015-05-19 16:59:06 -0700 | [diff] [blame] | 10 | hostprogs-y += sockex3 |
Alexei Starovoitov | b896c4f | 2015-03-25 12:49:23 -0700 | [diff] [blame] | 11 | hostprogs-y += tracex1 |
Alexei Starovoitov | d822a19 | 2015-03-25 12:49:24 -0700 | [diff] [blame] | 12 | hostprogs-y += tracex2 |
Alexei Starovoitov | 5c7fc2d | 2015-03-25 12:49:25 -0700 | [diff] [blame] | 13 | hostprogs-y += tracex3 |
Alexei Starovoitov | 9811e35 | 2015-03-25 12:49:26 -0700 | [diff] [blame] | 14 | hostprogs-y += tracex4 |
Alexei Starovoitov | 5bacd78 | 2015-05-19 16:59:05 -0700 | [diff] [blame] | 15 | hostprogs-y += tracex5 |
Kaixu Xia | 47efb30 | 2015-08-06 07:02:36 +0000 | [diff] [blame] | 16 | hostprogs-y += tracex6 |
Alexei Starovoitov | 3911169 | 2015-10-20 20:02:35 -0700 | [diff] [blame] | 17 | hostprogs-y += trace_output |
Daniel Wagner | 0fb1170 | 2015-06-19 16:00:44 +0200 | [diff] [blame] | 18 | hostprogs-y += lathist |
Alexei Starovoitov | a6ffe7b | 2016-02-17 19:58:59 -0800 | [diff] [blame] | 19 | hostprogs-y += offwaketime |
Alexei Starovoitov | 9d8b612 | 2016-03-08 15:07:52 -0800 | [diff] [blame^] | 20 | hostprogs-y += spintest |
Alexei Starovoitov | 3c731eb | 2014-09-26 00:17:07 -0700 | [diff] [blame] | 21 | |
| 22 | test_verifier-objs := test_verifier.o libbpf.o |
Alexei Starovoitov | ffb65f2 | 2014-11-13 17:36:48 -0800 | [diff] [blame] | 23 | test_maps-objs := test_maps.o libbpf.o |
Alexei Starovoitov | 03f4723 | 2014-12-01 15:06:36 -0800 | [diff] [blame] | 24 | sock_example-objs := sock_example.o libbpf.o |
Daniel Borkmann | 42984d7 | 2015-10-29 14:58:10 +0100 | [diff] [blame] | 25 | fds_example-objs := bpf_load.o libbpf.o fds_example.o |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 26 | sockex1-objs := bpf_load.o libbpf.o sockex1_user.o |
Alexei Starovoitov | fbe3310 | 2014-12-01 15:06:39 -0800 | [diff] [blame] | 27 | sockex2-objs := bpf_load.o libbpf.o sockex2_user.o |
Alexei Starovoitov | 530b2c8 | 2015-05-19 16:59:06 -0700 | [diff] [blame] | 28 | sockex3-objs := bpf_load.o libbpf.o sockex3_user.o |
Alexei Starovoitov | b896c4f | 2015-03-25 12:49:23 -0700 | [diff] [blame] | 29 | tracex1-objs := bpf_load.o libbpf.o tracex1_user.o |
Alexei Starovoitov | d822a19 | 2015-03-25 12:49:24 -0700 | [diff] [blame] | 30 | tracex2-objs := bpf_load.o libbpf.o tracex2_user.o |
Alexei Starovoitov | 5c7fc2d | 2015-03-25 12:49:25 -0700 | [diff] [blame] | 31 | tracex3-objs := bpf_load.o libbpf.o tracex3_user.o |
Alexei Starovoitov | 9811e35 | 2015-03-25 12:49:26 -0700 | [diff] [blame] | 32 | tracex4-objs := bpf_load.o libbpf.o tracex4_user.o |
Alexei Starovoitov | 5bacd78 | 2015-05-19 16:59:05 -0700 | [diff] [blame] | 33 | tracex5-objs := bpf_load.o libbpf.o tracex5_user.o |
Kaixu Xia | 47efb30 | 2015-08-06 07:02:36 +0000 | [diff] [blame] | 34 | tracex6-objs := bpf_load.o libbpf.o tracex6_user.o |
Alexei Starovoitov | 3911169 | 2015-10-20 20:02:35 -0700 | [diff] [blame] | 35 | trace_output-objs := bpf_load.o libbpf.o trace_output_user.o |
Daniel Wagner | 0fb1170 | 2015-06-19 16:00:44 +0200 | [diff] [blame] | 36 | lathist-objs := bpf_load.o libbpf.o lathist_user.o |
Alexei Starovoitov | a6ffe7b | 2016-02-17 19:58:59 -0800 | [diff] [blame] | 37 | offwaketime-objs := bpf_load.o libbpf.o offwaketime_user.o |
Alexei Starovoitov | 9d8b612 | 2016-03-08 15:07:52 -0800 | [diff] [blame^] | 38 | spintest-objs := bpf_load.o libbpf.o spintest_user.o |
Alexei Starovoitov | 3c731eb | 2014-09-26 00:17:07 -0700 | [diff] [blame] | 39 | |
| 40 | # Tell kbuild to always build the programs |
| 41 | always := $(hostprogs-y) |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 42 | always += sockex1_kern.o |
Alexei Starovoitov | fbe3310 | 2014-12-01 15:06:39 -0800 | [diff] [blame] | 43 | always += sockex2_kern.o |
Alexei Starovoitov | 530b2c8 | 2015-05-19 16:59:06 -0700 | [diff] [blame] | 44 | always += sockex3_kern.o |
Alexei Starovoitov | b896c4f | 2015-03-25 12:49:23 -0700 | [diff] [blame] | 45 | always += tracex1_kern.o |
Alexei Starovoitov | d822a19 | 2015-03-25 12:49:24 -0700 | [diff] [blame] | 46 | always += tracex2_kern.o |
Alexei Starovoitov | 5c7fc2d | 2015-03-25 12:49:25 -0700 | [diff] [blame] | 47 | always += tracex3_kern.o |
Alexei Starovoitov | 9811e35 | 2015-03-25 12:49:26 -0700 | [diff] [blame] | 48 | always += tracex4_kern.o |
Alexei Starovoitov | 5bacd78 | 2015-05-19 16:59:05 -0700 | [diff] [blame] | 49 | always += tracex5_kern.o |
Kaixu Xia | 47efb30 | 2015-08-06 07:02:36 +0000 | [diff] [blame] | 50 | always += tracex6_kern.o |
Alexei Starovoitov | 3911169 | 2015-10-20 20:02:35 -0700 | [diff] [blame] | 51 | always += trace_output_kern.o |
Alexei Starovoitov | 91bc4822 | 2015-04-01 17:12:13 -0700 | [diff] [blame] | 52 | always += tcbpf1_kern.o |
Daniel Wagner | 0fb1170 | 2015-06-19 16:00:44 +0200 | [diff] [blame] | 53 | always += lathist_kern.o |
Alexei Starovoitov | a6ffe7b | 2016-02-17 19:58:59 -0800 | [diff] [blame] | 54 | always += offwaketime_kern.o |
Alexei Starovoitov | 9d8b612 | 2016-03-08 15:07:52 -0800 | [diff] [blame^] | 55 | always += spintest_kern.o |
Alexei Starovoitov | 3c731eb | 2014-09-26 00:17:07 -0700 | [diff] [blame] | 56 | |
| 57 | HOSTCFLAGS += -I$(objtree)/usr/include |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 58 | |
| 59 | HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable |
Daniel Borkmann | 42984d7 | 2015-10-29 14:58:10 +0100 | [diff] [blame] | 60 | HOSTLOADLIBES_fds_example += -lelf |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 61 | HOSTLOADLIBES_sockex1 += -lelf |
Alexei Starovoitov | fbe3310 | 2014-12-01 15:06:39 -0800 | [diff] [blame] | 62 | HOSTLOADLIBES_sockex2 += -lelf |
Alexei Starovoitov | 530b2c8 | 2015-05-19 16:59:06 -0700 | [diff] [blame] | 63 | HOSTLOADLIBES_sockex3 += -lelf |
Alexei Starovoitov | b896c4f | 2015-03-25 12:49:23 -0700 | [diff] [blame] | 64 | HOSTLOADLIBES_tracex1 += -lelf |
Alexei Starovoitov | d822a19 | 2015-03-25 12:49:24 -0700 | [diff] [blame] | 65 | HOSTLOADLIBES_tracex2 += -lelf |
Alexei Starovoitov | 5c7fc2d | 2015-03-25 12:49:25 -0700 | [diff] [blame] | 66 | HOSTLOADLIBES_tracex3 += -lelf |
Alexei Starovoitov | 9811e35 | 2015-03-25 12:49:26 -0700 | [diff] [blame] | 67 | HOSTLOADLIBES_tracex4 += -lelf -lrt |
Alexei Starovoitov | 5bacd78 | 2015-05-19 16:59:05 -0700 | [diff] [blame] | 68 | HOSTLOADLIBES_tracex5 += -lelf |
Kaixu Xia | 47efb30 | 2015-08-06 07:02:36 +0000 | [diff] [blame] | 69 | HOSTLOADLIBES_tracex6 += -lelf |
Alexei Starovoitov | 3911169 | 2015-10-20 20:02:35 -0700 | [diff] [blame] | 70 | HOSTLOADLIBES_trace_output += -lelf -lrt |
Daniel Wagner | 0fb1170 | 2015-06-19 16:00:44 +0200 | [diff] [blame] | 71 | HOSTLOADLIBES_lathist += -lelf |
Alexei Starovoitov | a6ffe7b | 2016-02-17 19:58:59 -0800 | [diff] [blame] | 72 | HOSTLOADLIBES_offwaketime += -lelf |
Alexei Starovoitov | 9d8b612 | 2016-03-08 15:07:52 -0800 | [diff] [blame^] | 73 | HOSTLOADLIBES_spintest += -lelf |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 74 | |
| 75 | # point this to your LLVM backend with bpf support |
| 76 | LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc |
| 77 | |
Yang Shi | 30b50aa | 2015-11-12 14:07:46 -0800 | [diff] [blame] | 78 | # asm/sysreg.h inline assmbly used by it is incompatible with llvm. |
| 79 | # But, ehere is not easy way to fix it, so just exclude it since it is |
| 80 | # useless for BPF samples. |
Brenden Blanco | b88c06e | 2015-05-11 21:25:51 -0700 | [diff] [blame] | 81 | $(obj)/%.o: $(src)/%.c |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 82 | clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ |
Yang Shi | 30b50aa | 2015-11-12 14:07:46 -0800 | [diff] [blame] | 83 | -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \ |
Alexei Starovoitov | a808578 | 2014-12-01 15:06:38 -0800 | [diff] [blame] | 84 | -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ |
Alexei Starovoitov | 3911169 | 2015-10-20 20:02:35 -0700 | [diff] [blame] | 85 | clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ |
Yang Shi | 30b50aa | 2015-11-12 14:07:46 -0800 | [diff] [blame] | 86 | -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \ |
Alexei Starovoitov | 3911169 | 2015-10-20 20:02:35 -0700 | [diff] [blame] | 87 | -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=asm -o $@.s |