Moved libskin_parser to lib. Added it to link line.
[kugel-rb.git] / tools / root.make
blob686b8774918442d2e7dd96ecbead19a404647213
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 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 ifeq (,$(findstring database,$(APPSDIR)))
60 include $(FIRMDIR)/firmware.make
61 include $(ROOTDIR)/lib/skin_parser/skin_parser.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 lib \
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) $$(SKINLIB) $$(LINKRAM)
163 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
164 -L$(BUILDDIR)/firmware -lfirmware \
165 -L$(BUILDDIR)/lib -lskin_parser \
166 -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
167 -lgcc $(BOOTBOXLDOPTS) \
168 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
170 $(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB) $$(LINKROM)
171 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
172 $(VOICESPEEXLIB) $(FIRMLIB) -lgcc -L$(BUILDDIR)/firmware \
173 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
175 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
176 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
178 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
179 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
182 # If there's a flashfile defined for this target (rockbox.ucl for Archos
183 # models) Then check if the mkfirmware script fails, as then it is (likely)
184 # because the image is too big and we need to create a compressed image
185 # instead.
187 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
188 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
189 stat=$$?; \
190 if test -n "$(FLASHFILE)"; then \
191 if test "$$stat" -ne 0; then \
192 echo "Image too big, making a compressed version!"; \
193 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
194 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
195 fi \
196 fi )
198 # archos
199 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
200 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
202 MAXINFILE = $(BUILDDIR)/temp.txt
203 MAXOUTFILE = $(BUILDDIR)/romstart.txt
205 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
206 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
207 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
208 if test $$? -ne 0; then \
209 echo "removing UCL file again, making it a fake one"; \
210 echo "fake" > $@; \
213 $(MAXOUTFILE):
214 $(call PRINTS,Creating $(@F))
215 $(SILENT)$(shell echo '#include "config.h"' > $(MAXINFILE))
216 $(SILENT)$(shell echo "ROM_START" >> $(MAXINFILE))
217 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
218 $(SILENT)rm $(MAXINFILE)
220 # iriver
221 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
222 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
224 endif # !SIMVER
225 endif # !bootloader
228 voicetools:
229 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
231 tags:
232 $(SILENT)rm -f TAGS
233 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
235 fontzip:
236 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
238 zip:
239 $(SILENT)$(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)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
247 7zip:
248 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.7z" -z "7za a -mx=9" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
250 tar:
251 $(SILENT)rm -f rockbox.tar
252 $(SILENT)$(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 bininstall: $(BUILDDIR)/$(BINARY)
281 @echo "Installing your rockbox binary in your '$(PREFIX)' dir"
282 $(SILENT)cp $(BINARY) "$(PREFIX)/.rockbox/"
284 install:
285 @echo "Installing your build in your '$(PREFIX)' dir"
286 $(SILENT)$(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)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
292 help:
293 @echo "A few helpful make targets"
294 @echo ""
295 @echo "all - builds a full Rockbox (default), including tools"
296 @echo "bin - builds only the Rockbox.<target name> file"
297 @echo "rocks - builds only plugins"
298 @echo "codecs - builds only codecs"
299 @echo "dep - regenerates make dependency database"
300 @echo "clean - cleans a build directory (not tools)"
301 @echo "veryclean - cleans the build and tools directories"
302 @echo "manual - builds a manual (pdf)"
303 @echo "manual-html - HTML manual"
304 @echo "manual-zip - HTML manual (zipped)"
305 @echo "manual-txt - txt manual"
306 @echo "fullzip - creates a rockbox.zip of your build with fonts"
307 @echo "zip - creates a rockbox.zip of your build (no fonts)"
308 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
309 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
310 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
311 @echo "fontzip - creates rockbox-fonts.zip"
312 @echo "mapzip - creates rockbox-maps.zip with all .map files"
313 @echo "tools - builds the tools only"
314 @echo "voice - creates the voice clips (voice builds only)"
315 @echo "voicetools - builds the voice tools only"
316 @echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
317 @echo "fullinstall - installs your build (like install, but with fonts)"
318 @echo "reconf - rerun configure with the same selection"
320 ### general compile rules:
322 # when source and object are in different locations (normal):
323 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
324 $(SILENT)mkdir -p $(dir $@)
325 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
327 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
328 $(SILENT)mkdir -p $(dir $@)
329 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
331 # generated definitions for use in .S files
332 $(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
333 $(call PRINTS,ASMDEFS $(@F))
334 $(SILENT)mkdir -p $(dir $@)
335 $(call asmdefs2file,$<,$@)
337 # when source and object are both in BUILDDIR (generated code):
338 %.o: %.c
339 $(SILENT)mkdir -p $(dir $@)
340 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
342 %.o: %.S
343 $(SILENT)mkdir -p $(dir $@)
344 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
346 Makefile: $(TOOLSDIR)/configure
347 ifneq (reconf,$(MAKECMDGOALS))
348 $(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
349 endif
351 reconf:
352 $(SILENT$)PREFIX=$(PREFIX) $(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)