12a171788SDavid S. Miller# SPDX-License-Identifier: GPL-2.0 2*5a8997f2SJiri Bencinclude ../scripts/Makefile.include 3*5a8997f2SJiri Benc 4a92bb546SJakub Kicinskiprefix = /usr 5a92bb546SJakub Kicinski 6a92bb546SJakub KicinskiCC = gcc 7a92bb546SJakub KicinskiLEX = flex 8a92bb546SJakub KicinskiYACC = bison 971bb428fSJakub KicinskiMAKE = make 10a92bb546SJakub Kicinski 11a92bb546SJakub KicinskiCFLAGS += -Wall -O2 12*5a8997f2SJiri BencCFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include 13a92bb546SJakub Kicinski 14fb982666SRoman Gushchinifeq ($(srctree),) 15fb982666SRoman Gushchinsrctree := $(patsubst %/,%,$(dir $(CURDIR))) 16fb982666SRoman Gushchinsrctree := $(patsubst %/,%,$(dir $(srctree))) 17fb982666SRoman Gushchinendif 18fb982666SRoman Gushchin 19fb982666SRoman GushchinFEATURE_USER = .bpf 20fb982666SRoman GushchinFEATURE_TESTS = libbfd disassembler-four-args 21fb982666SRoman GushchinFEATURE_DISPLAY = libbfd disassembler-four-args 22fb982666SRoman Gushchin 23fb982666SRoman Gushchincheck_feat := 1 24fb982666SRoman GushchinNON_CHECK_FEAT_TARGETS := clean bpftool_clean 25fb982666SRoman Gushchinifdef MAKECMDGOALS 26fb982666SRoman Gushchinifeq ($(filter-out $(NON_CHECK_FEAT_TARGETS),$(MAKECMDGOALS)),) 27fb982666SRoman Gushchin check_feat := 0 28fb982666SRoman Gushchinendif 29fb982666SRoman Gushchinendif 30fb982666SRoman Gushchin 31fb982666SRoman Gushchinifeq ($(check_feat),1) 32fb982666SRoman Gushchinifeq ($(FEATURES_DUMP),) 33fb982666SRoman Gushchininclude $(srctree)/tools/build/Makefile.feature 34fb982666SRoman Gushchinelse 35fb982666SRoman Gushchininclude $(FEATURES_DUMP) 36fb982666SRoman Gushchinendif 37fb982666SRoman Gushchinendif 38fb982666SRoman Gushchin 39fb982666SRoman Gushchinifeq ($(feature-disassembler-four-args), 1) 40fb982666SRoman GushchinCFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE 41fb982666SRoman Gushchinendif 42fb982666SRoman Gushchin 43*5a8997f2SJiri Benc$(OUTPUT)%.yacc.c: $(srctree)/tools/bpf/%.y 44a92bb546SJakub Kicinski $(YACC) -o $@ -d $< 45a92bb546SJakub Kicinski 46*5a8997f2SJiri Benc$(OUTPUT)%.lex.c: $(srctree)/tools/bpf/%.l 47a92bb546SJakub Kicinski $(LEX) -o $@ $< 48a92bb546SJakub Kicinski 49*5a8997f2SJiri Benc$(OUTPUT)%.o: $(srctree)/tools/bpf/%.c 50*5a8997f2SJiri Benc $(COMPILE.c) -o $@ $< 51a92bb546SJakub Kicinski 52*5a8997f2SJiri Bencall: $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg $(OUTPUT)bpf_asm bpftool 53a92bb546SJakub Kicinski 54*5a8997f2SJiri Benc$(OUTPUT)bpf_jit_disasm: CFLAGS += -DPACKAGE='bpf_jit_disasm' 55*5a8997f2SJiri Benc$(OUTPUT)bpf_jit_disasm: LDLIBS = -lopcodes -lbfd -ldl 56*5a8997f2SJiri Benc$(OUTPUT)bpf_jit_disasm: $(OUTPUT)bpf_jit_disasm.o 57a92bb546SJakub Kicinski 58*5a8997f2SJiri Benc$(OUTPUT)bpf_dbg: LDLIBS = -lreadline 59*5a8997f2SJiri Benc$(OUTPUT)bpf_dbg: $(OUTPUT)bpf_dbg.o 60*5a8997f2SJiri Benc 61*5a8997f2SJiri Benc$(OUTPUT)bpf_asm: LDLIBS = 62*5a8997f2SJiri Benc$(OUTPUT)bpf_asm: $(OUTPUT)bpf_asm.o $(OUTPUT)bpf_exp.yacc.o $(OUTPUT)bpf_exp.lex.o 63*5a8997f2SJiri Benc$(OUTPUT)bpf_exp.lex.o: $(OUTPUT)bpf_exp.yacc.c 64a92bb546SJakub Kicinski 6571bb428fSJakub Kicinskiclean: bpftool_clean 66*5a8997f2SJiri Benc rm -rf $(OUTPUT)*.o $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg \ 67*5a8997f2SJiri Benc $(OUTPUT)bpf_asm $(OUTPUT)bpf_exp.yacc.* $(OUTPUT)bpf_exp.lex.* 68a92bb546SJakub Kicinski 6971bb428fSJakub Kicinskiinstall: bpftool_install 70*5a8997f2SJiri Benc install $(OUTPUT)bpf_jit_disasm $(prefix)/bin/bpf_jit_disasm 71*5a8997f2SJiri Benc install $(OUTPUT)bpf_dbg $(prefix)/bin/bpf_dbg 72*5a8997f2SJiri Benc install $(OUTPUT)bpf_asm $(prefix)/bin/bpf_asm 7371bb428fSJakub Kicinski 7471bb428fSJakub Kicinskibpftool: 7571bb428fSJakub Kicinski $(MAKE) -C bpftool 7671bb428fSJakub Kicinski 7771bb428fSJakub Kicinskibpftool_install: 7871bb428fSJakub Kicinski $(MAKE) -C bpftool install 7971bb428fSJakub Kicinski 8071bb428fSJakub Kicinskibpftool_clean: 8171bb428fSJakub Kicinski $(MAKE) -C bpftool clean 8271bb428fSJakub Kicinski 8371bb428fSJakub Kicinski.PHONY: bpftool FORCE 84