blob: 63e7d50e6a4fe3ca46cbd3b7ae064600bf6696ff [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
Alexei Starovoitova8085782014-12-01 15:06:38 -08007hostprogs-y += sockex1
Alexei Starovoitovfbe33102014-12-01 15:06:39 -08008hostprogs-y += sockex2
Alexei Starovoitov530b2c82015-05-19 16:59:06 -07009hostprogs-y += sockex3
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070010hostprogs-y += tracex1
Alexei Starovoitovd822a192015-03-25 12:49:24 -070011hostprogs-y += tracex2
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070012hostprogs-y += tracex3
Alexei Starovoitov9811e352015-03-25 12:49:26 -070013hostprogs-y += tracex4
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070014hostprogs-y += tracex5
Kaixu Xia47efb302015-08-06 07:02:36 +000015hostprogs-y += tracex6
Daniel Wagner0fb11702015-06-19 16:00:44 +020016hostprogs-y += lathist
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070017
18test_verifier-objs := test_verifier.o libbpf.o
Alexei Starovoitovffb65f22014-11-13 17:36:48 -080019test_maps-objs := test_maps.o libbpf.o
Alexei Starovoitov03f47232014-12-01 15:06:36 -080020sock_example-objs := sock_example.o libbpf.o
Alexei Starovoitova8085782014-12-01 15:06:38 -080021sockex1-objs := bpf_load.o libbpf.o sockex1_user.o
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080022sockex2-objs := bpf_load.o libbpf.o sockex2_user.o
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070023sockex3-objs := bpf_load.o libbpf.o sockex3_user.o
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070024tracex1-objs := bpf_load.o libbpf.o tracex1_user.o
Alexei Starovoitovd822a192015-03-25 12:49:24 -070025tracex2-objs := bpf_load.o libbpf.o tracex2_user.o
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070026tracex3-objs := bpf_load.o libbpf.o tracex3_user.o
Alexei Starovoitov9811e352015-03-25 12:49:26 -070027tracex4-objs := bpf_load.o libbpf.o tracex4_user.o
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070028tracex5-objs := bpf_load.o libbpf.o tracex5_user.o
Kaixu Xia47efb302015-08-06 07:02:36 +000029tracex6-objs := bpf_load.o libbpf.o tracex6_user.o
Daniel Wagner0fb11702015-06-19 16:00:44 +020030lathist-objs := bpf_load.o libbpf.o lathist_user.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070031
32# Tell kbuild to always build the programs
33always := $(hostprogs-y)
Alexei Starovoitova8085782014-12-01 15:06:38 -080034always += sockex1_kern.o
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080035always += sockex2_kern.o
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070036always += sockex3_kern.o
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070037always += tracex1_kern.o
Alexei Starovoitovd822a192015-03-25 12:49:24 -070038always += tracex2_kern.o
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070039always += tracex3_kern.o
Alexei Starovoitov9811e352015-03-25 12:49:26 -070040always += tracex4_kern.o
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070041always += tracex5_kern.o
Kaixu Xia47efb302015-08-06 07:02:36 +000042always += tracex6_kern.o
Alexei Starovoitov91bc48222015-04-01 17:12:13 -070043always += tcbpf1_kern.o
Daniel Wagner0fb11702015-06-19 16:00:44 +020044always += lathist_kern.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070045
46HOSTCFLAGS += -I$(objtree)/usr/include
Alexei Starovoitova8085782014-12-01 15:06:38 -080047
48HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
49HOSTLOADLIBES_sockex1 += -lelf
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080050HOSTLOADLIBES_sockex2 += -lelf
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070051HOSTLOADLIBES_sockex3 += -lelf
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070052HOSTLOADLIBES_tracex1 += -lelf
Alexei Starovoitovd822a192015-03-25 12:49:24 -070053HOSTLOADLIBES_tracex2 += -lelf
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070054HOSTLOADLIBES_tracex3 += -lelf
Alexei Starovoitov9811e352015-03-25 12:49:26 -070055HOSTLOADLIBES_tracex4 += -lelf -lrt
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070056HOSTLOADLIBES_tracex5 += -lelf
Kaixu Xia47efb302015-08-06 07:02:36 +000057HOSTLOADLIBES_tracex6 += -lelf
Daniel Wagner0fb11702015-06-19 16:00:44 +020058HOSTLOADLIBES_lathist += -lelf
Alexei Starovoitova8085782014-12-01 15:06:38 -080059
60# point this to your LLVM backend with bpf support
61LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc
62
Brenden Blancob88c06e2015-05-11 21:25:51 -070063$(obj)/%.o: $(src)/%.c
Alexei Starovoitova8085782014-12-01 15:06:38 -080064 clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
65 -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \
66 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@