1 # SPDX-License-Identifier: GPL-2.0
2 include ..
/scripts
/Makefile.
include
13 CFLAGS
+= -D__EXPORTED_HEADERS__
-I
$(srctree
)/include/uapi
-I
$(srctree
)/include
16 srctree
:= $(patsubst %/,%,$(dir $(CURDIR
)))
17 srctree
:= $(patsubst %/,%,$(dir $(srctree
)))
27 FEATURE_TESTS
= libbfd disassembler-four-args
28 FEATURE_DISPLAY
= libbfd disassembler-four-args
31 NON_CHECK_FEAT_TARGETS
:= clean bpftool_clean
33 ifeq ($(filter-out $(NON_CHECK_FEAT_TARGETS
),$(MAKECMDGOALS
)),)
38 ifeq ($(check_feat
),1)
39 ifeq ($(FEATURES_DUMP
),)
40 include $(srctree
)/tools
/build
/Makefile.feature
42 include $(FEATURES_DUMP
)
46 ifeq ($(feature-disassembler-four-args
), 1)
47 CFLAGS
+= -DDISASM_FOUR_ARGS_SIGNATURE
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
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
81 $(call QUIET_CLEAN
, bpf-progs
)
82 $(Q
)rm -rf
$(OUTPUT
)*.o
$(OUTPUT
)bpf_jit_disasm
$(OUTPUT
)bpf_dbg \
83 $(OUTPUT
)bpf_asm
$(OUTPUT
)bpf_exp.
yacc.
* $(OUTPUT
)bpf_exp.
lex.
*
84 $(call QUIET_CLEAN
, core-gen
)
85 $(Q
)rm -f
$(OUTPUT
)FEATURE-DUMP.bpf
87 install: $(PROGS
) bpftool_install
88 $(call QUIET_INSTALL
, bpf_jit_disasm
)
89 $(Q
)$(INSTALL
) -m
0755 -d
$(DESTDIR
)$(prefix)/bin
90 $(Q
)$(INSTALL
) $(OUTPUT
)bpf_jit_disasm
$(DESTDIR
)$(prefix)/bin
/bpf_jit_disasm
91 $(call QUIET_INSTALL
, bpf_dbg
)
92 $(Q
)$(INSTALL
) $(OUTPUT
)bpf_dbg
$(DESTDIR
)$(prefix)/bin
/bpf_dbg
93 $(call QUIET_INSTALL
, bpf_asm
)
94 $(Q
)$(INSTALL
) $(OUTPUT
)bpf_asm
$(DESTDIR
)$(prefix)/bin
/bpf_asm
97 $(call descend
,bpftool
)
100 $(call descend
,bpftool
,install)
103 $(call descend
,bpftool
,clean)
105 .PHONY
: all install clean bpftool bpftool_install bpftool_clean