Prepare new maemo release
[maemo-rb.git] / tools / root.make
blobc8c4eb4f8906afcccf97314b919d73ba6eeb9ec5
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
26 ifeq ($(MODELNAME),archosplayer)
27 TOOLS += $(TOOLSDIR)/player_unifont
28 endif
30 ifeq (,$(PREFIX))
31 ifdef APP_TYPE
32 # for sims, set simdisk/ as default
33 ifeq ($(APP_TYPE),sdl-sim)
34 RBPREFIX = simdisk
35 else ifeq ($(APP_TYPE),sdl-app)
36 RBPREFIX = /usr/local
37 endif
39 INSTALL = --install="$(RBPREFIX)"
40 else
41 # /dev/null as magic to tell it wasn't set, error out later in buildzip.pl
42 INSTALL = --install=/dev/null
43 endif
44 else
45 RBPREFIX = $(PREFIX)
46 INSTALL = --install="$(RBPREFIX)"
47 endif
49 RBINFO = $(BUILDDIR)/rockbox-info.txt
51 # list suffixes to be understood by $*
52 .SUFFIXES: .rock .codec .map .elf .c .S .o .bmp .a
54 .PHONY: all clean tags zip tools manual bin build info langs
56 ifeq (,$(filter clean veryclean reconf tags voice voicetools manual manual-pdf manual-html manual-zhtml manual-txt manual-ztxt manual-zip help fontzip ,$(MAKECMDGOALS)))
57 # none of the above
58 DEPFILE = $(BUILDDIR)/make.dep
60 endif
62 all: $(DEPFILE) build
64 # Subdir makefiles. their primary purpose is to populate SRC, OTHER_SRC,
65 # ASMDEFS_SRC and CORE_LIBS. But they also define special dependencies and
66 # compile rules
67 include $(TOOLSDIR)/tools.make
69 ifeq (,$(findstring checkwps,$(APP_TYPE)))
70 ifeq (,$(findstring database,$(APP_TYPE)))
71 ifeq (,$(findstring warble,$(APP_TYPE)))
72 include $(FIRMDIR)/firmware.make
73 include $(ROOTDIR)/apps/bitmaps/bitmaps.make
74 ifeq (,$(findstring bootloader,$(APPSDIR)))
75 include $(ROOTDIR)/lib/skin_parser/skin_parser.make
76 include $(ROOTDIR)/lib/tlsf/libtlsf.make
77 endif
78 endif
79 endif
80 endif
82 #included before codecs.make and plugins.make so they see them)
83 ifndef APP_TYPE
84 include $(ROOTDIR)/lib/libsetjmp/libsetjmp.make
85 ifeq (arch_arm,$(ARCH))
86 include $(ROOTDIR)/lib/arm_support/arm_support.make
87 endif
88 endif
90 ifeq (arch_arm,$(ARCH))
91 include $(ROOTDIR)/lib/unwarminder/unwarminder.make
92 endif
94 ifneq (,$(findstring bootloader,$(APPSDIR)))
95 include $(APPSDIR)/bootloader.make
96 else ifneq (,$(findstring bootbox,$(APPSDIR)))
97 BOOTBOXLDOPTS = -Wl,--gc-sections
98 include $(APPSDIR)/bootbox.make
99 else ifneq (,$(findstring checkwps,$(APP_TYPE)))
100 include $(APPSDIR)/checkwps.make
101 include $(ROOTDIR)/lib/skin_parser/skin_parser.make
102 else ifneq (,$(findstring database,$(APP_TYPE)))
103 include $(APPSDIR)/database.make
104 else ifneq (,$(findstring warble,$(APP_TYPE)))
105 include $(ROOTDIR)/lib/rbcodec/test/warble.make
106 include $(ROOTDIR)/lib/tlsf/libtlsf.make
107 include $(ROOTDIR)/lib/rbcodec/rbcodec.make
108 else
109 include $(APPSDIR)/apps.make
110 include $(ROOTDIR)/lib/rbcodec/rbcodec.make
111 include $(APPSDIR)/lang/lang.make
113 ifdef ENABLEDPLUGINS
114 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
115 include $(APPSDIR)/plugins/plugins.make
116 endif
118 ifneq (,$(findstring sdl,$(APP_TYPE)))
119 include $(ROOTDIR)/uisimulator/uisimulator.make
120 endif
122 ifneq (,$(findstring ypr0,$(APP_TYPE)))
123 include $(ROOTDIR)/firmware/target/hosted/ypr0/ypr0.make
124 endif
126 ifneq (,$(findstring android, $(APP_TYPE)))
127 include $(ROOTDIR)/android/android.make
128 endif
130 ifneq (,$(findstring pandora, $(MODELNAME)))
131 include $(ROOTDIR)/packaging/pandora/pandora.make
132 endif
134 endif # bootloader
136 OBJ := $(SRC:.c=.o)
137 OBJ := $(OBJ:.S=.o)
138 OBJ += $(BMP:.bmp=.o)
139 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
141 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
143 $(RBINFO): $(BUILDDIR)/$(BINARY)
144 $(SILENT)echo Creating $(@F)
145 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
147 $(DEPFILE) dep:
148 $(call PRINTS,Generating dependencies)
149 $(call mkdepfile,$(DEPFILE)_,$(SRC))
150 $(call mkdepfile,$(DEPFILE)_,$(OTHER_SRC:%.lua=))
151 $(call mkdepfile,$(DEPFILE)_,$(ASMDEFS_SRC))
152 $(call bmpdepfile,$(DEPFILE)_,$(BMP) $(PBMP))
153 @mv $(DEPFILE)_ $(DEPFILE)
155 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
156 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
157 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
158 tools: $(TOOLS)
160 -include $(DEPFILE)
162 veryclean: clean
163 $(SILENT)rm -rf $(TOOLS)
165 clean::
166 $(SILENT)echo Cleaning build directory
167 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
168 rockbox.tar.bz2 TAGS apps firmware tools comsim sim lang lib \
169 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
170 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
171 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
172 *.wav *.mp3 *.voice $(CLEANOBJS) \
173 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
174 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
175 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK) \
176 rockbox.apk
178 #### linking the binaries: ####
180 .SECONDEXPANSION:
182 ifeq (,$(findstring bootloader,$(APPSDIR)))
183 # not bootloader
185 OBJ += $(LANG_O)
187 ifndef APP_TYPE
189 ## target build
190 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
191 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
192 LINKRAM := $(BUILDDIR)/ram.link
193 ROMLDS := $(FIRMDIR)/rom.lds
194 LINKROM := $(BUILDDIR)/rom.link
196 $(LINKRAM): $(RAMLDS) $(CONFIGFILE)
197 $(call PRINTS,PP $(@F))
198 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
200 $(LINKROM): $(ROMLDS)
201 $(call PRINTS,PP $(@F))
202 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
204 $(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $$(LINKRAM)
205 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
206 -L$(BUILDDIR)/firmware -lfirmware \
207 -L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \
208 -L$(BUILDDIR)/lib $(call a2lnk, $(CORE_LIBS)) \
209 -lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \
210 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
212 $(BUILDDIR)/rombox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $$(LINKROM)
213 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
214 -L$(BUILDDIR)/firmware -lfirmware \
215 -L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \
216 -L$(BUILDDIR)/lib $(call a2lnk, $(CORE_LIBS)) \
217 -lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \
218 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
220 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
221 $(call PRINTS,OC $(@F))$(call objcopy,$<,$@)
223 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
224 $(call PRINTS,OC $(@F))$(call objcopy,$<,$@)
227 # If there's a flashfile defined for this target (rockbox.ucl for Archos
228 # models) Then check if the mkfirmware script fails, as then it is (likely)
229 # because the image is too big and we need to create a compressed image
230 # instead.
232 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
233 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
234 stat=$$?; \
235 if test -n "$(FLASHFILE)"; then \
236 if test "$$stat" -ne 0; then \
237 echo "Image too big, making a compressed version!"; \
238 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
239 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
240 fi \
241 fi )
243 # archos
244 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
245 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
247 MAXINFILE = $(BUILDDIR)/temp.txt
248 MAXOUTFILE = $(BUILDDIR)/romstart.txt
250 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
251 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
252 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
253 if test $$? -ne 0; then \
254 echo "removing UCL file again, making it a fake one"; \
255 echo "fake" > $@; \
258 $(MAXOUTFILE):
259 $(call PRINTS,Creating $(@F))
260 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
261 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
262 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
263 $(SILENT)rm $(MAXINFILE)
265 # iriver
266 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
267 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
269 endif # !APP_TYPE
270 endif # !bootloader
273 voicetools:
274 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
276 tags:
277 $(SILENT)rm -f TAGS
278 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
280 fontzip:
281 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
283 zip: $(BUILDDIR)/rockbox.zip
285 ifdef NODEPS
286 $(BUILDDIR)/rockbox.zip:
287 else
288 $(BUILDDIR)/rockbox.zip: build
289 endif
290 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
292 mapzip:
293 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
295 elfzip:
296 $(SILENT)find . -name "*.elf" | xargs zip rockbox-elfs.zip
298 fullzip:
299 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
301 7zip:
302 $(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)
304 tar:
305 $(SILENT)rm -f rockbox.tar
306 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
308 bzip2: tar
309 $(SILENT)bzip2 -f9 rockbox.tar
311 gzip: tar
312 $(SILENT)gzip -f9 rockbox.tar
314 manual manual-pdf:
315 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
316 manual-html:
317 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
318 manual-zhtml: manual-zip
319 manual-txt:
320 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
321 manual-ztxt:
322 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
323 manual-zip:
324 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
326 ifdef TTS_ENGINE
328 voice: voicetools $(BUILDDIR)/apps/features
329 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
330 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 \
332 endif
334 ifeq (,$(findstring android, $(APP_TYPE)))
335 bininstall: $(BUILDDIR)/$(BINARY)
336 @echo "Installing your rockbox binary in your '$(RBPREFIX)' dir"
337 $(SILENT)cp $(BINARY) "$(RBPREFIX)/.rockbox/"
339 install:
340 @echo "Installing your build in your '$(RBPREFIX)' dir"
341 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
343 fullinstall:
344 @echo "Installing a full setup 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 2 $(TARGET) $(BINARY)
347 symlinkinstall:
348 @echo "Installing a full setup with links 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) -l
350 endif
352 help:
353 @echo "A few helpful make targets"
354 @echo ""
355 @echo "all - builds a full Rockbox (default), including tools"
356 @echo "bin - builds only the Rockbox.<target name> file"
357 @echo "rocks - builds only plugins"
358 @echo "codecs - builds only codecs"
359 @echo "dep - regenerates make dependency database"
360 @echo "clean - cleans a build directory (not tools)"
361 @echo "veryclean - cleans the build and tools directories"
362 @echo "manual - builds a manual (pdf)"
363 @echo "manual-html - HTML manual"
364 @echo "manual-zip - HTML manual (zipped)"
365 @echo "manual-txt - txt manual"
366 @echo "fullzip - creates a rockbox.zip of your build with fonts"
367 @echo "zip - creates a rockbox.zip of your build (no fonts)"
368 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
369 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
370 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
371 @echo "fontzip - creates rockbox-fonts.zip"
372 @echo "mapzip - creates rockbox-maps.zip with all .map files"
373 @echo "elfzip - creates rockbox-elfs.zip with all .elf files"
374 @echo "pnd - creates rockbox.pnd archive (Pandora builds only)"
375 @echo "tools - builds the tools only"
376 @echo "voice - creates the voice clips (voice builds only)"
377 @echo "voicetools - builds the voice tools only"
378 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
379 @echo "fullinstall - installs your build (like install, but with fonts)"
380 @echo "symlinkinstall - like fullinstall, but with links instead of copying files. (Good for developing on simulator)"
381 @echo "reconf - rerun configure with the same selection"
383 ### general compile rules:
385 # when source and object are in different locations (normal):
386 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
387 $(SILENT)mkdir -p $(dir $@)
388 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
390 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
391 $(SILENT)mkdir -p $(dir $@)
392 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
394 # generated definitions for use in .S files
395 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
396 $(call PRINTS,ASMDEFS $(@F))
397 $(SILENT)mkdir -p $(dir $@)
398 $(call asmdefs2file,$<,$@)
400 # when source and object are both in BUILDDIR (generated code):
401 %.o: %.c
402 $(SILENT)mkdir -p $(dir $@)
403 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
405 %.o: %.S
406 $(SILENT)mkdir -p $(dir $@)
407 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
409 Makefile: $(TOOLSDIR)/configure
410 ifneq (reconf,$(MAKECMDGOALS))
411 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
412 endif
414 reconf:
415 $(SILENT$)$(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)