archos player debug menu: factorize and use lcd_putsf
[maemo-rb.git] / tools / root.make
blobeda27b77c0a5135948a0a663d1adb0e63b8c1a0c
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 include $(TOOLSDIR)/functions.make
12 DEFINES = -DROCKBOX -DMEMORYSIZE=$(MEMORYSIZE) -DMEM=$(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
20 TOOLS = $(TOOLSDIR)/rdf2binary $(TOOLSDIR)/convbdf \
21 $(TOOLSDIR)/codepages $(TOOLSDIR)/scramble $(TOOLSDIR)/bmp2rb \
22 $(TOOLSDIR)/uclpack $(TOOLSDIR)/mkboot $(TOOLSDIR)/iaudio_bl_flash.c \
23 $(TOOLSDIR)/iaudio_bl_flash.h
26 ifeq (,$(PREFIX))
27 ifdef APP_TYPE
28 # for sims, set simdisk/ as default
29 ifeq ($(APP_TYPE),sdl-sim)
30 RBPREFIX = simdisk
31 else ifeq ($(APP_TYPE),sdl-app)
32 RBPREFIX = /usr/local
33 endif
35 INSTALL = --install="$(RBPREFIX)"
36 else
37 # /dev/null as magic to tell it wasn't set, error out later in buildzip.pl
38 INSTALL = --install=/dev/null
39 endif
40 else
41 RBPREFIX = $(PREFIX)
42 INSTALL = --install="$(RBPREFIX)"
43 endif
45 RBINFO = $(BUILDDIR)/rockbox-info.txt
47 # list suffixes to be understood by $*
48 .SUFFIXES: .rock .codec .map .elf .c .S .o .bmp .a
50 .PHONY: all clean tags zip tools manual bin build info langs
52 ifeq (,$(filter clean veryclean reconf tags voice voicetools manual manual-pdf manual-html manual-zhtml manual-txt manual-ztxt manual-zip help fontzip ,$(MAKECMDGOALS)))
53 # none of the above
54 DEPFILE = $(BUILDDIR)/make.dep
56 endif
58 all: $(DEPFILE) build
60 # Subdir makefiles. their primary purpose is to populate SRC, OTHER_SRC &
61 # ASMDEFS_SRC but they also define special dependencies and compile rules
62 include $(TOOLSDIR)/tools.make
64 ifeq (,$(findstring checkwps,$(APPSDIR)))
65 ifeq (,$(findstring database,$(APPSDIR)))
66 include $(FIRMDIR)/firmware.make
67 include $(ROOTDIR)/lib/skin_parser/skin_parser.make
68 include $(ROOTDIR)/apps/bitmaps/bitmaps.make
69 endif
70 endif
72 #included before codecs.make and plugins.make so they see $(LIBSETJMP)
73 ifndef APP_TYPE
74 include $(ROOTDIR)/lib/libsetjmp/libsetjmp.make
75 endif
77 ifneq (,$(findstring bootloader,$(APPSDIR)))
78 include $(APPSDIR)/bootloader.make
79 else ifneq (,$(findstring bootbox,$(APPSDIR)))
80 BOOTBOXLDOPTS = -Wl,--gc-sections
81 include $(APPSDIR)/bootbox.make
82 else ifneq (,$(findstring checkwps,$(APPSDIR)))
83 include $(APPSDIR)/checkwps.make
84 include $(ROOTDIR)/lib/skin_parser/skin_parser.make
85 else ifneq (,$(findstring database,$(APPSDIR)))
86 include $(APPSDIR)/database.make
87 else
88 include $(APPSDIR)/apps.make
89 include $(APPSDIR)/lang/lang.make
91 ifdef SOFTWARECODECS
92 include $(APPSDIR)/codecs/codecs.make
93 endif
95 ifdef ENABLEDPLUGINS
96 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
97 include $(APPSDIR)/plugins/plugins.make
98 endif
100 ifdef APP_TYPE
101 include $(ROOTDIR)/uisimulator/uisimulator.make
102 endif
104 endif # bootloader
106 OBJ := $(SRC:.c=.o)
107 OBJ := $(OBJ:.S=.o)
108 OBJ += $(BMP:.bmp=.o)
109 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
111 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
113 $(RBINFO): $(BUILDDIR)/$(BINARY)
114 $(SILENT)echo Creating $(@F)
115 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
117 $(DEPFILE) dep:
118 $(call PRINTS,Generating dependencies)
119 $(call mkdepfile,$(DEPFILE)_,$(SRC))
120 $(call mkdepfile,$(DEPFILE)_,$(OTHER_SRC:%.lua=))
121 $(call mkdepfile,$(DEPFILE)_,$(ASMDEFS_SRC))
122 $(call bmpdepfile,$(DEPFILE)_,$(BMP) $(PBMP))
123 @mv $(DEPFILE)_ $(DEPFILE)
125 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
126 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
127 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
128 tools: $(TOOLS)
130 -include $(DEPFILE)
132 veryclean: clean
133 $(SILENT)rm -rf $(TOOLS)
135 clean:
136 $(SILENT)echo Cleaning build directory
137 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
138 rockbox.tar.bz2 TAGS apps firmware tools comsim sim lang lib \
139 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
140 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
141 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
142 *.wav *.mp3 *.voice $(CLEANOBJS) \
143 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
144 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
145 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK)
147 #### linking the binaries: ####
149 .SECONDEXPANSION:
151 ifeq (,$(findstring bootloader,$(APPSDIR)))
152 # not bootloader
154 OBJ += $(LANG_O)
156 ifndef APP_TYPE
158 ## target build
159 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
160 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
161 LINKRAM := $(BUILDDIR)/ram.link
162 ROMLDS := $(FIRMDIR)/rom.lds
163 LINKROM := $(BUILDDIR)/rom.link
166 $(LINKRAM): $(RAMLDS) $(CONFIGFILE)
167 $(call PRINTS,PP $(@F))
168 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
170 $(LINKROM): $(ROMLDS)
171 $(call PRINTS,PP $(@F))
172 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
174 $(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LINKRAM)
175 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
176 -L$(BUILDDIR)/firmware -lfirmware \
177 -L$(BUILDDIR)/lib -lskin_parser \
178 -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
179 -lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \
180 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
182 $(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LINKROM)
183 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
184 $(VOICESPEEXLIB) $(FIRMLIB) -lgcc $(GLOBAL_LDOPTS) \
185 -L$(BUILDDIR)/lib -lskin_parser \
186 -L$(BUILDDIR)/firmware -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
188 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
189 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
191 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
192 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
195 # If there's a flashfile defined for this target (rockbox.ucl for Archos
196 # models) Then check if the mkfirmware script fails, as then it is (likely)
197 # because the image is too big and we need to create a compressed image
198 # instead.
200 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
201 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
202 stat=$$?; \
203 if test -n "$(FLASHFILE)"; then \
204 if test "$$stat" -ne 0; then \
205 echo "Image too big, making a compressed version!"; \
206 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
207 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
208 fi \
209 fi )
211 # archos
212 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
213 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
215 MAXINFILE = $(BUILDDIR)/temp.txt
216 MAXOUTFILE = $(BUILDDIR)/romstart.txt
218 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
219 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
220 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
221 if test $$? -ne 0; then \
222 echo "removing UCL file again, making it a fake one"; \
223 echo "fake" > $@; \
226 $(MAXOUTFILE):
227 $(call PRINTS,Creating $(@F))
228 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
229 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
230 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
231 $(SILENT)rm $(MAXINFILE)
233 # iriver
234 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
235 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
237 endif # !APP_TYPE
238 endif # !bootloader
241 voicetools:
242 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
244 tags:
245 $(SILENT)rm -f TAGS
246 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
248 fontzip:
249 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
251 zip:
252 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
254 mapzip:
255 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
257 fullzip:
258 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
260 7zip:
261 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.7z" -z "7za a -mx=9" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
263 tar:
264 $(SILENT)rm -f rockbox.tar
265 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
267 bzip2: tar
268 $(SILENT)bzip2 -f9 rockbox.tar
270 gzip: tar
271 $(SILENT)gzip -f9 rockbox.tar
273 manual manual-pdf:
274 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
275 manual-html:
276 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
277 manual-zhtml: manual-zip
278 manual-txt:
279 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
280 manual-ztxt:
281 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
282 manual-zip:
283 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
285 ifdef TTS_ENGINE
287 voice: voicetools $(BUILDDIR)/apps/features
288 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
289 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 \
291 endif
293 bininstall: $(BUILDDIR)/$(BINARY)
294 @echo "Installing your rockbox binary in your '$(RBPREFIX)' dir"
295 $(SILENT)cp $(BINARY) "$(RBPREFIX)/.rockbox/"
297 install:
298 @echo "Installing your build in your '$(RBPREFIX)' dir"
299 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
301 fullinstall:
302 @echo "Installing a full setup in your '$(RBPREFIX)' dir"
303 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
305 help:
306 @echo "A few helpful make targets"
307 @echo ""
308 @echo "all - builds a full Rockbox (default), including tools"
309 @echo "bin - builds only the Rockbox.<target name> file"
310 @echo "rocks - builds only plugins"
311 @echo "codecs - builds only codecs"
312 @echo "dep - regenerates make dependency database"
313 @echo "clean - cleans a build directory (not tools)"
314 @echo "veryclean - cleans the build and tools directories"
315 @echo "manual - builds a manual (pdf)"
316 @echo "manual-html - HTML manual"
317 @echo "manual-zip - HTML manual (zipped)"
318 @echo "manual-txt - txt manual"
319 @echo "fullzip - creates a rockbox.zip of your build with fonts"
320 @echo "zip - creates a rockbox.zip of your build (no fonts)"
321 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
322 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
323 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
324 @echo "fontzip - creates rockbox-fonts.zip"
325 @echo "mapzip - creates rockbox-maps.zip with all .map files"
326 @echo "tools - builds the tools only"
327 @echo "voice - creates the voice clips (voice builds only)"
328 @echo "voicetools - builds the voice tools only"
329 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
330 @echo "fullinstall - installs your build (like install, but with fonts)"
331 @echo "reconf - rerun configure with the same selection"
333 ### general compile rules:
335 # when source and object are in different locations (normal):
336 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
337 $(SILENT)mkdir -p $(dir $@)
338 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
340 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
341 $(SILENT)mkdir -p $(dir $@)
342 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
344 # generated definitions for use in .S files
345 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
346 $(call PRINTS,ASMDEFS $(@F))
347 $(SILENT)mkdir -p $(dir $@)
348 $(call asmdefs2file,$<,$@)
350 # when source and object are both in BUILDDIR (generated code):
351 %.o: %.c
352 $(SILENT)mkdir -p $(dir $@)
353 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
355 %.o: %.S
356 $(SILENT)mkdir -p $(dir $@)
357 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
359 Makefile: $(TOOLSDIR)/configure
360 ifneq (reconf,$(MAKECMDGOALS))
361 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
362 endif
364 reconf:
365 $(SILENT$)$(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)