2017-08-16 36 views
2

我有一个Makefile看起来像这样,从.o -> .bin -> .stub大多数目标。但我有另一个更复杂的目标,我想通过.o -> .elf -> .bin -> .stub生成。如何为单个目标添加额外的Makefile步骤?

all: simple.stub complex.stub 

%.bin: %.o 
    $(Q)echo " OBJCOPY [email protected]" 
    $(Q)$(OBJCOPY) -O binary $< [email protected] 

%.stub: %.bin 
    $(Q)echo " HEXDUMP [email protected]" 
    $(Q)$(HEXDUMP) -v -e '/2 "0x%04X, "' $< > [email protected] 

%.elf: %.o 
    arm-none-eabi-gcc $< %@ 

我如何告诉make.o -> .bin不是同时建立complex.stub一个有效的过渡,并防止它通过.elf去为其他人呢?

回答

1

你需要告诉make有关例外,并提供了另一种模式的规则,因为没有内置的规则%.bin: %.elf

.PHONY: all 
all: simple.stub complex.stub 

.INTERMEDIATE: complex.bin complex.elf 

complex.bin: complex.elf 

%.bin: %.o 
    @echo Making [email protected] from $^ 
    @echo "test" > [email protected] 

%.bin: %.elf 
    @echo Making [email protected] from $^ 
    @echo "test" > [email protected] 

%.stub: %.bin 
    @echo Making [email protected] from $^ 
    @echo "test" > [email protected] 

%.elf: %.o 
    @echo Making [email protected] from $^ 
    @echo "test" > [email protected] 

%.o: 
    @echo Making [email protected] 
    @echo "test" > [email protected] 

.INTERMEDIATE是不是绝对必要的,它只是一个有用自动清理看到,因为它不太可能需要保留中间文件。

相关问题