代码之家  ›  专栏  ›  技术社区  ›  joeforker

如何为单个目标添加额外的Makefile步骤?

  •  2
  • joeforker  · 技术社区  · 8 年前

    Makefile 看起来像这样,从 .o -> .bin -> .stub .o -> .elf -> .bin -> .stub .

    all: simple.stub complex.stub
    
    %.bin:  %.o
        $(Q)echo "  OBJCOPY $@"
        $(Q)$(OBJCOPY) -O binary $< $@
    
    %.stub: %.bin
        $(Q)echo "  HEXDUMP $@"
        $(Q)$(HEXDUMP) -v -e '/2 "0x%04X, "' $< > $@
    
    %.elf: %.o
        arm-none-eabi-gcc $< %@
    

    我该怎么说 make 那个 .o -> .bin 在生成时不是有效的转换 complex.stub ,并防止其通过 .elf

    1 回复  |  直到 8 年前
        1
  •  1
  •   user657267    8 年前

    你需要告诉我 make %.bin: %.elf

    .PHONY: all
    all: simple.stub complex.stub
    
    .INTERMEDIATE: complex.bin complex.elf
    
    complex.bin: complex.elf
    
    %.bin: %.o
        @echo Making $@ from $^
        @echo "test" > $@
    
    %.bin: %.elf
        @echo Making $@ from $^
        @echo "test" > $@
    
    %.stub: %.bin
        @echo Making $@ from $^
        @echo "test" > $@
    
    %.elf: %.o
        @echo Making $@ from $^
        @echo "test" > $@
    
    %.o:
        @echo Making $@
        @echo "test" > $@
    

    .INTERMEDIATE