1 # SPDX-License-Identifier: GPL-2.0 1 # SPDX-License-Identifier: GPL-2.0 2 include ../scripts/Makefile.include !! 2 prefix = /usr 3 << 4 prefix ?= /usr/local << 5 3 >> 4 CC = gcc 6 LEX = flex 5 LEX = flex 7 YACC = bison 6 YACC = bison 8 MAKE = make 7 MAKE = make 9 INSTALL ?= install << 10 8 11 CFLAGS += -Wall -O2 9 CFLAGS += -Wall -O2 12 CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/ !! 10 CFLAGS += -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include 13 -I$(srctree)/tools/include << 14 11 15 # This will work when bpf is built in tools en << 16 # isn't set and when invoked from selftests bu << 17 # is set to ".". building_out_of_srctree is un << 18 # builds << 19 ifeq ($(srctree),) 12 ifeq ($(srctree),) 20 update_srctree := 1 << 21 endif << 22 ifndef building_out_of_srctree << 23 update_srctree := 1 << 24 endif << 25 ifeq ($(update_srctree),1) << 26 srctree := $(patsubst %/,%,$(dir $(CURDIR))) 13 srctree := $(patsubst %/,%,$(dir $(CURDIR))) 27 srctree := $(patsubst %/,%,$(dir $(srctree))) 14 srctree := $(patsubst %/,%,$(dir $(srctree))) 28 endif 15 endif 29 16 30 ifeq ($(V),1) << 31 Q = << 32 else << 33 Q = @ << 34 endif << 35 << 36 FEATURE_USER = .bpf 17 FEATURE_USER = .bpf 37 FEATURE_TESTS = libbfd disassembler-four-args !! 18 FEATURE_TESTS = libbfd disassembler-four-args 38 FEATURE_DISPLAY = libbfd !! 19 FEATURE_DISPLAY = libbfd disassembler-four-args 39 20 40 check_feat := 1 21 check_feat := 1 41 NON_CHECK_FEAT_TARGETS := clean bpftool_clean !! 22 NON_CHECK_FEAT_TARGETS := clean bpftool_clean 42 ifdef MAKECMDGOALS 23 ifdef MAKECMDGOALS 43 ifeq ($(filter-out $(NON_CHECK_FEAT_TARGETS),$ 24 ifeq ($(filter-out $(NON_CHECK_FEAT_TARGETS),$(MAKECMDGOALS)),) 44 check_feat := 0 25 check_feat := 0 45 endif 26 endif 46 endif 27 endif 47 28 48 ifeq ($(check_feat),1) 29 ifeq ($(check_feat),1) 49 ifeq ($(FEATURES_DUMP),) 30 ifeq ($(FEATURES_DUMP),) 50 include $(srctree)/tools/build/Makefile.featur 31 include $(srctree)/tools/build/Makefile.feature 51 else 32 else 52 include $(FEATURES_DUMP) 33 include $(FEATURES_DUMP) 53 endif 34 endif 54 endif 35 endif 55 36 56 ifeq ($(feature-disassembler-four-args), 1) 37 ifeq ($(feature-disassembler-four-args), 1) 57 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE 38 CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE 58 endif 39 endif 59 ifeq ($(feature-disassembler-init-styled), 1) << 60 CFLAGS += -DDISASM_INIT_STYLED << 61 endif << 62 40 63 $(OUTPUT)%.yacc.c: $(srctree)/tools/bpf/%.y !! 41 %.yacc.c: %.y 64 $(QUIET_BISON)$(YACC) -o $@ -d $< !! 42 $(YACC) -o $@ -d $< 65 43 66 $(OUTPUT)%.lex.c: $(srctree)/tools/bpf/%.l !! 44 %.lex.c: %.l 67 $(QUIET_FLEX)$(LEX) -o $@ $< !! 45 $(LEX) -o $@ $< 68 << 69 $(OUTPUT)%.o: $(srctree)/tools/bpf/%.c << 70 $(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $< << 71 << 72 $(OUTPUT)%.yacc.o: $(OUTPUT)%.yacc.c << 73 $(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $< << 74 $(OUTPUT)%.lex.o: $(OUTPUT)%.lex.c << 75 $(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $< << 76 << 77 PROGS = $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_d << 78 << 79 all: $(PROGS) bpftool runqslower << 80 << 81 $(OUTPUT)bpf_jit_disasm: CFLAGS += -DPACKAGE=' << 82 $(OUTPUT)bpf_jit_disasm: $(OUTPUT)bpf_jit_disa << 83 $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $^ << 84 << 85 $(OUTPUT)bpf_dbg: $(OUTPUT)bpf_dbg.o << 86 $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $^ << 87 << 88 $(OUTPUT)bpf_asm: $(OUTPUT)bpf_asm.o $(OUTPUT) << 89 $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $^ << 90 << 91 $(OUTPUT)bpf_exp.lex.c: $(OUTPUT)bpf_exp.yacc. << 92 $(OUTPUT)bpf_exp.yacc.o: $(OUTPUT)bpf_exp.yacc << 93 $(OUTPUT)bpf_exp.lex.o: $(OUTPUT)bpf_exp.lex.c << 94 << 95 clean: bpftool_clean runqslower_clean resolve_ << 96 $(call QUIET_CLEAN, bpf-progs) << 97 $(Q)$(RM) -r -- $(OUTPUT)*.o $(OUTPUT) << 98 $(OUTPUT)bpf_asm $(OUTPUT)bpf_e << 99 $(call QUIET_CLEAN, core-gen) << 100 $(Q)$(RM) -- $(OUTPUT)FEATURE-DUMP.bpf << 101 $(Q)$(RM) -r -- $(OUTPUT)feature << 102 << 103 install: $(PROGS) bpftool_install << 104 $(call QUIET_INSTALL, bpf_jit_disasm) << 105 $(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$( << 106 $(Q)$(INSTALL) $(OUTPUT)bpf_jit_disasm << 107 $(call QUIET_INSTALL, bpf_dbg) << 108 $(Q)$(INSTALL) $(OUTPUT)bpf_dbg $(DEST << 109 $(call QUIET_INSTALL, bpf_asm) << 110 $(Q)$(INSTALL) $(OUTPUT)bpf_asm $(DEST << 111 46 112 bpftool: !! 47 all: bpf_jit_disasm bpf_dbg bpf_asm bpftool 113 $(call descend,bpftool) << 114 48 115 bpftool_install: !! 49 bpf_jit_disasm : CFLAGS += -DPACKAGE='bpf_jit_disasm' 116 $(call descend,bpftool,install) !! 50 bpf_jit_disasm : LDLIBS = -lopcodes -lbfd -ldl >> 51 bpf_jit_disasm : bpf_jit_disasm.o 117 52 118 bpftool_clean: !! 53 bpf_dbg : LDLIBS = -lreadline 119 $(call descend,bpftool,clean) !! 54 bpf_dbg : bpf_dbg.o 120 55 121 runqslower: !! 56 bpf_asm : LDLIBS = 122 $(call descend,runqslower) !! 57 bpf_asm : bpf_asm.o bpf_exp.yacc.o bpf_exp.lex.o >> 58 bpf_exp.lex.o : bpf_exp.yacc.c 123 59 124 runqslower_clean: !! 60 clean: bpftool_clean 125 $(call descend,runqslower,clean) !! 61 rm -rf *.o bpf_jit_disasm bpf_dbg bpf_asm bpf_exp.yacc.* bpf_exp.lex.* 126 62 127 resolve_btfids: !! 63 install: bpftool_install 128 $(call descend,resolve_btfids) !! 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 129 70 130 resolve_btfids_clean: !! 71 bpftool_install: 131 $(call descend,resolve_btfids,clean) !! 72 $(MAKE) -C bpftool install >> 73 >> 74 bpftool_clean: >> 75 $(MAKE) -C bpftool clean 132 76 133 .PHONY: all install clean bpftool bpftool_inst !! 77 .PHONY: bpftool FORCE 134 runqslower runqslower_clean \ << 135 resolve_btfids resolve_btfids_clean <<
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.