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 += fds_example 8hostprogs-y += sockex1 9hostprogs-y += sockex2 10hostprogs-y += sockex3 11hostprogs-y += tracex1 12hostprogs-y += tracex2 13hostprogs-y += tracex3 14hostprogs-y += tracex4 15hostprogs-y += tracex5 16hostprogs-y += tracex6 17hostprogs-y += trace_output 18hostprogs-y += lathist 19 20test_verifier-objs := test_verifier.o libbpf.o 21test_maps-objs := test_maps.o libbpf.o 22sock_example-objs := sock_example.o libbpf.o 23fds_example-objs := bpf_load.o libbpf.o fds_example.o 24sockex1-objs := bpf_load.o libbpf.o sockex1_user.o 25sockex2-objs := bpf_load.o libbpf.o sockex2_user.o 26sockex3-objs := bpf_load.o libbpf.o sockex3_user.o 27tracex1-objs := bpf_load.o libbpf.o tracex1_user.o 28tracex2-objs := bpf_load.o libbpf.o tracex2_user.o 29tracex3-objs := bpf_load.o libbpf.o tracex3_user.o 30tracex4-objs := bpf_load.o libbpf.o tracex4_user.o 31tracex5-objs := bpf_load.o libbpf.o tracex5_user.o 32tracex6-objs := bpf_load.o libbpf.o tracex6_user.o 33trace_output-objs := bpf_load.o libbpf.o trace_output_user.o 34lathist-objs := bpf_load.o libbpf.o lathist_user.o 35 36# Tell kbuild to always build the programs 37always := $(hostprogs-y) 38always += sockex1_kern.o 39always += sockex2_kern.o 40always += sockex3_kern.o 41always += tracex1_kern.o 42always += tracex2_kern.o 43always += tracex3_kern.o 44always += tracex4_kern.o 45always += tracex5_kern.o 46always += tracex6_kern.o 47always += trace_output_kern.o 48always += tcbpf1_kern.o 49always += lathist_kern.o 50 51HOSTCFLAGS += -I$(objtree)/usr/include 52 53HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable 54HOSTLOADLIBES_fds_example += -lelf 55HOSTLOADLIBES_sockex1 += -lelf 56HOSTLOADLIBES_sockex2 += -lelf 57HOSTLOADLIBES_sockex3 += -lelf 58HOSTLOADLIBES_tracex1 += -lelf 59HOSTLOADLIBES_tracex2 += -lelf 60HOSTLOADLIBES_tracex3 += -lelf 61HOSTLOADLIBES_tracex4 += -lelf -lrt 62HOSTLOADLIBES_tracex5 += -lelf 63HOSTLOADLIBES_tracex6 += -lelf 64HOSTLOADLIBES_trace_output += -lelf -lrt 65HOSTLOADLIBES_lathist += -lelf 66 67# point this to your LLVM backend with bpf support 68LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc 69 70# asm/sysreg.h inline assmbly used by it is incompatible with llvm. 71# But, ehere is not easy way to fix it, so just exclude it since it is 72# useless for BPF samples. 73$(obj)/%.o: $(src)/%.c 74 clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ 75 -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \ 76 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ 77 clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \ 78 -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \ 79 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=asm -o $@.s 80