From 84430961da1a62a2ba137188dbd91881b723c67f Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Sat, 5 Nov 2016 21:01:06 +0100 Subject: [PATCH] Executables are not always .elf files Change-Id: I1abebbe9d3e7a4a208ba912f1f29ceddf23617ca --- Makefile | 17 ++++++++++------- Makefile.device | 1 + Makefile.simulator | 1 + apps/Makefile | 2 +- quiz/Makefile | 4 ++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 9a4d9a89f..13c884d3a 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,9 @@ include Makefile.$(PLATFORM) ifndef USE_LIBA $(error Makefile.PLATFORM should define USE_LIBA) endif +ifndef EXE + $(error Makefile.PLATFORM should define EXE, the extension for executables) +endif HOSTCC = gcc HOSTCXX = g++ @@ -30,12 +33,12 @@ endif CFLAGS = -std=c99 CXXFLAGS = -std=c++11 -fno-exceptions -fno-rtti -fno-threadsafe-statics -products := boot.elf boot.hex boot.bin test.elf test.hex test.bin +products := boot.$(EXE) boot.$(EXE) boot.bin test.$(EXE) test.hex test.bin ifeq ($(VERBOSE),1) default: info clean app_size app_memory_map else -default: app.elf +default: app.$(EXE) endif run: app_run @@ -71,26 +74,26 @@ dependencies = $(objs:.o=.d) -include $(dependencies) -%.elf: $(objs) +%.$(EXE): $(objs) @echo "LD $@" @$(LD) $^ $(LDFLAGS) -o $@ .PHONY: %_size -%_size: %.elf +%_size: %.$(EXE) @echo "========= BUILD OUTPUT ========" @echo "File: $<" @$(SIZE) $< | tail -n 1 | awk '{print "Code: " $$1 " bytes";print "Data: " $$2 " bytes"; print "Total: " int(($$1+$$2)/1024) " kB (" $$1 + $$2 " bytes)";}' @echo "===============================" .PHONY: %_run -%_run: %.elf +%_run: %.$(EXE) $(GDB) -x gdb_script.gdb $< -%.hex: %.elf +%.hex: %.$(EXE) @echo "OBJCOPY $@" @$(OBJCOPY) -O ihex $< $@ -%.bin: %.elf +%.bin: %.$(EXE) @echo "OBJCOPY $@" @$(OBJCOPY) -O binary $< $@ diff --git a/Makefile.device b/Makefile.device index d5ea90b68..887f02fca 100644 --- a/Makefile.device +++ b/Makefile.device @@ -25,3 +25,4 @@ SFLAGS += -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 # Platform configuration USE_LIBA=1 +EXE=elf diff --git a/Makefile.simulator b/Makefile.simulator index c1d186892..84d775678 100644 --- a/Makefile.simulator +++ b/Makefile.simulator @@ -4,3 +4,4 @@ LD=clang++ SIZE=size USE_LIBA=0 +EXE=elf diff --git a/apps/Makefile b/apps/Makefile index 815800ced..11eac9842 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -15,4 +15,4 @@ $(app_objs): $(inline_images:.png=.o) products += $(app_objs) app.elf app.hex app.bin -app.elf: $(app_objs) +app.$(EXE): $(app_objs) diff --git a/quiz/Makefile b/quiz/Makefile index bb238bf13..9e56ca958 100644 --- a/quiz/Makefile +++ b/quiz/Makefile @@ -9,6 +9,6 @@ $(symbols_file): $(tests) runner_objs += $(addprefix quiz/src/, runner.o symbols.o) test_objs = $(subst .c,.o, $(subst .cpp,.o,$(tests))) -products += test.elf test.hex test.bin $(runner_objs) $(test_objs) +products += test.$(EXE) test.hex test.bin $(runner_objs) $(test_objs) -test.elf: $(objs) $(runner_objs) $(test_objs) +test.$(EXE): $(objs) $(runner_objs) $(test_objs)