]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - samples/sockmap/Makefile
Merge tag 'mmc-v4.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
[mirror_ubuntu-bionic-kernel.git] / samples / sockmap / Makefile
1 # List of programs to build
2 hostprogs-y := sockmap
3
4 # Libbpf dependencies
5 LIBBPF := ../../tools/lib/bpf/bpf.o
6
7 HOSTCFLAGS += -I$(objtree)/usr/include
8 HOSTCFLAGS += -I$(srctree)/tools/lib/
9 HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
10 HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include
11 HOSTCFLAGS += -I$(srctree)/tools/perf
12
13 sockmap-objs := ../bpf/bpf_load.o $(LIBBPF) sockmap_user.o
14
15 # Tell kbuild to always build the programs
16 always := $(hostprogs-y)
17 always += sockmap_kern.o
18
19 HOSTLOADLIBES_sockmap += -lelf -lpthread
20
21 # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
22 # make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
23 LLC ?= llc
24 CLANG ?= clang
25
26 # Trick to allow make to be run from this directory
27 all:
28 $(MAKE) -C ../../ $(CURDIR)/
29
30 clean:
31 $(MAKE) -C ../../ M=$(CURDIR) clean
32 @rm -f *~
33
34 $(obj)/syscall_nrs.s: $(src)/syscall_nrs.c
35 $(call if_changed_dep,cc_s_c)
36
37 $(obj)/syscall_nrs.h: $(obj)/syscall_nrs.s FORCE
38 $(call filechk,offsets,__SYSCALL_NRS_H__)
39
40 clean-files += syscall_nrs.h
41
42 FORCE:
43
44
45 # Verify LLVM compiler tools are available and bpf target is supported by llc
46 .PHONY: verify_cmds verify_target_bpf $(CLANG) $(LLC)
47
48 verify_cmds: $(CLANG) $(LLC)
49 @for TOOL in $^ ; do \
50 if ! (which -- "$${TOOL}" > /dev/null 2>&1); then \
51 echo "*** ERROR: Cannot find LLVM tool $${TOOL}" ;\
52 exit 1; \
53 else true; fi; \
54 done
55
56 verify_target_bpf: verify_cmds
57 @if ! (${LLC} -march=bpf -mattr=help > /dev/null 2>&1); then \
58 echo "*** ERROR: LLVM (${LLC}) does not support 'bpf' target" ;\
59 echo " NOTICE: LLVM version >= 3.7.1 required" ;\
60 exit 2; \
61 else true; fi
62
63 $(src)/*.c: verify_target_bpf
64
65 # asm/sysreg.h - inline assembly used by it is incompatible with llvm.
66 # But, there is no easy way to fix it, so just exclude it since it is
67 # useless for BPF samples.
68 $(obj)/%.o: $(src)/%.c
69 $(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \
70 -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
71 -Wno-compare-distinct-pointer-types \
72 -Wno-gnu-variable-sized-type-not-at-end \
73 -Wno-address-of-packed-member -Wno-tautological-compare \
74 -Wno-unknown-warning-option \
75 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@