Fix FS#12606 - next track can cause the screen to be cleared
[maemo-rb.git] / tools / root.make
blob3231b730539dbf28069cbc1ce2f3d18511f07209
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 include $(TOOLSDIR)/functions.make
12 DEFINES = -DROCKBOX -DMEMORYSIZE=$(MEMORYSIZE) $(TARGET) \
13 -DTARGET_ID=$(TARGET_ID) -DTARGET_NAME=\"$(MODELNAME)\" $(BUILDDATE) \
14 $(EXTRA_DEFINES) # <-- -DSIMULATOR or not
15 INCLUDES = -I$(BUILDDIR) -I$(BUILDDIR)/lang $(TARGET_INC)
17 CFLAGS = $(INCLUDES) $(DEFINES) $(GCCOPTS)
18 PPCFLAGS = $(filter-out -g -Dmain=SDL_main,$(CFLAGS)) # cygwin sdl-config fix
19 ASMFLAGS = -D__ASSEMBLER__ # work around gcc 3.4.x bug with -std=gnu99, only meant for .S files
21 TOOLS = $(TOOLSDIR)/rdf2binary $(TOOLSDIR)/convbdf \
22 $(TOOLSDIR)/codepages $(TOOLSDIR)/scramble $(TOOLSDIR)/bmp2rb \
23 $(TOOLSDIR)/uclpack $(TOOLSDIR)/mkboot $(TOOLSDIR)/iaudio_bl_flash.c \
24 $(TOOLSDIR)/iaudio_bl_flash.h
27 ifeq (,$(PREFIX))
28 ifdef APP_TYPE
29 # for sims, set simdisk/ as default
30 ifeq ($(APP_TYPE),sdl-sim)
31 RBPREFIX = simdisk
32 else ifeq ($(APP_TYPE),sdl-app)
33 RBPREFIX = /usr/local
34 endif
36 INSTALL = --install="$(RBPREFIX)"
37 else
38 # /dev/null as magic to tell it wasn't set, error out later in buildzip.pl
39 INSTALL = --install=/dev/null
40 endif
41 else
42 RBPREFIX = $(PREFIX)
43 INSTALL = --install="$(RBPREFIX)"
44 endif
46 RBINFO = $(BUILDDIR)/rockbox-info.txt
48 # list suffixes to be understood by $*
49 .SUFFIXES: .rock .codec .map .elf .c .S .o .bmp .a
51 .PHONY: all clean tags zip tools manual bin build info langs
53 ifeq (,$(filter clean veryclean reconf tags voice voicetools manual manual-pdf manual-html manual-zhtml manual-txt manual-ztxt manual-zip help fontzip ,$(MAKECMDGOALS)))
54 # none of the above
55 DEPFILE = $(BUILDDIR)/make.dep
57 endif
59 all: $(DEPFILE) build
61 # Subdir makefiles. their primary purpose is to populate SRC, OTHER_SRC &
62 # ASMDEFS_SRC but they also define special dependencies and compile rules
63 include $(TOOLSDIR)/tools.make
65 ifeq (,$(findstring checkwps,$(APPSDIR)))
66 ifeq (,$(findstring database,$(APPSDIR)))
67 include $(FIRMDIR)/firmware.make
68 include $(ROOTDIR)/lib/skin_parser/skin_parser.make
69 include $(ROOTDIR)/apps/bitmaps/bitmaps.make
70 endif
71 endif
73 #included before codecs.make and plugins.make so they see them)
74 ifndef APP_TYPE
75 include $(ROOTDIR)/lib/libsetjmp/libsetjmp.make
76 ifeq (arm,$(ARCH))
77 include $(ROOTDIR)/lib/arm_support/arm_support.make
78 endif
79 endif
81 ifeq (arm,$(ARCH))
82 include $(ROOTDIR)/lib/unwarminder/unwarminder.make
83 endif
85 ifneq (,$(findstring bootloader,$(APPSDIR)))
86 include $(APPSDIR)/bootloader.make
87 else ifneq (,$(findstring bootbox,$(APPSDIR)))
88 BOOTBOXLDOPTS = -Wl,--gc-sections
89 include $(APPSDIR)/bootbox.make
90 else ifneq (,$(findstring checkwps,$(APP_TYPE)))
91 include $(APPSDIR)/checkwps.make
92 include $(ROOTDIR)/lib/skin_parser/skin_parser.make
93 else ifneq (,$(findstring database,$(APP_TYPE)))
94 include $(APPSDIR)/database.make
95 else ifneq (,$(findstring warble,$(APP_TYPE)))
96 include $(ROOTDIR)/lib/rbcodec/test/warble.make
97 else
98 include $(APPSDIR)/apps.make
99 include $(APPSDIR)/lang/lang.make
101 ifdef SOFTWARECODECS
102 include $(APPSDIR)/codecs/codecs.make
103 endif
105 ifdef ENABLEDPLUGINS
106 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
107 include $(APPSDIR)/plugins/plugins.make
108 endif
110 ifneq (,$(findstring sdl,$(APP_TYPE)))
111 include $(ROOTDIR)/uisimulator/uisimulator.make
112 endif
114 ifneq (,$(findstring ypr0,$(APP_TYPE)))
115 include $(ROOTDIR)/firmware/target/hosted/ypr0/ypr0.make
116 endif
118 ifneq (,$(findstring android, $(APP_TYPE)))
119 include $(ROOTDIR)/android/android.make
120 endif
122 ifneq (,$(findstring pandora, $(MODELNAME)))
123 include $(ROOTDIR)/packaging/pandora/pandora.make
124 endif
126 endif # bootloader
128 OBJ := $(SRC:.c=.o)
129 OBJ := $(OBJ:.S=.o)
130 OBJ += $(BMP:.bmp=.o)
131 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
133 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
135 $(RBINFO): $(BUILDDIR)/$(BINARY)
136 $(SILENT)echo Creating $(@F)
137 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
139 $(DEPFILE) dep:
140 $(call PRINTS,Generating dependencies)
141 $(call mkdepfile,$(DEPFILE)_,$(SRC))
142 $(call mkdepfile,$(DEPFILE)_,$(OTHER_SRC:%.lua=))
143 $(call mkdepfile,$(DEPFILE)_,$(ASMDEFS_SRC))
144 $(call bmpdepfile,$(DEPFILE)_,$(BMP) $(PBMP))
145 @mv $(DEPFILE)_ $(DEPFILE)
147 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
148 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
149 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
150 tools: $(TOOLS)
152 -include $(DEPFILE)
154 veryclean: clean
155 $(SILENT)rm -rf $(TOOLS)
157 clean::
158 $(SILENT)echo Cleaning build directory
159 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
160 rockbox.tar.bz2 TAGS apps firmware tools comsim sim lang lib \
161 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
162 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
163 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
164 *.wav *.mp3 *.voice $(CLEANOBJS) \
165 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
166 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
167 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK) \
168 rockbox.apk
170 #### linking the binaries: ####
172 .SECONDEXPANSION:
174 ifeq (,$(findstring bootloader,$(APPSDIR)))
175 # not bootloader
177 OBJ += $(LANG_O)
179 ifeq (arm,$(ARCH))
180 UNWARMINDER_LINK := -lunwarminder
181 else
182 UNWARMINDER_LINK :=
183 endif
185 ifndef APP_TYPE
187 ## target build
188 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
189 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
190 LINKRAM := $(BUILDDIR)/ram.link
191 ROMLDS := $(FIRMDIR)/rom.lds
192 LINKROM := $(BUILDDIR)/rom.link
194 ifeq (arm,$(ARCH))
195 LIBARMSUPPORT_LINK := -larm_support
196 else
197 LIBARMSUPPORT_LINK :=
198 endif
200 $(LINKRAM): $(RAMLDS) $(CONFIGFILE)
201 $(call PRINTS,PP $(@F))
202 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
204 $(LINKROM): $(ROMLDS)
205 $(call PRINTS,PP $(@F))
206 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
208 $(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LIBARMSUPPORT) $$(UNWARMINDER) $$(LINKRAM)
209 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
210 -L$(BUILDDIR)/firmware -lfirmware \
211 -L$(BUILDDIR)/lib -lskin_parser $(LIBARMSUPPORT_LINK) \
212 $(UNWARMINDER_LINK) -L$(BUILDDIR)/apps/codecs \
213 $(VOICESPEEXLIB:lib%.a=-l%) -lgcc $(BOOTBOXLDOPTS) \
214 $(GLOBAL_LDOPTS) -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
216 $(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LIBARMSUPPORT) $$(UNWARMINDER) $$(LINKROM)
217 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
218 -L$(BUILDDIR)/firmware -lfirmware \
219 -L$(BUILDDIR)/lib -lskin_parser $(LIBARMSUPPORT_LINK) \
220 $(UNWARMINDER_LINK) -L$(BUILDDIR)/apps/codecs \
221 $(VOICESPEEXLIB:lib%.a=-l%) -lgcc $(GLOBAL_LDOPTS) \
222 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
224 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
225 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
227 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
228 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
231 # If there's a flashfile defined for this target (rockbox.ucl for Archos
232 # models) Then check if the mkfirmware script fails, as then it is (likely)
233 # because the image is too big and we need to create a compressed image
234 # instead.
236 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
237 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
238 stat=$$?; \
239 if test -n "$(FLASHFILE)"; then \
240 if test "$$stat" -ne 0; then \
241 echo "Image too big, making a compressed version!"; \
242 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
243 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
244 fi \
245 fi )
247 # archos
248 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
249 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
251 MAXINFILE = $(BUILDDIR)/temp.txt
252 MAXOUTFILE = $(BUILDDIR)/romstart.txt
254 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
255 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
256 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
257 if test $$? -ne 0; then \
258 echo "removing UCL file again, making it a fake one"; \
259 echo "fake" > $@; \
262 $(MAXOUTFILE):
263 $(call PRINTS,Creating $(@F))
264 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
265 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
266 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
267 $(SILENT)rm $(MAXINFILE)
269 # iriver
270 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
271 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
273 endif # !APP_TYPE
274 endif # !bootloader
277 voicetools:
278 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
280 tags:
281 $(SILENT)rm -f TAGS
282 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
284 fontzip:
285 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
287 zip: $(BUILDDIR)/rockbox.zip
289 ifdef NODEPS
290 $(BUILDDIR)/rockbox.zip:
291 else
292 $(BUILDDIR)/rockbox.zip: build
293 endif
294 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
296 mapzip:
297 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
299 elfzip:
300 $(SILENT)find . -name "*.elf" | xargs zip rockbox-elfs.zip
302 fullzip:
303 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
305 7zip:
306 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.7z" -z "7za a -mx=9" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
308 tar:
309 $(SILENT)rm -f rockbox.tar
310 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
312 bzip2: tar
313 $(SILENT)bzip2 -f9 rockbox.tar
315 gzip: tar
316 $(SILENT)gzip -f9 rockbox.tar
318 manual manual-pdf:
319 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
320 manual-html:
321 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
322 manual-zhtml: manual-zip
323 manual-txt:
324 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
325 manual-ztxt:
326 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
327 manual-zip:
328 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
330 ifdef TTS_ENGINE
332 voice: voicetools $(BUILDDIR)/apps/features
333 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
334 for lang in `echo $(VOICELANGUAGE) |sed "s/,/ /g"`; do $(TOOLSDIR)/voice.pl -V -l=$$lang -t=$(MODELNAME)$$feat -i=$(TARGET_ID) -e="$(ENCODER)" -E="$(ENC_OPTS)" -s=$(TTS_ENGINE) -S="$(TTS_OPTS)"; done \
336 endif
338 ifeq (,$(findstring android, $(APP_TYPE)))
339 bininstall: $(BUILDDIR)/$(BINARY)
340 @echo "Installing your rockbox binary in your '$(RBPREFIX)' dir"
341 $(SILENT)cp $(BINARY) "$(RBPREFIX)/.rockbox/"
343 install:
344 @echo "Installing your build in your '$(RBPREFIX)' dir"
345 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
347 fullinstall:
348 @echo "Installing a full setup in your '$(RBPREFIX)' dir"
349 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
351 symlinkinstall:
352 @echo "Installing a full setup with links in your '$(RBPREFIX)' dir"
353 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY) -l
354 endif
356 help:
357 @echo "A few helpful make targets"
358 @echo ""
359 @echo "all - builds a full Rockbox (default), including tools"
360 @echo "bin - builds only the Rockbox.<target name> file"
361 @echo "rocks - builds only plugins"
362 @echo "codecs - builds only codecs"
363 @echo "dep - regenerates make dependency database"
364 @echo "clean - cleans a build directory (not tools)"
365 @echo "veryclean - cleans the build and tools directories"
366 @echo "manual - builds a manual (pdf)"
367 @echo "manual-html - HTML manual"
368 @echo "manual-zip - HTML manual (zipped)"
369 @echo "manual-txt - txt manual"
370 @echo "fullzip - creates a rockbox.zip of your build with fonts"
371 @echo "zip - creates a rockbox.zip of your build (no fonts)"
372 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
373 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
374 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
375 @echo "fontzip - creates rockbox-fonts.zip"
376 @echo "mapzip - creates rockbox-maps.zip with all .map files"
377 @echo "elfzip - creates rockbox-elfs.zip with all .elf files"
378 @echo "pnd - creates rockbox.pnd archive (Pandora builds only)"
379 @echo "tools - builds the tools only"
380 @echo "voice - creates the voice clips (voice builds only)"
381 @echo "voicetools - builds the voice tools only"
382 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
383 @echo "fullinstall - installs your build (like install, but with fonts)"
384 @echo "symlinkinstall - like fullinstall, but with links instead of copying files. (Good for developing on simulator)"
385 @echo "reconf - rerun configure with the same selection"
387 ### general compile rules:
389 # when source and object are in different locations (normal):
390 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
391 $(SILENT)mkdir -p $(dir $@)
392 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
394 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
395 $(SILENT)mkdir -p $(dir $@)
396 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
398 # generated definitions for use in .S files
399 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
400 $(call PRINTS,ASMDEFS $(@F))
401 $(SILENT)mkdir -p $(dir $@)
402 $(call asmdefs2file,$<,$@)
404 # when source and object are both in BUILDDIR (generated code):
405 %.o: %.c
406 $(SILENT)mkdir -p $(dir $@)
407 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
409 %.o: %.S
410 $(SILENT)mkdir -p $(dir $@)
411 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
413 Makefile: $(TOOLSDIR)/configure
414 ifneq (reconf,$(MAKECMDGOALS))
415 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
416 endif
418 reconf:
419 $(SILENT$)$(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)