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 9hostprogs-y += tracex1 10hostprogs-y += tracex2 11hostprogs-y += tracex3 12hostprogs-y += tracex4 13 14test_verifier-objs := test_verifier.o libbpf.o 15test_maps-objs := test_maps.o libbpf.o 16sock_example-objs := sock_example.o libbpf.o 17sockex1-objs := bpf_load.o libbpf.o sockex1_user.o 18sockex2-objs := bpf_load.o libbpf.o sockex2_user.o 19tracex1-objs := bpf_load.o libbpf.o tracex1_user.o 20tracex2-objs := bpf_load.o libbpf.o tracex2_user.o 21tracex3-objs := bpf_load.o libbpf.o tracex3_user.o 22tracex4-objs := bpf_load.o libbpf.o tracex4_user.o 23 24# Tell kbuild to always build the programs 25always := $(hostprogs-y) 26always += sockex1_kern.o 27always += sockex2_kern.o 28always += tracex1_kern.o 29always += tracex2_kern.o 30always += tracex3_kern.o 31always += tracex4_kern.o 32 33HOSTCFLAGS += -I$(objtree)/usr/include 34 35HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable 36HOSTLOADLIBES_sockex1 += -lelf 37HOSTLOADLIBES_sockex2 += -lelf 38HOSTLOADLIBES_tracex1 += -lelf 39HOSTLOADLIBES_tracex2 += -lelf 40HOSTLOADLIBES_tracex3 += -lelf 41HOSTLOADLIBES_tracex4 += -lelf -lrt 42 43# point this to your LLVM backend with bpf support 44LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc 45 46%.o: %.c 47 clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ 48 -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \ 49 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ 50