summaryrefslogtreecommitdiff
path: root/tools/root.make
diff options
context:
space:
mode:
Diffstat (limited to 'tools/root.make')
-rw-r--r--tools/root.make294
1 files changed, 294 insertions, 0 deletions
diff --git a/tools/root.make b/tools/root.make
new file mode 100644
index 0000000000..87937d9cd1
--- /dev/null
+++ b/tools/root.make
@@ -0,0 +1,294 @@
1# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
7# $Id: Makefile 19082 2008-11-10 23:54:24Z zagor $
8#
9
10include $(TOOLSDIR)/functions.make
11
12DEFINES = -DROCKBOX -DMEMORYSIZE=$(MEMORYSIZE) -DMEM=$(MEMORYSIZE) $(TARGET) \
13 -DTARGET_ID=$(TARGET_ID) -DTARGET_NAME=\"$(MODELNAME)\" \
14 -DAPPSVERSION=\"$(VERSION)\" $(BUILDDATE) \
15 $(EXTRA_DEFINES) # <-- -DSIMULATOR or not
16INCLUDES = -I$(BUILDDIR) $(TARGET_INC)
17
18CFLAGS = $(INCLUDES) $(DEFINES) $(GCCOPTS)
19PPCFLAGS = $(filter-out -Dmain=SDL_main,$(CFLAGS)) # cygwin sdl-config fix
20
21TOOLS = $(TOOLSDIR)/rdf2binary $(TOOLSDIR)/convbdf \
22 $(TOOLSDIR)/codepages $(TOOLSDIR)/scramble $(TOOLSDIR)/bmp2rb \
23 $(TOOLSDIR)/uclpack $(TOOLSDIR)/mktccboot $(TOOLSDIR)/mkboot
24
25# list suffixes to be understood by $*
26.SUFFIXES: .rock .codec .map .elf .c .S .o .bmp .a
27
28.PHONY: all clean tags zip tools manual bin build info langs
29
30DEPFILE = $(BUILDDIR)/make.dep
31
32all: $(DEPFILE) build
33
34# Subdir makefiles. their primary purpose is to populate SRC & OTHER_SRC
35# but they also define special dependencies and compile rules
36include $(TOOLSDIR)/tools.make
37include $(FIRMDIR)/firmware.make
38include $(ROOTDIR)/apps/bitmaps/bitmaps.make
39
40ifneq (,$(findstring bootloader,$(APPSDIR)))
41 include $(APPSDIR)/bootloader.make
42else ifneq (,$(findstring bootbox,$(APPSDIR)))
43 include $(APPSDIR)/bootbox.make
44else
45 include $(APPSDIR)/apps.make
46 include $(APPSDIR)/lang/lang.make
47
48 ifdef SOFTWARECODECS
49 include $(APPSDIR)/codecs/codecs.make
50 endif
51
52 ifdef ENABLEDPLUGINS
53 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
54 include $(APPSDIR)/plugins/plugins.make
55 endif
56
57 ifdef SIMVER
58 include $(ROOTDIR)/uisimulator/uisimulator.make
59 endif
60endif # bootloader
61
62OBJ := $(SRC:.c=.o)
63OBJ := $(OBJ:.S=.o)
64OBJ += $(BMP:.bmp=.o)
65OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
66
67build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM)
68 $(SILENT)$(TOOLSDIR)/mkinfo.pl $(BUILDDIR)/rockbox-info.txt
69
70ifneq (clean,$(findstring clean,$(MAKECMDGOALS))) # don't build deps before cleaning
71$(DEPFILE) dep:
72 $(call PRINTS,Generating dependencies)
73 @echo foo > /dev/null # there must be a "real" command in the rule
74 $(call mkdepfile,$(DEPFILE),$(SRC) $(OTHER_SRC))
75 $(call bmpdepfile,$(DEPFILE),$(BMP) $(PBMP))
76endif
77
78bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY)
79rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
80codecs: $(DEPFILE) $(TOOLS) $(CODECS)
81
82-include $(DEPFILE)
83
84veryclean: clean
85 $(SILENT)rm -rf $(TOOLS)
86
87clean:
88 $(SILENT)echo Cleaning build directory
89 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz rockbox.tar.bz2 TAGS apps firmware comsim sim lang.[ch] manual *.pdf *.a credits.raw rockbox.ipod bitmaps pluginbitmaps UI256.bmp rockbox-full.zip html txt rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids *.wav *.mp3 *.voice max_language_size.h $(CLEANOBJS) $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin $(DEPFILE) rombox.elf rombox.map rombox.bin $(BINARY) $(FLASHFILE) uisimulator bootloader flash
90
91#### linking the binaries: ####
92
93.SECONDEXPANSION:
94
95ifndef SIMVER
96
97ifeq (,$(findstring bootloader,$(APPSDIR)))
98# not bootloader
99
100## target build
101RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
102LINKRAM := $(BUILDDIR)/ram.link
103ROMLDS := $(FIRMDIR)/rom.lds
104LINKROM := $(BUILDDIR)/rom.link
105
106$(LINKRAM): $(RAMLDS)
107 $(call PRINTS,PP $(@F))
108 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
109
110$(LINKROM): $(ROMLDS)
111 $(call PRINTS,PP $(@F))
112 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
113
114$(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(LINKRAM)
115 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Wl,--gc-sections -Os -nostdlib -o $@ $(OBJ) \
116 -L$(BUILDDIR)/firmware -lfirmware\
117 -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
118 -lgcc \
119 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
120
121$(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(LINKROM)
122 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
123 $(VOICESPEEXLIB) $(FIRMLIB) -lgcc -L$(BUILDDIR)/firmware \
124 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rockbox.map
125
126$(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
127 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
128
129$(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
130 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
131
132#
133# If there's a flashfile defined for this target (rockbox.ucl for Archos
134# models) Then check if the mkfirmware script fails, as then it is (likely)
135# because the image is too big and we need to create a compressed image
136# instead.
137#
138$(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
139 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
140 stat=$$?; \
141 if test -n "$(FLASHFILE)"; then \
142 if test "$$stat" -ne 0; then \
143 echo "Image too big, making a compressed version!"; \
144 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
145 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
146 fi \
147 fi )
148
149# archos
150$(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
151 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null 2>&1
152
153MAXINFILE = $(BUILDDIR)/temp.txt
154MAXOUTFILE = $(BUILDDIR)/romstart.txt
155
156$(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
157 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
158 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
159 if test $$? -ne 0; then \
160 echo "removing UCL file again, making it a fake one"; \
161 echo "fake" > $@; \
162 fi
163
164$(MAXOUTFILE):
165 $(call PRINTS,Creating $(@F))
166 $(SILENT)$(shell echo '#include "config.h"' > $(MAXINFILE))
167 $(SILENT)$(shell echo "ROM_START" >> $(MAXINFILE))
168 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
169 $(SILENT)rm $(MAXINFILE)
170
171# iriver
172$(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
173 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
174
175endif # !bootloader
176endif # !SIMVER
177
178
179voicetools:
180 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
181
182tags:
183 $(SILENT)rm -f TAGS
184 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
185
186fontzip:
187 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)\" -r "$(ROOTDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
188
189zip:
190 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
191 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" $(TARGET) $(BINARY)
192
193mapzip:
194 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
195
196fullzip:
197 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
198 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
199
2007zip:
201 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
202 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -o "rockbox.7z" -z "7za a -mx=9" -r "$(ROOTDIR)" $(TARGET) $(BINARY)
203
204tar:
205 $(SILENT)rm -f rockbox.tar
206 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
207 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" $(TARGET) $(BINARY)
208
209bzip2: tar
210 $(SILENT)bzip2 -f9 rockbox.tar
211
212gzip: tar
213 $(SILENT)gzip -f9 rockbox.tar
214
215manual manual-pdf:
216 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
217manual-html:
218 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
219manual-zhtml: manual-zip
220manual-txt:
221 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
222manual-ztxt:
223 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
224manual-zip:
225 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
226
227ifdef TTS_ENGINE
228
229voice: voicetools features
230 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
231 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 \
232
233endif
234
235ifdef SIMVER
236
237install:
238 @echo "Installing your build in your archos dir"
239 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
240 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -s -r "$(ROOTDIR)" -f 0 $(TARGET) $(BINARY)
241
242fullinstall:
243 @echo "Installing a full setup in your archos dir"
244 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
245 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -s -r "$(ROOTDIR)" -f 2 $(TARGET) $(BINARY)
246
247endif
248
249help:
250 @echo "A few helpful make targets"
251 @echo ""
252 @echo "all - builds a full Rockbox (default), including tools"
253 @echo "bin - builds only the Rockbox.<target name> file"
254 @echo "rocks - builds only plugins"
255 @echo "codecs - builds only codecs"
256 @echo "dep - regenerates make dependency database"
257 @echo "clean - cleans a build directory (not tools)"
258 @echo "veryclean - cleans the build and tools directories"
259 @echo "manual - builds a manual (pdf)"
260 @echo "manual-html - HTML manual"
261 @echo "manual-zip - HTML manual (zipped)"
262 @echo "manual-txt - txt manual"
263 @echo "fullzip - creates a rockbox.zip of your build with fonts"
264 @echo "zip - creates a rockbox.zip of your build (no fonts)"
265 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
266 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
267 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
268 @echo "fontzip - creates rockbox-fonts.zip"
269 @echo "mapzip - creates rockbox-maps.zip with all .map files"
270 @echo "tools - builds the tools only"
271 @echo "voice - creates the voice clips (voice builds only)"
272 @echo "voicetools - builds the voice tools only"
273 @echo "install - installs your build (for simulator builds only, no fonts)"
274 @echo "fullinstall - installs your build (for simulator builds only, with fonts)"
275
276### general compile rules:
277
278# when source and object are in different locations (normal):
279$(BUILDDIR)/%.o: $(ROOTDIR)/%.c
280 $(SILENT)mkdir -p $(dir $@)
281 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
282
283$(BUILDDIR)/%.o: $(ROOTDIR)/%.S
284 $(SILENT)mkdir -p $(dir $@)
285 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
286
287# when source and object are both in BUILDDIR (generated code):
288%.o: %.c
289 $(SILENT)mkdir -p $(dir $@)
290 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
291
292%.o: %.S
293 $(SILENT)mkdir -p $(dir $@)
294 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@