Merge tag 'xtensa-20180225' of git://github.com/jcmvbkbc/linux-xtensa
[cris-mirror.git] / tools / bpf / Makefile
blobc8ec0ae16bf03af4c40f08b06dcea2b7e24e4b9e
1 # SPDX-License-Identifier: GPL-2.0
2 prefix = /usr
4 CC = gcc
5 LEX = flex
6 YACC = bison
7 MAKE = make
9 CFLAGS += -Wall -O2
10 CFLAGS += -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include
12 ifeq ($(srctree),)
13 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
14 srctree := $(patsubst %/,%,$(dir $(srctree)))
15 endif
17 FEATURE_USER = .bpf
18 FEATURE_TESTS = libbfd disassembler-four-args
19 FEATURE_DISPLAY = libbfd disassembler-four-args
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
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
37 ifeq ($(feature-disassembler-four-args), 1)
38 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
39 endif
41 %.yacc.c: %.y
42 $(YACC) -o $@ -d $<
44 %.lex.c: %.l
45 $(LEX) -o $@ $<
47 all: bpf_jit_disasm bpf_dbg bpf_asm bpftool
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
53 bpf_dbg : LDLIBS = -lreadline
54 bpf_dbg : bpf_dbg.o
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
60 clean: bpftool_clean
61 rm -rf *.o bpf_jit_disasm bpf_dbg bpf_asm bpf_exp.yacc.* bpf_exp.lex.*
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
68 bpftool:
69 $(MAKE) -C bpftool
71 bpftool_install:
72 $(MAKE) -C bpftool install
74 bpftool_clean:
75 $(MAKE) -C bpftool clean
77 .PHONY: bpftool FORCE