Some entropy decoder tweaks. Also removed unnecessary 'tmp' variables.
[kugel-rb.git] / apps / Makefile
blobd643da4418c4e8a428c735603b718cb0317ee119
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 INCLUDES= $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. \
11 -I$(BUILDDIR) -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 SOFTWARECODECS
20 CODECS=build-codecs
22 # This sets up the parameters for building and linking libspeex for core voice
23 VOICE=libspeex-rockbox
24 LINKVOICE= -lspeex-rockbox
26 endif
28 # Set up the bitmap libraries
29 BITMAPLIBS =
30 LINKBITMAPS =
31 ifneq ($(strip $(BMP2RB_MONO)),)
32 BITMAPLIBS += bitmapsmono
33 LINKBITMAPS += -lbitmapsmono
34 endif
35 ifneq ($(strip $(BMP2RB_NATIVE)),)
36 BITMAPLIBS += bitmapsnative
37 LINKBITMAPS += -lbitmapsnative
38 endif
39 ifneq ($(strip $(BMP2RB_REMOTEMONO)),)
40 BITMAPLIBS += bitmapsremotemono
41 LINKBITMAPS += -lbitmapsremotemono
42 endif
43 ifneq ($(strip $(BMP2RB_REMOTENATIVE)),)
44 BITMAPLIBS += bitmapsremotenative
45 LINKBITMAPS += -lbitmapsremotenative
46 endif
48 # This sets up 'SRC' based on the files mentioned in SOURCES
49 include $(TOOLSDIR)/makesrc.inc
51 DEFINES = $(DEBUG)
53 DIRS = .
55 ifdef APPEXTRA
56 DIRS += $(subst :, ,$(APPEXTRA))
57 INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA)))
58 endif
60 CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET) $(BUILDDATE) $(DEFINES) \
61 -DTARGET_ID=$(TARGET_ID) \
62 -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE} \
63 -DTARGET_NAME=\"$(MODELNAME)\"
65 OBJS2 := $(OBJDIR)/lang.o $(patsubst %.c, $(OBJDIR)/%.o, $(SRC))
66 OBJS = $(patsubst %.S, $(OBJDIR)/%.o, $(OBJS2))
67 SOURCES = $(SRC)
68 LINKFILE = $(OBJDIR)/linkage.lds
69 LINKROM = $(OBJDIR)/linkrom.lds
70 MAXINFILE = $(OBJDIR)/romstart.temp
71 MAXOUTFILE = $(OBJDIR)/romstart
73 LIBROCKBOX = $(BUILDDIR)/librockbox.a
75 ifdef SIMVER
76 # this is a sim build
78 all: simbuild
80 else
81 # regular target build
83 ifdef DEBUG
84 REALBIN = $(OBJDIR)/rockbox.elf
85 else
86 # this is not needed to get built when doing debug builds
87 REALBIN = $(BUILDDIR)/$(BINARY)
88 endif
90 all: build
92 endif
94 build: $(DEPFILE) $(BITMAPLIBS) build-codecs build-pluginlib
95 ifdef ENABLEDPLUGINS
96 $(call PRINTS,MAKE in plugins)$(MAKE) -C plugins OBJDIR=$(OBJDIR)/plugins
97 endif
98 $(call PRINTS,MAKE in apps)$(MAKE) $(REALBIN) $(FLASHFILE) $(ARCHOSROM)
100 simbuild: $(DEPFILE) $(BITMAPLIBS) build-codecs build-pluginlib
101 ifdef ENABLEDPLUGINS
102 $(call PRINTS,MAKE in plugins)$(MAKE) -C plugins OBJDIR=$(OBJDIR)/plugins
103 endif
104 $(call PRINTS,MAKE in apps)$(MAKE) $(BUILDDIR)/$(BINARY)
106 build-codecs:
107 ifdef SOFTWARECODECS
108 $(SILENT)$(MAKE) -C codecs/lib OBJDIR=$(OBJDIR)/codecs/lib
109 $(SILENT)$(MAKE) -C codecs OBJDIR=$(OBJDIR)/codecs
110 endif
112 build-pluginlib:
113 ifdef ENABLEDPLUGINS
114 $(SILENT)$(MAKE) -C plugins/lib OBJDIR=$(OBJDIR)/plugins/lib
115 endif
117 bitmapsmono:
118 $(call PRINTS,MAKE in bitmaps/mono)$(MAKE) -C bitmaps/mono OBJDIR=$(OBJDIR)/bitmaps/mono
120 bitmapsnative:
121 $(call PRINTS,MAKE in bitmaps/native)$(MAKE) -C bitmaps/native OBJDIR=$(OBJDIR)/bitmaps/native
123 bitmapsremotemono:
124 $(call PRINTS,MAKE in bitmaps/remote_mono)$(MAKE) -C bitmaps/remote_mono OBJDIR=$(OBJDIR)/bitmaps/remote_mono
126 bitmapsremotenative:
127 $(call PRINTS,MAKE in bitmaps/remote_native)$(MAKE) -C bitmaps/remote_native OBJDIR=$(OBJDIR)/bitmaps/remote_native
129 rocks: build-codecs build-pluginlib
130 $(SILENT)$(MAKE) -C plugins OBJDIR=$(OBJDIR)/plugins
132 libspeex-rockbox:
133 $(SILENT)mkdir -p $(OBJDIR)/libspeex-rockbox
134 $(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
136 $(LINKFILE): $(LDS)
137 $(call PRINTS,Build $(@F))cat $< | $(CC) -DLOADADDRESS=$(LOADADDRESS) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
139 $(LINKROM): $(ROMLDS)
140 $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
142 $(MAXOUTFILE):
143 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
144 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
145 $(SILENT)cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
146 $(SILENT)rm $(MAXINFILE)
148 $(OBJDIR)/rombox.elf : $(OBJS) $(LINKROM) $(LIBROCKBOX) $(VOICE)
149 $(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
151 objs: $(OBJS)
153 ifndef SIMVER
155 $(OBJDIR)/rockbox.elf : $(LINKFILE) $(LIBROCKBOX) $(VOICE) $(BITMAPLIBS)
156 $(call PRINTS,MAKE objs)$(MAKE) objs
157 $(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
159 $(OBJDIR)/rockbox.bin : $(OBJDIR)/rockbox.elf
160 $(call PRINTS,OBJCOPY $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
162 $(OBJDIR)/rombox.bin : $(OBJDIR)/rombox.elf
163 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
165 $(OBJDIR)/rockbox.asm: $(OBJDIR)/rockbox.bin
166 $(TOOLSDIR)/sh2d -sh1 $< > $@
169 # If there's a flashfile defined for this target (rockbox.ucl for Archos
170 # models) Then check if the mkfirmware script fails, as then it is (likely)
171 # because the image is too big and we need to create a compressed image
172 # instead.
174 $(BUILDDIR)/$(BINARY) : $(OBJDIR)/rockbox.bin $(FLASHFILE) $(BITMAPLIBS)
175 $(call PRINTS,Build firmware file)($(MKFIRMWARE) $< $@; \
176 stat=$$?; \
177 if test -n "$(FLASHFILE)"; then \
178 if test "$$stat" -ne 0; then \
179 echo "Image too big, making a compressed version!"; \
180 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
181 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
182 fi \
183 fi )
185 else
186 # this is a simulator build
188 ifeq ($(SIMVER), win32)
189 # OK, this is ugly but we need it on the link line to make it do right
190 EXTRAOBJ = $(BUILDDIR)/sim/uisw32-res.o
191 LDOPTS += -lwinmm
192 endif
194 # OS X's ld does not support -Map
195 ifeq ($(UNAME), Darwin)
196 SIMULATOR_MAP=
197 else
198 #SIMULATOR_MAP=-Wl,-Map,$(OBJDIR)/rockbox.map
199 endif
201 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/libsim.a \
202 $(BUILDDIR)/libcomsim.a $(LIBROCKBOX) $(VOICE) $(BITMAPLIBS)
203 $(call PRINTS,MAKE objs)$(MAKE) objs
204 $(call PRINTS,LD $(BINARY))$(CC) $(GCCOPTS) -o $@ $(OBJS) -L$(BUILDDIR) -lrockbox -lsim -lcomsim $(LINKVOICE) $(LINKBITMAPS) $(LDOPTS) $(EXTRAOBJ) $(SIMULATOR_MAP)
205 endif
207 $(BUILDDIR)/rockbox.ucl: $(OBJDIR)/rockbox.bin
208 $(call PRINTS,UCLPACK rockbox)$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null 2>&1
210 $(BUILDDIR)/rombox.ucl: $(OBJDIR)/rombox.bin $(MAXOUTFILE)
211 $(call PRINTS,UCLPACK rombox)$(TOOLSDIR)/uclpack --none $< $@ >/dev/null 2>&1; \
212 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
213 if test $$? -ne 0; then \
214 echo "removing UCL file again, making it a fake one"; \
215 echo "fake" > $@; \
218 $(BUILDDIR)/rombox.iriver: $(OBJDIR)/rombox.bin
219 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
221 # make.inc contains the $(DEPFILE) generation
222 include $(TOOLSDIR)/make.inc
224 # apps/features.txt is a file that (is preprocessed and) lists named features
225 # based on defines in the config-*.h files. The named features will be passed
226 # to genlang and thus (translated) phrases can be used based on those names.
227 # button.h is included for the HAS_BUTTON_HOLD define.
230 features: $(OBJDIR)/features
232 $(OBJDIR)/features: features.txt
233 $(SILENT)mkdir -p $(OBJDIR)
234 $(SILENT)cat $< | $(HOSTCC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) \
235 $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -imacros "config.h" -imacros "button.h" - | \
236 grep -v "^\#" | grep -v "^$$" > $@; \
237 for f in `cat $(OBJDIR)/features`; do feat="$$feat:$$f" ; done ; \
238 echo "$$feat" >$(OBJDIR)/genlang-features
240 $(OBJDIR)/lang.o: lang/$(LANGUAGE).lang $(OBJDIR)/features
241 $(SILENT)for f in `cat $(OBJDIR)/features`; do feat="$$feat:$$f" ; done; \
242 perl -s $(TOOLSDIR)/genlang -p=$(BUILDDIR)/lang -t=$(MODELNAME)$$feat $<
243 $(call PRINTS,CC lang.c)$(CC) $(CFLAGS) -c $(BUILDDIR)/lang.c -o $@
245 clean:
246 $(call PRINTS,cleaning apps)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/rockbox.asm \
247 $(OBJDIR)/rockbox.bin $(OBJDIR)/rockbox.elf $(OBJDIR)/*.map \
248 $(OBJDIR)/lang.o $(OBJDIR)/build.lang $(BUILDDIR)/lang.[ch] \
249 $(LINKFILE) $(BUILDDIR)/rockbox.ucl $(LINKROM) \
250 $(BUILDDIR)/rombox.ucl $(OBJDIR)/rombox.bin $(OBJDIR)/rombox.elf \
251 $(MAXOUTFILE) $(DEPFILE)
252 $(SILENT)$(MAKE) -C bitmaps/mono clean OBJDIR=$(OBJDIR)/bitmaps/mono
253 $(SILENT)$(MAKE) -C bitmaps/native clean OBJDIR=$(OBJDIR)/bitmaps/native
254 $(SILENT)$(MAKE) -C bitmaps/remote_mono clean OBJDIR=$(OBJDIR)/bitmaps/remote_mono
255 $(SILENT)$(MAKE) -C bitmaps/remote_native clean OBJDIR=$(OBJDIR)/bitmaps/remote_native
256 $(SILENT)$(MAKE) -C plugins clean OBJDIR=$(OBJDIR)/plugins
257 $(SILENT)$(MAKE) -C codecs clean OBJDIR=$(OBJDIR)/codecs
258 $(SILENT)rm -rf $(OBJDIR)/recorder $(OBJDIR)/player
259 $(SILENT)rm -rf $(BUILDDIR)/bitmaps
260 $(SILENT)rm -rf $(BUILDDIR)/pluginbitmaps
261 ifdef SIMVER
262 $(SILENT)$(MAKE) -C $(SIMDIR) clean
263 endif
265 ifneq ($(MAKECMDGOALS),clean)
266 -include $(DEPFILE)
267 endif