(Hopefully) fix overlay plugins.
[maemo-rb.git] / tools / root.make
blob861f017a8270fdc8cd2b01f5f303a07590866019
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, CORE_LIBS and EXTRA_LIBS. But they also define special
63 # dependencies and compile rules
64 include $(TOOLSDIR)/tools.make
66 ifeq (,$(findstring checkwps,$(APPSDIR)))
67 ifeq (,$(findstring database,$(APPSDIR)))
68 include $(FIRMDIR)/firmware.make
69 include $(ROOTDIR)/lib/skin_parser/skin_parser.make
70 include $(ROOTDIR)/apps/bitmaps/bitmaps.make
71 endif
72 endif
74 #included before codecs.make and plugins.make so they see them)
75 ifndef APP_TYPE
76 include $(ROOTDIR)/lib/libsetjmp/libsetjmp.make
77 ifeq (arm,$(ARCH))
78 include $(ROOTDIR)/lib/arm_support/arm_support.make
79 endif
80 endif
82 ifeq (arm,$(ARCH))
83 include $(ROOTDIR)/lib/unwarminder/unwarminder.make
84 endif
86 ifneq (,$(findstring bootloader,$(APPSDIR)))
87 include $(APPSDIR)/bootloader.make
88 else ifneq (,$(findstring bootbox,$(APPSDIR)))
89 BOOTBOXLDOPTS = -Wl,--gc-sections
90 include $(APPSDIR)/bootbox.make
91 else ifneq (,$(findstring checkwps,$(APP_TYPE)))
92 include $(APPSDIR)/checkwps.make
93 else ifneq (,$(findstring database,$(APP_TYPE)))
94 include $(APPSDIR)/database.make
95 else ifneq (,$(findstring warble,$(APP_TYPE)))
96 include $(ROOTDIR)/lib/rbcodec/test/warble.make
97 else
98 include $(APPSDIR)/apps.make
99 include $(ROOTDIR)/lib/rbcodec/rbcodec.make
100 include $(APPSDIR)/lang/lang.make
102 ifdef SOFTWARECODECS
103 include $(APPSDIR)/codecs/codecs.make
104 endif
106 ifdef ENABLEDPLUGINS
107 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
108 include $(APPSDIR)/plugins/plugins.make
109 endif
111 ifneq (,$(findstring sdl,$(APP_TYPE)))
112 include $(ROOTDIR)/uisimulator/uisimulator.make
113 endif
115 ifneq (,$(findstring ypr0,$(APP_TYPE)))
116 include $(ROOTDIR)/firmware/target/hosted/ypr0/ypr0.make
117 endif
119 ifneq (,$(findstring android, $(APP_TYPE)))
120 include $(ROOTDIR)/android/android.make
121 endif
123 ifneq (,$(findstring pandora, $(MODELNAME)))
124 include $(ROOTDIR)/packaging/pandora/pandora.make
125 endif
127 endif # bootloader
129 OBJ := $(SRC:.c=.o)
130 OBJ := $(OBJ:.S=.o)
131 OBJ += $(BMP:.bmp=.o)
132 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
134 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
136 $(RBINFO): $(BUILDDIR)/$(BINARY)
137 $(SILENT)echo Creating $(@F)
138 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
140 $(DEPFILE) dep:
141 $(call PRINTS,Generating dependencies)
142 $(call mkdepfile,$(DEPFILE)_,$(SRC))
143 $(call mkdepfile,$(DEPFILE)_,$(OTHER_SRC:%.lua=))
144 $(call mkdepfile,$(DEPFILE)_,$(ASMDEFS_SRC))
145 $(call bmpdepfile,$(DEPFILE)_,$(BMP) $(PBMP))
146 @mv $(DEPFILE)_ $(DEPFILE)
148 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
149 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
150 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
151 tools: $(TOOLS)
153 -include $(DEPFILE)
155 veryclean: clean
156 $(SILENT)rm -rf $(TOOLS)
158 clean::
159 $(SILENT)echo Cleaning build directory
160 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
161 rockbox.tar.bz2 TAGS apps firmware tools comsim sim lang lib \
162 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
163 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
164 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
165 *.wav *.mp3 *.voice $(CLEANOBJS) \
166 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
167 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
168 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK) \
169 rockbox.apk
171 #### linking the binaries: ####
173 .SECONDEXPANSION:
175 ifeq (,$(findstring bootloader,$(APPSDIR)))
176 # not bootloader
178 OBJ += $(LANG_O)
180 ifndef APP_TYPE
182 ## target build
183 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
184 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
185 LINKRAM := $(BUILDDIR)/ram.link
186 ROMLDS := $(FIRMDIR)/rom.lds
187 LINKROM := $(BUILDDIR)/rom.link
189 $(LINKRAM): $(RAMLDS) $(CONFIGFILE)
190 $(call PRINTS,PP $(@F))
191 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
193 $(LINKROM): $(ROMLDS)
194 $(call PRINTS,PP $(@F))
195 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
197 $(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $$(LINKRAM)
198 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
199 -L$(BUILDDIR)/firmware -lfirmware \
200 -L$(BUILDDIR)/apps/codecs $(call a2lnk, $(VOICESPEEXLIB)) \
201 -L$(BUILDDIR)/lib $(call a2lnk, $(CORE_LIBS)) \
202 -lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \
203 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
205 $(BUILDDIR)/rombox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $$(LINKROM)
206 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
207 -L$(BUILDDIR)/firmware -lfirmware \
208 -L$(BUILDDIR)/apps/codecs $(call a2lnk, $(VOICESPEEXLIB)) \
209 -L$(BUILDDIR)/lib $(call a2lnk, $(CORE_LIBS)) \
210 -lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \
211 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
213 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
214 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
216 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
217 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
220 # If there's a flashfile defined for this target (rockbox.ucl for Archos
221 # models) Then check if the mkfirmware script fails, as then it is (likely)
222 # because the image is too big and we need to create a compressed image
223 # instead.
225 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
226 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
227 stat=$$?; \
228 if test -n "$(FLASHFILE)"; then \
229 if test "$$stat" -ne 0; then \
230 echo "Image too big, making a compressed version!"; \
231 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
232 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
233 fi \
234 fi )
236 # archos
237 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
238 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
240 MAXINFILE = $(BUILDDIR)/temp.txt
241 MAXOUTFILE = $(BUILDDIR)/romstart.txt
243 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
244 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
245 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
246 if test $$? -ne 0; then \
247 echo "removing UCL file again, making it a fake one"; \
248 echo "fake" > $@; \
251 $(MAXOUTFILE):
252 $(call PRINTS,Creating $(@F))
253 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
254 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
255 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
256 $(SILENT)rm $(MAXINFILE)
258 # iriver
259 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
260 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
262 endif # !APP_TYPE
263 endif # !bootloader
266 voicetools:
267 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
269 tags:
270 $(SILENT)rm -f TAGS
271 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
273 fontzip:
274 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
276 zip: $(BUILDDIR)/rockbox.zip
278 ifdef NODEPS
279 $(BUILDDIR)/rockbox.zip:
280 else
281 $(BUILDDIR)/rockbox.zip: build
282 endif
283 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
285 mapzip:
286 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
288 elfzip:
289 $(SILENT)find . -name "*.elf" | xargs zip rockbox-elfs.zip
291 fullzip:
292 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
294 7zip:
295 $(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)
297 tar:
298 $(SILENT)rm -f rockbox.tar
299 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
301 bzip2: tar
302 $(SILENT)bzip2 -f9 rockbox.tar
304 gzip: tar
305 $(SILENT)gzip -f9 rockbox.tar
307 manual manual-pdf:
308 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
309 manual-html:
310 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
311 manual-zhtml: manual-zip
312 manual-txt:
313 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
314 manual-ztxt:
315 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
316 manual-zip:
317 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
319 ifdef TTS_ENGINE
321 voice: voicetools $(BUILDDIR)/apps/features
322 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
323 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 \
325 endif
327 ifeq (,$(findstring android, $(APP_TYPE)))
328 bininstall: $(BUILDDIR)/$(BINARY)
329 @echo "Installing your rockbox binary in your '$(RBPREFIX)' dir"
330 $(SILENT)cp $(BINARY) "$(RBPREFIX)/.rockbox/"
332 install:
333 @echo "Installing your build in your '$(RBPREFIX)' dir"
334 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
336 fullinstall:
337 @echo "Installing a full setup in your '$(RBPREFIX)' dir"
338 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
340 symlinkinstall:
341 @echo "Installing a full setup with links in your '$(RBPREFIX)' dir"
342 $(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
343 endif
345 help:
346 @echo "A few helpful make targets"
347 @echo ""
348 @echo "all - builds a full Rockbox (default), including tools"
349 @echo "bin - builds only the Rockbox.<target name> file"
350 @echo "rocks - builds only plugins"
351 @echo "codecs - builds only codecs"
352 @echo "dep - regenerates make dependency database"
353 @echo "clean - cleans a build directory (not tools)"
354 @echo "veryclean - cleans the build and tools directories"
355 @echo "manual - builds a manual (pdf)"
356 @echo "manual-html - HTML manual"
357 @echo "manual-zip - HTML manual (zipped)"
358 @echo "manual-txt - txt manual"
359 @echo "fullzip - creates a rockbox.zip of your build with fonts"
360 @echo "zip - creates a rockbox.zip of your build (no fonts)"
361 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
362 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
363 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
364 @echo "fontzip - creates rockbox-fonts.zip"
365 @echo "mapzip - creates rockbox-maps.zip with all .map files"
366 @echo "elfzip - creates rockbox-elfs.zip with all .elf files"
367 @echo "pnd - creates rockbox.pnd archive (Pandora builds only)"
368 @echo "tools - builds the tools only"
369 @echo "voice - creates the voice clips (voice builds only)"
370 @echo "voicetools - builds the voice tools only"
371 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
372 @echo "fullinstall - installs your build (like install, but with fonts)"
373 @echo "symlinkinstall - like fullinstall, but with links instead of copying files. (Good for developing on simulator)"
374 @echo "reconf - rerun configure with the same selection"
376 ### general compile rules:
378 # when source and object are in different locations (normal):
379 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
380 $(SILENT)mkdir -p $(dir $@)
381 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
383 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
384 $(SILENT)mkdir -p $(dir $@)
385 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
387 # generated definitions for use in .S files
388 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
389 $(call PRINTS,ASMDEFS $(@F))
390 $(SILENT)mkdir -p $(dir $@)
391 $(call asmdefs2file,$<,$@)
393 # when source and object are both in BUILDDIR (generated code):
394 %.o: %.c
395 $(SILENT)mkdir -p $(dir $@)
396 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
398 %.o: %.S
399 $(SILENT)mkdir -p $(dir $@)
400 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
402 Makefile: $(TOOLSDIR)/configure
403 ifneq (reconf,$(MAKECMDGOALS))
404 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
405 endif
407 reconf:
408 $(SILENT$)$(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)