blob: 46c6a8cf74d3e56cad920616208b9d603a08153c [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
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070015
16test_verifier-objs := test_verifier.o libbpf.o
Alexei Starovoitovffb65f22014-11-13 17:36:48 -080017test_maps-objs := test_maps.o libbpf.o
Alexei Starovoitov03f47232014-12-01 15:06:36 -080018sock_example-objs := sock_example.o libbpf.o
Alexei Starovoitova8085782014-12-01 15:06:38 -080019sockex1-objs := bpf_load.o libbpf.o sockex1_user.o
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080020sockex2-objs := bpf_load.o libbpf.o sockex2_user.o
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070021sockex3-objs := bpf_load.o libbpf.o sockex3_user.o
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070022tracex1-objs := bpf_load.o libbpf.o tracex1_user.o
Alexei Starovoitovd822a192015-03-25 12:49:24 -070023tracex2-objs := bpf_load.o libbpf.o tracex2_user.o
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070024tracex3-objs := bpf_load.o libbpf.o tracex3_user.o
Alexei Starovoitov9811e352015-03-25 12:49:26 -070025tracex4-objs := bpf_load.o libbpf.o tracex4_user.o
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070026tracex5-objs := bpf_load.o libbpf.o tracex5_user.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070027
28# Tell kbuild to always build the programs
29always := $(hostprogs-y)
Alexei Starovoitova8085782014-12-01 15:06:38 -080030always += sockex1_kern.o
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080031always += sockex2_kern.o
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070032always += sockex3_kern.o
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070033always += tracex1_kern.o
Alexei Starovoitovd822a192015-03-25 12:49:24 -070034always += tracex2_kern.o
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070035always += tracex3_kern.o
Alexei Starovoitov9811e352015-03-25 12:49:26 -070036always += tracex4_kern.o
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070037always += tracex5_kern.o
Alexei Starovoitov91bc48222015-04-01 17:12:13 -070038always += tcbpf1_kern.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070039
40HOSTCFLAGS += -I$(objtree)/usr/include
Alexei Starovoitova8085782014-12-01 15:06:38 -080041
42HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
43HOSTLOADLIBES_sockex1 += -lelf
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080044HOSTLOADLIBES_sockex2 += -lelf
Alexei Starovoitov530b2c82015-05-19 16:59:06 -070045HOSTLOADLIBES_sockex3 += -lelf
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070046HOSTLOADLIBES_tracex1 += -lelf
Alexei Starovoitovd822a192015-03-25 12:49:24 -070047HOSTLOADLIBES_tracex2 += -lelf
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -070048HOSTLOADLIBES_tracex3 += -lelf
Alexei Starovoitov9811e352015-03-25 12:49:26 -070049HOSTLOADLIBES_tracex4 += -lelf -lrt
Alexei Starovoitov5bacd782015-05-19 16:59:05 -070050HOSTLOADLIBES_tracex5 += -lelf
Alexei Starovoitova8085782014-12-01 15:06:38 -080051
52# point this to your LLVM backend with bpf support
53LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc
54
Brenden Blancob88c06e2015-05-11 21:25:51 -070055$(obj)/%.o: $(src)/%.c
Alexei Starovoitova8085782014-12-01 15:06:38 -080056 clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
57 -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \
58 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@