RaaA: Add RTC support
[maemo-rb.git] / tools / root.make
blob20b11ae1fbf55bb9ed36d9fb61f716fddba4d88a
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 $(TOOLSDIR)/convttf
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 $(LIBSETJMP)
74 ifndef APP_TYPE
75 include $(ROOTDIR)/lib/libsetjmp/libsetjmp.make
76 endif
78 ifneq (,$(findstring bootloader,$(APPSDIR)))
79 include $(APPSDIR)/bootloader.make
80 else ifneq (,$(findstring bootbox,$(APPSDIR)))
81 BOOTBOXLDOPTS = -Wl,--gc-sections
82 include $(APPSDIR)/bootbox.make
83 else ifneq (,$(findstring checkwps,$(APPSDIR)))
84 include $(APPSDIR)/checkwps.make
85 include $(ROOTDIR)/lib/skin_parser/skin_parser.make
86 else ifneq (,$(findstring database,$(APPSDIR)))
87 include $(APPSDIR)/database.make
88 else
89 include $(APPSDIR)/apps.make
90 include $(APPSDIR)/lang/lang.make
92 ifdef SOFTWARECODECS
93 include $(APPSDIR)/codecs/codecs.make
94 endif
96 ifdef ENABLEDPLUGINS
97 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
98 include $(APPSDIR)/plugins/plugins.make
99 endif
101 ifneq (,$(findstring sdl,$(APP_TYPE)))
102 include $(ROOTDIR)/uisimulator/uisimulator.make
103 endif
105 ifneq (,$(findstring android, $(APP_TYPE)))
106 include $(ROOTDIR)/android/android.make
107 endif
109 endif # bootloader
111 OBJ := $(SRC:.c=.o)
112 OBJ := $(OBJ:.S=.o)
113 OBJ += $(BMP:.bmp=.o)
114 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
116 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
118 $(RBINFO): $(BUILDDIR)/$(BINARY)
119 $(SILENT)echo Creating $(@F)
120 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
122 $(DEPFILE) dep:
123 $(call PRINTS,Generating dependencies)
124 $(call mkdepfile,$(DEPFILE)_,$(SRC))
125 $(call mkdepfile,$(DEPFILE)_,$(OTHER_SRC:%.lua=))
126 $(call mkdepfile,$(DEPFILE)_,$(ASMDEFS_SRC))
127 $(call bmpdepfile,$(DEPFILE)_,$(BMP) $(PBMP))
128 @mv $(DEPFILE)_ $(DEPFILE)
130 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
131 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
132 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
133 tools: $(TOOLS)
135 -include $(DEPFILE)
137 veryclean: clean
138 $(SILENT)rm -rf $(TOOLS)
140 clean::
141 $(SILENT)echo Cleaning build directory
142 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
143 rockbox.tar.bz2 TAGS apps firmware tools comsim sim lang lib \
144 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
145 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
146 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
147 *.wav *.mp3 *.voice $(CLEANOBJS) \
148 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
149 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
150 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK)
152 #### linking the binaries: ####
154 .SECONDEXPANSION:
156 ifeq (,$(findstring bootloader,$(APPSDIR)))
157 # not bootloader
159 OBJ += $(LANG_O)
161 ifndef APP_TYPE
163 ## target build
164 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
165 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
166 LINKRAM := $(BUILDDIR)/ram.link
167 ROMLDS := $(FIRMDIR)/rom.lds
168 LINKROM := $(BUILDDIR)/rom.link
171 $(LINKRAM): $(RAMLDS) $(CONFIGFILE)
172 $(call PRINTS,PP $(@F))
173 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
175 $(LINKROM): $(ROMLDS)
176 $(call PRINTS,PP $(@F))
177 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
179 $(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LINKRAM)
180 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
181 -L$(BUILDDIR)/firmware -lfirmware \
182 -L$(BUILDDIR)/lib -lskin_parser \
183 -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
184 -lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \
185 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
187 $(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LINKROM)
188 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
189 $(VOICESPEEXLIB) $(FIRMLIB) -lgcc $(GLOBAL_LDOPTS) \
190 -L$(BUILDDIR)/lib -lskin_parser \
191 -L$(BUILDDIR)/firmware -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
193 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
194 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
196 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
197 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
200 # If there's a flashfile defined for this target (rockbox.ucl for Archos
201 # models) Then check if the mkfirmware script fails, as then it is (likely)
202 # because the image is too big and we need to create a compressed image
203 # instead.
205 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
206 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
207 stat=$$?; \
208 if test -n "$(FLASHFILE)"; then \
209 if test "$$stat" -ne 0; then \
210 echo "Image too big, making a compressed version!"; \
211 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
212 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
213 fi \
214 fi )
216 # archos
217 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
218 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
220 MAXINFILE = $(BUILDDIR)/temp.txt
221 MAXOUTFILE = $(BUILDDIR)/romstart.txt
223 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
224 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
225 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
226 if test $$? -ne 0; then \
227 echo "removing UCL file again, making it a fake one"; \
228 echo "fake" > $@; \
231 $(MAXOUTFILE):
232 $(call PRINTS,Creating $(@F))
233 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
234 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
235 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
236 $(SILENT)rm $(MAXINFILE)
238 # iriver
239 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
240 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
242 endif # !APP_TYPE
243 endif # !bootloader
246 voicetools:
247 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
249 tags:
250 $(SILENT)rm -f TAGS
251 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
253 fontzip:
254 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
256 zip:
257 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
259 mapzip:
260 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
262 elfzip:
263 $(SILENT)find . -name "*.elf" | xargs zip rockbox-elfs.zip
265 fullzip:
266 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
268 7zip:
269 $(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)
271 tar:
272 $(SILENT)rm -f rockbox.tar
273 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
275 bzip2: tar
276 $(SILENT)bzip2 -f9 rockbox.tar
278 gzip: tar
279 $(SILENT)gzip -f9 rockbox.tar
281 manual manual-pdf:
282 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
283 manual-html:
284 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
285 manual-zhtml: manual-zip
286 manual-txt:
287 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
288 manual-ztxt:
289 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
290 manual-zip:
291 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
293 ifdef TTS_ENGINE
295 voice: voicetools $(BUILDDIR)/apps/features
296 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
297 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 \
299 endif
301 ifeq (,$(findstring android, $(APP_TYPE)))
302 bininstall: $(BUILDDIR)/$(BINARY)
303 @echo "Installing your rockbox binary in your '$(RBPREFIX)' dir"
304 $(SILENT)cp $(BINARY) "$(RBPREFIX)/.rockbox/"
306 install:
307 @echo "Installing your build in your '$(RBPREFIX)' dir"
308 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
310 fullinstall:
311 @echo "Installing a full setup in your '$(RBPREFIX)' dir"
312 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
314 symlinkinstall:
315 @echo "Installing a full setup with links in your '$(RBPREFIX)' dir"
316 $(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
317 endif
319 help:
320 @echo "A few helpful make targets"
321 @echo ""
322 @echo "all - builds a full Rockbox (default), including tools"
323 @echo "bin - builds only the Rockbox.<target name> file"
324 @echo "rocks - builds only plugins"
325 @echo "codecs - builds only codecs"
326 @echo "dep - regenerates make dependency database"
327 @echo "clean - cleans a build directory (not tools)"
328 @echo "veryclean - cleans the build and tools directories"
329 @echo "manual - builds a manual (pdf)"
330 @echo "manual-html - HTML manual"
331 @echo "manual-zip - HTML manual (zipped)"
332 @echo "manual-txt - txt manual"
333 @echo "fullzip - creates a rockbox.zip of your build with fonts"
334 @echo "zip - creates a rockbox.zip of your build (no fonts)"
335 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
336 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
337 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
338 @echo "fontzip - creates rockbox-fonts.zip"
339 @echo "mapzip - creates rockbox-maps.zip with all .map files"
340 @echo "elfzip - creates rockbox-elfs.zip with all .elf files"
341 @echo "tools - builds the tools only"
342 @echo "voice - creates the voice clips (voice builds only)"
343 @echo "voicetools - builds the voice tools only"
344 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
345 @echo "fullinstall - installs your build (like install, but with fonts)"
346 @echo "symlinkinstall - like fullinstall, but with links instead of copying files. (Good for developing on simulator)"
347 @echo "reconf - rerun configure with the same selection"
349 ### general compile rules:
351 # when source and object are in different locations (normal):
352 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
353 $(SILENT)mkdir -p $(dir $@)
354 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
356 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
357 $(SILENT)mkdir -p $(dir $@)
358 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
360 # generated definitions for use in .S files
361 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
362 $(call PRINTS,ASMDEFS $(@F))
363 $(SILENT)mkdir -p $(dir $@)
364 $(call asmdefs2file,$<,$@)
366 # when source and object are both in BUILDDIR (generated code):
367 %.o: %.c
368 $(SILENT)mkdir -p $(dir $@)
369 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
371 %.o: %.S
372 $(SILENT)mkdir -p $(dir $@)
373 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
375 Makefile: $(TOOLSDIR)/configure
376 ifneq (reconf,$(MAKECMDGOALS))
377 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
378 endif
380 reconf:
381 $(SILENT$)$(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)