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