blob: c4f8ae0c8afe74ac82c69d24849f6f1c974664ff [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 Starovoitov3c731eb2014-09-26 00:17:07 -070020
21test_verifier-objs := test_verifier.o libbpf.o
Alexei Starovoitovffb65f22014-11-13 17:36:48 -080022test_maps-objs := test_maps.o libbpf.o
Alexei Starovoitov03f47232014-12-01 15:06:36 -080023sock_example-objs := sock_example.o libbpf.o
Daniel Borkmann42984d72015-10-29 14:58:10 +010024fds_example-objs := bpf_load.o libbpf.o fds_example.o
Alexei Starovoitova8085782014-12-01 15:06:38 -080025sockex1-objs := bpf_load.o libbpf.o sockex1_user.o
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080026sockex2-objs := bpf_load.o libbpf.o sockex2_user.o
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070027sockex3-objs := bpf_load.o libbpf.o sockex3_user.o
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070028tracex1-objs := bpf_load.o libbpf.o tracex1_user.o
Alexei Starovoitovd822a192015-03-25 12:49:24 -070029tracex2-objs := bpf_load.o libbpf.o tracex2_user.o
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070030tracex3-objs := bpf_load.o libbpf.o tracex3_user.o
Alexei Starovoitov9811e352015-03-25 12:49:26 -070031tracex4-objs := bpf_load.o libbpf.o tracex4_user.o
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070032tracex5-objs := bpf_load.o libbpf.o tracex5_user.o
Kaixu Xia47efb302015-08-06 07:02:36 +000033tracex6-objs := bpf_load.o libbpf.o tracex6_user.o
Alexei Starovoitov39111692015-10-20 20:02:35 -070034trace_output-objs := bpf_load.o libbpf.o trace_output_user.o
Daniel Wagner0fb11702015-06-19 16:00:44 +020035lathist-objs := bpf_load.o libbpf.o lathist_user.o
Alexei Starovoitova6ffe7b2016-02-17 19:58:59 -080036offwaketime-objs := bpf_load.o libbpf.o offwaketime_user.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070037
38# Tell kbuild to always build the programs
39always := $(hostprogs-y)
Alexei Starovoitova8085782014-12-01 15:06:38 -080040always += sockex1_kern.o
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080041always += sockex2_kern.o
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070042always += sockex3_kern.o
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070043always += tracex1_kern.o
Alexei Starovoitovd822a192015-03-25 12:49:24 -070044always += tracex2_kern.o
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070045always += tracex3_kern.o
Alexei Starovoitov9811e352015-03-25 12:49:26 -070046always += tracex4_kern.o
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070047always += tracex5_kern.o
Kaixu Xia47efb302015-08-06 07:02:36 +000048always += tracex6_kern.o
Alexei Starovoitov39111692015-10-20 20:02:35 -070049always += trace_output_kern.o
Alexei Starovoitov91bc48222015-04-01 17:12:13 -070050always += tcbpf1_kern.o
Daniel Wagner0fb11702015-06-19 16:00:44 +020051always += lathist_kern.o
Alexei Starovoitova6ffe7b2016-02-17 19:58:59 -080052always += offwaketime_kern.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070053
54HOSTCFLAGS += -I$(objtree)/usr/include
Alexei Starovoitova8085782014-12-01 15:06:38 -080055
56HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
Daniel Borkmann42984d72015-10-29 14:58:10 +010057HOSTLOADLIBES_fds_example += -lelf
Alexei Starovoitova8085782014-12-01 15:06:38 -080058HOSTLOADLIBES_sockex1 += -lelf
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080059HOSTLOADLIBES_sockex2 += -lelf
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070060HOSTLOADLIBES_sockex3 += -lelf
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070061HOSTLOADLIBES_tracex1 += -lelf
Alexei Starovoitovd822a192015-03-25 12:49:24 -070062HOSTLOADLIBES_tracex2 += -lelf
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070063HOSTLOADLIBES_tracex3 += -lelf
Alexei Starovoitov9811e352015-03-25 12:49:26 -070064HOSTLOADLIBES_tracex4 += -lelf -lrt
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070065HOSTLOADLIBES_tracex5 += -lelf
Kaixu Xia47efb302015-08-06 07:02:36 +000066HOSTLOADLIBES_tracex6 += -lelf
Alexei Starovoitov39111692015-10-20 20:02:35 -070067HOSTLOADLIBES_trace_output += -lelf -lrt
Daniel Wagner0fb11702015-06-19 16:00:44 +020068HOSTLOADLIBES_lathist += -lelf
Alexei Starovoitova6ffe7b2016-02-17 19:58:59 -080069HOSTLOADLIBES_offwaketime += -lelf
Alexei Starovoitova8085782014-12-01 15:06:38 -080070
71# point this to your LLVM backend with bpf support
72LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc
73
Yang Shi30b50aa2015-11-12 14:07:46 -080074# asm/sysreg.h inline assmbly used by it is incompatible with llvm.
75# But, ehere is not easy way to fix it, so just exclude it since it is
76# useless for BPF samples.
Brenden Blancob88c06e2015-05-11 21:25:51 -070077$(obj)/%.o: $(src)/%.c
Alexei Starovoitova8085782014-12-01 15:06:38 -080078 clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
Yang Shi30b50aa2015-11-12 14:07:46 -080079 -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
Alexei Starovoitova8085782014-12-01 15:06:38 -080080 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
Alexei Starovoitov39111692015-10-20 20:02:35 -070081 clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
Yang Shi30b50aa2015-11-12 14:07:46 -080082 -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
Alexei Starovoitov39111692015-10-20 20:02:35 -070083 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=asm -o $@.s