Merge tag 'dma-mapping-4.16-3' of git://git.infradead.org/users/hch/dma-mapping
[sfrench/cifs-2.6.git] / tools / bpf / Makefile
1 # SPDX-License-Identifier: GPL-2.0
2 prefix = /usr
3
4 CC = gcc
5 LEX = flex
6 YACC = bison
7 MAKE = make
8
9 CFLAGS += -Wall -O2
10 CFLAGS += -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include
11
12 ifeq ($(srctree),)
13 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
14 srctree := $(patsubst %/,%,$(dir $(srctree)))
15 endif
16
17 FEATURE_USER = .bpf
18 FEATURE_TESTS = libbfd disassembler-four-args
19 FEATURE_DISPLAY = libbfd disassembler-four-args
20
21 check_feat := 1
22 NON_CHECK_FEAT_TARGETS := clean bpftool_clean
23 ifdef MAKECMDGOALS
24 ifeq ($(filter-out $(NON_CHECK_FEAT_TARGETS),$(MAKECMDGOALS)),)
25   check_feat := 0
26 endif
27 endif
28
29 ifeq ($(check_feat),1)
30 ifeq ($(FEATURES_DUMP),)
31 include $(srctree)/tools/build/Makefile.feature
32 else
33 include $(FEATURES_DUMP)
34 endif
35 endif
36
37 ifeq ($(feature-disassembler-four-args), 1)
38 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
39 endif
40
41 %.yacc.c: %.y
42         $(YACC) -o $@ -d $<
43
44 %.lex.c: %.l
45         $(LEX) -o $@ $<
46
47 all: bpf_jit_disasm bpf_dbg bpf_asm bpftool
48
49 bpf_jit_disasm : CFLAGS += -DPACKAGE='bpf_jit_disasm'
50 bpf_jit_disasm : LDLIBS = -lopcodes -lbfd -ldl
51 bpf_jit_disasm : bpf_jit_disasm.o
52
53 bpf_dbg : LDLIBS = -lreadline
54 bpf_dbg : bpf_dbg.o
55
56 bpf_asm : LDLIBS =
57 bpf_asm : bpf_asm.o bpf_exp.yacc.o bpf_exp.lex.o
58 bpf_exp.lex.o : bpf_exp.yacc.c
59
60 clean: bpftool_clean
61         rm -rf *.o bpf_jit_disasm bpf_dbg bpf_asm bpf_exp.yacc.* bpf_exp.lex.*
62
63 install: bpftool_install
64         install bpf_jit_disasm $(prefix)/bin/bpf_jit_disasm
65         install bpf_dbg $(prefix)/bin/bpf_dbg
66         install bpf_asm $(prefix)/bin/bpf_asm
67
68 bpftool:
69         $(MAKE) -C bpftool
70
71 bpftool_install:
72         $(MAKE) -C bpftool install
73
74 bpftool_clean:
75         $(MAKE) -C bpftool clean
76
77 .PHONY: bpftool FORCE