Revert r25739 which added libwmapro to apps/codecs, in preparation to commit the...
[kugel-rb.git] / tools / root.make
blobf2373f5f7d576741fe6f5f8bc63d50aa905264d9
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 -g -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 $(TOOLSDIR)/iaudio_bl_flash.c \
24 $(TOOLSDIR)/iaudio_bl_flash.h
27 ifeq (,$(PREFIX))
28 ifdef SIMVER
29 # for sims, set simdisk/ as default
30 PREFIX = simdisk
31 INSTALL = --install="$(PREFIX)"
32 else
33 # /dev/null as magic to tell it wasn't set, error out later in buildzip.pl
34 INSTALL = --install=/dev/null
35 endif
36 else
37 INSTALL = --install="$(PREFIX)"
38 endif
40 RBINFO = $(BUILDDIR)/rockbox-info.txt
42 # list suffixes to be understood by $*
43 .SUFFIXES: .rock .codec .map .elf .c .S .o .bmp .a
45 .PHONY: all clean tags zip tools manual bin build info langs
47 ifeq (,$(filter clean veryclean reconf tags voice voicetools manual manual-pdf manual-html manual-zhtml manual-txt manual-ztxt manual-zip help fontzip ,$(MAKECMDGOALS)))
48 # none of the above
49 DEPFILE = $(BUILDDIR)/make.dep
51 endif
53 all: $(DEPFILE) build
55 # Subdir makefiles. their primary purpose is to populate SRC, OTHER_SRC &
56 # ASMDEFS_SRC but they also define special dependencies and compile rules
57 include $(TOOLSDIR)/tools.make
59 ifeq (,$(findstring checkwps,$(APPSDIR)))
60 ifeq (,$(findstring database,$(APPSDIR)))
61 include $(FIRMDIR)/firmware.make
62 include $(ROOTDIR)/apps/bitmaps/bitmaps.make
63 endif
64 endif
66 ifneq (,$(findstring bootloader,$(APPSDIR)))
67 include $(APPSDIR)/bootloader.make
68 else ifneq (,$(findstring bootbox,$(APPSDIR)))
69 BOOTBOXLDOPTS = -Wl,--gc-sections
70 include $(APPSDIR)/bootbox.make
71 else ifneq (,$(findstring checkwps,$(APPSDIR)))
72 include $(APPSDIR)/checkwps.make
73 else ifneq (,$(findstring database,$(APPSDIR)))
74 include $(APPSDIR)/database.make
75 else
76 include $(APPSDIR)/apps.make
77 include $(APPSDIR)/lang/lang.make
79 ifdef SOFTWARECODECS
80 include $(APPSDIR)/codecs/codecs.make
81 endif
83 ifdef ENABLEDPLUGINS
84 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
85 include $(APPSDIR)/plugins/plugins.make
86 endif
88 ifdef SIMVER
89 include $(ROOTDIR)/uisimulator/uisimulator.make
90 endif
91 endif # bootloader
93 OBJ := $(SRC:.c=.o)
94 OBJ := $(OBJ:.S=.o)
95 OBJ += $(BMP:.bmp=.o)
96 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
98 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
100 $(RBINFO): $(BUILDDIR)/$(BINARY)
101 $(SILENT)echo Creating $(@F)
102 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
104 $(DEPFILE) dep:
105 $(call PRINTS,Generating dependencies)
106 @echo foo > /dev/null # there must be a "real" command in the rule
107 $(call mkdepfile,$(DEPFILE),$(SRC))
108 $(call mkdepfile,$(DEPFILE),$(OTHER_SRC:%.lua=))
109 $(call mkdepfile,$(DEPFILE),$(ASMDEFS_SRC))
110 @mv $(DEPFILE)_ $(DEPFILE)
111 $(call bmpdepfile,$(DEPFILE),$(BMP) $(PBMP))
113 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
114 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
115 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
116 tools: $(TOOLS)
118 -include $(DEPFILE)
120 veryclean: clean
121 $(SILENT)rm -rf $(TOOLS)
123 clean:
124 $(SILENT)echo Cleaning build directory
125 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
126 rockbox.tar.bz2 TAGS apps firmware tools comsim sim lang \
127 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
128 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
129 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
130 *.wav *.mp3 *.voice $(CLEANOBJS) \
131 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
132 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
133 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK)
135 #### linking the binaries: ####
137 .SECONDEXPANSION:
139 ifeq (,$(findstring bootloader,$(APPSDIR)))
140 # not bootloader
142 OBJ += $(LANG_O)
144 ifndef SIMVER
146 ## target build
147 CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
148 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
149 LINKRAM := $(BUILDDIR)/ram.link
150 ROMLDS := $(FIRMDIR)/rom.lds
151 LINKROM := $(BUILDDIR)/rom.link
154 $(LINKRAM): $(RAMLDS) $(CONFIGFILE)
155 $(call PRINTS,PP $(@F))
156 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
158 $(LINKROM): $(ROMLDS)
159 $(call PRINTS,PP $(@F))
160 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
162 $(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(LINKRAM)
163 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
164 -L$(BUILDDIR)/firmware -lfirmware \
165 -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
166 -lgcc $(BOOTBOXLDOPTS) \
167 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
169 $(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(LINKROM)
170 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
171 $(VOICESPEEXLIB) $(FIRMLIB) -lgcc -L$(BUILDDIR)/firmware \
172 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
174 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
175 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
177 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
178 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
181 # If there's a flashfile defined for this target (rockbox.ucl for Archos
182 # models) Then check if the mkfirmware script fails, as then it is (likely)
183 # because the image is too big and we need to create a compressed image
184 # instead.
186 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
187 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
188 stat=$$?; \
189 if test -n "$(FLASHFILE)"; then \
190 if test "$$stat" -ne 0; then \
191 echo "Image too big, making a compressed version!"; \
192 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
193 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
194 fi \
195 fi )
197 # archos
198 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
199 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
201 MAXINFILE = $(BUILDDIR)/temp.txt
202 MAXOUTFILE = $(BUILDDIR)/romstart.txt
204 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
205 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
206 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
207 if test $$? -ne 0; then \
208 echo "removing UCL file again, making it a fake one"; \
209 echo "fake" > $@; \
212 $(MAXOUTFILE):
213 $(call PRINTS,Creating $(@F))
214 $(SILENT)$(shell echo '#include "config.h"' > $(MAXINFILE))
215 $(SILENT)$(shell echo "ROM_START" >> $(MAXINFILE))
216 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
217 $(SILENT)rm $(MAXINFILE)
219 # iriver
220 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
221 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
223 endif # !SIMVER
224 endif # !bootloader
227 voicetools:
228 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
230 tags:
231 $(SILENT)rm -f TAGS
232 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
234 fontzip:
235 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
237 zip:
238 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
239 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
241 mapzip:
242 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
244 fullzip:
245 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
246 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
248 7zip:
249 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
250 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.7z" -z "7za a -mx=9" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
252 tar:
253 $(SILENT)rm -f rockbox.tar
254 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
255 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
257 bzip2: tar
258 $(SILENT)bzip2 -f9 rockbox.tar
260 gzip: tar
261 $(SILENT)gzip -f9 rockbox.tar
263 manual manual-pdf:
264 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
265 manual-html:
266 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
267 manual-zhtml: manual-zip
268 manual-txt:
269 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
270 manual-ztxt:
271 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
272 manual-zip:
273 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
275 ifdef TTS_ENGINE
277 voice: voicetools features
278 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
279 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 \
281 endif
283 install:
284 @echo "Installing your build in your '$(PREFIX)' dir"
285 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
286 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
288 fullinstall:
289 @echo "Installing a full setup in your '$(PREFIX)' dir"
290 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
291 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
293 help:
294 @echo "A few helpful make targets"
295 @echo ""
296 @echo "all - builds a full Rockbox (default), including tools"
297 @echo "bin - builds only the Rockbox.<target name> file"
298 @echo "rocks - builds only plugins"
299 @echo "codecs - builds only codecs"
300 @echo "dep - regenerates make dependency database"
301 @echo "clean - cleans a build directory (not tools)"
302 @echo "veryclean - cleans the build and tools directories"
303 @echo "manual - builds a manual (pdf)"
304 @echo "manual-html - HTML manual"
305 @echo "manual-zip - HTML manual (zipped)"
306 @echo "manual-txt - txt manual"
307 @echo "fullzip - creates a rockbox.zip of your build with fonts"
308 @echo "zip - creates a rockbox.zip of your build (no fonts)"
309 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
310 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
311 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
312 @echo "fontzip - creates rockbox-fonts.zip"
313 @echo "mapzip - creates rockbox-maps.zip with all .map files"
314 @echo "tools - builds the tools only"
315 @echo "voice - creates the voice clips (voice builds only)"
316 @echo "voicetools - builds the voice tools only"
317 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
318 @echo "fullinstall - installs your build (like install, but with fonts)"
319 @echo "reconf - rerun configure with the same selection"
321 ### general compile rules:
323 # when source and object are in different locations (normal):
324 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
325 $(SILENT)mkdir -p $(dir $@)
326 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
328 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
329 $(SILENT)mkdir -p $(dir $@)
330 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
332 # generated definitions for use in .S files
333 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
334 $(call PRINTS,ASMDEFS $(@F))
335 $(SILENT)mkdir -p $(dir $@)
336 $(call asmdefs2file,$<,$@)
338 # when source and object are both in BUILDDIR (generated code):
339 %.o: %.c
340 $(SILENT)mkdir -p $(dir $@)
341 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
343 %.o: %.S
344 $(SILENT)mkdir -p $(dir $@)
345 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
347 Makefile: $(TOOLSDIR)/configure
348 ifneq (reconf,$(MAKECMDGOALS))
349 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
350 endif
352 reconf:
353 $(SILENT$)PREFIX=$(PREFIX) $(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)