Skip to content
Snippets Groups Projects
Commit f64de068 authored by Gaëtan Harter's avatar Gaëtan Harter
Browse files

Makefile.include: separate link in subtargets

* Add ELFFILE, HEXFILE, print-size targets

$(BINDIR)/$(APPLICATION_MODULE).a target builds libraries in RIOT and in DIRS.

Uses a FORCE phony target dependency to force rebuilding but still let
`make` use the file modification timestamps
parent a83c8d22
No related branches found
No related tags found
No related merge requests found
...@@ -308,7 +308,12 @@ BASELIBS += $(BINDIR)/$(APPLICATION_MODULE).a ...@@ -308,7 +308,12 @@ BASELIBS += $(BINDIR)/$(APPLICATION_MODULE).a
BASELIBS += $(APPDEPS) BASELIBS += $(APPDEPS)
.PHONY: all link clean flash flash-only term doc debug debug-server reset objdump help info-modules .PHONY: all link clean flash flash-only term doc debug debug-server reset objdump help info-modules
.PHONY: print-size
.PHONY: ..in-docker-container .PHONY: ..in-docker-container
# Target can depend on FORCE to always rebuild but still let make use file
# modification timestamp (contrary to .PHONY).
# Use it for goals that may keep outputs unchanged when executed.
.PHONY: FORCE
ELFFILE ?= $(BINDIR)/$(APPLICATION).elf ELFFILE ?= $(BINDIR)/$(APPLICATION).elf
HEXFILE ?= $(ELFFILE:.elf=.hex) HEXFILE ?= $(ELFFILE:.elf=.hex)
...@@ -322,6 +327,7 @@ LINKFLAGPREFIX ?= -Wl, ...@@ -322,6 +327,7 @@ LINKFLAGPREFIX ?= -Wl,
DIRS += $(EXTERNAL_MODULE_DIRS) DIRS += $(EXTERNAL_MODULE_DIRS)
# Linker rule # Linker rule
$(ELFFILE): FORCE
ifeq ($(BUILDOSXNATIVE),1) ifeq ($(BUILDOSXNATIVE),1)
_LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $(UNDEF) $$(find $(BASELIBS) -size +8c) $(LINKFLAGS) $(LINKFLAGPREFIX)-no_pie _LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $(UNDEF) $$(find $(BASELIBS) -size +8c) $(LINKFLAGS) $(LINKFLAGPREFIX)-no_pie
else else
...@@ -331,14 +337,27 @@ endif # BUILDOSXNATIVE ...@@ -331,14 +337,27 @@ endif # BUILDOSXNATIVE
ifeq ($(BUILD_IN_DOCKER),1) ifeq ($(BUILD_IN_DOCKER),1)
link: ..in-docker-container link: ..in-docker-container
else else
## make script for your application. Build RIOT-base here!
link: ..compiler-check ..build-message $(RIOTBUILD_CONFIG_HEADER_C) $(USEPKG:%=$(BINDIR)/%.a) $(APPDEPS)
$(Q)DIRS="$(DIRS)" "$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk
ifeq (,$(RIOTNOLINK)) ifeq (,$(RIOTNOLINK))
$(Q)$(_LINK) -o $(ELFFILE) link: ..compiler-check ..build-message $(ELFFILE) $(HEXFILE) print-size
$(Q)$(SIZE) $(ELFFILE) else
$(Q)$(OBJCOPY) $(OFLAGS) $(ELFFILE) $(HEXFILE) link: ..compiler-check ..build-message $(BASELIBS)
endif endif # RIOTNOLINK
$(ELFFILE): $(BASELIBS)
$(Q)$(_LINK) -o $@
# All modules are built by application.inc.mk makefile
$(BINDIR)/$(APPLICATION_MODULE).a: $(RIOTBUILD_CONFIG_HEADER_C) $(USEPKG:%=$(BINDIR)/%.a) $(APPDEPS)
$(Q)DIRS="$(DIRS)" "$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk
$(BINDIR)/$(APPLICATION_MODULE).a: FORCE
# 'print-size' triggers a rebuild. Use 'info-buildsize' if you do not need to rebuild.
print-size: $(ELFFILE)
$(Q)$(SIZE) $<
$(HEXFILE): $(ELFFILE)
$(Q)$(OBJCOPY) $(OFLAGS) $< $@
endif # BUILD_IN_DOCKER endif # BUILD_IN_DOCKER
# Check given command is available in the path # Check given command is available in the path
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment