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