makefile中把生成的文件放到指定的目录

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

vpath %.S src/arm
vpath %.c src 
vpath %.c src/init

OBJ_PATH = obj
BIN_PATH = bin
SRC_PATH :=src/arm src/init src
SRC= $(foreach x,$(SRC_PATH),$(wildcard $(addprefix $(x)/*,.c .S))) 
#OBJ= $(addsuffix .o, $(notdir $(basename $(SRC)))) 
OBJ = $(addprefix $(OBJ_PATH)/, $(addsuffix .o,$(notdir $(basename $(SRC))))) 
ELF=obj/irq_elf
TARGET = irq.bin

$(BIN_PATH)/$(TARGET):$(OBJ)
	@echo '+++++++++++Make echo: build $(TARGET)'
	arm-linux-ld -Ttext 0x00000000 $(OBJ) -o $(ELF)
	arm-linux-objdump -D -m arm $(ELF) > $(OBJ_PATH)/irq.dis
	arm-linux-objcopy -O binary -S $(ELF) $@

$(OBJ_PATH)/%.o:%.c
	arm-linux-gcc -Wall -O2 -c -o $@ $<
	
$(OBJ_PATH)/%.o:%.S
	arm-linux-gcc -Wall -O2 -c -o $@ $<


.PHONY:clean
clean:
	rm -f $(BIN_PATH)/*  $(OBJ_PATH)/*