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