1
1
# SPDX-License-Identifier: GPL-2.0
2
+ include ../scripts/Makefile.include
3
+
2
4
prefix = /usr
3
5
4
6
CC = gcc
@@ -7,7 +9,7 @@ YACC = bison
7
9
MAKE = make
8
10
9
11
CFLAGS += -Wall -O2
10
- CFLAGS += -D__EXPORTED_HEADERS__ -I../../ include/uapi -I../.. /include
12
+ CFLAGS += -D__EXPORTED_HEADERS__ -I$( srctree ) / include/uapi -I$( srctree ) /include
11
13
12
14
ifeq ($(srctree ) ,)
13
15
srctree := $(patsubst % /,% ,$(dir $(CURDIR ) ) )
@@ -38,32 +40,36 @@ ifeq ($(feature-disassembler-four-args), 1)
38
40
CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
39
41
endif
40
42
41
- % .yacc.c : % .y
43
+ $( OUTPUT ) % .yacc.c : $( srctree ) /tools/bpf/ % .y
42
44
$(YACC ) -o $@ -d $<
43
45
44
- % .lex.c : % .l
46
+ $( OUTPUT ) % .lex.c : $( srctree ) /tools/bpf/ % .l
45
47
$(LEX ) -o $@ $<
46
48
47
- all : bpf_jit_disasm bpf_dbg bpf_asm bpftool
49
+ $(OUTPUT ) % .o : $(srctree ) /tools/bpf/% .c
50
+ $(COMPILE.c ) -o $@ $<
51
+
52
+ all : $(OUTPUT ) bpf_jit_disasm $(OUTPUT ) bpf_dbg $(OUTPUT ) bpf_asm bpftool
48
53
49
- bpf_jit_disasm : CFLAGS += -DPACKAGE='bpf_jit_disasm'
50
- bpf_jit_disasm : LDLIBS = -lopcodes -lbfd -ldl
51
- bpf_jit_disasm : bpf_jit_disasm.o
54
+ $( OUTPUT ) bpf_jit_disasm : CFLAGS += -DPACKAGE='bpf_jit_disasm'
55
+ $( OUTPUT ) bpf_jit_disasm : LDLIBS = -lopcodes -lbfd -ldl
56
+ $( OUTPUT ) bpf_jit_disasm: $( OUTPUT ) bpf_jit_disasm.o
52
57
53
- bpf_dbg : LDLIBS = -lreadline
54
- bpf_dbg : bpf_dbg.o
58
+ $( OUTPUT ) bpf_dbg : LDLIBS = -lreadline
59
+ $( OUTPUT ) bpf_dbg: $( OUTPUT ) bpf_dbg.o
55
60
56
- bpf_asm : LDLIBS =
57
- bpf_asm : bpf_asm.o bpf_exp.yacc.o bpf_exp.lex.o
58
- bpf_exp.lex.o : bpf_exp.yacc.c
61
+ $( OUTPUT ) bpf_asm : LDLIBS =
62
+ $( OUTPUT ) bpf_asm: $( OUTPUT ) bpf_asm.o $( OUTPUT ) bpf_exp.yacc.o $( OUTPUT ) bpf_exp.lex.o
63
+ $( OUTPUT ) bpf_exp.lex.o: $( OUTPUT ) bpf_exp.yacc.c
59
64
60
65
clean : bpftool_clean
61
- rm -rf * .o bpf_jit_disasm bpf_dbg bpf_asm bpf_exp.yacc.* bpf_exp.lex.*
66
+ rm -rf $(OUTPUT ) * .o $(OUTPUT ) bpf_jit_disasm $(OUTPUT ) bpf_dbg \
67
+ $(OUTPUT ) bpf_asm $(OUTPUT ) bpf_exp.yacc.* $(OUTPUT ) bpf_exp.lex.*
62
68
63
69
install : 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
70
+ install $( OUTPUT ) bpf_jit_disasm $(prefix ) /bin/bpf_jit_disasm
71
+ install $( OUTPUT ) bpf_dbg $(prefix ) /bin/bpf_dbg
72
+ install $( OUTPUT ) bpf_asm $(prefix ) /bin/bpf_asm
67
73
68
74
bpftool :
69
75
$(MAKE ) -C bpftool
0 commit comments