Revert r14786 which resulted in a substantial reduction in accuracy to save a 7.6KB...
[kugel-rb.git] / apps / Makefile
blob88d3155b2dd00023dc73df427cdddf317c2a033a
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 INCLUDES= $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(BUILDDIR) \
11 -I$(BUILDDIR)/bitmaps -I$(OBJDIR)
13 DEPFILE = $(OBJDIR)/dep-apps
15 LDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
17 ROMLDS := $(FIRMDIR)/rom.lds
19 ifdef ENABLEDPLUGINS
20 ROCKS=rocks
21 endif
23 ifdef SOFTWARECODECS
24 CODECS=build-codecs
26 # This sets up the parameters for building and linking libspeex for core voice
27 VOICE=libspeex-rockbox
28 VOICELIB=$(BUILDDIR)/libspeex-rockbox.a
29 LINKVOICE= -lspeex-rockbox
31 endif
33 # Set up the bitmap libraries
34 BITMAPLIBS =
35 LINKBITMAPS =
36 ifneq ($(strip $(BMP2RB_MONO)),)
37 BITMAPLIBS += $(BUILDDIR)/libbitmapsmono.a
38 LINKBITMAPS += -lbitmapsmono
39 endif
40 ifneq ($(strip $(BMP2RB_NATIVE)),)
41 BITMAPLIBS += $(BUILDDIR)/libbitmapsnative.a
42 LINKBITMAPS += -lbitmapsnative
43 endif
44 ifneq ($(strip $(BMP2RB_REMOTEMONO)),)
45 BITMAPLIBS += $(BUILDDIR)/libbitmapsremotemono.a
46 LINKBITMAPS += -lbitmapsremotemono
47 endif
48 ifneq ($(strip $(BMP2RB_REMOTENATIVE)),)
49 BITMAPLIBS += $(BUILDDIR)/libbitmapsremotenative.a
50 LINKBITMAPS += -lbitmapsremotenative
51 endif
53 # This sets up 'SRC' based on the files mentioned in SOURCES
54 include $(TOOLSDIR)/makesrc.inc
56 DEFINES = $(DEBUG)
58 DIRS = .
60 ifdef APPEXTRA
61 DIRS += $(subst :, ,$(APPEXTRA))
62 INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA)))
63 endif
65 CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET) $(BUILDDATE) $(DEFINES) -DTARGET_ID=$(TARGET_ID) \
66 -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE} \
67 -DTARGET_NAME=\"$(MODELNAME)\"
69 OBJS2 := $(OBJDIR)/lang.o $(patsubst %.c, $(OBJDIR)/%.o, $(SRC))
70 OBJS = $(patsubst %.S, $(OBJDIR)/%.o, $(OBJS2))
71 SOURCES = $(SRC)
72 LINKFILE = $(OBJDIR)/linkage.lds
73 LINKROM = $(OBJDIR)/linkrom.lds
74 MAXINFILE = $(OBJDIR)/romstart.temp
75 MAXOUTFILE = $(OBJDIR)/romstart
77 LIBROCKBOX = $(BUILDDIR)/librockbox.a
79 ifdef SIMVER
80 # this is a sim build
82 all: $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS)
84 else
85 # regular target build
87 ifdef DEBUG
88 REALBIN = $(OBJDIR)/rockbox.elf
89 else
90 # this is not needed to get built when doing debug builds
91 REALBIN = $(BUILDDIR)/$(BINARY)
92 endif
94 all: $(REALBIN) $(FLASHFILE) $(CODECS) $(ROCKS) $(ARCHOSROM)
95 endif
97 $(DEPFILE): $(BITMAPLIBS)
99 dep: $(DEPFILE)
101 features: $(OBJDIR)/features
103 libspeex-rockbox:
104 $(SILENT)mkdir -p $(OBJDIR)/libspeex-rockbox
105 $(call PRINTS,MAKE in libspeex for rockbox core)$(MAKE) -C $(APPSDIR)/codecs/libspeex ROCKBOX_VOICE_CODEC=1 OBJDIR=$(OBJDIR)/libspeex-rockbox OUTPUT=$(BUILDDIR)/libspeex-rockbox.a
107 build-codecs:
108 $(SILENT)$(MAKE) -C codecs/lib OBJDIR=$(OBJDIR)/codecs/lib
109 $(SILENT)$(MAKE) -C codecs OBJDIR=$(OBJDIR)/codecs
111 build-bitmapsmono:
112 $(call PRINTS,MAKE in bitmaps/mono)$(MAKE) -C bitmaps/mono OBJDIR=$(OBJDIR)/bitmaps/mono
114 build-bitmapsnative:
115 $(call PRINTS,MAKE in bitmaps/native)$(MAKE) -C bitmaps/native OBJDIR=$(OBJDIR)/bitmaps/native
117 build-bitmapsremotemono:
118 $(call PRINTS,MAKE in bitmaps/remote_mono)$(MAKE) -C bitmaps/remote_mono OBJDIR=$(OBJDIR)/bitmaps/remote_mono
120 build-bitmapsremotenative:
121 $(call PRINTS,MAKE in bitmaps/remote_native)$(MAKE) -C bitmaps/remote_native OBJDIR=$(OBJDIR)/bitmaps/remote_native
123 $(BITMAPLIBS): $(BUILDDIR)/lib%.a: build-%
125 rocks: build-codecs
126 $(SILENT)$(MAKE) -C plugins/lib OBJDIR=$(OBJDIR)/plugins/lib
127 $(SILENT)$(MAKE) -C plugins OBJDIR=$(OBJDIR)/plugins
129 $(LINKFILE): $(LDS)
130 $(call PRINTS,Build $(@F))cat $< | $(CC) -DLOADADDRESS=$(LOADADDRESS) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
132 $(LINKROM): $(ROMLDS)
133 $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
135 $(MAXOUTFILE):
136 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
137 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
138 $(SILENT)cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
139 $(SILENT)rm $(MAXINFILE)
141 $(OBJDIR)/rombox.elf : $(OBJS) $(LINKROM) $(DEPFILE) $(LIBROCKBOX) $(VOICE) $(BITMAPLIBS)
142 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -lrockbox -lgcc $(LINKVOICE) $(LINKBITMAPS) -L$(BUILDDIR)/firmware -T$(LINKROM) -Wl,-Map,$(OBJDIR)/rombox.map
144 ifndef SIMVER
146 $(OBJDIR)/rockbox.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) $(VOICE) $(BITMAPLIBS)
147 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR)/firmware -L$(BUILDDIR) -lrockbox $(LINKVOICE) $(LINKBITMAPS) -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/rockbox.map
149 $(OBJDIR)/rockbox.bin : $(OBJDIR)/rockbox.elf
150 $(call PRINTS,OBJCOPY $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
152 $(OBJDIR)/rombox.bin : $(OBJDIR)/rombox.elf
153 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
155 $(OBJDIR)/rockbox.asm: $(OBJDIR)/rockbox.bin
156 $(TOOLSDIR)/sh2d -sh1 $< > $@
159 # If there's a flashfile defined for this target (rockbox.ucl for Archos
160 # models) Then check if the mkfirmware script fails, as then it is (likely)
161 # because the image is too big and we need to create a compressed image
162 # instead.
164 $(BUILDDIR)/$(BINARY) : $(OBJDIR)/rockbox.bin $(FLASHFILE)
165 $(call PRINTS,Build firmware file)($(MKFIRMWARE) $< $@; \
166 stat=$$?; \
167 if test -n "$(FLASHFILE)"; then \
168 if test "$$stat" -ne 0; then \
169 echo "Image too big, making a compressed version!"; \
170 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
171 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
172 fi \
173 fi )
175 else
176 # this is a simulator build
178 ifeq ($(SIMVER), win32)
179 # OK, this is ugly but we need it on the link line to make it do right
180 EXTRAOBJ = $(BUILDDIR)/sim/uisw32-res.o
181 LDOPTS += -lwinmm
182 endif
184 # OS X's ld does not support -Map
185 ifeq ($(UNAME), Darwin)
186 SIMULATOR_MAP=
187 else
188 #SIMULATOR_MAP=-Wl,-Map,$(OBJDIR)/rockbox.map
189 endif
191 $(BUILDDIR)/$(BINARY) : $(OBJS) $(DEPFILE) $(BUILDDIR)/libsim.a \
192 $(BUILDDIR)/libcomsim.a $(LIBROCKBOX) $(VOICE) $(BITMAPLIBS)
193 $(call PRINTS,LD $(BINARY))$(CC) $(GCCOPTS) -o $@ $(OBJS) -L$(BUILDDIR) -lrockbox -lsim -lcomsim $(LINKVOICE) $(LINKBITMAPS) $(LDOPTS) $(EXTRAOBJ) $(SIMULATOR_MAP)
194 endif
196 $(BUILDDIR)/rockbox.ucl: $(OBJDIR)/rockbox.bin
197 $(call PRINTS,UCLPACK rockbox)$(TOOLSDIR)/uclpack --best --2e $< $@ >/dev/null 2>&1
199 $(BUILDDIR)/rombox.ucl: $(OBJDIR)/rombox.bin $(MAXOUTFILE)
200 $(call PRINTS,UCLPACK rombox)$(TOOLSDIR)/uclpack --none $< $@ >/dev/null 2>&1; \
201 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
202 if test $$? -ne 0; then \
203 echo "removing UCL file again, making it a fake one"; \
204 echo "fake" > $@; \
207 $(BUILDDIR)/rombox.iriver: $(OBJDIR)/rombox.bin
208 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
210 include $(TOOLSDIR)/make.inc
212 # apps/features.txt is a file that (is preprocessed and) lists named features
213 # based on defines in the config-*.h files. The named features will be passed
214 # to genlang and thus (translated) phrases can be used based on those names.
215 # button.h is included for the HAS_BUTTON_HOLD define.
218 $(OBJDIR)/features: features.txt
219 $(SILENT)mkdir -p `dirname $@`
220 $(SILENT)cat $< | $(HOSTCC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) \
221 $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -imacros "config.h" -imacros "button.h" - | \
222 grep -v "^\#" | grep -v "^$$" > $@; \
223 for f in `cat $(OBJDIR)/features`; do feat="$$feat:$$f" ; done ; \
224 echo "$$feat" >$(OBJDIR)/genlang-features
226 $(OBJDIR)/lang.o: lang/$(LANGUAGE).lang $(OBJDIR)/features
227 $(SILENT)for f in `cat $(OBJDIR)/features`; do feat="$$feat:$$f" ; done; \
228 perl -s $(TOOLSDIR)/genlang -p=$(BUILDDIR)/lang -t=$(MODELNAME)$$feat $<
229 $(call PRINTS,CC lang.c)$(CC) $(CFLAGS) -c $(BUILDDIR)/lang.c -o $@
231 clean:
232 $(call PRINTS,cleaning apps)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/rockbox.asm \
233 $(OBJDIR)/rockbox.bin $(OBJDIR)/rockbox.elf $(OBJDIR)/*.map \
234 $(OBJDIR)/lang.o $(OBJDIR)/build.lang $(BUILDDIR)/lang.[ch] \
235 $(LINKFILE) $(BUILDDIR)/rockbox.ucl $(LINKROM) \
236 $(BUILDDIR)/rombox.ucl $(OBJDIR)/rombox.bin $(OBJDIR)/rombox.elf \
237 $(MAXOUTFILE) $(DEPFILE)
238 $(SILENT)$(MAKE) -C bitmaps/mono clean OBJDIR=$(OBJDIR)/bitmaps/mono
239 $(SILENT)$(MAKE) -C bitmaps/native clean OBJDIR=$(OBJDIR)/bitmaps/native
240 $(SILENT)$(MAKE) -C bitmaps/remote_mono clean OBJDIR=$(OBJDIR)/bitmaps/remote_mono
241 $(SILENT)$(MAKE) -C bitmaps/remote_native clean OBJDIR=$(OBJDIR)/bitmaps/remote_native
242 $(SILENT)$(MAKE) -C plugins clean OBJDIR=$(OBJDIR)/plugins
243 $(SILENT)$(MAKE) -C codecs clean OBJDIR=$(OBJDIR)/codecs
244 $(SILENT)rm -rf $(OBJDIR)/recorder $(OBJDIR)/player
245 $(SILENT)rm -rf $(BUILDDIR)/bitmaps
246 ifdef SIMVER
247 $(SILENT)$(MAKE) -C $(SIMDIR) clean
248 endif
250 ifneq ($(MAKECMDGOALS),clean)
251 -include $(DEPFILE)
252 endif