fix red
[kugel-rb.git] / apps / Makefile
blobcc5594a7dd2c0ea96abe8d985e22cb064a1d23cc
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 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 recorder/icons.h: $(BITMAPLIBS)
111 $(BUILDDIR)/libbitmapsmono.a:
112 $(call PRINTS,MAKE in bitmaps/mono)$(MAKE) -C bitmaps/mono OBJDIR=$(OBJDIR)/bitmaps/mono
114 $(BUILDDIR)/libbitmapsnative.a:
115 $(call PRINTS,MAKE in bitmaps/native)$(MAKE) -C bitmaps/native OBJDIR=$(OBJDIR)/bitmaps/native
117 $(BUILDDIR)/libbitmapsremotemono.a:
118 $(call PRINTS,MAKE in bitmaps/remote_mono)$(MAKE) -C bitmaps/remote_mono OBJDIR=$(OBJDIR)/bitmaps/remote_mono
120 $(BUILDDIR)/libbitmapsremotenative.a:
121 $(call PRINTS,MAKE in bitmaps/remote_native)$(MAKE) -C bitmaps/remote_native OBJDIR=$(OBJDIR)/bitmaps/remote_native
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 : $(BITMAPLIBS) $(OBJS) $(LINKROM) $(DEPFILE) $(LIBROCKBOX) $(VOICE)
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 : $(BITMAPLIBS) $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) $(VOICE)
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) $(if $(filter yes, $(USE_ELF)), -S -x, -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) : $(BITMAPLIBS) $(OBJS) $(DEPFILE) $(BUILDDIR)/libsim.a \
190 $(BUILDDIR)/libcomsim.a $(LIBROCKBOX) $(VOICE)
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 -b1048576 $< $@ >/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 for f in `cat $(OBJDIR)/features`; do feat="$$feat:$$f" ; done ; \
222 echo "$$feat" >$(OBJDIR)/genlang-features
224 $(OBJDIR)/lang.o: lang/$(LANGUAGE).lang $(OBJDIR)/features
225 $(SILENT)for f in `cat $(OBJDIR)/features`; do feat="$$feat:$$f" ; done; \
226 perl -s $(TOOLSDIR)/genlang -p=$(BUILDDIR)/lang -t=$(MODELNAME)$$feat $<
227 $(call PRINTS,CC lang.c)$(CC) $(CFLAGS) -c $(BUILDDIR)/lang.c -o $@
229 clean:
230 $(call PRINTS,cleaning apps)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/rockbox.asm \
231 $(OBJDIR)/rockbox.bin $(OBJDIR)/rockbox.elf $(OBJDIR)/*.map \
232 $(OBJDIR)/lang.o $(OBJDIR)/build.lang $(BUILDDIR)/lang.[ch] \
233 $(LINKFILE) $(BUILDDIR)/rockbox.ucl $(LINKROM) \
234 $(BUILDDIR)/rombox.ucl $(OBJDIR)/rombox.bin $(OBJDIR)/rombox.elf \
235 $(MAXOUTFILE) $(DEPFILE)
236 $(SILENT)$(MAKE) -C bitmaps/mono clean OBJDIR=$(OBJDIR)/bitmaps/mono
237 $(SILENT)$(MAKE) -C bitmaps/native clean OBJDIR=$(OBJDIR)/bitmaps/native
238 $(SILENT)$(MAKE) -C bitmaps/remote_mono clean OBJDIR=$(OBJDIR)/bitmaps/remote_mono
239 $(SILENT)$(MAKE) -C bitmaps/remote_native clean OBJDIR=$(OBJDIR)/bitmaps/remote_native
240 $(SILENT)$(MAKE) -C plugins clean OBJDIR=$(OBJDIR)/plugins
241 $(SILENT)$(MAKE) -C codecs clean OBJDIR=$(OBJDIR)/codecs
242 $(SILENT)rm -rf $(OBJDIR)/recorder $(OBJDIR)/player
243 $(SILENT)rm -rf $(BUILDDIR)/bitmaps
244 ifdef SIMVER
245 $(SILENT)$(MAKE) -C $(SIMDIR) clean
246 endif
248 ifneq ($(MAKECMDGOALS),clean)
249 -include $(DEPFILE)
250 endif