blob: 75a13e742ab41ccf3f173e0d5c93873bebd249de [file] [log] [blame]
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -07001# kbuild trick to avoid linker error. Can be omitted if a module is built.
2obj- := dummy.o
3
4# List of programs to build
Alexei Starovoitovffb65f22014-11-13 17:36:48 -08005hostprogs-y := test_verifier test_maps
Alexei Starovoitov03f47232014-12-01 15:06:36 -08006hostprogs-y += sock_example
Daniel Borkmann42984d72015-10-29 14:58:10 +01007hostprogs-y += fds_example
Alexei Starovoitova8085782014-12-01 15:06:38 -08008hostprogs-y += sockex1
Alexei Starovoitovfbe33102014-12-01 15:06:39 -08009hostprogs-y += sockex2
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070010hostprogs-y += sockex3
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070011hostprogs-y += tracex1
Alexei Starovoitovd822a192015-03-25 12:49:24 -070012hostprogs-y += tracex2
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070013hostprogs-y += tracex3
Alexei Starovoitov9811e352015-03-25 12:49:26 -070014hostprogs-y += tracex4
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070015hostprogs-y += tracex5
Kaixu Xia47efb302015-08-06 07:02:36 +000016hostprogs-y += tracex6
Alexei Starovoitov39111692015-10-20 20:02:35 -070017hostprogs-y += trace_output
Daniel Wagner0fb11702015-06-19 16:00:44 +020018hostprogs-y += lathist
Alexei Starovoitova6ffe7b2016-02-17 19:58:59 -080019hostprogs-y += offwaketime
Alexei Starovoitov9d8b6122016-03-08 15:07:52 -080020hostprogs-y += spintest
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070021
22test_verifier-objs := test_verifier.o libbpf.o
Alexei Starovoitovffb65f22014-11-13 17:36:48 -080023test_maps-objs := test_maps.o libbpf.o
Alexei Starovoitov03f47232014-12-01 15:06:36 -080024sock_example-objs := sock_example.o libbpf.o
Daniel Borkmann42984d72015-10-29 14:58:10 +010025fds_example-objs := bpf_load.o libbpf.o fds_example.o
Alexei Starovoitova8085782014-12-01 15:06:38 -080026sockex1-objs := bpf_load.o libbpf.o sockex1_user.o
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080027sockex2-objs := bpf_load.o libbpf.o sockex2_user.o
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070028sockex3-objs := bpf_load.o libbpf.o sockex3_user.o
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070029tracex1-objs := bpf_load.o libbpf.o tracex1_user.o
Alexei Starovoitovd822a192015-03-25 12:49:24 -070030tracex2-objs := bpf_load.o libbpf.o tracex2_user.o
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070031tracex3-objs := bpf_load.o libbpf.o tracex3_user.o
Alexei Starovoitov9811e352015-03-25 12:49:26 -070032tracex4-objs := bpf_load.o libbpf.o tracex4_user.o
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070033tracex5-objs := bpf_load.o libbpf.o tracex5_user.o
Kaixu Xia47efb302015-08-06 07:02:36 +000034tracex6-objs := bpf_load.o libbpf.o tracex6_user.o
Alexei Starovoitov39111692015-10-20 20:02:35 -070035trace_output-objs := bpf_load.o libbpf.o trace_output_user.o
Daniel Wagner0fb11702015-06-19 16:00:44 +020036lathist-objs := bpf_load.o libbpf.o lathist_user.o
Alexei Starovoitova6ffe7b2016-02-17 19:58:59 -080037offwaketime-objs := bpf_load.o libbpf.o offwaketime_user.o
Alexei Starovoitov9d8b6122016-03-08 15:07:52 -080038spintest-objs := bpf_load.o libbpf.o spintest_user.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070039
40# Tell kbuild to always build the programs
41always := $(hostprogs-y)
Alexei Starovoitova8085782014-12-01 15:06:38 -080042always += sockex1_kern.o
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080043always += sockex2_kern.o
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070044always += sockex3_kern.o
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070045always += tracex1_kern.o
Alexei Starovoitovd822a192015-03-25 12:49:24 -070046always += tracex2_kern.o
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070047always += tracex3_kern.o
Alexei Starovoitov9811e352015-03-25 12:49:26 -070048always += tracex4_kern.o
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070049always += tracex5_kern.o
Kaixu Xia47efb302015-08-06 07:02:36 +000050always += tracex6_kern.o
Alexei Starovoitov39111692015-10-20 20:02:35 -070051always += trace_output_kern.o
Alexei Starovoitov91bc48222015-04-01 17:12:13 -070052always += tcbpf1_kern.o
Daniel Wagner0fb11702015-06-19 16:00:44 +020053always += lathist_kern.o
Alexei Starovoitova6ffe7b2016-02-17 19:58:59 -080054always += offwaketime_kern.o
Alexei Starovoitov9d8b6122016-03-08 15:07:52 -080055always += spintest_kern.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070056
57HOSTCFLAGS += -I$(objtree)/usr/include
Alexei Starovoitova8085782014-12-01 15:06:38 -080058
59HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
Daniel Borkmann42984d72015-10-29 14:58:10 +010060HOSTLOADLIBES_fds_example += -lelf
Alexei Starovoitova8085782014-12-01 15:06:38 -080061HOSTLOADLIBES_sockex1 += -lelf
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080062HOSTLOADLIBES_sockex2 += -lelf
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070063HOSTLOADLIBES_sockex3 += -lelf
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070064HOSTLOADLIBES_tracex1 += -lelf
Alexei Starovoitovd822a192015-03-25 12:49:24 -070065HOSTLOADLIBES_tracex2 += -lelf
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070066HOSTLOADLIBES_tracex3 += -lelf
Alexei Starovoitov9811e352015-03-25 12:49:26 -070067HOSTLOADLIBES_tracex4 += -lelf -lrt
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070068HOSTLOADLIBES_tracex5 += -lelf
Kaixu Xia47efb302015-08-06 07:02:36 +000069HOSTLOADLIBES_tracex6 += -lelf
Alexei Starovoitov39111692015-10-20 20:02:35 -070070HOSTLOADLIBES_trace_output += -lelf -lrt
Daniel Wagner0fb11702015-06-19 16:00:44 +020071HOSTLOADLIBES_lathist += -lelf
Alexei Starovoitova6ffe7b2016-02-17 19:58:59 -080072HOSTLOADLIBES_offwaketime += -lelf
Alexei Starovoitov9d8b6122016-03-08 15:07:52 -080073HOSTLOADLIBES_spintest += -lelf
Alexei Starovoitova8085782014-12-01 15:06:38 -080074
75# point this to your LLVM backend with bpf support
76LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc
77
Yang Shi30b50aa2015-11-12 14:07:46 -080078# 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 Blancob88c06e2015-05-11 21:25:51 -070081$(obj)/%.o: $(src)/%.c
Alexei Starovoitova8085782014-12-01 15:06:38 -080082 clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
Yang Shi30b50aa2015-11-12 14:07:46 -080083 -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
Alexei Starovoitova8085782014-12-01 15:06:38 -080084 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
Alexei Starovoitov39111692015-10-20 20:02:35 -070085 clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
Yang Shi30b50aa2015-11-12 14:07:46 -080086 -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
Alexei Starovoitov39111692015-10-20 20:02:35 -070087 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=asm -o $@.s