imx233: correctly stop charging on topoff (fix battery discharging)
[maemo-rb.git] / tools / root.make
blob74279064bfe65d628c81f92b71e9adc7ddfb6a7b
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 them)
74 ifndef APP_TYPE
75 include $(ROOTDIR)/lib/libsetjmp/libsetjmp.make
76 ifeq (arm,$(ARCH))
77 include $(ROOTDIR)/lib/arm_support/arm_support.make
78 endif
79 endif
81 ifeq (arm,$(ARCH))
82 include $(ROOTDIR)/lib/unwarminder/unwarminder.make
83 endif
85 ifneq (,$(findstring bootloader,$(APPSDIR)))
86 include $(APPSDIR)/bootloader.make
87 else ifneq (,$(findstring bootbox,$(APPSDIR)))
88 BOOTBOXLDOPTS = -Wl,--gc-sections
89 include $(APPSDIR)/bootbox.make
90 else ifneq (,$(findstring checkwps,$(APPSDIR)))
91 include $(APPSDIR)/checkwps.make
92 include $(ROOTDIR)/lib/skin_parser/skin_parser.make
93 else ifneq (,$(findstring database,$(APPSDIR)))
94 include $(APPSDIR)/database.make
95 else
96 include $(APPSDIR)/apps.make
97 include $(APPSDIR)/lang/lang.make
99 ifdef SOFTWARECODECS
100 include $(APPSDIR)/codecs/codecs.make
101 endif
103 ifdef ENABLEDPLUGINS
104 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
105 include $(APPSDIR)/plugins/plugins.make
106 endif
108 ifneq (,$(findstring sdl,$(APP_TYPE)))
109 include $(ROOTDIR)/uisimulator/uisimulator.make
110 endif
112 ifneq (,$(findstring ypr0,$(APP_TYPE)))
113 include $(ROOTDIR)/firmware/target/hosted/ypr0/ypr0.make
114 endif
116 ifneq (,$(findstring android, $(APP_TYPE)))
117 include $(ROOTDIR)/android/android.make
118 endif
120 ifneq (,$(findstring pandora, $(MODELNAME)))
121 include $(ROOTDIR)/packaging/pandora/pandora.make
122 endif
124 endif # bootloader
126 OBJ := $(SRC:.c=.o)
127 OBJ := $(OBJ:.S=.o)
128 OBJ += $(BMP:.bmp=.o)
129 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
131 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
133 $(RBINFO): $(BUILDDIR)/$(BINARY)
134 $(SILENT)echo Creating $(@F)
135 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
137 $(DEPFILE) dep:
138 $(call PRINTS,Generating dependencies)
139 $(call mkdepfile,$(DEPFILE)_,$(SRC))
140 $(call mkdepfile,$(DEPFILE)_,$(OTHER_SRC:%.lua=))
141 $(call mkdepfile,$(DEPFILE)_,$(ASMDEFS_SRC))
142 $(call bmpdepfile,$(DEPFILE)_,$(BMP) $(PBMP))
143 @mv $(DEPFILE)_ $(DEPFILE)
145 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
146 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
147 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
148 tools: $(TOOLS)
150 -include $(DEPFILE)
152 veryclean: clean
153 $(SILENT)rm -rf $(TOOLS)
155 clean::
156 $(SILENT)echo Cleaning build directory
157 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
158 rockbox.tar.bz2 TAGS apps firmware tools comsim sim lang lib \
159 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
160 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
161 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
162 *.wav *.mp3 *.voice $(CLEANOBJS) \
163 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
164 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
165 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK) \
166 rockbox.apk
168 #### linking the binaries: ####
170 .SECONDEXPANSION:
172 ifeq (,$(findstring bootloader,$(APPSDIR)))
173 # not bootloader
175 OBJ += $(LANG_O)
177 ifeq (arm,$(ARCH))
178 UNWARMINDER_LINK := -lunwarminder
179 else
180 UNWARMINDER_LINK :=
181 endif
183 ifndef APP_TYPE
185 ## target build
186 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
187 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
188 LINKRAM := $(BUILDDIR)/ram.link
189 ROMLDS := $(FIRMDIR)/rom.lds
190 LINKROM := $(BUILDDIR)/rom.link
192 ifeq (arm,$(ARCH))
193 LIBARMSUPPORT_LINK := -larm_support
194 else
195 LIBARMSUPPORT_LINK :=
196 endif
198 $(LINKRAM): $(RAMLDS) $(CONFIGFILE)
199 $(call PRINTS,PP $(@F))
200 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
202 $(LINKROM): $(ROMLDS)
203 $(call PRINTS,PP $(@F))
204 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
206 $(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LIBARMSUPPORT) $$(UNWARMINDER) $$(LINKRAM)
207 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
208 -L$(BUILDDIR)/firmware -lfirmware \
209 -L$(BUILDDIR)/lib -lskin_parser $(LIBARMSUPPORT_LINK) \
210 $(UNWARMINDER_LINK) -L$(BUILDDIR)/apps/codecs \
211 $(VOICESPEEXLIB:lib%.a=-l%) -lgcc $(BOOTBOXLDOPTS) \
212 $(GLOBAL_LDOPTS) -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
214 $(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LIBARMSUPPORT) $$(UNWARMINDER) $$(LINKROM)
215 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
216 -L$(BUILDDIR)/firmware -lfirmware \
217 -L$(BUILDDIR)/lib -lskin_parser $(LIBARMSUPPORT_LINK) \
218 $(UNWARMINDER_LINK) -L$(BUILDDIR)/apps/codecs \
219 $(VOICESPEEXLIB:lib%.a=-l%) -lgcc $(GLOBAL_LDOPTS) \
220 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
222 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
223 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
225 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
226 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
229 # If there's a flashfile defined for this target (rockbox.ucl for Archos
230 # models) Then check if the mkfirmware script fails, as then it is (likely)
231 # because the image is too big and we need to create a compressed image
232 # instead.
234 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
235 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
236 stat=$$?; \
237 if test -n "$(FLASHFILE)"; then \
238 if test "$$stat" -ne 0; then \
239 echo "Image too big, making a compressed version!"; \
240 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
241 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
242 fi \
243 fi )
245 # archos
246 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
247 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
249 MAXINFILE = $(BUILDDIR)/temp.txt
250 MAXOUTFILE = $(BUILDDIR)/romstart.txt
252 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
253 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
254 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
255 if test $$? -ne 0; then \
256 echo "removing UCL file again, making it a fake one"; \
257 echo "fake" > $@; \
260 $(MAXOUTFILE):
261 $(call PRINTS,Creating $(@F))
262 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
263 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
264 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
265 $(SILENT)rm $(MAXINFILE)
267 # iriver
268 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
269 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
271 endif # !APP_TYPE
272 endif # !bootloader
275 voicetools:
276 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
278 tags:
279 $(SILENT)rm -f TAGS
280 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
282 fontzip:
283 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
285 zip: $(BUILDDIR)/rockbox.zip
287 ifdef NODEPS
288 $(BUILDDIR)/rockbox.zip:
289 else
290 $(BUILDDIR)/rockbox.zip: build
291 endif
292 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
294 mapzip:
295 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
297 elfzip:
298 $(SILENT)find . -name "*.elf" | xargs zip rockbox-elfs.zip
300 fullzip:
301 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
303 7zip:
304 $(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)
306 tar:
307 $(SILENT)rm -f rockbox.tar
308 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
310 bzip2: tar
311 $(SILENT)bzip2 -f9 rockbox.tar
313 gzip: tar
314 $(SILENT)gzip -f9 rockbox.tar
316 manual manual-pdf:
317 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
318 manual-html:
319 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
320 manual-zhtml: manual-zip
321 manual-txt:
322 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
323 manual-ztxt:
324 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
325 manual-zip:
326 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
328 ifdef TTS_ENGINE
330 voice: voicetools $(BUILDDIR)/apps/features
331 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
332 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 \
334 endif
336 ifeq (,$(findstring android, $(APP_TYPE)))
337 bininstall: $(BUILDDIR)/$(BINARY)
338 @echo "Installing your rockbox binary in your '$(RBPREFIX)' dir"
339 $(SILENT)cp $(BINARY) "$(RBPREFIX)/.rockbox/"
341 install:
342 @echo "Installing your build in your '$(RBPREFIX)' dir"
343 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
345 fullinstall:
346 @echo "Installing a full setup in your '$(RBPREFIX)' dir"
347 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) --app=$(APPLICATION) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
349 symlinkinstall:
350 @echo "Installing a full setup with links in your '$(RBPREFIX)' dir"
351 $(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
352 endif
354 help:
355 @echo "A few helpful make targets"
356 @echo ""
357 @echo "all - builds a full Rockbox (default), including tools"
358 @echo "bin - builds only the Rockbox.<target name> file"
359 @echo "rocks - builds only plugins"
360 @echo "codecs - builds only codecs"
361 @echo "dep - regenerates make dependency database"
362 @echo "clean - cleans a build directory (not tools)"
363 @echo "veryclean - cleans the build and tools directories"
364 @echo "manual - builds a manual (pdf)"
365 @echo "manual-html - HTML manual"
366 @echo "manual-zip - HTML manual (zipped)"
367 @echo "manual-txt - txt manual"
368 @echo "fullzip - creates a rockbox.zip of your build with fonts"
369 @echo "zip - creates a rockbox.zip of your build (no fonts)"
370 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
371 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
372 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
373 @echo "fontzip - creates rockbox-fonts.zip"
374 @echo "mapzip - creates rockbox-maps.zip with all .map files"
375 @echo "elfzip - creates rockbox-elfs.zip with all .elf files"
376 @echo "pnd - creates rockbox.pnd archive (Pandora builds only)"
377 @echo "tools - builds the tools only"
378 @echo "voice - creates the voice clips (voice builds only)"
379 @echo "voicetools - builds the voice tools only"
380 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
381 @echo "fullinstall - installs your build (like install, but with fonts)"
382 @echo "symlinkinstall - like fullinstall, but with links instead of copying files. (Good for developing on simulator)"
383 @echo "reconf - rerun configure with the same selection"
385 ### general compile rules:
387 # when source and object are in different locations (normal):
388 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
389 $(SILENT)mkdir -p $(dir $@)
390 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
392 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
393 $(SILENT)mkdir -p $(dir $@)
394 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
396 # generated definitions for use in .S files
397 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
398 $(call PRINTS,ASMDEFS $(@F))
399 $(SILENT)mkdir -p $(dir $@)
400 $(call asmdefs2file,$<,$@)
402 # when source and object are both in BUILDDIR (generated code):
403 %.o: %.c
404 $(SILENT)mkdir -p $(dir $@)
405 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
407 %.o: %.S
408 $(SILENT)mkdir -p $(dir $@)
409 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) $(ASMFLAGS) -c $< -o $@
411 Makefile: $(TOOLSDIR)/configure
412 ifneq (reconf,$(MAKECMDGOALS))
413 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
414 endif
416 reconf:
417 $(SILENT$)$(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)