blob: 770d145186c33b26145b033282149f630727a693 [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 Starovoitov3c731eb2014-09-26 00:17:07 -07008
9test_verifier-objs := test_verifier.o libbpf.o
Alexei Starovoitovffb65f22014-11-13 17:36:48 -080010test_maps-objs := test_maps.o libbpf.o
Alexei Starovoitov03f47232014-12-01 15:06:36 -080011sock_example-objs := sock_example.o libbpf.o
Alexei Starovoitova8085782014-12-01 15:06:38 -080012sockex1-objs := bpf_load.o libbpf.o sockex1_user.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070013
14# Tell kbuild to always build the programs
15always := $(hostprogs-y)
Alexei Starovoitova8085782014-12-01 15:06:38 -080016always += sockex1_kern.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070017
18HOSTCFLAGS += -I$(objtree)/usr/include
Alexei Starovoitova8085782014-12-01 15:06:38 -080019
20HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
21HOSTLOADLIBES_sockex1 += -lelf
22
23# point this to your LLVM backend with bpf support
24LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc
25
26%.o: %.c
27 clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
28 -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \
29 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@