Executables are not always .elf files

Change-Id: I1abebbe9d3e7a4a208ba912f1f29ceddf23617ca
This commit is contained in:
Romain Goyet
2016-11-05 21:01:06 +01:00
parent 8cc570e6f4
commit 84430961da
5 changed files with 15 additions and 10 deletions

View File

@@ -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 $< $@

View File

@@ -25,3 +25,4 @@ SFLAGS += -mcpu=cortex-m4 -mfpu=fpv4-sp-d16
# Platform configuration
USE_LIBA=1
EXE=elf

View File

@@ -4,3 +4,4 @@ LD=clang++
SIZE=size
USE_LIBA=0
EXE=elf

View File

@@ -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)

View File

@@ -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)