From 4b56ee048a950eb8190abec3f8dc8b7a9b6e8946 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Wed, 4 Apr 2012 21:43:22 +0200 Subject: Refactor and unify objcopy calls in the build system. Also now properly handles DEBUG builds on hosted targets to keep debug symbols if necessary. Change-Id: I884031b79c6d49479e4d95752f35ced68872dd5d --- tools/functions.make | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tools/functions.make') diff --git a/tools/functions.make b/tools/functions.make index db7bbe9680..ead62f7b10 100644 --- a/tools/functions.make +++ b/tools/functions.make @@ -28,6 +28,20 @@ c2obj = $(addsuffix .o,$(basename $(subst $(ROOTDIR),$(BUILDDIR),$(1)))) a2lnk = $(patsubst lib%.a,-l%,$(notdir $(1))) +# objcopy wrapper that keeps debug symbols in DEBUG builds +# handles the $(1) == $(2) case too +ifndef APP_TYPE +objcopy = $(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $(1) $(2) # objcopy native +else ifneq (,$(findstring sdl-sim,$(APP_TYPE))) +objcopy = cp $(1) $(1).tmp;mv -f $(1).tmp $(2) # objcopy simulator +else + ifdef DEBUG + objcopy = cp $(1) $(1).tmp;mv -f $(1).tmp $(2) # objcopy hosted (DEBUG) + else + objcopy = $(OC) -S -x $(1) $(2) # objcopy hosted (!DEBUG) + endif +endif + # calculate dependencies for a list of source files $(2) and output them to $(1) mkdepfile = $(SILENT)perl $(TOOLSDIR)/multigcc.pl $(CC) $(PPCFLAGS) $(OTHER_INC) -MG -MM -include config.h -- $(2) | \ sed -e "s: lang.h: lang/lang.h:" \ -- cgit