samples: bpf: trivial eBPF program in C
[linux-2.6-block.git] / samples / bpf / Makefile
CommitLineData
3c731eba
AS
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
ffb65f27 5hostprogs-y := test_verifier test_maps
03f4723e 6hostprogs-y += sock_example
a8085782 7hostprogs-y += sockex1
3c731eba
AS
8
9test_verifier-objs := test_verifier.o libbpf.o
ffb65f27 10test_maps-objs := test_maps.o libbpf.o
03f4723e 11sock_example-objs := sock_example.o libbpf.o
a8085782 12sockex1-objs := bpf_load.o libbpf.o sockex1_user.o
3c731eba
AS
13
14# Tell kbuild to always build the programs
15always := $(hostprogs-y)
a8085782 16always += sockex1_kern.o
3c731eba
AS
17
18HOSTCFLAGS += -I$(objtree)/usr/include
a8085782
AS
19
20HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
21HOSTLOADLIBES_sockex1 += -lelf
22
23# point this to your LLVM backend with bpf support
24LLC=$(srctree)/tools/bpf/llvm/bld/Debug+Asserts/bin/llc
25
26%.o: %.c
27 clang $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) \
28 -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \
29 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@