1# kbuild trick to avoid linker error. Can be omitted if a module is built. 2obj- := dummy.o 3 4# List of programs to build 5hostprogs-y := test_verifier test_maps 6hostprogs-y += sock_example 7hostprogs-y += sockex1 8hostprogs-y += sockex2 9 10test_verifier-objs := test_verifier.o libbpf.o 11test_maps-objs := test_maps.o libbpf.o 12sock_example-objs := sock_example.o libbpf.o 13sockex1-objs := bpf_load.o libbpf.o sockex1_user.o 14sockex2-objs := bpf_load.o libbpf.o sockex2_user.o 15 16# Tell kbuild to always build the programs 17always := $(hostprogs-y) 18always += sockex1_kern.o 19always += sockex2_kern.o 20 21HOSTCFLAGS += -I$(objtree)/usr/include 22 23HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable 24HOSTLOADLIBES_sockex1 += -lelf 25HOSTLOADLIBES_sockex2 += -lelf 26 27# point this to your LLVM backend with bpf support 28LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc 29 30%.o: %.c 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 $@ 34