fix checkwps
[maemo-rb.git] / tools / root.make
blobf97588f158e9875f4811597a25f26f699a4fd36f
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 $(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 ifneq (,$(findstring pandora, $(MODELNAME)))
110 include $(ROOTDIR)/packaging/pandora/pandora.make
111 endif
113 endif # bootloader
115 OBJ := $(SRC:.c=.o)
116 OBJ := $(OBJ:.S=.o)
117 OBJ += $(BMP:.bmp=.o)
118 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
120 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
122 $(RBINFO): $(BUILDDIR)/$(BINARY)
123 $(SILENT)echo Creating $(@F)
124 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
126 $(DEPFILE) dep:
127 $(call PRINTS,Generating dependencies)
128 $(call mkdepfile,$(DEPFILE)_,$(SRC))
129 $(call mkdepfile,$(DEPFILE)_,$(OTHER_SRC:%.lua=))
130 $(call mkdepfile,$(DEPFILE)_,$(ASMDEFS_SRC))
131 $(call bmpdepfile,$(DEPFILE)_,$(BMP) $(PBMP))
132 @mv $(DEPFILE)_ $(DEPFILE)
134 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
135 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
136 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
137 tools: $(TOOLS)
139 -include $(DEPFILE)
141 veryclean: clean
142 $(SILENT)rm -rf $(TOOLS)
144 clean::
145 $(SILENT)echo Cleaning build directory
146 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
147 rockbox.tar.bz2 TAGS apps firmware tools comsim sim lang lib \
148 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
149 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
150 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
151 *.wav *.mp3 *.voice $(CLEANOBJS) \
152 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
153 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
154 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK) \
155 rockbox.apk
157 #### linking the binaries: ####
159 .SECONDEXPANSION:
161 ifeq (,$(findstring bootloader,$(APPSDIR)))
162 # not bootloader
164 OBJ += $(LANG_O)
166 ifndef APP_TYPE
168 ## target build
169 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
170 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
171 LINKRAM := $(BUILDDIR)/ram.link
172 ROMLDS := $(FIRMDIR)/rom.lds
173 LINKROM := $(BUILDDIR)/rom.link
176 $(LINKRAM): $(RAMLDS) $(CONFIGFILE)
177 $(call PRINTS,PP $(@F))
178 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
180 $(LINKROM): $(ROMLDS)
181 $(call PRINTS,PP $(@F))
182 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
184 $(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LINKRAM)
185 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
186 -L$(BUILDDIR)/firmware -lfirmware \
187 -L$(BUILDDIR)/lib -lskin_parser \
188 -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
189 -lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \
190 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
192 $(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LINKROM)
193 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
194 $(VOICESPEEXLIB) $(FIRMLIB) -lgcc $(GLOBAL_LDOPTS) \
195 -L$(BUILDDIR)/lib -lskin_parser \
196 -L$(BUILDDIR)/firmware -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
198 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
199 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
201 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
202 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
205 # If there's a flashfile defined for this target (rockbox.ucl for Archos
206 # models) Then check if the mkfirmware script fails, as then it is (likely)
207 # because the image is too big and we need to create a compressed image
208 # instead.
210 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
211 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
212 stat=$$?; \
213 if test -n "$(FLASHFILE)"; then \
214 if test "$$stat" -ne 0; then \
215 echo "Image too big, making a compressed version!"; \
216 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
217 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
218 fi \
219 fi )
221 # archos
222 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
223 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
225 MAXINFILE = $(BUILDDIR)/temp.txt
226 MAXOUTFILE = $(BUILDDIR)/romstart.txt
228 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
229 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
230 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
231 if test $$? -ne 0; then \
232 echo "removing UCL file again, making it a fake one"; \
233 echo "fake" > $@; \
236 $(MAXOUTFILE):
237 $(call PRINTS,Creating $(@F))
238 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
239 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
240 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
241 $(SILENT)rm $(MAXINFILE)
243 # iriver
244 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
245 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
247 endif # !APP_TYPE
248 endif # !bootloader
251 voicetools:
252 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
254 tags:
255 $(SILENT)rm -f TAGS
256 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
258 fontzip:
259 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
261 zip: $(BUILDDIR)/rockbox.zip
263 ifdef NODEPS
264 $(BUILDDIR)/rockbox.zip:
265 else
266 $(BUILDDIR)/rockbox.zip: build
267 endif
268 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
270 mapzip:
271 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
273 elfzip:
274 $(SILENT)find . -name "*.elf" | xargs zip rockbox-elfs.zip
276 fullzip:
277 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
279 7zip:
280 $(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)
282 tar:
283 $(SILENT)rm -f rockbox.tar
284 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
286 bzip2: tar
287 $(SILENT)bzip2 -f9 rockbox.tar
289 gzip: tar
290 $(SILENT)gzip -f9 rockbox.tar
292 manual manual-pdf:
293 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
294 manual-html:
295 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
296 manual-zhtml: manual-zip
297 manual-txt:
298 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
299 manual-ztxt:
300 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
301 manual-zip:
302 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
304 ifdef TTS_ENGINE
306 voice: voicetools $(BUILDDIR)/apps/features
307 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
308 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 \
310 endif
312 ifeq (,$(findstring android, $(APP_TYPE)))
313 bininstall: $(BUILDDIR)/$(BINARY)
314 @echo "Installing your rockbox binary in your '$(RBPREFIX)' dir"
315 $(SILENT)cp $(BINARY) "$(RBPREFIX)/.rockbox/"
317 install:
318 @echo "Installing your build in your '$(RBPREFIX)' dir"
319 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
321 fullinstall:
322 @echo "Installing a full setup in your '$(RBPREFIX)' dir"
323 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
325 symlinkinstall:
326 @echo "Installing a full setup with links in your '$(RBPREFIX)' dir"
327 $(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
328 endif
330 help:
331 @echo "A few helpful make targets"
332 @echo ""
333 @echo "all - builds a full Rockbox (default), including tools"
334 @echo "bin - builds only the Rockbox.<target name> file"
335 @echo "rocks - builds only plugins"
336 @echo "codecs - builds only codecs"
337 @echo "dep - regenerates make dependency database"
338 @echo "clean - cleans a build directory (not tools)"
339 @echo "veryclean - cleans the build and tools directories"
340 @echo "manual - builds a manual (pdf)"
341 @echo "manual-html - HTML manual"
342 @echo "manual-zip - HTML manual (zipped)"
343 @echo "manual-txt - txt manual"
344 @echo "fullzip - creates a rockbox.zip of your build with fonts"
345 @echo "zip - creates a rockbox.zip of your build (no fonts)"
346 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
347 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
348 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
349 @echo "fontzip - creates rockbox-fonts.zip"
350 @echo "mapzip - creates rockbox-maps.zip with all .map files"
351 @echo "elfzip - creates rockbox-elfs.zip with all .elf files"
352 @echo "pnd - creates rockbox.pnd archive (Pandora builds only)"
353 @echo "tools - builds the tools only"
354 @echo "voice - creates the voice clips (voice builds only)"
355 @echo "voicetools - builds the voice tools only"
356 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
357 @echo "fullinstall - installs your build (like install, but with fonts)"
358 @echo "symlinkinstall - like fullinstall, but with links instead of copying files. (Good for developing on simulator)"
359 @echo "reconf - rerun configure with the same selection"
361 ### general compile rules:
363 # when source and object are in different locations (normal):
364 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
365 $(SILENT)mkdir -p $(dir $@)
366 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
368 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
369 $(SILENT)mkdir -p $(dir $@)
370 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
372 # generated definitions for use in .S files
373 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
374 $(call PRINTS,ASMDEFS $(@F))
375 $(SILENT)mkdir -p $(dir $@)
376 $(call asmdefs2file,$<,$@)
378 # when source and object are both in BUILDDIR (generated code):
379 %.o: %.c
380 $(SILENT)mkdir -p $(dir $@)
381 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
383 %.o: %.S
384 $(SILENT)mkdir -p $(dir $@)
385 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
387 Makefile: $(TOOLSDIR)/configure
388 ifneq (reconf,$(MAKECMDGOALS))
389 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
390 endif
392 reconf:
393 $(SILENT$)$(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)