blob: 6dd272143733f4cab9932719f5e5c5ad279354a5 [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 Starovoitovb896c4f2015-03-25 12:49:23 -07009hostprogs-y += tracex1
Alexei Starovoitovd822a192015-03-25 12:49:24 -070010hostprogs-y += tracex2
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070011
12test_verifier-objs := test_verifier.o libbpf.o
Alexei Starovoitovffb65f22014-11-13 17:36:48 -080013test_maps-objs := test_maps.o libbpf.o
Alexei Starovoitov03f47232014-12-01 15:06:36 -080014sock_example-objs := sock_example.o libbpf.o
Alexei Starovoitova8085782014-12-01 15:06:38 -080015sockex1-objs := bpf_load.o libbpf.o sockex1_user.o
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080016sockex2-objs := bpf_load.o libbpf.o sockex2_user.o
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070017tracex1-objs := bpf_load.o libbpf.o tracex1_user.o
Alexei Starovoitovd822a192015-03-25 12:49:24 -070018tracex2-objs := bpf_load.o libbpf.o tracex2_user.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070019
20# Tell kbuild to always build the programs
21always := $(hostprogs-y)
Alexei Starovoitova8085782014-12-01 15:06:38 -080022always += sockex1_kern.o
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080023always += sockex2_kern.o
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070024always += tracex1_kern.o
Alexei Starovoitovd822a192015-03-25 12:49:24 -070025always += tracex2_kern.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070026
27HOSTCFLAGS += -I$(objtree)/usr/include
Alexei Starovoitova8085782014-12-01 15:06:38 -080028
29HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
30HOSTLOADLIBES_sockex1 += -lelf
Alexei Starovoitovfbe33102014-12-01 15:06:39 -080031HOSTLOADLIBES_sockex2 += -lelf
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -070032HOSTLOADLIBES_tracex1 += -lelf
Alexei Starovoitovd822a192015-03-25 12:49:24 -070033HOSTLOADLIBES_tracex2 += -lelf
Alexei Starovoitova8085782014-12-01 15:06:38 -080034
35# point this to your LLVM backend with bpf support
36LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc
37
38%.o: %.c
39 clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
40 -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \
41 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@