シェル(Shell)でmakefileの作成ファイルを指定ディレクトリに入れる
Shellコード:
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)/*