Revert r22339 as it causes immediate stack overflow on target, at least on coldfire.
[kugel-rb.git] / tools / root.make
blob5ff920c20d80374b9e53982cf4020d0fc9059ba4
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)/mktccboot $(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
57 include $(FIRMDIR)/firmware.make
58 include $(ROOTDIR)/apps/bitmaps/bitmaps.make
60 ifneq (,$(findstring bootloader,$(APPSDIR)))
61 include $(APPSDIR)/bootloader.make
62 else ifneq (,$(findstring bootbox,$(APPSDIR)))
63 BOOTBOXLDOPTS = -Wl,--gc-sections
64 include $(APPSDIR)/bootbox.make
65 else
66 include $(APPSDIR)/apps.make
67 include $(APPSDIR)/lang/lang.make
69 ifdef SOFTWARECODECS
70 include $(APPSDIR)/codecs/codecs.make
71 endif
73 ifdef ENABLEDPLUGINS
74 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
75 include $(APPSDIR)/plugins/plugins.make
76 endif
78 ifdef SIMVER
79 include $(ROOTDIR)/uisimulator/uisimulator.make
80 endif
81 endif # bootloader
83 OBJ := $(SRC:.c=.o)
84 OBJ := $(OBJ:.S=.o)
85 OBJ += $(BMP:.bmp=.o)
86 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
88 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
90 $(RBINFO): $(BUILDDIR)/$(BINARY)
91 $(SILENT)echo Creating $(@F)
92 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
94 $(DEPFILE) dep:
95 $(call PRINTS,Generating dependencies)
96 @echo foo > /dev/null # there must be a "real" command in the rule
97 $(call mkdepfile,$(DEPFILE),$(SRC))
98 $(call mkdepfile,$(DEPFILE),$(OTHER_SRC))
99 $(call mkdepfile,$(DEPFILE),$(ASMDEFS_SRC))
100 @mv $(DEPFILE)_ $(DEPFILE)
101 $(call bmpdepfile,$(DEPFILE),$(BMP) $(PBMP))
103 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
104 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
105 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
106 tools: $(TOOLS)
108 -include $(DEPFILE)
110 veryclean: clean
111 $(SILENT)rm -rf $(TOOLS)
113 clean:
114 $(SILENT)echo Cleaning build directory
115 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
116 rockbox.tar.bz2 TAGS apps firmware comsim sim lang \
117 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
118 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
119 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
120 *.wav *.mp3 *.voice $(CLEANOBJS) \
121 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
122 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
123 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK)
125 #### linking the binaries: ####
127 .SECONDEXPANSION:
129 ifeq (,$(findstring bootloader,$(APPSDIR)))
130 # not bootloader
132 OBJ += $(LANG_O)
134 ifndef SIMVER
136 ## target build
137 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
138 LINKRAM := $(BUILDDIR)/ram.link
139 ROMLDS := $(FIRMDIR)/rom.lds
140 LINKROM := $(BUILDDIR)/rom.link
143 $(LINKRAM): $(RAMLDS)
144 $(call PRINTS,PP $(@F))
145 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
147 $(LINKROM): $(ROMLDS)
148 $(call PRINTS,PP $(@F))
149 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
151 $(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(LINKRAM)
152 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
153 -L$(BUILDDIR)/firmware -lfirmware \
154 -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
155 -lgcc $(BOOTBOXLDOPTS) \
156 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
158 $(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(LINKROM)
159 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
160 $(VOICESPEEXLIB) $(FIRMLIB) -lgcc -L$(BUILDDIR)/firmware \
161 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
163 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
164 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
166 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
167 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
170 # If there's a flashfile defined for this target (rockbox.ucl for Archos
171 # models) Then check if the mkfirmware script fails, as then it is (likely)
172 # because the image is too big and we need to create a compressed image
173 # instead.
175 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
176 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
177 stat=$$?; \
178 if test -n "$(FLASHFILE)"; then \
179 if test "$$stat" -ne 0; then \
180 echo "Image too big, making a compressed version!"; \
181 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
182 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
183 fi \
184 fi )
186 # archos
187 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
188 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
190 MAXINFILE = $(BUILDDIR)/temp.txt
191 MAXOUTFILE = $(BUILDDIR)/romstart.txt
193 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
194 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
195 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
196 if test $$? -ne 0; then \
197 echo "removing UCL file again, making it a fake one"; \
198 echo "fake" > $@; \
201 $(MAXOUTFILE):
202 $(call PRINTS,Creating $(@F))
203 $(SILENT)$(shell echo '#include "config.h"' > $(MAXINFILE))
204 $(SILENT)$(shell echo "ROM_START" >> $(MAXINFILE))
205 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
206 $(SILENT)rm $(MAXINFILE)
208 # iriver
209 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
210 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
212 endif # !SIMVER
213 endif # !bootloader
216 voicetools:
217 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
219 tags:
220 $(SILENT)rm -f TAGS
221 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
223 fontzip:
224 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
226 zip:
227 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
228 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
230 mapzip:
231 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
233 fullzip:
234 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
235 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
237 7zip:
238 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
239 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.7z" -z "7za a -mx=9" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
241 tar:
242 $(SILENT)rm -f rockbox.tar
243 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
244 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
246 bzip2: tar
247 $(SILENT)bzip2 -f9 rockbox.tar
249 gzip: tar
250 $(SILENT)gzip -f9 rockbox.tar
252 manual manual-pdf:
253 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
254 manual-html:
255 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
256 manual-zhtml: manual-zip
257 manual-txt:
258 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
259 manual-ztxt:
260 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
261 manual-zip:
262 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
264 ifdef TTS_ENGINE
266 voice: voicetools features
267 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
268 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 \
270 endif
272 install:
273 @echo "Installing your build in your '$(PREFIX)' dir"
274 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
275 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
277 fullinstall:
278 @echo "Installing a full setup in your '$(PREFIX)' dir"
279 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
280 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
282 help:
283 @echo "A few helpful make targets"
284 @echo ""
285 @echo "all - builds a full Rockbox (default), including tools"
286 @echo "bin - builds only the Rockbox.<target name> file"
287 @echo "rocks - builds only plugins"
288 @echo "codecs - builds only codecs"
289 @echo "dep - regenerates make dependency database"
290 @echo "clean - cleans a build directory (not tools)"
291 @echo "veryclean - cleans the build and tools directories"
292 @echo "manual - builds a manual (pdf)"
293 @echo "manual-html - HTML manual"
294 @echo "manual-zip - HTML manual (zipped)"
295 @echo "manual-txt - txt manual"
296 @echo "fullzip - creates a rockbox.zip of your build with fonts"
297 @echo "zip - creates a rockbox.zip of your build (no fonts)"
298 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
299 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
300 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
301 @echo "fontzip - creates rockbox-fonts.zip"
302 @echo "mapzip - creates rockbox-maps.zip with all .map files"
303 @echo "tools - builds the tools only"
304 @echo "voice - creates the voice clips (voice builds only)"
305 @echo "voicetools - builds the voice tools only"
306 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
307 @echo "fullinstall - installs your build (like install, but with fonts)"
308 @echo "reconf - rerun configure with the same selection"
310 ### general compile rules:
312 # when source and object are in different locations (normal):
313 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
314 $(SILENT)mkdir -p $(dir $@)
315 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
317 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
318 $(SILENT)mkdir -p $(dir $@)
319 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
321 # generated definitions for use in .S files
322 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
323 $(call PRINTS,ASMDEFS $(@F))
324 $(SILENT)mkdir -p $(dir $@)
325 $(call asmdefs2file,$<,$@)
327 # when source and object are both in BUILDDIR (generated code):
328 %.o: %.c
329 $(SILENT)mkdir -p $(dir $@)
330 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
332 %.o: %.S
333 $(SILENT)mkdir -p $(dir $@)
334 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
336 Makefile: $(TOOLSDIR)/configure
337 ifneq (reconf,$(MAKECMDGOALS))
338 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
339 endif
341 reconf:
342 $(SILENT$)PREFIX=$(PREFIX) $(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)