summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorNicolas Schodet2012-10-20 21:29:52 +0200
committerNicolas Schodet2019-10-06 23:26:28 +0200
commitec16bd04529ccc14589a5b1d55a2ce8e1080b6f8 (patch)
treef5a160c7505331f53730b0cbc7698d4b23b922b4 /build
parent2dfe87e9378d89338fff5461a5f882a252a1c7de (diff)
Add binary files build
Diffstat (limited to 'build')
-rw-r--r--build/arch.mk31
-rw-r--r--build/stm32f4.mk1
-rw-r--r--build/top.mk5
3 files changed, 36 insertions, 1 deletions
diff --git a/build/arch.mk b/build/arch.mk
index 1d03504..75b9eaa 100644
--- a/build/arch.mk
+++ b/build/arch.mk
@@ -79,6 +79,37 @@ $1_EXTRA_CLEAN += $$($1_PROGS:%=%.$1.lst)
endef
+# Define binary rules.
+define arch_bin_rules
+
+hex: hex.$1
+srec: srec.$1
+bin: bin.$1
+all.$1: hex.$1
+
+.PHONY: hex.$1 srec.$1 bin.$1
+
+hex.$1: $$($1_PROGS:%=%.$1.hex)
+srec.$1: $$($1_PROGS:%=%.$1.srec)
+bin.$1: $$($1_PROGS:%=%.$1.bin)
+
+%.$1.hex: %.$1$$($1_ELF_SUFFIX)
+ @echo "HEX [$1] $$@"
+ $$Q$$($1_OBJCOPY) -O ihex $$< $$@
+%.$1.srec: %.$1$$($1_ELF_SUFFIX)
+ @echo "SREC [$1] $$@"
+ $$Q$$($1_OBJCOPY) -O srec $$< $$@
+%.$1.bin: %.$1$$($1_ELF_SUFFIX)
+ @echo "BIN [$1] $$@"
+ $$Q$$($1_OBJCOPY) -O binary $$< $$@
+
+$1_EXTRA_CLEAN += $$($1_PROGS:%=%.$1.hex) \
+ $$($1_PROGS:%=%.$1.srec) \
+ $$($1_PROGS:%=%.$1.bin)
+
+endef
+
+
# Define size report rules.
define arch_size_rules
diff --git a/build/stm32f4.mk b/build/stm32f4.mk
index fca60c8..c22358a 100644
--- a/build/stm32f4.mk
+++ b/build/stm32f4.mk
@@ -31,5 +31,6 @@ stm32f4_ELF_SUFFIX = .elf
$(eval $(call arch_build_rules,stm32f4))
$(eval $(call arch_lst_rules,stm32f4))
+$(eval $(call arch_bin_rules,stm32f4))
$(eval $(call arch_size_rules,stm32f4))
$(eval $(call arch_misc_rules,stm32f4))
diff --git a/build/top.mk b/build/top.mk
index adb4e95..7ac7735 100644
--- a/build/top.mk
+++ b/build/top.mk
@@ -30,11 +30,14 @@ Q = @
all:
lst:
size:
+hex:
+srec:
+bin:
clean:
rmdir $(OBJDIR) 2> /dev/null || true
-.PHONY: all lst size clean
+.PHONY: all lst size hex srec bin clean
# Modules and sources setup.