Linux 5.1.15
[linux/fpc-iii.git] / tools / bpf / Makefile
blob53b60ad452f5d3ebd5d2edad0b80ef12558f2215
1 # SPDX-License-Identifier: GPL-2.0
2 include ../scripts/Makefile.include
4 prefix ?= /usr/local
6 CC = gcc
7 LEX = flex
8 YACC = bison
9 MAKE = make
10 INSTALL ?= install
12 CFLAGS += -Wall -O2
13 CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include
15 ifeq ($(srctree),)
16 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
17 srctree := $(patsubst %/,%,$(dir $(srctree)))
18 endif
20 ifeq ($(V),1)
21 Q =
22 else
23 Q = @
24 endif
26 FEATURE_USER = .bpf
27 FEATURE_TESTS = libbfd disassembler-four-args
28 FEATURE_DISPLAY = libbfd disassembler-four-args
30 check_feat := 1
31 NON_CHECK_FEAT_TARGETS := clean bpftool_clean
32 ifdef MAKECMDGOALS
33 ifeq ($(filter-out $(NON_CHECK_FEAT_TARGETS),$(MAKECMDGOALS)),)
34 check_feat := 0
35 endif
36 endif
38 ifeq ($(check_feat),1)
39 ifeq ($(FEATURES_DUMP),)
40 include $(srctree)/tools/build/Makefile.feature
41 else
42 include $(FEATURES_DUMP)
43 endif
44 endif
46 ifeq ($(feature-disassembler-four-args), 1)
47 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
48 endif
50 $(OUTPUT)%.yacc.c: $(srctree)/tools/bpf/%.y
51 $(QUIET_BISON)$(YACC) -o $@ -d $<
53 $(OUTPUT)%.lex.c: $(srctree)/tools/bpf/%.l
54 $(QUIET_FLEX)$(LEX) -o $@ $<
56 $(OUTPUT)%.o: $(srctree)/tools/bpf/%.c
57 $(QUIET_CC)$(COMPILE.c) -o $@ $<
59 $(OUTPUT)%.yacc.o: $(OUTPUT)%.yacc.c
60 $(QUIET_CC)$(COMPILE.c) -o $@ $<
61 $(OUTPUT)%.lex.o: $(OUTPUT)%.lex.c
62 $(QUIET_CC)$(COMPILE.c) -o $@ $<
64 PROGS = $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg $(OUTPUT)bpf_asm
66 all: $(PROGS) bpftool
68 $(OUTPUT)bpf_jit_disasm: CFLAGS += -DPACKAGE='bpf_jit_disasm'
69 $(OUTPUT)bpf_jit_disasm: $(OUTPUT)bpf_jit_disasm.o
70 $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $^ -lopcodes -lbfd -ldl
72 $(OUTPUT)bpf_dbg: $(OUTPUT)bpf_dbg.o
73 $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $^ -lreadline
75 $(OUTPUT)bpf_asm: $(OUTPUT)bpf_asm.o $(OUTPUT)bpf_exp.yacc.o $(OUTPUT)bpf_exp.lex.o
76 $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $^
78 $(OUTPUT)bpf_exp.lex.c: $(OUTPUT)bpf_exp.yacc.c
79 $(OUTPUT)bpf_exp.yacc.o: $(OUTPUT)bpf_exp.yacc.c
80 $(OUTPUT)bpf_exp.lex.o: $(OUTPUT)bpf_exp.lex.c
82 clean: bpftool_clean
83 $(call QUIET_CLEAN, bpf-progs)
84 $(Q)rm -rf $(OUTPUT)*.o $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg \
85 $(OUTPUT)bpf_asm $(OUTPUT)bpf_exp.yacc.* $(OUTPUT)bpf_exp.lex.*
86 $(call QUIET_CLEAN, core-gen)
87 $(Q)rm -f $(OUTPUT)FEATURE-DUMP.bpf
89 install: $(PROGS) bpftool_install
90 $(call QUIET_INSTALL, bpf_jit_disasm)
91 $(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(prefix)/bin
92 $(Q)$(INSTALL) $(OUTPUT)bpf_jit_disasm $(DESTDIR)$(prefix)/bin/bpf_jit_disasm
93 $(call QUIET_INSTALL, bpf_dbg)
94 $(Q)$(INSTALL) $(OUTPUT)bpf_dbg $(DESTDIR)$(prefix)/bin/bpf_dbg
95 $(call QUIET_INSTALL, bpf_asm)
96 $(Q)$(INSTALL) $(OUTPUT)bpf_asm $(DESTDIR)$(prefix)/bin/bpf_asm
98 bpftool:
99 $(call descend,bpftool)
101 bpftool_install:
102 $(call descend,bpftool,install)
104 bpftool_clean:
105 $(call descend,bpftool,clean)
107 .PHONY: all install clean bpftool bpftool_install bpftool_clean