That was a bit too far upwards :(
[kugel-rb.git] / tools / root.make
blob401599aeb5e2876442e486538286e817ead56595
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)\" $(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
20 TOOLS = $(TOOLSDIR)/rdf2binary $(TOOLSDIR)/convbdf \
21 $(TOOLSDIR)/codepages $(TOOLSDIR)/scramble $(TOOLSDIR)/bmp2rb \
22 $(TOOLSDIR)/uclpack $(TOOLSDIR)/mkboot $(TOOLSDIR)/iaudio_bl_flash.c \
23 $(TOOLSDIR)/iaudio_bl_flash.h
26 ifeq (,$(PREFIX))
27 ifdef APP_TYPE
28 # for sims, set simdisk/ as default
29 ifeq ($(APP_TYPE),sdl-sim)
30 RBPREFIX = simdisk
31 else ifeq ($(APP_TYPE),sdl-app)
32 RBPREFIX = /usr/local
33 endif
35 INSTALL = --install="$(RBPREFIX)"
36 else
37 # /dev/null as magic to tell it wasn't set, error out later in buildzip.pl
38 INSTALL = --install=/dev/null
39 endif
40 else
41 RBPREFIX = $(PREFIX)
42 INSTALL = --install="$(RBPREFIX)"
43 endif
45 RBINFO = $(BUILDDIR)/rockbox-info.txt
47 # list suffixes to be understood by $*
48 .SUFFIXES: .rock .codec .map .elf .c .S .o .bmp .a
50 .PHONY: all clean tags zip tools manual bin build info langs
52 ifeq (,$(filter clean veryclean reconf tags voice voicetools manual manual-pdf manual-html manual-zhtml manual-txt manual-ztxt manual-zip help fontzip ,$(MAKECMDGOALS)))
53 # none of the above
54 DEPFILE = $(BUILDDIR)/make.dep
56 endif
58 all: $(DEPFILE) build
60 # Subdir makefiles. their primary purpose is to populate SRC, OTHER_SRC &
61 # ASMDEFS_SRC but they also define special dependencies and compile rules
62 include $(TOOLSDIR)/tools.make
64 ifeq (,$(findstring checkwps,$(APPSDIR)))
65 ifeq (,$(findstring database,$(APPSDIR)))
66 include $(FIRMDIR)/firmware.make
67 include $(ROOTDIR)/lib/skin_parser/skin_parser.make
68 include $(ROOTDIR)/apps/bitmaps/bitmaps.make
69 endif
70 endif
72 #included before codecs.make and plugins.make so they see $(LIBSETJMP)
73 ifndef APP_TYPE
74 include $(ROOTDIR)/lib/libsetjmp/libsetjmp.make
75 endif
77 ifneq (,$(findstring bootloader,$(APPSDIR)))
78 include $(APPSDIR)/bootloader.make
79 else ifneq (,$(findstring bootbox,$(APPSDIR)))
80 BOOTBOXLDOPTS = -Wl,--gc-sections
81 include $(APPSDIR)/bootbox.make
82 else ifneq (,$(findstring checkwps,$(APPSDIR)))
83 include $(APPSDIR)/checkwps.make
84 include $(ROOTDIR)/lib/skin_parser/skin_parser.make
85 else ifneq (,$(findstring database,$(APPSDIR)))
86 include $(APPSDIR)/database.make
87 else
88 include $(APPSDIR)/apps.make
89 include $(APPSDIR)/lang/lang.make
91 ifdef SOFTWARECODECS
92 include $(APPSDIR)/codecs/codecs.make
93 endif
95 ifdef ENABLEDPLUGINS
96 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
97 include $(APPSDIR)/plugins/plugins.make
98 endif
100 ifneq (,$(findstring sdl,$(APP_TYPE)))
101 include $(ROOTDIR)/uisimulator/uisimulator.make
102 endif
104 ifneq (,$(findstring android, $(APP_TYPE)))
105 include $(ROOTDIR)/android/android.make
106 endif
108 endif # bootloader
110 OBJ := $(SRC:.c=.o)
111 OBJ := $(OBJ:.S=.o)
112 OBJ += $(BMP:.bmp=.o)
113 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
115 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
117 $(RBINFO): $(BUILDDIR)/$(BINARY)
118 $(SILENT)echo Creating $(@F)
119 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
121 $(DEPFILE) dep:
122 $(call PRINTS,Generating dependencies)
123 $(call mkdepfile,$(DEPFILE)_,$(SRC))
124 $(call mkdepfile,$(DEPFILE)_,$(OTHER_SRC:%.lua=))
125 $(call mkdepfile,$(DEPFILE)_,$(ASMDEFS_SRC))
126 $(call bmpdepfile,$(DEPFILE)_,$(BMP) $(PBMP))
127 @mv $(DEPFILE)_ $(DEPFILE)
129 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
130 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
131 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
132 tools: $(TOOLS)
134 -include $(DEPFILE)
136 veryclean: clean
137 $(SILENT)rm -rf $(TOOLS)
139 clean::
140 $(SILENT)echo Cleaning build directory
141 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
142 rockbox.tar.bz2 TAGS apps firmware tools comsim sim lang lib \
143 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
144 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
145 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
146 *.wav *.mp3 *.voice $(CLEANOBJS) \
147 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
148 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
149 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK)
151 #### linking the binaries: ####
153 .SECONDEXPANSION:
155 ifeq (,$(findstring bootloader,$(APPSDIR)))
156 # not bootloader
158 OBJ += $(LANG_O)
160 ifndef APP_TYPE
162 ## target build
163 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
164 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
165 LINKRAM := $(BUILDDIR)/ram.link
166 ROMLDS := $(FIRMDIR)/rom.lds
167 LINKROM := $(BUILDDIR)/rom.link
170 $(LINKRAM): $(RAMLDS) $(CONFIGFILE)
171 $(call PRINTS,PP $(@F))
172 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
174 $(LINKROM): $(ROMLDS)
175 $(call PRINTS,PP $(@F))
176 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
178 $(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LINKRAM)
179 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
180 -L$(BUILDDIR)/firmware -lfirmware \
181 -L$(BUILDDIR)/lib -lskin_parser \
182 -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
183 -lgcc $(BOOTBOXLDOPTS) $(GLOBAL_LDOPTS) \
184 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
186 $(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LINKROM)
187 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
188 $(VOICESPEEXLIB) $(FIRMLIB) -lgcc $(GLOBAL_LDOPTS) \
189 -L$(BUILDDIR)/lib -lskin_parser \
190 -L$(BUILDDIR)/firmware -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
192 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
193 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
195 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
196 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
199 # If there's a flashfile defined for this target (rockbox.ucl for Archos
200 # models) Then check if the mkfirmware script fails, as then it is (likely)
201 # because the image is too big and we need to create a compressed image
202 # instead.
204 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
205 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
206 stat=$$?; \
207 if test -n "$(FLASHFILE)"; then \
208 if test "$$stat" -ne 0; then \
209 echo "Image too big, making a compressed version!"; \
210 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
211 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
212 fi \
213 fi )
215 # archos
216 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
217 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
219 MAXINFILE = $(BUILDDIR)/temp.txt
220 MAXOUTFILE = $(BUILDDIR)/romstart.txt
222 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
223 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
224 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
225 if test $$? -ne 0; then \
226 echo "removing UCL file again, making it a fake one"; \
227 echo "fake" > $@; \
230 $(MAXOUTFILE):
231 $(call PRINTS,Creating $(@F))
232 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
233 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
234 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
235 $(SILENT)rm $(MAXINFILE)
237 # iriver
238 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
239 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
241 endif # !APP_TYPE
242 endif # !bootloader
245 voicetools:
246 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
248 tags:
249 $(SILENT)rm -f TAGS
250 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
252 fontzip:
253 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
255 zip:
256 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
258 mapzip:
259 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
261 fullzip:
262 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
264 7zip:
265 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.7z" -z "7za a -mx=9" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
267 tar:
268 $(SILENT)rm -f rockbox.tar
269 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
271 bzip2: tar
272 $(SILENT)bzip2 -f9 rockbox.tar
274 gzip: tar
275 $(SILENT)gzip -f9 rockbox.tar
277 manual manual-pdf:
278 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
279 manual-html:
280 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
281 manual-zhtml: manual-zip
282 manual-txt:
283 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
284 manual-ztxt:
285 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
286 manual-zip:
287 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
289 ifdef TTS_ENGINE
291 voice: voicetools $(BUILDDIR)/apps/features
292 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
293 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 \
295 endif
297 bininstall: $(BUILDDIR)/$(BINARY)
298 @echo "Installing your rockbox binary in your '$(RBPREFIX)' dir"
299 $(SILENT)cp $(BINARY) "$(RBPREFIX)/.rockbox/"
301 install:
302 @echo "Installing your build in your '$(RBPREFIX)' dir"
303 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
305 fullinstall:
306 @echo "Installing a full setup in your '$(RBPREFIX)' dir"
307 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
309 help:
310 @echo "A few helpful make targets"
311 @echo ""
312 @echo "all - builds a full Rockbox (default), including tools"
313 @echo "bin - builds only the Rockbox.<target name> file"
314 @echo "rocks - builds only plugins"
315 @echo "codecs - builds only codecs"
316 @echo "dep - regenerates make dependency database"
317 @echo "clean - cleans a build directory (not tools)"
318 @echo "veryclean - cleans the build and tools directories"
319 @echo "manual - builds a manual (pdf)"
320 @echo "manual-html - HTML manual"
321 @echo "manual-zip - HTML manual (zipped)"
322 @echo "manual-txt - txt manual"
323 @echo "fullzip - creates a rockbox.zip of your build with fonts"
324 @echo "zip - creates a rockbox.zip of your build (no fonts)"
325 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
326 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
327 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
328 @echo "fontzip - creates rockbox-fonts.zip"
329 @echo "mapzip - creates rockbox-maps.zip with all .map files"
330 @echo "tools - builds the tools only"
331 @echo "voice - creates the voice clips (voice builds only)"
332 @echo "voicetools - builds the voice tools only"
333 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
334 @echo "fullinstall - installs your build (like install, but with fonts)"
335 @echo "reconf - rerun configure with the same selection"
337 ### general compile rules:
339 # when source and object are in different locations (normal):
340 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
341 $(SILENT)mkdir -p $(dir $@)
342 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
344 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
345 $(SILENT)mkdir -p $(dir $@)
346 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
348 # generated definitions for use in .S files
349 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
350 $(call PRINTS,ASMDEFS $(@F))
351 $(SILENT)mkdir -p $(dir $@)
352 $(call asmdefs2file,$<,$@)
354 # when source and object are both in BUILDDIR (generated code):
355 %.o: %.c
356 $(SILENT)mkdir -p $(dir $@)
357 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
359 %.o: %.S
360 $(SILENT)mkdir -p $(dir $@)
361 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
363 Makefile: $(TOOLSDIR)/configure
364 ifneq (reconf,$(MAKECMDGOALS))
365 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
366 endif
368 reconf:
369 $(SILENT$)$(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)