2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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
)/mktccboot
$(TOOLSDIR
)/mkboot
28 # for sims, set simdisk/ as default
30 INSTALL
= --install="$(PREFIX)"
32 # /dev/null as magic to tell it wasn't set, error out later in buildzip.pl
33 INSTALL
= --install=/dev
/null
36 INSTALL
= --install="$(PREFIX)"
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
)))
48 DEPFILE
= $(BUILDDIR
)/make.dep
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
57 include $(FIRMDIR
)/firmware.make
58 include $(ROOTDIR
)/apps
/bitmaps
/bitmaps.make
60 ifneq (,$(findstring bootloader
,$(APPSDIR
)))
61 include $(APPSDIR
)/bootloader.make
62 else ifneq (,$(findstring bootbox
,$(APPSDIR
)))
63 BOOTBOXLDOPTS
= -Wl
,--gc-sections
64 include $(APPSDIR
)/bootbox.make
65 else ifneq (,$(findstring checkwps
,$(APPSDIR
)))
66 include $(APPSDIR
)/checkwps.make
68 include $(APPSDIR
)/apps.make
69 include $(APPSDIR
)/lang
/lang.make
72 include $(APPSDIR
)/codecs
/codecs.make
76 include $(APPSDIR
)/plugins
/bitmaps
/pluginbitmaps.make
77 include $(APPSDIR
)/plugins
/plugins.make
81 include $(ROOTDIR
)/uisimulator
/uisimulator.make
88 OBJ
:= $(subst $(ROOTDIR
),$(BUILDDIR
),$(OBJ
))
90 build
: $(TOOLS
) $(BUILDDIR
)/$(BINARY
) $(CODECS
) $(ROCKS
) $(ARCHOSROM
) $(RBINFO
)
92 $(RBINFO
): $(BUILDDIR
)/$(BINARY
)
93 $(SILENT
)echo Creating
$(@F
)
94 $(SILENT
)$(TOOLSDIR
)/mkinfo.pl
$@
97 $(call PRINTS
,Generating dependencies
)
98 @echo foo
> /dev
/null
# there must be a "real" command in the rule
99 $(call mkdepfile
,$(DEPFILE
),$(SRC
))
100 $(call mkdepfile
,$(DEPFILE
),$(OTHER_SRC
))
101 $(call mkdepfile
,$(DEPFILE
),$(ASMDEFS_SRC
))
102 @mv
$(DEPFILE
)_
$(DEPFILE
)
103 $(call bmpdepfile
,$(DEPFILE
),$(BMP
) $(PBMP
))
105 bin
: $(DEPFILE
) $(TOOLS
) $(BUILDDIR
)/$(BINARY
) $(RBINFO
)
106 rocks
: $(DEPFILE
) $(TOOLS
) $(ROCKS
)
107 codecs
: $(DEPFILE
) $(TOOLS
) $(CODECS
)
113 $(SILENT
)rm -rf
$(TOOLS
)
116 $(SILENT
)echo Cleaning build directory
117 $(SILENT
)rm -rf rockbox.zip rockbox
.7z rockbox.
tar rockbox.
tar.gz \
118 rockbox.
tar.bz2 TAGS apps firmware comsim sim lang \
119 manual
*.pdf
*.a credits.raw rockbox.ipod bitmaps \
120 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
121 rockbox-manual
*.zip sysfont.h rockbox-info.txt voicefontids \
122 *.wav
*.mp3
*.voice
$(CLEANOBJS
) \
123 $(LINKRAM
) $(LINKROM
) rockbox.elf rockbox.map rockbox.bin \
124 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
125 $(BINARY
) $(FLASHFILE
) uisimulator bootloader flash
$(BOOTLINK
)
127 #### linking the binaries: ####
131 ifeq (,$(findstring bootloader
,$(APPSDIR
)))
139 RAMLDS
:= $(FIRMDIR
)/target
/$(CPU
)/$(MANUFACTURER
)/app.lds
140 LINKRAM
:= $(BUILDDIR
)/ram.link
141 ROMLDS
:= $(FIRMDIR
)/rom.lds
142 LINKROM
:= $(BUILDDIR
)/rom.link
145 $(LINKRAM
): $(RAMLDS
)
146 $(call PRINTS
,PP
$(@F
))
147 $(call preprocess2file
,$<,$@
,-DLOADADDRESS
=$(LOADADDRESS
))
149 $(LINKROM
): $(ROMLDS
)
150 $(call PRINTS
,PP
$(@F
))
151 $(call preprocess2file
,$<,$@
,-DLOADADDRESS
=$(LOADADDRESS
))
153 $(BUILDDIR
)/rockbox.elf
: $$(OBJ
) $$(FIRMLIB
) $$(VOICESPEEXLIB
) $$(LINKRAM
)
154 $(call PRINTS
,LD
$(@F
))$(CC
) $(GCCOPTS
) -Os
-nostdlib
-o
$@
$(OBJ
) \
155 -L
$(BUILDDIR
)/firmware
-lfirmware \
156 -L
$(BUILDDIR
)/apps
/codecs
$(VOICESPEEXLIB
:lib
%.a
=-l
%) \
157 -lgcc
$(BOOTBOXLDOPTS
) \
158 -T
$(LINKRAM
) -Wl
,-Map
,$(BUILDDIR
)/rockbox.map
160 $(BUILDDIR
)/rombox.elf
: $$(OBJ
) $$(FIRMLIB
) $$(VOICESPEEXLIB
) $$(LINKROM
)
161 $(call PRINTS
,LD
$(@F
))$(CC
) $(GCCOPTS
) -Os
-nostdlib
-o
$@
$(OBJ
) \
162 $(VOICESPEEXLIB
) $(FIRMLIB
) -lgcc
-L
$(BUILDDIR
)/firmware \
163 -T
$(LINKROM
) -Wl
,-Map
,$(BUILDDIR
)/rombox.map
165 $(BUILDDIR
)/rockbox.bin
: $(BUILDDIR
)/rockbox.elf
166 $(call PRINTS
,OC
$(@F
))$(OC
) $(if
$(filter yes
, $(USE_ELF
)), -S
-x
, -O binary
) $< $@
168 $(BUILDDIR
)/rombox.bin
: $(BUILDDIR
)/rombox.elf
169 $(call PRINTS
,OC
$(@F
))$(OC
) -O binary
$< $@
172 # If there's a flashfile defined for this target (rockbox.ucl for Archos
173 # models) Then check if the mkfirmware script fails, as then it is (likely)
174 # because the image is too big and we need to create a compressed image
177 $(BUILDDIR
)/$(BINARY
) : $(BUILDDIR
)/rockbox.bin
$(FLASHFILE
)
178 $(call PRINTS
,SCRAMBLE
$(notdir $@
))($(MKFIRMWARE
) $< $@
; \
180 if
test -n
"$(FLASHFILE)"; then \
181 if
test "$$stat" -ne
0; then \
182 echo
"Image too big, making a compressed version!"; \
183 $(MAKE
) -C
$(FIRMDIR
)/decompressor OBJDIR
=$(BUILDDIR
)/firmware
/decompressor
; \
184 $(MKFIRMWARE
) $(BUILDDIR
)/firmware
/decompressor
/compressed.bin
$@
; \
189 $(BUILDDIR
)/rockbox.ucl
: $(BUILDDIR
)/rockbox.bin
190 $(call PRINTS
,UCLPACK
$(@F
))$(TOOLSDIR
)/uclpack
--best
--2e
-b1048576
$< $@
>/dev
/null
192 MAXINFILE
= $(BUILDDIR
)/temp.txt
193 MAXOUTFILE
= $(BUILDDIR
)/romstart.txt
195 $(BUILDDIR
)/rombox.ucl
: $(BUILDDIR
)/rombox.bin
$(MAXOUTFILE
)
196 $(call PRINTS
,UCLPACK
$(@F
))$(TOOLSDIR
)/uclpack
--none
$< $@
>/dev
/null
; \
197 perl
$(TOOLSDIR
)/romsizetest.pl
`cat $(MAXOUTFILE)` $<; \
198 if
test $$?
-ne
0; then \
199 echo
"removing UCL file again, making it a fake one"; \
204 $(call PRINTS
,Creating
$(@F
))
205 $(SILENT
)$(shell echo
'#include "config.h"' > $(MAXINFILE
))
206 $(SILENT
)$(shell echo
"ROM_START" >> $(MAXINFILE
))
207 $(call preprocess2file
,$(MAXINFILE
),$(MAXOUTFILE
))
208 $(SILENT
)rm $(MAXINFILE
)
211 $(BUILDDIR
)/rombox.iriver
: $(BUILDDIR
)/rombox.bin
212 $(call PRINTS
,Build ROM file
)$(MKFIRMWARE
) $< $@
219 $(SILENT
)$(MAKE
) -C
$(TOOLSDIR
) CC
=$(HOSTCC
) AR
=$(HOSTAR
) rbspeexenc voicefont wavtrim
223 $(SILENT
)etags
-o
$(BUILDDIR
)/TAGS
$(filter-out %.o
,$(SRC
) $(OTHER_SRC
))
226 $(SILENT
)$(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
1 -o rockbox-fonts.zip
$(TARGET
) $(BINARY
)
229 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
230 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" $(TARGET
) $(BINARY
)
233 $(SILENT
)find .
-name
"*.map" | xargs zip rockbox-maps.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)" -f
2 -o rockbox-full.zip
$(TARGET
) $(BINARY
)
240 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
241 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -o
"rockbox.7z" -z
"7za a -mx=9" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" $(TARGET
) $(BINARY
)
244 $(SILENT
)rm -f rockbox.
tar
245 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
246 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -o
"rockbox.tar" -z
"tar -cf" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" $(TARGET
) $(BINARY
)
249 $(SILENT
)bzip2
-f9 rockbox.
tar
252 $(SILENT
)gzip
-f9 rockbox.
tar
255 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-pdf
257 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-html
258 manual-zhtml
: manual-zip
260 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-txt
262 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-txt-zip
264 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-zip
268 voice
: voicetools features
269 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
270 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 \
275 @echo
"Installing your build in your '$(PREFIX)' dir"
276 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
277 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
"$(MODELNAME)" -i
"$(TARGET_ID)" $(INSTALL
) -z
"zip -r0" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
0 $(TARGET
) $(BINARY
)
280 @echo
"Installing a full setup in your '$(PREFIX)' dir"
281 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
282 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
"$(MODELNAME)" -i
"$(TARGET_ID)" $(INSTALL
) -z
"zip -r0" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
2 $(TARGET
) $(BINARY
)
285 @echo
"A few helpful make targets"
287 @echo
"all - builds a full Rockbox (default), including tools"
288 @echo
"bin - builds only the Rockbox.<target name> file"
289 @echo
"rocks - builds only plugins"
290 @echo
"codecs - builds only codecs"
291 @echo
"dep - regenerates make dependency database"
292 @echo
"clean - cleans a build directory (not tools)"
293 @echo
"veryclean - cleans the build and tools directories"
294 @echo
"manual - builds a manual (pdf)"
295 @echo
"manual-html - HTML manual"
296 @echo
"manual-zip - HTML manual (zipped)"
297 @echo
"manual-txt - txt manual"
298 @echo
"fullzip - creates a rockbox.zip of your build with fonts"
299 @echo
"zip - creates a rockbox.zip of your build (no fonts)"
300 @echo
"gzip - creates a rockbox.tar.gz of your build (no fonts)"
301 @echo
"bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
302 @echo
"7zip - creates a rockbox.7z of your build (no fonts)"
303 @echo
"fontzip - creates rockbox-fonts.zip"
304 @echo
"mapzip - creates rockbox-maps.zip with all .map files"
305 @echo
"tools - builds the tools only"
306 @echo
"voice - creates the voice clips (voice builds only)"
307 @echo
"voicetools - builds the voice tools only"
308 @echo
"install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
309 @echo
"fullinstall - installs your build (like install, but with fonts)"
310 @echo
"reconf - rerun configure with the same selection"
312 ### general compile rules:
314 # when source and object are in different locations (normal):
315 $(BUILDDIR
)/%.o
: $(ROOTDIR
)/%.c
316 $(SILENT
)mkdir
-p
$(dir $@
)
317 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
319 $(BUILDDIR
)/%.o
: $(ROOTDIR
)/%.S
320 $(SILENT
)mkdir
-p
$(dir $@
)
321 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
323 # generated definitions for use in .S files
324 $(BUILDDIR
)/%_asmdefs.h
: $(ROOTDIR
)/%_asmdefs.c
325 $(call PRINTS
,ASMDEFS
$(@F
))
326 $(SILENT
)mkdir
-p
$(dir $@
)
327 $(call asmdefs2file
,$<,$@
)
329 # when source and object are both in BUILDDIR (generated code):
331 $(SILENT
)mkdir
-p
$(dir $@
)
332 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
335 $(SILENT
)mkdir
-p
$(dir $@
)
336 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
338 Makefile
: $(TOOLSDIR
)/configure
339 ifneq (reconf
,$(MAKECMDGOALS
))
340 $(SILENT
)echo
"*** tools/configure is newer than Makefile. You should run 'make reconf'."
344 $(SILENT
$)PREFIX
=$(PREFIX
) $(TOOLSDIR
)/configure
$(CONFIGURE_OPTIONS
)