Store listitem_viewport_cfg->label as skinoffset instead of raw pointer
[maemo-rb.git] / tools / root.make
blob3cdee2caf72f02ce81fda4b118ebd8037bf5f0f7
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 ifneq (,$(findstring bootloader,$(APPSDIR)))
82 include $(APPSDIR)/bootloader.make
83 else ifneq (,$(findstring bootbox,$(APPSDIR)))
84 BOOTBOXLDOPTS = -Wl,--gc-sections
85 include $(APPSDIR)/bootbox.make
86 else ifneq (,$(findstring checkwps,$(APPSDIR)))
87 include $(APPSDIR)/checkwps.make
88 include $(ROOTDIR)/lib/skin_parser/skin_parser.make
89 else ifneq (,$(findstring database,$(APPSDIR)))
90 include $(APPSDIR)/database.make
91 else
92 include $(APPSDIR)/apps.make
93 include $(APPSDIR)/lang/lang.make
95 ifdef SOFTWARECODECS
96 include $(APPSDIR)/codecs/codecs.make
97 endif
99 ifdef ENABLEDPLUGINS
100 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
101 include $(APPSDIR)/plugins/plugins.make
102 endif
104 ifneq (,$(findstring sdl,$(APP_TYPE)))
105 include $(ROOTDIR)/uisimulator/uisimulator.make
106 endif
108 ifneq (,$(findstring ypr0,$(APP_TYPE)))
109 include $(ROOTDIR)/firmware/target/hosted/ypr0/ypr0.make
110 endif
112 ifneq (,$(findstring android, $(APP_TYPE)))
113 include $(ROOTDIR)/android/android.make
114 endif
116 ifneq (,$(findstring pandora, $(MODELNAME)))
117 include $(ROOTDIR)/packaging/pandora/pandora.make
118 endif
120 endif # bootloader
122 OBJ := $(SRC:.c=.o)
123 OBJ := $(OBJ:.S=.o)
124 OBJ += $(BMP:.bmp=.o)
125 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
127 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
129 $(RBINFO): $(BUILDDIR)/$(BINARY)
130 $(SILENT)echo Creating $(@F)
131 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
133 $(DEPFILE) dep:
134 $(call PRINTS,Generating dependencies)
135 $(call mkdepfile,$(DEPFILE)_,$(SRC))
136 $(call mkdepfile,$(DEPFILE)_,$(OTHER_SRC:%.lua=))
137 $(call mkdepfile,$(DEPFILE)_,$(ASMDEFS_SRC))
138 $(call bmpdepfile,$(DEPFILE)_,$(BMP) $(PBMP))
139 @mv $(DEPFILE)_ $(DEPFILE)
141 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
142 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
143 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
144 tools: $(TOOLS)
146 -include $(DEPFILE)
148 veryclean: clean
149 $(SILENT)rm -rf $(TOOLS)
151 clean::
152 $(SILENT)echo Cleaning build directory
153 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
154 rockbox.tar.bz2 TAGS apps firmware tools comsim sim lang lib \
155 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
156 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
157 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
158 *.wav *.mp3 *.voice $(CLEANOBJS) \
159 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
160 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
161 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK) \
162 rockbox.apk
164 #### linking the binaries: ####
166 .SECONDEXPANSION:
168 ifeq (,$(findstring bootloader,$(APPSDIR)))
169 # not bootloader
171 OBJ += $(LANG_O)
173 ifndef APP_TYPE
175 ## target build
176 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
177 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
178 LINKRAM := $(BUILDDIR)/ram.link
179 ROMLDS := $(FIRMDIR)/rom.lds
180 LINKROM := $(BUILDDIR)/rom.link
182 ifeq (arm,$(ARCH))
183 LIBARMSUPPORT_LINK := -larm_support
184 else
185 LIBARMSUPPORT_LINK :=
186 endif
190 $(LINKRAM): $(RAMLDS) $(CONFIGFILE)
191 $(call PRINTS,PP $(@F))
192 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
194 $(LINKROM): $(ROMLDS)
195 $(call PRINTS,PP $(@F))
196 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
198 $(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LIBARMSUPPORT) $$(LINKRAM)
199 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
200 -L$(BUILDDIR)/firmware -lfirmware \
201 -L$(BUILDDIR)/lib -lskin_parser $(LIBARMSUPPORT_LINK) \
202 -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
203 -lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \
204 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
206 $(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LIBARMSUPPORT) $$(LINKROM)
207 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
208 -L$(BUILDDIR)/firmware -lfirmware \
209 -L$(BUILDDIR)/lib -lskin_parser $(LIBARMSUPPORT_LINK) \
210 -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
211 -lgcc $(GLOBAL_LDOPTS) \
212 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
214 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
215 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
217 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
218 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
221 # If there's a flashfile defined for this target (rockbox.ucl for Archos
222 # models) Then check if the mkfirmware script fails, as then it is (likely)
223 # because the image is too big and we need to create a compressed image
224 # instead.
226 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
227 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
228 stat=$$?; \
229 if test -n "$(FLASHFILE)"; then \
230 if test "$$stat" -ne 0; then \
231 echo "Image too big, making a compressed version!"; \
232 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
233 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
234 fi \
235 fi )
237 # archos
238 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
239 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
241 MAXINFILE = $(BUILDDIR)/temp.txt
242 MAXOUTFILE = $(BUILDDIR)/romstart.txt
244 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
245 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
246 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
247 if test $$? -ne 0; then \
248 echo "removing UCL file again, making it a fake one"; \
249 echo "fake" > $@; \
252 $(MAXOUTFILE):
253 $(call PRINTS,Creating $(@F))
254 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
255 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
256 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
257 $(SILENT)rm $(MAXINFILE)
259 # iriver
260 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
261 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
263 endif # !APP_TYPE
264 endif # !bootloader
267 voicetools:
268 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
270 tags:
271 $(SILENT)rm -f TAGS
272 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
274 fontzip:
275 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
277 zip: $(BUILDDIR)/rockbox.zip
279 ifdef NODEPS
280 $(BUILDDIR)/rockbox.zip:
281 else
282 $(BUILDDIR)/rockbox.zip: build
283 endif
284 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
286 mapzip:
287 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
289 elfzip:
290 $(SILENT)find . -name "*.elf" | xargs zip rockbox-elfs.zip
292 fullzip:
293 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
295 7zip:
296 $(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)
298 tar:
299 $(SILENT)rm -f rockbox.tar
300 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
302 bzip2: tar
303 $(SILENT)bzip2 -f9 rockbox.tar
305 gzip: tar
306 $(SILENT)gzip -f9 rockbox.tar
308 manual manual-pdf:
309 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
310 manual-html:
311 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
312 manual-zhtml: manual-zip
313 manual-txt:
314 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
315 manual-ztxt:
316 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
317 manual-zip:
318 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
320 ifdef TTS_ENGINE
322 voice: voicetools $(BUILDDIR)/apps/features
323 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
324 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 \
326 endif
328 ifeq (,$(findstring android, $(APP_TYPE)))
329 bininstall: $(BUILDDIR)/$(BINARY)
330 @echo "Installing your rockbox binary in your '$(RBPREFIX)' dir"
331 $(SILENT)cp $(BINARY) "$(RBPREFIX)/.rockbox/"
333 install:
334 @echo "Installing your build in your '$(RBPREFIX)' dir"
335 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
337 fullinstall:
338 @echo "Installing a full setup in your '$(RBPREFIX)' dir"
339 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
341 symlinkinstall:
342 @echo "Installing a full setup with links in your '$(RBPREFIX)' dir"
343 $(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
344 endif
346 help:
347 @echo "A few helpful make targets"
348 @echo ""
349 @echo "all - builds a full Rockbox (default), including tools"
350 @echo "bin - builds only the Rockbox.<target name> file"
351 @echo "rocks - builds only plugins"
352 @echo "codecs - builds only codecs"
353 @echo "dep - regenerates make dependency database"
354 @echo "clean - cleans a build directory (not tools)"
355 @echo "veryclean - cleans the build and tools directories"
356 @echo "manual - builds a manual (pdf)"
357 @echo "manual-html - HTML manual"
358 @echo "manual-zip - HTML manual (zipped)"
359 @echo "manual-txt - txt manual"
360 @echo "fullzip - creates a rockbox.zip of your build with fonts"
361 @echo "zip - creates a rockbox.zip of your build (no fonts)"
362 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
363 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
364 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
365 @echo "fontzip - creates rockbox-fonts.zip"
366 @echo "mapzip - creates rockbox-maps.zip with all .map files"
367 @echo "elfzip - creates rockbox-elfs.zip with all .elf files"
368 @echo "pnd - creates rockbox.pnd archive (Pandora builds only)"
369 @echo "tools - builds the tools only"
370 @echo "voice - creates the voice clips (voice builds only)"
371 @echo "voicetools - builds the voice tools only"
372 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
373 @echo "fullinstall - installs your build (like install, but with fonts)"
374 @echo "symlinkinstall - like fullinstall, but with links instead of copying files. (Good for developing on simulator)"
375 @echo "reconf - rerun configure with the same selection"
377 ### general compile rules:
379 # when source and object are in different locations (normal):
380 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
381 $(SILENT)mkdir -p $(dir $@)
382 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
384 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
385 $(SILENT)mkdir -p $(dir $@)
386 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
388 # generated definitions for use in .S files
389 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
390 $(call PRINTS,ASMDEFS $(@F))
391 $(SILENT)mkdir -p $(dir $@)
392 $(call asmdefs2file,$<,$@)
394 # when source and object are both in BUILDDIR (generated code):
395 %.o: %.c
396 $(SILENT)mkdir -p $(dir $@)
397 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
399 %.o: %.S
400 $(SILENT)mkdir -p $(dir $@)
401 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
403 Makefile: $(TOOLSDIR)/configure
404 ifneq (reconf,$(MAKECMDGOALS))
405 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
406 endif
408 reconf:
409 $(SILENT$)$(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)