summaryrefslogtreecommitdiff
path: root/tools/make/toolchain/arm_iar_rules.mk
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-06-24 17:35:37 +0700
committerhathach <[email protected]>2023-06-24 17:35:37 +0700
commitedbf06aaab9ac7cf098f1170a7a9861f5cf3572e (patch)
tree1594eaf35aba0312e6a76f47a80986cb9fd90ad3 /tools/make/toolchain/arm_iar_rules.mk
parent50e61e0e16122a2466536d77b858cb228d60d0c2 (diff)
separate iar and gcc build for clean make, also add cpu specific make
Diffstat (limited to 'tools/make/toolchain/arm_iar_rules.mk')
-rw-r--r--tools/make/toolchain/arm_iar_rules.mk44
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/make/toolchain/arm_iar_rules.mk b/tools/make/toolchain/arm_iar_rules.mk
new file mode 100644
index 000000000..4b5cc90e3
--- /dev/null
+++ b/tools/make/toolchain/arm_iar_rules.mk
@@ -0,0 +1,44 @@
+SRC_S += $(IAR_SRC_S)
+
+# 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
+LDFLAGS += --config $(TOP)/$(IAR_LD_FILE)
+
+# ---------------------------------------
+# 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) $^