1 # kbuild trick to avoid linker error. Can be omitted if a module is built.
4 # List of programs to build
5 hostprogs-y
:= test_verifier test_maps
6 hostprogs-y
+= sock_example
10 test_verifier-objs
:= test_verifier.o libbpf.o
11 test_maps-objs
:= test_maps.o libbpf.o
12 sock_example-objs
:= sock_example.o libbpf.o
13 sockex1-objs
:= bpf_load.o libbpf.o sockex1_user.o
14 sockex2-objs
:= bpf_load.o libbpf.o sockex2_user.o
16 # Tell kbuild to always build the programs
17 always
:= $(hostprogs-y
)
18 always
+= sockex1_kern.o
19 always
+= sockex2_kern.o
21 HOSTCFLAGS
+= -I
$(objtree
)/usr
/include
23 HOSTCFLAGS_bpf_load.o
+= -I
$(objtree
)/usr
/include -Wno-unused-variable
24 HOSTLOADLIBES_sockex1
+= -lelf
25 HOSTLOADLIBES_sockex2
+= -lelf
27 # point this to your LLVM backend with bpf support
28 LLC
=$(srctree
)/tools
/bpf
/llvm
/bld
/Debug
+Asserts
/bin
/llc
31 clang
$(NOSTDINC_FLAGS
) $(LINUXINCLUDE
) $(EXTRA_CFLAGS
) \
32 -D__KERNEL__
-Wno-unused-value
-Wno-pointer-sign \
33 -O2
-emit-llvm
-c
$< -o
-|
$(LLC
) -march
=bpf
-filetype
=obj
-o
$@