Simulate the effects of sector caching a bit. Bypass I/O yield if a byte counter...
[Rockbox.git] / apps / Makefile
blob649dd484965ce410ca1c27ed8860d7ed280de18a
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
14 LDS := $(FIRMDIR)/app.lds
15 ROMLDS := $(FIRMDIR)/rom.lds
17 ifdef ENABLEDPLUGINS
18 ROCKS=rocks
19 endif
21 ifdef SOFTWARECODECS
22 CODECS=build-codecs
24 # This sets up the parameters for building and linking libspeex for core voice
25 VOICE=libspeex-rockbox
26 VOICELIB=$(BUILDDIR)/libspeex-rockbox.a
27 LINKVOICE= -lspeex-rockbox
29 endif
31 # Set up the bitmap libraries
32 BITMAPLIBS =
33 LINKBITMAPS =
34 ifneq ($(strip $(BMP2RB_MONO)),)
35 BITMAPLIBS += $(BUILDDIR)/libbitmapsmono.a
36 LINKBITMAPS += -lbitmapsmono
37 endif
38 ifneq ($(strip $(BMP2RB_NATIVE)),)
39 BITMAPLIBS += $(BUILDDIR)/libbitmapsnative.a
40 LINKBITMAPS += -lbitmapsnative
41 endif
42 ifneq ($(strip $(BMP2RB_REMOTEMONO)),)
43 BITMAPLIBS += $(BUILDDIR)/libbitmapsremotemono.a
44 LINKBITMAPS += -lbitmapsremotemono
45 endif
46 ifneq ($(strip $(BMP2RB_REMOTENATIVE)),)
47 BITMAPLIBS += $(BUILDDIR)/libbitmapsremotenative.a
48 LINKBITMAPS += -lbitmapsremotenative
49 endif
51 # This sets up 'SRC' based on the files mentioned in SOURCES
52 include $(TOOLSDIR)/makesrc.inc
54 DEFINES = $(DEBUG)
56 DIRS = .
58 ifdef APPEXTRA
59 DIRS += $(subst :, ,$(APPEXTRA))
60 INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA)))
61 endif
63 CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET) $(BUILDDATE) $(DEFINES) -DTARGET_ID=$(TARGET_ID) \
64 -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE} \
65 -DTARGET_NAME=\"$(ARCHOS)\"
67 OBJS2 := $(OBJDIR)/lang.o $(patsubst %.c, $(OBJDIR)/%.o, $(SRC))
68 OBJS = $(patsubst %.S, $(OBJDIR)/%.o, $(OBJS2))
69 SOURCES = $(SRC)
70 LINKFILE = $(OBJDIR)/linkage.lds
71 LINKROM = $(OBJDIR)/linkrom.lds
72 MAXINFILE = $(OBJDIR)/romstart.temp
73 MAXOUTFILE = $(OBJDIR)/romstart
75 LIBROCKBOX = $(BUILDDIR)/librockbox.a
77 ifdef SIMVER
78 # this is a sim build
80 all: $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS)
82 else
83 # regular target build
85 ifdef DEBUG
86 REALBIN = $(OBJDIR)/rockbox.elf
87 else
88 # this is not needed to get built when doing debug builds
89 REALBIN = $(BUILDDIR)/$(BINARY)
90 endif
92 all: $(REALBIN) $(FLASHFILE) $(CODECS) $(ROCKS) $(ARCHOSROM)
93 endif
95 $(DEPFILE): $(BITMAPLIBS)
97 dep: $(DEPFILE)
99 features: $(OBJDIR)/features
101 libspeex-rockbox:
102 $(SILENT)mkdir -p $(OBJDIR)/libspeex-rockbox
103 $(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
105 build-codecs:
106 $(SILENT)$(MAKE) -C codecs/lib OBJDIR=$(OBJDIR)/codecs/lib
107 $(SILENT)$(MAKE) -C codecs OBJDIR=$(OBJDIR)/codecs
109 build-bitmapsmono:
110 $(call PRINTS,MAKE in bitmaps/mono)$(MAKE) -C bitmaps/mono OBJDIR=$(OBJDIR)/bitmaps/mono
112 build-bitmapsnative:
113 $(call PRINTS,MAKE in bitmaps/native)$(MAKE) -C bitmaps/native OBJDIR=$(OBJDIR)/bitmaps/native
115 build-bitmapsremotemono:
116 $(call PRINTS,MAKE in bitmaps/remote_mono)$(MAKE) -C bitmaps/remote_mono OBJDIR=$(OBJDIR)/bitmaps/remote_mono
118 build-bitmapsremotenative:
119 $(call PRINTS,MAKE in bitmaps/remote_native)$(MAKE) -C bitmaps/remote_native OBJDIR=$(OBJDIR)/bitmaps/remote_native
121 $(BITMAPLIBS): $(BUILDDIR)/lib%.a: build-%
123 rocks: build-codecs
124 $(SILENT)$(MAKE) -C plugins/lib OBJDIR=$(OBJDIR)/plugins/lib
125 $(SILENT)$(MAKE) -C plugins OBJDIR=$(OBJDIR)/plugins
127 $(LINKFILE): $(LDS)
128 $(call PRINTS,Build $(@F))cat $< | $(CC) -DLOADADDRESS=$(LOADADDRESS) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
130 $(LINKROM): $(ROMLDS)
131 $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
133 $(MAXOUTFILE):
134 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
135 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
136 $(SILENT)cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
137 $(SILENT)rm $(MAXINFILE)
139 $(OBJDIR)/rombox.elf : $(OBJS) $(LINKROM) $(DEPFILE) $(LIBROCKBOX) $(VOICE) $(BITMAPLIBS)
140 $(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
142 ifndef SIMVER
144 $(OBJDIR)/rockbox.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) $(VOICE) $(BITMAPLIBS)
145 $(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
147 $(OBJDIR)/rockbox.bin : $(OBJDIR)/rockbox.elf
148 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
150 $(OBJDIR)/rombox.bin : $(OBJDIR)/rombox.elf
151 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
153 $(OBJDIR)/rockbox.asm: $(OBJDIR)/rockbox.bin
154 $(TOOLSDIR)/sh2d -sh1 $< > $@
157 # If there's a flashfile defined for this target (rockbox.ucl for Archos
158 # models) Then check if the mkfirmware script fails, as then it is (likely)
159 # because the image is too big and we need to create a compressed image
160 # instead.
162 $(BUILDDIR)/$(BINARY) : $(OBJDIR)/rockbox.bin $(FLASHFILE)
163 $(call PRINTS,Build firmware file)($(MKFIRMWARE) $< $@; \
164 stat=$$?; \
165 if test -n "$(FLASHFILE)"; then \
166 if test "$$stat" -ne 0; then \
167 echo "Image too big, making a compressed version!"; \
168 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
169 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
170 fi \
171 fi )
173 else
174 # this is a simulator build
176 ifeq ($(SIMVER), win32)
177 # OK, this is ugly but we need it on the link line to make it do right
178 EXTRAOBJ = $(BUILDDIR)/sim/uisw32-res.o
179 LDOPTS += -lwinmm
180 endif
182 # OS X's ld does not support -Map
183 ifeq ($(UNAME), Darwin)
184 SIMULATOR_MAP=
185 else
186 #SIMULATOR_MAP=-Wl,-Map,$(OBJDIR)/rockbox.map
187 endif
189 $(BUILDDIR)/$(BINARY) : $(OBJS) $(DEPFILE) $(BUILDDIR)/libsim.a \
190 $(BUILDDIR)/libcomsim.a $(LIBROCKBOX) $(VOICE) $(BITMAPLIBS)
191 $(call PRINTS,LD $(BINARY))$(CC) $(GCCOPTS) -o $@ $(OBJS) -L$(BUILDDIR) -lrockbox -lsim -lcomsim $(LINKVOICE) $(LINKBITMAPS) $(LDOPTS) $(EXTRAOBJ) $(SIMULATOR_MAP)
192 endif
194 $(BUILDDIR)/rockbox.ucl: $(OBJDIR)/rockbox.bin
195 $(call PRINTS,UCLPACK rockbox)$(TOOLSDIR)/uclpack --best --2e $< $@ >/dev/null 2>&1
197 $(BUILDDIR)/rombox.ucl: $(OBJDIR)/rombox.bin $(MAXOUTFILE)
198 $(call PRINTS,UCLPACK rombox)$(TOOLSDIR)/uclpack --none $< $@ >/dev/null 2>&1; \
199 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
200 if test $$? -ne 0; then \
201 echo "removing UCL file again, making it a fake one"; \
202 echo "fake" > $@; \
205 $(BUILDDIR)/rombox.iriver: $(OBJDIR)/rombox.bin
206 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
208 include $(TOOLSDIR)/make.inc
210 # apps/features.txt is a file that (is preprocessed and) lists named features
211 # based on defines in the config-*.h files. The named features will be passed
212 # to genlang and thus (translated) phrases can be used based on those names.
213 # button.h is included for the HAS_BUTTON_HOLD define.
216 $(OBJDIR)/features: features.txt
217 $(SILENT)mkdir -p `dirname $@`
218 $(SILENT)cat $< | $(HOSTCC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) \
219 $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -imacros "config.h" -imacros "button.h" - | \
220 grep -v "^\#" | grep -v "^$$" > $@; \
221 echo "" >/dev/null
223 $(OBJDIR)/lang.o: lang/$(LANGUAGE).lang $(OBJDIR)/features
224 $(SILENT)for f in `cat $(OBJDIR)/features`; do feat="$$feat:$$f" ; done; \
225 perl -s $(TOOLSDIR)/genlang -p=$(BUILDDIR)/lang -t=$(ARCHOS)$$feat $<
226 $(call PRINTS,CC lang.c)$(CC) $(CFLAGS) -c $(BUILDDIR)/lang.c -o $@
228 clean:
229 $(call PRINTS,cleaning apps)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/rockbox.asm \
230 $(OBJDIR)/rockbox.bin $(OBJDIR)/rockbox.elf $(OBJDIR)/*.map \
231 $(OBJDIR)/lang.o $(OBJDIR)/build.lang $(BUILDDIR)/lang.[ch] \
232 $(LINKFILE) $(BUILDDIR)/rockbox.ucl $(LINKROM) \
233 $(BUILDDIR)/rombox.ucl $(OBJDIR)/rombox.bin $(OBJDIR)/rombox.elf \
234 $(MAXOUTFILE) $(DEPFILE)
235 $(SILENT)$(MAKE) -C bitmaps/mono clean OBJDIR=$(OBJDIR)/bitmaps/mono
236 $(SILENT)$(MAKE) -C bitmaps/native clean OBJDIR=$(OBJDIR)/bitmaps/native
237 $(SILENT)$(MAKE) -C bitmaps/remote_mono clean OBJDIR=$(OBJDIR)/bitmaps/remote_mono
238 $(SILENT)$(MAKE) -C bitmaps/remote_native clean OBJDIR=$(OBJDIR)/bitmaps/remote_native
239 $(SILENT)$(MAKE) -C plugins clean OBJDIR=$(OBJDIR)/plugins
240 $(SILENT)$(MAKE) -C codecs clean OBJDIR=$(OBJDIR)/codecs
241 $(SILENT)rm -rf $(OBJDIR)/recorder $(OBJDIR)/player
242 $(SILENT)rm -rf $(BUILDDIR)/bitmaps
243 ifdef SIMVER
244 $(SILENT)$(MAKE) -C $(SIMDIR) clean
245 endif
247 ifneq ($(MAKECMDGOALS),clean)
248 -include $(DEPFILE)
249 endif