mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	tools: bpf: respect output directory during build
Currently, the programs under tools/bpf (with the notable exception of bpftool) do not respect the output directory (make O=dir). Fix that. Signed-off-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
		
							parent
							
								
									72ab55e96e
								
							
						
					
					
						commit
						5a8997f207
					
				
					 1 changed files with 22 additions and 16 deletions
				
			
		| 
						 | 
					@ -1,4 +1,6 @@
 | 
				
			||||||
# SPDX-License-Identifier: GPL-2.0
 | 
					# SPDX-License-Identifier: GPL-2.0
 | 
				
			||||||
 | 
					include ../scripts/Makefile.include
 | 
				
			||||||
 | 
					
 | 
				
			||||||
prefix = /usr
 | 
					prefix = /usr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CC = gcc
 | 
					CC = gcc
 | 
				
			||||||
| 
						 | 
					@ -7,7 +9,7 @@ YACC = bison
 | 
				
			||||||
MAKE = make
 | 
					MAKE = make
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CFLAGS += -Wall -O2
 | 
					CFLAGS += -Wall -O2
 | 
				
			||||||
CFLAGS += -D__EXPORTED_HEADERS__ -I../../include/uapi -I../../include
 | 
					CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ifeq ($(srctree),)
 | 
					ifeq ($(srctree),)
 | 
				
			||||||
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
 | 
					srctree := $(patsubst %/,%,$(dir $(CURDIR)))
 | 
				
			||||||
| 
						 | 
					@ -38,32 +40,36 @@ ifeq ($(feature-disassembler-four-args), 1)
 | 
				
			||||||
CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
 | 
					CFLAGS += -DDISASM_FOUR_ARGS_SIGNATURE
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
%.yacc.c: %.y
 | 
					$(OUTPUT)%.yacc.c: $(srctree)/tools/bpf/%.y
 | 
				
			||||||
	$(YACC) -o $@ -d $<
 | 
						$(YACC) -o $@ -d $<
 | 
				
			||||||
 | 
					
 | 
				
			||||||
%.lex.c: %.l
 | 
					$(OUTPUT)%.lex.c: $(srctree)/tools/bpf/%.l
 | 
				
			||||||
	$(LEX) -o $@ $<
 | 
						$(LEX) -o $@ $<
 | 
				
			||||||
 | 
					
 | 
				
			||||||
all: bpf_jit_disasm bpf_dbg bpf_asm bpftool
 | 
					$(OUTPUT)%.o: $(srctree)/tools/bpf/%.c
 | 
				
			||||||
 | 
						$(COMPILE.c) -o $@ $<
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bpf_jit_disasm : CFLAGS += -DPACKAGE='bpf_jit_disasm'
 | 
					all: $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg $(OUTPUT)bpf_asm bpftool
 | 
				
			||||||
bpf_jit_disasm : LDLIBS = -lopcodes -lbfd -ldl
 | 
					 | 
				
			||||||
bpf_jit_disasm : bpf_jit_disasm.o
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
bpf_dbg : LDLIBS = -lreadline
 | 
					$(OUTPUT)bpf_jit_disasm: CFLAGS += -DPACKAGE='bpf_jit_disasm'
 | 
				
			||||||
bpf_dbg : bpf_dbg.o
 | 
					$(OUTPUT)bpf_jit_disasm: LDLIBS = -lopcodes -lbfd -ldl
 | 
				
			||||||
 | 
					$(OUTPUT)bpf_jit_disasm: $(OUTPUT)bpf_jit_disasm.o
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bpf_asm : LDLIBS =
 | 
					$(OUTPUT)bpf_dbg: LDLIBS = -lreadline
 | 
				
			||||||
bpf_asm : bpf_asm.o bpf_exp.yacc.o bpf_exp.lex.o
 | 
					$(OUTPUT)bpf_dbg: $(OUTPUT)bpf_dbg.o
 | 
				
			||||||
bpf_exp.lex.o : bpf_exp.yacc.c
 | 
					
 | 
				
			||||||
 | 
					$(OUTPUT)bpf_asm: LDLIBS =
 | 
				
			||||||
 | 
					$(OUTPUT)bpf_asm: $(OUTPUT)bpf_asm.o $(OUTPUT)bpf_exp.yacc.o $(OUTPUT)bpf_exp.lex.o
 | 
				
			||||||
 | 
					$(OUTPUT)bpf_exp.lex.o: $(OUTPUT)bpf_exp.yacc.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
clean: bpftool_clean
 | 
					clean: bpftool_clean
 | 
				
			||||||
	rm -rf *.o bpf_jit_disasm bpf_dbg bpf_asm bpf_exp.yacc.* bpf_exp.lex.*
 | 
						rm -rf $(OUTPUT)*.o $(OUTPUT)bpf_jit_disasm $(OUTPUT)bpf_dbg \
 | 
				
			||||||
 | 
						       $(OUTPUT)bpf_asm $(OUTPUT)bpf_exp.yacc.* $(OUTPUT)bpf_exp.lex.*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
install: bpftool_install
 | 
					install: bpftool_install
 | 
				
			||||||
	install bpf_jit_disasm $(prefix)/bin/bpf_jit_disasm
 | 
						install $(OUTPUT)bpf_jit_disasm $(prefix)/bin/bpf_jit_disasm
 | 
				
			||||||
	install bpf_dbg $(prefix)/bin/bpf_dbg
 | 
						install $(OUTPUT)bpf_dbg $(prefix)/bin/bpf_dbg
 | 
				
			||||||
	install bpf_asm $(prefix)/bin/bpf_asm
 | 
						install $(OUTPUT)bpf_asm $(prefix)/bin/bpf_asm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bpftool:
 | 
					bpftool:
 | 
				
			||||||
	$(MAKE) -C bpftool
 | 
						$(MAKE) -C bpftool
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue