summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-04-04 21:43:22 +0200
committerThomas Martitz <kugel@rockbox.org>2012-04-04 21:48:19 +0200
commit4b56ee048a950eb8190abec3f8dc8b7a9b6e8946 (patch)
tree5f7275d75c32831531963c6fecf64dbcad250efa
parenta54072e2992ad8b6fccdaf8e8062f37c53743be8 (diff)
downloadrockbox-4b56ee048a950eb8190abec3f8dc8b7a9b6e8946.tar.gz
rockbox-4b56ee048a950eb8190abec3f8dc8b7a9b6e8946.zip
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
-rw-r--r--android/android.make2
-rw-r--r--apps/codecs/codecs.make8
-rw-r--r--apps/plugins/chessbox/chessbox.make2
-rw-r--r--apps/plugins/goban/goban.make2
-rw-r--r--apps/plugins/imageviewer/imageviewer.make6
-rw-r--r--apps/plugins/lua/lua.make2
-rw-r--r--apps/plugins/pdbox/pdbox.make6
-rw-r--r--apps/plugins/pictureflow/pictureflow.make2
-rw-r--r--apps/plugins/plugins.make8
-rw-r--r--apps/plugins/rockboy/rockboy.make2
-rw-r--r--apps/plugins/zxbox/zxbox.make2
-rw-r--r--bootloader/bootloader.make2
-rw-r--r--firmware/target/hosted/ypr0/ypr0.make2
-rw-r--r--tools/functions.make14
-rw-r--r--tools/root.make4
-rw-r--r--uisimulator/uisimulator.make1
16 files changed, 30 insertions, 35 deletions
diff --git a/android/android.make b/android/android.make
index dfbc64ef6e..b1f8588c93 100644
--- a/android/android.make
+++ b/android/android.make
@@ -116,7 +116,7 @@ classes: $(R_OBJ) $(JAVA_OBJ)
$(BUILDDIR)/$(BINARY): $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $(CPUFEAT_BUILD)/cpu-features.o
$(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map
- $(call PRINTS,OC $(@F))$(OC) -S -x $@
+ $(call PRINTS,OC $(@F))$(call objcopy,$@,$@)
$(BINLIB_DIR)/$(BINARY): $(BUILDDIR)/$(BINARY)
$(call PRINTS,CP $(BINARY))cp $^ $@
diff --git a/apps/codecs/codecs.make b/apps/codecs/codecs.make
index f2d2f13794..3e4ec3aa5f 100644
--- a/apps/codecs/codecs.make
+++ b/apps/codecs/codecs.make
@@ -202,10 +202,4 @@ $(CODECDIR)/%.codec: $(CODECDIR)/%.o
$(filter %.o, $^) \
$(filter %.a, $+) \
-lgcc $(CODECLDFLAGS)
-ifndef APP_TYPE
- $(SILENT)$(OC) -O binary $(CODECDIR)/$*.elf $@ # objcopy native
-else ifeq (,$(findstring sdl-sim,$(APP_TYPE)))
- $(SILENT)$(OC) -S -x $(CODECDIR)/$*.elf $@ # objcopy hosted
-else
- $(SILENT)cp $(CODECDIR)/$*.elf $@ # no objcopy, keep debug symbols
-endif
+ $(SILENT)$(call objcopy,$(CODECDIR)/$*.elf,$@)
diff --git a/apps/plugins/chessbox/chessbox.make b/apps/plugins/chessbox/chessbox.make
index 357130cb74..ee4940de8b 100644
--- a/apps/plugins/chessbox/chessbox.make
+++ b/apps/plugins/chessbox/chessbox.make
@@ -44,7 +44,7 @@ $(CHESSBOX_OBJDIR)/chessbox.ovl: $(CHESSBOX_OBJ) $(CHESSBOX_OUTLDS)
$(filter %.o, $^) \
$(filter %.a, $+) \
-lgcc $(CHESSBOX_OVLFLAGS)
- $(call PRINTS,LD $(@F))$(OC) -O binary $(basename $@).elf $@
+ $(call PRINTS,LD $(@F))$(call objcopy,$(basename $@).elf,$@)
# special pattern rule for compiling chessbox with extra flags
$(CHESSBOX_OBJDIR)/%.o: $(CHESSBOX_SRCDIR)/%.c $(CHESSBOX_SRCDIR)/chessbox.make
diff --git a/apps/plugins/goban/goban.make b/apps/plugins/goban/goban.make
index 2bc85ad8e1..a8b41285f0 100644
--- a/apps/plugins/goban/goban.make
+++ b/apps/plugins/goban/goban.make
@@ -43,4 +43,4 @@ $(GOBAN_BUILDDIR)/goban.ovl: $(GOBAN_OBJ) $(GOBAN_OUTLDS)
$(filter %.o, $^) \
$(filter %.a, $+) \
-lgcc $(GOBAN_OVLFLAGS)
- $(call PRINTS,LD $(@F))$(OC) -O binary $(basename $@).elf $@
+ $(call PRINTS,LD $(@F))$(call objcopy,$(basename $@).elf,$@)
diff --git a/apps/plugins/imageviewer/imageviewer.make b/apps/plugins/imageviewer/imageviewer.make
index 7f7d94320a..97af1e98a7 100644
--- a/apps/plugins/imageviewer/imageviewer.make
+++ b/apps/plugins/imageviewer/imageviewer.make
@@ -40,11 +40,7 @@ $(IMGVBUILDDIR)/%.ovl: $(IMGDEC_OUTLDS)
$(filter-out $(PLUGIN_CRT0),$(filter %.o, $^)) \
$(filter %.a, $+) \
-lgcc $(IMGDEC_OVLFLAGS)
-ifdef APP_TYPE
- $(SILENT)cp $(IMGVBUILDDIR)/$*.elf $@
-else
- $(SILENT)$(OC) -O binary $(IMGVBUILDDIR)/$*.elf $@
-endif
+ $(SILENT)$(call objcopy,$(IMGVBUILDDIR)/$*.elf,$@)
# rule to create reference map for image decoder
$(IMGVBUILDDIR)/%.refmap: $(APPSDIR)/plugin.h $(IMGVSRCDIR)/imageviewer.h $(PLUGINLINK_LDS) $(PLUGIN_LIBS)
diff --git a/apps/plugins/lua/lua.make b/apps/plugins/lua/lua.make
index 9e2db62e39..a70f0280b0 100644
--- a/apps/plugins/lua/lua.make
+++ b/apps/plugins/lua/lua.make
@@ -56,4 +56,4 @@ $(LUA_BUILDDIR)/lua.ovl: $(LUA_OBJ) $(LUA_OUTLDS)
$(filter %.o, $^) \
$(filter %.a, $+) \
-lgcc $(LUA_OVLFLAGS)
- $(call PRINTS,LD $(@F))$(OC) -O binary $(basename $@).elf $@
+ $(call PRINTS,LD $(@F))$(call objcopy,$(basename $@).elf,$@)
diff --git a/apps/plugins/pdbox/pdbox.make b/apps/plugins/pdbox/pdbox.make
index 239e1c0852..3edc97efe5 100644
--- a/apps/plugins/pdbox/pdbox.make
+++ b/apps/plugins/pdbox/pdbox.make
@@ -36,10 +36,6 @@ $(PDBOXBUILDDIR)/pdbox.rock:
$(filter %.o, $^) \
$(filter %.a, $+) \
-lgcc $(PDBOXLDFLAGS)
-ifdef APP_TYPE
- $(SILENT)cp $*.elf $@
-else
- $(SILENT)$(OC) -O binary $*.elf $@
-endif
+ $(SILENT)$(call objcopy,$*.elf,$@)
diff --git a/apps/plugins/pictureflow/pictureflow.make b/apps/plugins/pictureflow/pictureflow.make
index e3d4544e07..9c29f7abd9 100644
--- a/apps/plugins/pictureflow/pictureflow.make
+++ b/apps/plugins/pictureflow/pictureflow.make
@@ -50,7 +50,7 @@ $(PICTUREFLOW_OBJDIR)/pictureflow.ovl: $(PICTUREFLOW_OBJ) $(PICTUREFLOW_OUTLDS)
$(filter %.o, $^) \
$(filter %.a, $+) \
-lgcc $(PICTUREFLOW_OVLFLAGS)
- $(call PRINTS,LD $(@F))$(OC) -O binary $(basename $@).elf $@
+ $(call PRINTS,LD $(@F))$(call objcopy,$(basename $@).elf,$@)
# special pattern rule for compiling pictureflow with extra flags
$(PICTUREFLOW_OBJDIR)/%.o: $(PICTUREFLOW_SRCDIR)/%.c $(PICTUREFLOW_SRCDIR)/pictureflow.make
diff --git a/apps/plugins/plugins.make b/apps/plugins/plugins.make
index b80523d41b..27bc69f1ca 100644
--- a/apps/plugins/plugins.make
+++ b/apps/plugins/plugins.make
@@ -120,13 +120,7 @@ $(BUILDDIR)/%.rock:
$(filter %.o, $^) \
$(filter %.a, $+) \
-lgcc $(PLUGINLDFLAGS)
-ifndef APP_TYPE
- $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@ # objcopy native
-else ifeq (,$(findstring sdl-sim,$(APP_TYPE)))
- $(SILENT)$(OC) -S -x $(BUILDDIR)/$*.elf $@ # objcopy hosted
-else
- $(SILENT)cp $(BUILDDIR)/$*.elf $@ # no objcopy, keep debug symbols
-endif
+ $(SILENT)$(call objcopy,$(BUILDDIR)/$*.elf,$@)
$(BUILDDIR)/apps/plugins/%.lua: $(ROOTDIR)/apps/plugins/%.lua
$(call PRINTS,CP $(subst $(ROOTDIR)/,,$<))cp $< $(BUILDDIR)/apps/plugins/
diff --git a/apps/plugins/rockboy/rockboy.make b/apps/plugins/rockboy/rockboy.make
index 4869cedcbf..625c40eca8 100644
--- a/apps/plugins/rockboy/rockboy.make
+++ b/apps/plugins/rockboy/rockboy.make
@@ -37,4 +37,4 @@ $(ROCKBOY_OBJDIR)/rockboy.ovl: $(ROCKBOY_OBJ) $(ROCKBOY_OUTLDS)
$(filter %.o, $^) \
$(filter %.a, $+) \
-lgcc $(ROCKBOY_OVLFLAGS)
- $(call PRINTS,LD $(@F))$(OC) -O binary $(basename $@).elf $@
+ $(call PRINTS,LD $(@F))$(call objcopy,$(basename $@).elf,$@)
diff --git a/apps/plugins/zxbox/zxbox.make b/apps/plugins/zxbox/zxbox.make
index a04801aa31..4638d5f0a2 100644
--- a/apps/plugins/zxbox/zxbox.make
+++ b/apps/plugins/zxbox/zxbox.make
@@ -45,7 +45,7 @@ $(ZXBOX_OBJDIR)/zxbox.ovl: $(ZXBOX_OBJ) $(ZXBOX_OUTLDS)
$(filter %.o, $^) \
$(filter %.a, $+) \
-lgcc $(ZXBOX_LDFLAGS)
- $(call PRINTS,LD $(@F))$(OC) -O binary $(basename $@).elf $@
+ $(call PRINTS,LD $(@F))$(call objcopy,$(basename $@).elf,$@)
# special pattern rule for compiling zxbox with extra flags
$(ZXBOX_OBJDIR)/%.o: $(ZXBOX_SRCDIR)/%.c $(ZXBOX_SRCDIR)/zxbox.make
diff --git a/bootloader/bootloader.make b/bootloader/bootloader.make
index 88305f3c89..d1f580a52e 100644
--- a/bootloader/bootloader.make
+++ b/bootloader/bootloader.make
@@ -30,7 +30,7 @@ $(BUILDDIR)/bootloader.elf: $$(OBJ) $(FIRMLIB) $(CORE_LIBS) $$(BOOTLINK)
-Wl,--gc-sections -Wl,-Map,$(BUILDDIR)/bootloader.map
$(BUILDDIR)/bootloader.bin : $(BUILDDIR)/bootloader.elf
- $(call PRINTS,OBJCOPY $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
+ $(call PRINTS,OC $(@F))$(call objcopy,$<,$@)
$(BUILDDIR)/bootloader.asm: $(BUILDDIR)/bootloader.bin
$(TOOLSDIR)/sh2d -sh1 $< > $@
diff --git a/firmware/target/hosted/ypr0/ypr0.make b/firmware/target/hosted/ypr0/ypr0.make
index 68f53902ad..d0f4cb7fe2 100644
--- a/firmware/target/hosted/ypr0/ypr0.make
+++ b/firmware/target/hosted/ypr0/ypr0.make
@@ -21,4 +21,4 @@ $(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS)
$(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map
$(BUILDDIR)/rockbox : $(BUILDDIR)/rockbox.elf
- $(call PRINTS,OC $(@F))$(OC) -S -x $< $@
+ $(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
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:" \
diff --git a/tools/root.make b/tools/root.make
index 30e3b3f865..0fc6c55403 100644
--- a/tools/root.make
+++ b/tools/root.make
@@ -220,10 +220,10 @@ $(BUILDDIR)/rombox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $$(LIN
-T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
$(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
- $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
+ $(call PRINTS,OC $(@F))$(call objcopy,$<,$@)
$(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
- $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
+ $(call PRINTS,OC $(@F))$(call objcopy,$<,$@)
#
# If there's a flashfile defined for this target (rockbox.ucl for Archos
diff --git a/uisimulator/uisimulator.make b/uisimulator/uisimulator.make
index 1ab3fda83c..8756ac65b7 100644
--- a/uisimulator/uisimulator.make
+++ b/uisimulator/uisimulator.make
@@ -33,6 +33,7 @@ $(SIMLIB): $$(SIMOBJ) $(UIBMP)
$(BUILDDIR)/$(BINARY): $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $(SIMLIB)
$(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(SIMLIB) $(LDOPTS) $(GLOBAL_LDOPTS) \
-Wl,-Map,$(BUILDDIR)/rockbox.map
+ $(SILENT)$(call objcopy,$@,$@)
$(BUILDDIR)/uisimulator/%.o: $(ROOTDIR)/uisimulator/%.c
$(SILENT)mkdir -p $(dir $@)