summaryrefslogtreecommitdiff
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)
116 116
117$(BUILDDIR)/$(BINARY): $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $(CPUFEAT_BUILD)/cpu-features.o 117$(BUILDDIR)/$(BINARY): $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $(CPUFEAT_BUILD)/cpu-features.o
118 $(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map 118 $(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map
119 $(call PRINTS,OC $(@F))$(OC) -S -x $@ 119 $(call PRINTS,OC $(@F))$(call objcopy,$@,$@)
120 120
121$(BINLIB_DIR)/$(BINARY): $(BUILDDIR)/$(BINARY) 121$(BINLIB_DIR)/$(BINARY): $(BUILDDIR)/$(BINARY)
122 $(call PRINTS,CP $(BINARY))cp $^ $@ 122 $(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
202 $(filter %.o, $^) \ 202 $(filter %.o, $^) \
203 $(filter %.a, $+) \ 203 $(filter %.a, $+) \
204 -lgcc $(CODECLDFLAGS) 204 -lgcc $(CODECLDFLAGS)
205ifndef APP_TYPE 205 $(SILENT)$(call objcopy,$(CODECDIR)/$*.elf,$@)
206 $(SILENT)$(OC) -O binary $(CODECDIR)/$*.elf $@ # objcopy native
207else ifeq (,$(findstring sdl-sim,$(APP_TYPE)))
208 $(SILENT)$(OC) -S -x $(CODECDIR)/$*.elf $@ # objcopy hosted
209else
210 $(SILENT)cp $(CODECDIR)/$*.elf $@ # no objcopy, keep debug symbols
211endif
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)
44 $(filter %.o, $^) \ 44 $(filter %.o, $^) \
45 $(filter %.a, $+) \ 45 $(filter %.a, $+) \
46 -lgcc $(CHESSBOX_OVLFLAGS) 46 -lgcc $(CHESSBOX_OVLFLAGS)
47 $(call PRINTS,LD $(@F))$(OC) -O binary $(basename $@).elf $@ 47 $(call PRINTS,LD $(@F))$(call objcopy,$(basename $@).elf,$@)
48 48
49# special pattern rule for compiling chessbox with extra flags 49# special pattern rule for compiling chessbox with extra flags
50$(CHESSBOX_OBJDIR)/%.o: $(CHESSBOX_SRCDIR)/%.c $(CHESSBOX_SRCDIR)/chessbox.make 50$(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)
43 $(filter %.o, $^) \ 43 $(filter %.o, $^) \
44 $(filter %.a, $+) \ 44 $(filter %.a, $+) \
45 -lgcc $(GOBAN_OVLFLAGS) 45 -lgcc $(GOBAN_OVLFLAGS)
46 $(call PRINTS,LD $(@F))$(OC) -O binary $(basename $@).elf $@ 46 $(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)
40 $(filter-out $(PLUGIN_CRT0),$(filter %.o, $^)) \ 40 $(filter-out $(PLUGIN_CRT0),$(filter %.o, $^)) \
41 $(filter %.a, $+) \ 41 $(filter %.a, $+) \
42 -lgcc $(IMGDEC_OVLFLAGS) 42 -lgcc $(IMGDEC_OVLFLAGS)
43ifdef APP_TYPE 43 $(SILENT)$(call objcopy,$(IMGVBUILDDIR)/$*.elf,$@)
44 $(SILENT)cp $(IMGVBUILDDIR)/$*.elf $@
45else
46 $(SILENT)$(OC) -O binary $(IMGVBUILDDIR)/$*.elf $@
47endif
48 44
49# rule to create reference map for image decoder 45# rule to create reference map for image decoder
50$(IMGVBUILDDIR)/%.refmap: $(APPSDIR)/plugin.h $(IMGVSRCDIR)/imageviewer.h $(PLUGINLINK_LDS) $(PLUGIN_LIBS) 46$(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)
56 $(filter %.o, $^) \ 56 $(filter %.o, $^) \
57 $(filter %.a, $+) \ 57 $(filter %.a, $+) \
58 -lgcc $(LUA_OVLFLAGS) 58 -lgcc $(LUA_OVLFLAGS)
59 $(call PRINTS,LD $(@F))$(OC) -O binary $(basename $@).elf $@ 59 $(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:
36 $(filter %.o, $^) \ 36 $(filter %.o, $^) \
37 $(filter %.a, $+) \ 37 $(filter %.a, $+) \
38 -lgcc $(PDBOXLDFLAGS) 38 -lgcc $(PDBOXLDFLAGS)
39ifdef APP_TYPE 39 $(SILENT)$(call objcopy,$*.elf,$@)
40 $(SILENT)cp $*.elf $@
41else
42 $(SILENT)$(OC) -O binary $*.elf $@
43endif
44 40
45 41
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)
50 $(filter %.o, $^) \ 50 $(filter %.o, $^) \
51 $(filter %.a, $+) \ 51 $(filter %.a, $+) \
52 -lgcc $(PICTUREFLOW_OVLFLAGS) 52 -lgcc $(PICTUREFLOW_OVLFLAGS)
53 $(call PRINTS,LD $(@F))$(OC) -O binary $(basename $@).elf $@ 53 $(call PRINTS,LD $(@F))$(call objcopy,$(basename $@).elf,$@)
54 54
55# special pattern rule for compiling pictureflow with extra flags 55# special pattern rule for compiling pictureflow with extra flags
56$(PICTUREFLOW_OBJDIR)/%.o: $(PICTUREFLOW_SRCDIR)/%.c $(PICTUREFLOW_SRCDIR)/pictureflow.make 56$(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:
120 $(filter %.o, $^) \ 120 $(filter %.o, $^) \
121 $(filter %.a, $+) \ 121 $(filter %.a, $+) \
122 -lgcc $(PLUGINLDFLAGS) 122 -lgcc $(PLUGINLDFLAGS)
123ifndef APP_TYPE 123 $(SILENT)$(call objcopy,$(BUILDDIR)/$*.elf,$@)
124 $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@ # objcopy native
125else ifeq (,$(findstring sdl-sim,$(APP_TYPE)))
126 $(SILENT)$(OC) -S -x $(BUILDDIR)/$*.elf $@ # objcopy hosted
127else
128 $(SILENT)cp $(BUILDDIR)/$*.elf $@ # no objcopy, keep debug symbols
129endif
130 124
131$(BUILDDIR)/apps/plugins/%.lua: $(ROOTDIR)/apps/plugins/%.lua 125$(BUILDDIR)/apps/plugins/%.lua: $(ROOTDIR)/apps/plugins/%.lua
132 $(call PRINTS,CP $(subst $(ROOTDIR)/,,$<))cp $< $(BUILDDIR)/apps/plugins/ 126 $(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)
37 $(filter %.o, $^) \ 37 $(filter %.o, $^) \
38 $(filter %.a, $+) \ 38 $(filter %.a, $+) \
39 -lgcc $(ROCKBOY_OVLFLAGS) 39 -lgcc $(ROCKBOY_OVLFLAGS)
40 $(call PRINTS,LD $(@F))$(OC) -O binary $(basename $@).elf $@ 40 $(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)
45 $(filter %.o, $^) \ 45 $(filter %.o, $^) \
46 $(filter %.a, $+) \ 46 $(filter %.a, $+) \
47 -lgcc $(ZXBOX_LDFLAGS) 47 -lgcc $(ZXBOX_LDFLAGS)
48 $(call PRINTS,LD $(@F))$(OC) -O binary $(basename $@).elf $@ 48 $(call PRINTS,LD $(@F))$(call objcopy,$(basename $@).elf,$@)
49 49
50# special pattern rule for compiling zxbox with extra flags 50# special pattern rule for compiling zxbox with extra flags
51$(ZXBOX_OBJDIR)/%.o: $(ZXBOX_SRCDIR)/%.c $(ZXBOX_SRCDIR)/zxbox.make 51$(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)
30 -Wl,--gc-sections -Wl,-Map,$(BUILDDIR)/bootloader.map 30 -Wl,--gc-sections -Wl,-Map,$(BUILDDIR)/bootloader.map
31 31
32$(BUILDDIR)/bootloader.bin : $(BUILDDIR)/bootloader.elf 32$(BUILDDIR)/bootloader.bin : $(BUILDDIR)/bootloader.elf
33 $(call PRINTS,OBJCOPY $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@ 33 $(call PRINTS,OC $(@F))$(call objcopy,$<,$@)
34 34
35$(BUILDDIR)/bootloader.asm: $(BUILDDIR)/bootloader.bin 35$(BUILDDIR)/bootloader.asm: $(BUILDDIR)/bootloader.bin
36 $(TOOLSDIR)/sh2d -sh1 $< > $@ 36 $(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)
21 $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map 21 $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map
22 22
23$(BUILDDIR)/rockbox : $(BUILDDIR)/rockbox.elf 23$(BUILDDIR)/rockbox : $(BUILDDIR)/rockbox.elf
24 $(call PRINTS,OC $(@F))$(OC) -S -x $< $@ 24 $(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))))
28 28
29a2lnk = $(patsubst lib%.a,-l%,$(notdir $(1))) 29a2lnk = $(patsubst lib%.a,-l%,$(notdir $(1)))
30 30
31# objcopy wrapper that keeps debug symbols in DEBUG builds
32# handles the $(1) == $(2) case too
33ifndef APP_TYPE
34objcopy = $(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $(1) $(2) # objcopy native
35else ifneq (,$(findstring sdl-sim,$(APP_TYPE)))
36objcopy = cp $(1) $(1).tmp;mv -f $(1).tmp $(2) # objcopy simulator
37else
38 ifdef DEBUG
39 objcopy = cp $(1) $(1).tmp;mv -f $(1).tmp $(2) # objcopy hosted (DEBUG)
40 else
41 objcopy = $(OC) -S -x $(1) $(2) # objcopy hosted (!DEBUG)
42 endif
43endif
44
31# calculate dependencies for a list of source files $(2) and output them to $(1) 45# calculate dependencies for a list of source files $(2) and output them to $(1)
32mkdepfile = $(SILENT)perl $(TOOLSDIR)/multigcc.pl $(CC) $(PPCFLAGS) $(OTHER_INC) -MG -MM -include config.h -- $(2) | \ 46mkdepfile = $(SILENT)perl $(TOOLSDIR)/multigcc.pl $(CC) $(PPCFLAGS) $(OTHER_INC) -MG -MM -include config.h -- $(2) | \
33 sed -e "s: lang.h: lang/lang.h:" \ 47 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
220 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map 220 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
221 221
222$(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf 222$(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
223 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@ 223 $(call PRINTS,OC $(@F))$(call objcopy,$<,$@)
224 224
225$(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf 225$(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
226 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@ 226 $(call PRINTS,OC $(@F))$(call objcopy,$<,$@)
227 227
228# 228#
229# If there's a flashfile defined for this target (rockbox.ucl for Archos 229# 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)
33$(BUILDDIR)/$(BINARY): $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $(SIMLIB) 33$(BUILDDIR)/$(BINARY): $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $(SIMLIB)
34 $(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(SIMLIB) $(LDOPTS) $(GLOBAL_LDOPTS) \ 34 $(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(SIMLIB) $(LDOPTS) $(GLOBAL_LDOPTS) \
35 -Wl,-Map,$(BUILDDIR)/rockbox.map 35 -Wl,-Map,$(BUILDDIR)/rockbox.map
36 $(SILENT)$(call objcopy,$@,$@)
36 37
37$(BUILDDIR)/uisimulator/%.o: $(ROOTDIR)/uisimulator/%.c 38$(BUILDDIR)/uisimulator/%.o: $(ROOTDIR)/uisimulator/%.c
38 $(SILENT)mkdir -p $(dir $@) 39 $(SILENT)mkdir -p $(dir $@)