Blame view
tools/bpf/Makefile
3.54 KB
b24413180
|
1 |
# SPDX-License-Identifier: GPL-2.0 |
5a8997f20
|
2 |
include ../scripts/Makefile.include |
fde68c5be
|
3 |
prefix ?= /usr/local |
e306e2c13
|
4 |
|
3f356385e
|
5 6 |
LEX = flex YACC = bison |
71bb428fe
|
7 |
MAKE = make |
fde68c5be
|
8 |
INSTALL ?= install |
e306e2c13
|
9 |
|
d7475de58
|
10 |
CFLAGS += -Wall -O2 |
f143c11bb
|
11 12 |
CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi \ -I$(srctree)/tools/include |
d7475de58
|
13 |
|
55d554f5d
|
14 15 16 17 |
# This will work when bpf is built in tools env. where srctree # isn't set and when invoked from selftests build, where srctree # is set to ".". building_out_of_srctree is undefined for in srctree # builds |
a89b2cbf7
|
18 19 20 |
ifeq ($(srctree),) update_srctree := 1 endif |
55d554f5d
|
21 |
ifndef building_out_of_srctree |
a89b2cbf7
|
22 23 24 |
update_srctree := 1 endif ifeq ($(update_srctree),1) |
fb982666e
|
25 26 27 |
srctree := $(patsubst %/,%,$(dir $(CURDIR))) srctree := $(patsubst %/,%,$(dir $(srctree))) endif |
a50b7f8c6
|
28 29 30 31 32 |
ifeq ($(V),1) Q = else Q = @ endif |
fb982666e
|
33 34 35 36 37 |
FEATURE_USER = .bpf FEATURE_TESTS = libbfd disassembler-four-args FEATURE_DISPLAY = libbfd disassembler-four-args check_feat := 1 |
1eb832ac2
|
38 |
NON_CHECK_FEAT_TARGETS := clean bpftool_clean runqslower_clean resolve_btfids_clean |
fb982666e
|
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
ifdef MAKECMDGOALS ifeq ($(filter-out $(NON_CHECK_FEAT_TARGETS),$(MAKECMDGOALS)),) check_feat := 0 endif endif ifeq ($(check_feat),1) ifeq ($(FEATURES_DUMP),) include $(srctree)/tools/build/Makefile.feature else include $(FEATURES_DUMP) endif endif ifeq ($(feature-disassembler-four-args), 1) CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE endif |
5a8997f20
|
56 |
$(OUTPUT)%.yacc.c: $(srctree)/tools/bpf/%.y |
a50b7f8c6
|
57 |
$(QUIET_BISON)$(YACC) -o $@ -d $< |
3f356385e
|
58 |
|
5a8997f20
|
59 |
$(OUTPUT)%.lex.c: $(srctree)/tools/bpf/%.l |
a50b7f8c6
|
60 |
$(QUIET_FLEX)$(LEX) -o $@ $< |
3f356385e
|
61 |
|
5a8997f20
|
62 |
$(OUTPUT)%.o: $(srctree)/tools/bpf/%.c |
d70a6be1e
|
63 |
$(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $< |
a50b7f8c6
|
64 65 |
$(OUTPUT)%.yacc.o: $(OUTPUT)%.yacc.c |
d70a6be1e
|
66 |
$(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $< |
a50b7f8c6
|
67 |
$(OUTPUT)%.lex.o: $(OUTPUT)%.lex.c |
d70a6be1e
|
68 |
$(QUIET_CC)$(CC) $(CFLAGS) -c -o $@ $< |
5a8997f20
|
69 |
|
6c0710084
|
70 |
PROGS = $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg $(OUTPUT)bpf_asm |
9c01546d2
|
71 |
all: $(PROGS) bpftool runqslower |
e306e2c13
|
72 |
|
5a8997f20
|
73 |
$(OUTPUT)bpf_jit_disasm: CFLAGS += -DPACKAGE='bpf_jit_disasm' |
5a8997f20
|
74 |
$(OUTPUT)bpf_jit_disasm: $(OUTPUT)bpf_jit_disasm.o |
a50b7f8c6
|
75 |
$(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $^ -lopcodes -lbfd -ldl |
e306e2c13
|
76 |
|
5a8997f20
|
77 |
$(OUTPUT)bpf_dbg: $(OUTPUT)bpf_dbg.o |
a50b7f8c6
|
78 |
$(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $^ -lreadline |
fd981e3c3
|
79 |
|
5a8997f20
|
80 |
$(OUTPUT)bpf_asm: $(OUTPUT)bpf_asm.o $(OUTPUT)bpf_exp.yacc.o $(OUTPUT)bpf_exp.lex.o |
a50b7f8c6
|
81 |
$(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $^ |
ef8ba83b7
|
82 |
$(OUTPUT)bpf_exp.lex.c: $(OUTPUT)bpf_exp.yacc.c |
9c299a32e
|
83 84 |
$(OUTPUT)bpf_exp.yacc.o: $(OUTPUT)bpf_exp.yacc.c $(OUTPUT)bpf_exp.lex.o: $(OUTPUT)bpf_exp.lex.c |
3f356385e
|
85 |
|
1eb832ac2
|
86 |
clean: bpftool_clean runqslower_clean resolve_btfids_clean |
a50b7f8c6
|
87 |
$(call QUIET_CLEAN, bpf-progs) |
fbdb620b7
|
88 |
$(Q)$(RM) -r -- $(OUTPUT)*.o $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg \ |
5a8997f20
|
89 |
$(OUTPUT)bpf_asm $(OUTPUT)bpf_exp.yacc.* $(OUTPUT)bpf_exp.lex.* |
cc5b3403f
|
90 |
$(call QUIET_CLEAN, core-gen) |
fbdb620b7
|
91 92 |
$(Q)$(RM) -- $(OUTPUT)FEATURE-DUMP.bpf $(Q)$(RM) -r -- $(OUTPUT)feature |
e306e2c13
|
93 |
|
9c01546d2
|
94 |
install: $(PROGS) bpftool_install runqslower_install |
a50b7f8c6
|
95 96 97 98 99 100 101 |
$(call QUIET_INSTALL, bpf_jit_disasm) $(Q)$(INSTALL) -m 0755 -d $(DESTDIR)$(prefix)/bin $(Q)$(INSTALL) $(OUTPUT)bpf_jit_disasm $(DESTDIR)$(prefix)/bin/bpf_jit_disasm $(call QUIET_INSTALL, bpf_dbg) $(Q)$(INSTALL) $(OUTPUT)bpf_dbg $(DESTDIR)$(prefix)/bin/bpf_dbg $(call QUIET_INSTALL, bpf_asm) $(Q)$(INSTALL) $(OUTPUT)bpf_asm $(DESTDIR)$(prefix)/bin/bpf_asm |
71bb428fe
|
102 103 |
bpftool: |
58416c37d
|
104 |
$(call descend,bpftool) |
71bb428fe
|
105 106 |
bpftool_install: |
58416c37d
|
107 |
$(call descend,bpftool,install) |
71bb428fe
|
108 109 |
bpftool_clean: |
58416c37d
|
110 |
$(call descend,bpftool,clean) |
71bb428fe
|
111 |
|
9c01546d2
|
112 113 114 115 116 117 118 119 |
runqslower: $(call descend,runqslower) runqslower_install: $(call descend,runqslower,install) runqslower_clean: $(call descend,runqslower,clean) |
33a57ce0a
|
120 121 122 123 124 |
resolve_btfids: $(call descend,resolve_btfids) resolve_btfids_clean: $(call descend,resolve_btfids,clean) |
9c01546d2
|
125 |
.PHONY: all install clean bpftool bpftool_install bpftool_clean \ |
33a57ce0a
|
126 127 |
runqslower runqslower_install runqslower_clean \ resolve_btfids resolve_btfids_clean |