2023-06-24 14:31:33 +02:00
|
|
|
SRC_S += $(SRC_S_IAR)
|
2023-06-24 12:35:37 +02:00
|
|
|
|
|
|
|
# Assembly files can be name with upper case .S, convert it to .s
|
|
|
|
SRC_S := $(SRC_S:.S=.s)
|
|
|
|
|
|
|
|
# Due to GCC LTO bug https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966
|
|
|
|
# assembly file should be placed first in linking order
|
|
|
|
# '_asm' suffix is added to object of assembly file
|
|
|
|
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=_asm.o))
|
|
|
|
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o))
|
|
|
|
|
|
|
|
# Linker script
|
2023-06-24 14:31:33 +02:00
|
|
|
LDFLAGS += --config $(TOP)/$(LD_FILE_IAR)
|
2023-06-24 12:35:37 +02:00
|
|
|
|
|
|
|
# ---------------------------------------
|
|
|
|
# Rules
|
|
|
|
# ---------------------------------------
|
|
|
|
|
|
|
|
# Compile .c file
|
|
|
|
$(BUILD)/obj/%.o: %.c
|
|
|
|
@echo CC $(notdir $@)
|
|
|
|
@$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
|
|
|
|
# ASM sources lower case .s
|
|
|
|
$(BUILD)/obj/%_asm.o: %.s
|
|
|
|
@echo AS $(notdir $@)
|
|
|
|
@$(AS) $(ASFLAGS) -c -o $@ $<
|
|
|
|
|
|
|
|
# ASM sources upper case .S
|
|
|
|
$(BUILD)/obj/%_asm.o: %.S
|
|
|
|
@echo AS $(notdir $@)
|
|
|
|
@$(AS) $(ASFLAGS) -c -o $@ $<
|
|
|
|
|
|
|
|
$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf
|
|
|
|
@echo CREATE $@
|
|
|
|
@$(OBJCOPY) --bin $^ $@
|
|
|
|
|
|
|
|
$(BUILD)/$(PROJECT).hex: $(BUILD)/$(PROJECT).elf
|
|
|
|
@echo CREATE $@
|
|
|
|
@$(OBJCOPY) --ihex $^ $@
|
|
|
|
|
|
|
|
$(BUILD)/$(PROJECT).elf: $(OBJ)
|
|
|
|
@echo LINK $@
|
|
|
|
@$(LD) -o $@ $(LDFLAGS) $^
|