Fix multiscreen handling of the viewportmanager.
[kugel-rb.git] / tools / root.make
blob8d54140a9b432e582ef3790f5f347eef4c85dd55
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 include $(TOOLSDIR)/functions.make
12 DEFINES = -DROCKBOX -DMEMORYSIZE=$(MEMORYSIZE) -DMEM=$(MEMORYSIZE) $(TARGET) \
13 -DTARGET_ID=$(TARGET_ID) -DTARGET_NAME=\"$(MODELNAME)\" \
14 -DAPPSVERSION=\"$(VERSION)\" $(BUILDDATE) \
15 $(EXTRA_DEFINES) # <-- -DSIMULATOR or not
16 INCLUDES = -I$(BUILDDIR) -I$(BUILDDIR)/lang $(TARGET_INC)
18 CFLAGS = $(INCLUDES) $(DEFINES) $(GCCOPTS)
19 PPCFLAGS = $(filter-out -Dmain=SDL_main,$(CFLAGS)) # cygwin sdl-config fix
21 TOOLS = $(TOOLSDIR)/rdf2binary $(TOOLSDIR)/convbdf \
22 $(TOOLSDIR)/codepages $(TOOLSDIR)/scramble $(TOOLSDIR)/bmp2rb \
23 $(TOOLSDIR)/uclpack $(TOOLSDIR)/mkboot
26 ifeq (,$(PREFIX))
27 ifdef SIMVER
28 # for sims, set simdisk/ as default
29 PREFIX = simdisk
30 INSTALL = --install="$(PREFIX)"
31 else
32 # /dev/null as magic to tell it wasn't set, error out later in buildzip.pl
33 INSTALL = --install=/dev/null
34 endif
35 else
36 INSTALL = --install="$(PREFIX)"
37 endif
39 RBINFO = $(BUILDDIR)/rockbox-info.txt
41 # list suffixes to be understood by $*
42 .SUFFIXES: .rock .codec .map .elf .c .S .o .bmp .a
44 .PHONY: all clean tags zip tools manual bin build info langs
46 ifeq (,$(filter clean veryclean reconf tags voice voicetools manual manual-pdf manual-html manual-zhtml manual-txt manual-ztxt manual-zip help fontzip ,$(MAKECMDGOALS)))
47 # none of the above
48 DEPFILE = $(BUILDDIR)/make.dep
50 endif
52 all: $(DEPFILE) build
54 # Subdir makefiles. their primary purpose is to populate SRC, OTHER_SRC &
55 # ASMDEFS_SRC but they also define special dependencies and compile rules
56 include $(TOOLSDIR)/tools.make
58 ifeq (,$(findstring checkwps,$(APPSDIR)))
59 include $(FIRMDIR)/firmware.make
60 include $(ROOTDIR)/apps/bitmaps/bitmaps.make
61 endif
63 ifneq (,$(findstring bootloader,$(APPSDIR)))
64 include $(APPSDIR)/bootloader.make
65 else ifneq (,$(findstring bootbox,$(APPSDIR)))
66 BOOTBOXLDOPTS = -Wl,--gc-sections
67 include $(APPSDIR)/bootbox.make
68 else ifneq (,$(findstring checkwps,$(APPSDIR)))
69 include $(APPSDIR)/checkwps.make
70 else ifneq (,$(findstring database,$(APPSDIR)))
71 include $(APPSDIR)/database.make
72 else
73 include $(APPSDIR)/apps.make
74 include $(APPSDIR)/lang/lang.make
76 ifdef SOFTWARECODECS
77 include $(APPSDIR)/codecs/codecs.make
78 endif
80 ifdef ENABLEDPLUGINS
81 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
82 include $(APPSDIR)/plugins/plugins.make
83 endif
85 ifdef SIMVER
86 include $(ROOTDIR)/uisimulator/uisimulator.make
87 endif
88 endif # bootloader
90 OBJ := $(SRC:.c=.o)
91 OBJ := $(OBJ:.S=.o)
92 OBJ += $(BMP:.bmp=.o)
93 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
95 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
97 $(RBINFO): $(BUILDDIR)/$(BINARY)
98 $(SILENT)echo Creating $(@F)
99 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
101 $(DEPFILE) dep:
102 $(call PRINTS,Generating dependencies)
103 @echo foo > /dev/null # there must be a "real" command in the rule
104 $(call mkdepfile,$(DEPFILE),$(SRC))
105 $(call mkdepfile,$(DEPFILE),$(OTHER_SRC:%.lua=))
106 $(call mkdepfile,$(DEPFILE),$(ASMDEFS_SRC))
107 @mv $(DEPFILE)_ $(DEPFILE)
108 $(call bmpdepfile,$(DEPFILE),$(BMP) $(PBMP))
110 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
111 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
112 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
113 tools: $(TOOLS)
115 -include $(DEPFILE)
117 veryclean: clean
118 $(SILENT)rm -rf $(TOOLS)
120 clean:
121 $(SILENT)echo Cleaning build directory
122 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
123 rockbox.tar.bz2 TAGS apps firmware tools comsim sim lang \
124 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
125 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
126 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
127 *.wav *.mp3 *.voice $(CLEANOBJS) \
128 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
129 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
130 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK)
132 #### linking the binaries: ####
134 .SECONDEXPANSION:
136 ifeq (,$(findstring bootloader,$(APPSDIR)))
137 # not bootloader
139 OBJ += $(LANG_O)
141 ifndef SIMVER
143 ## target build
144 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
145 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
146 LINKRAM := $(BUILDDIR)/ram.link
147 ROMLDS := $(FIRMDIR)/rom.lds
148 LINKROM := $(BUILDDIR)/rom.link
151 $(LINKRAM): $(RAMLDS) $(CONFIGFILE)
152 $(call PRINTS,PP $(@F))
153 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
155 $(LINKROM): $(ROMLDS)
156 $(call PRINTS,PP $(@F))
157 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
159 $(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(LINKRAM)
160 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
161 -L$(BUILDDIR)/firmware -lfirmware \
162 -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
163 -lgcc $(BOOTBOXLDOPTS) \
164 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
166 $(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(LINKROM)
167 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
168 $(VOICESPEEXLIB) $(FIRMLIB) -lgcc -L$(BUILDDIR)/firmware \
169 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
171 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
172 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
174 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
175 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
178 # If there's a flashfile defined for this target (rockbox.ucl for Archos
179 # models) Then check if the mkfirmware script fails, as then it is (likely)
180 # because the image is too big and we need to create a compressed image
181 # instead.
183 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
184 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
185 stat=$$?; \
186 if test -n "$(FLASHFILE)"; then \
187 if test "$$stat" -ne 0; then \
188 echo "Image too big, making a compressed version!"; \
189 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
190 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
191 fi \
192 fi )
194 # archos
195 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
196 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
198 MAXINFILE = $(BUILDDIR)/temp.txt
199 MAXOUTFILE = $(BUILDDIR)/romstart.txt
201 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
202 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
203 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
204 if test $$? -ne 0; then \
205 echo "removing UCL file again, making it a fake one"; \
206 echo "fake" > $@; \
209 $(MAXOUTFILE):
210 $(call PRINTS,Creating $(@F))
211 $(SILENT)$(shell echo '#include "config.h"' > $(MAXINFILE))
212 $(SILENT)$(shell echo "ROM_START" >> $(MAXINFILE))
213 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
214 $(SILENT)rm $(MAXINFILE)
216 # iriver
217 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
218 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
220 endif # !SIMVER
221 endif # !bootloader
224 voicetools:
225 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
227 tags:
228 $(SILENT)rm -f TAGS
229 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
231 fontzip:
232 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
234 zip:
235 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
236 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
238 mapzip:
239 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
241 fullzip:
242 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
243 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
245 7zip:
246 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
247 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.7z" -z "7za a -mx=9" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
249 tar:
250 $(SILENT)rm -f rockbox.tar
251 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
252 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
254 bzip2: tar
255 $(SILENT)bzip2 -f9 rockbox.tar
257 gzip: tar
258 $(SILENT)gzip -f9 rockbox.tar
260 manual manual-pdf:
261 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
262 manual-html:
263 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
264 manual-zhtml: manual-zip
265 manual-txt:
266 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
267 manual-ztxt:
268 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
269 manual-zip:
270 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
272 ifdef TTS_ENGINE
274 voice: voicetools features
275 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
276 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 \
278 endif
280 install:
281 @echo "Installing your build in your '$(PREFIX)' dir"
282 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
283 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
285 fullinstall:
286 @echo "Installing a full setup in your '$(PREFIX)' dir"
287 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
288 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
290 help:
291 @echo "A few helpful make targets"
292 @echo ""
293 @echo "all - builds a full Rockbox (default), including tools"
294 @echo "bin - builds only the Rockbox.<target name> file"
295 @echo "rocks - builds only plugins"
296 @echo "codecs - builds only codecs"
297 @echo "dep - regenerates make dependency database"
298 @echo "clean - cleans a build directory (not tools)"
299 @echo "veryclean - cleans the build and tools directories"
300 @echo "manual - builds a manual (pdf)"
301 @echo "manual-html - HTML manual"
302 @echo "manual-zip - HTML manual (zipped)"
303 @echo "manual-txt - txt manual"
304 @echo "fullzip - creates a rockbox.zip of your build with fonts"
305 @echo "zip - creates a rockbox.zip of your build (no fonts)"
306 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
307 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
308 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
309 @echo "fontzip - creates rockbox-fonts.zip"
310 @echo "mapzip - creates rockbox-maps.zip with all .map files"
311 @echo "tools - builds the tools only"
312 @echo "voice - creates the voice clips (voice builds only)"
313 @echo "voicetools - builds the voice tools only"
314 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
315 @echo "fullinstall - installs your build (like install, but with fonts)"
316 @echo "reconf - rerun configure with the same selection"
318 ### general compile rules:
320 # when source and object are in different locations (normal):
321 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
322 $(SILENT)mkdir -p $(dir $@)
323 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
325 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
326 $(SILENT)mkdir -p $(dir $@)
327 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
329 # generated definitions for use in .S files
330 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
331 $(call PRINTS,ASMDEFS $(@F))
332 $(SILENT)mkdir -p $(dir $@)
333 $(call asmdefs2file,$<,$@)
335 # when source and object are both in BUILDDIR (generated code):
336 %.o: %.c
337 $(SILENT)mkdir -p $(dir $@)
338 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
340 %.o: %.S
341 $(SILENT)mkdir -p $(dir $@)
342 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
344 Makefile: $(TOOLSDIR)/configure
345 ifneq (reconf,$(MAKECMDGOALS))
346 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
347 endif
349 reconf:
350 $(SILENT$)PREFIX=$(PREFIX) $(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)