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
)\" $(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
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
58 ifeq (,$(findstring checkwps
,$(APPSDIR
)))
59 ifeq (,$(findstring database
,$(APPSDIR
)))
60 include $(FIRMDIR
)/firmware.make
61 include $(ROOTDIR
)/apps
/bitmaps
/bitmaps.make
65 ifneq (,$(findstring bootloader
,$(APPSDIR
)))
66 include $(APPSDIR
)/bootloader.make
67 else ifneq (,$(findstring bootbox
,$(APPSDIR
)))
68 BOOTBOXLDOPTS
= -Wl
,--gc-sections
69 include $(APPSDIR
)/bootbox.make
70 else ifneq (,$(findstring checkwps
,$(APPSDIR
)))
71 include $(APPSDIR
)/checkwps.make
72 else ifneq (,$(findstring database
,$(APPSDIR
)))
73 include $(APPSDIR
)/database.make
75 include $(APPSDIR
)/apps.make
76 include $(APPSDIR
)/lang
/lang.make
79 include $(APPSDIR
)/codecs
/codecs.make
83 include $(APPSDIR
)/plugins
/bitmaps
/pluginbitmaps.make
84 include $(APPSDIR
)/plugins
/plugins.make
88 include $(ROOTDIR
)/uisimulator
/uisimulator.make
95 OBJ
:= $(subst $(ROOTDIR
),$(BUILDDIR
),$(OBJ
))
97 build
: $(TOOLS
) $(BUILDDIR
)/$(BINARY
) $(CODECS
) $(ROCKS
) $(ARCHOSROM
) $(RBINFO
)
99 $(RBINFO
): $(BUILDDIR
)/$(BINARY
)
100 $(SILENT
)echo Creating
$(@F
)
101 $(SILENT
)$(TOOLSDIR
)/mkinfo.pl
$@
104 $(call PRINTS
,Generating dependencies
)
105 @echo foo
> /dev
/null
# there must be a "real" command in the rule
106 $(call mkdepfile
,$(DEPFILE
),$(SRC
))
107 $(call mkdepfile
,$(DEPFILE
),$(OTHER_SRC
:%.lua
=))
108 $(call mkdepfile
,$(DEPFILE
),$(ASMDEFS_SRC
))
109 @mv
$(DEPFILE
)_
$(DEPFILE
)
110 $(call bmpdepfile
,$(DEPFILE
),$(BMP
) $(PBMP
))
112 bin
: $(DEPFILE
) $(TOOLS
) $(BUILDDIR
)/$(BINARY
) $(RBINFO
)
113 rocks
: $(DEPFILE
) $(TOOLS
) $(ROCKS
)
114 codecs
: $(DEPFILE
) $(TOOLS
) $(CODECS
)
120 $(SILENT
)rm -rf
$(TOOLS
)
123 $(SILENT
)echo Cleaning build directory
124 $(SILENT
)rm -rf rockbox.zip rockbox
.7z rockbox.
tar rockbox.
tar.gz \
125 rockbox.
tar.bz2 TAGS apps firmware tools comsim sim lang \
126 manual
*.pdf
*.a credits.raw rockbox.ipod bitmaps \
127 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
128 rockbox-manual
*.zip sysfont.h rockbox-info.txt voicefontids \
129 *.wav
*.mp3
*.voice
$(CLEANOBJS
) \
130 $(LINKRAM
) $(LINKROM
) rockbox.elf rockbox.map rockbox.bin \
131 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
132 $(BINARY
) $(FLASHFILE
) uisimulator bootloader flash
$(BOOTLINK
)
134 #### linking the binaries: ####
138 ifeq (,$(findstring bootloader
,$(APPSDIR
)))
146 CONFIGFILE
:= $(FIRMDIR
)/export/config
/$(MODELNAME
).h
147 RAMLDS
:= $(FIRMDIR
)/target
/$(CPU
)/$(MANUFACTURER
)/app.lds
148 LINKRAM
:= $(BUILDDIR
)/ram.link
149 ROMLDS
:= $(FIRMDIR
)/rom.lds
150 LINKROM
:= $(BUILDDIR
)/rom.link
153 $(LINKRAM
): $(RAMLDS
) $(CONFIGFILE
)
154 $(call PRINTS
,PP
$(@F
))
155 $(call preprocess2file
,$<,$@
,-DLOADADDRESS
=$(LOADADDRESS
))
157 $(LINKROM
): $(ROMLDS
)
158 $(call PRINTS
,PP
$(@F
))
159 $(call preprocess2file
,$<,$@
,-DLOADADDRESS
=$(LOADADDRESS
))
161 $(BUILDDIR
)/rockbox.elf
: $$(OBJ
) $$(FIRMLIB
) $$(VOICESPEEXLIB
) $$(LINKRAM
)
162 $(call PRINTS
,LD
$(@F
))$(CC
) $(GCCOPTS
) -Os
-nostdlib
-o
$@
$(OBJ
) \
163 -L
$(BUILDDIR
)/firmware
-lfirmware \
164 -L
$(BUILDDIR
)/apps
/codecs
$(VOICESPEEXLIB
:lib
%.a
=-l
%) \
165 -lgcc
$(BOOTBOXLDOPTS
) \
166 -T
$(LINKRAM
) -Wl
,-Map
,$(BUILDDIR
)/rockbox.map
168 $(BUILDDIR
)/rombox.elf
: $$(OBJ
) $$(FIRMLIB
) $$(VOICESPEEXLIB
) $$(LINKROM
)
169 $(call PRINTS
,LD
$(@F
))$(CC
) $(GCCOPTS
) -Os
-nostdlib
-o
$@
$(OBJ
) \
170 $(VOICESPEEXLIB
) $(FIRMLIB
) -lgcc
-L
$(BUILDDIR
)/firmware \
171 -T
$(LINKROM
) -Wl
,-Map
,$(BUILDDIR
)/rombox.map
173 $(BUILDDIR
)/rockbox.bin
: $(BUILDDIR
)/rockbox.elf
174 $(call PRINTS
,OC
$(@F
))$(OC
) $(if
$(filter yes
, $(USE_ELF
)), -S
-x
, -O binary
) $< $@
176 $(BUILDDIR
)/rombox.bin
: $(BUILDDIR
)/rombox.elf
177 $(call PRINTS
,OC
$(@F
))$(OC
) -O binary
$< $@
180 # If there's a flashfile defined for this target (rockbox.ucl for Archos
181 # models) Then check if the mkfirmware script fails, as then it is (likely)
182 # because the image is too big and we need to create a compressed image
185 $(BUILDDIR
)/$(BINARY
) : $(BUILDDIR
)/rockbox.bin
$(FLASHFILE
)
186 $(call PRINTS
,SCRAMBLE
$(notdir $@
))($(MKFIRMWARE
) $< $@
; \
188 if
test -n
"$(FLASHFILE)"; then \
189 if
test "$$stat" -ne
0; then \
190 echo
"Image too big, making a compressed version!"; \
191 $(MAKE
) -C
$(FIRMDIR
)/decompressor OBJDIR
=$(BUILDDIR
)/firmware
/decompressor
; \
192 $(MKFIRMWARE
) $(BUILDDIR
)/firmware
/decompressor
/compressed.bin
$@
; \
197 $(BUILDDIR
)/rockbox.ucl
: $(BUILDDIR
)/rockbox.bin
198 $(call PRINTS
,UCLPACK
$(@F
))$(TOOLSDIR
)/uclpack
--best
--2e
-b1048576
$< $@
>/dev
/null
200 MAXINFILE
= $(BUILDDIR
)/temp.txt
201 MAXOUTFILE
= $(BUILDDIR
)/romstart.txt
203 $(BUILDDIR
)/rombox.ucl
: $(BUILDDIR
)/rombox.bin
$(MAXOUTFILE
)
204 $(call PRINTS
,UCLPACK
$(@F
))$(TOOLSDIR
)/uclpack
--none
$< $@
>/dev
/null
; \
205 perl
$(TOOLSDIR
)/romsizetest.pl
`cat $(MAXOUTFILE)` $<; \
206 if
test $$?
-ne
0; then \
207 echo
"removing UCL file again, making it a fake one"; \
212 $(call PRINTS
,Creating
$(@F
))
213 $(SILENT
)$(shell echo
'#include "config.h"' > $(MAXINFILE
))
214 $(SILENT
)$(shell echo
"ROM_START" >> $(MAXINFILE
))
215 $(call preprocess2file
,$(MAXINFILE
),$(MAXOUTFILE
))
216 $(SILENT
)rm $(MAXINFILE
)
219 $(BUILDDIR
)/rombox.iriver
: $(BUILDDIR
)/rombox.bin
220 $(call PRINTS
,Build ROM file
)$(MKFIRMWARE
) $< $@
227 $(SILENT
)$(MAKE
) -C
$(TOOLSDIR
) CC
=$(HOSTCC
) AR
=$(HOSTAR
) rbspeexenc voicefont wavtrim
231 $(SILENT
)etags
-o
$(BUILDDIR
)/TAGS
$(filter-out %.o
,$(SRC
) $(OTHER_SRC
))
234 $(SILENT
)$(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
1 -o rockbox-fonts.zip
$(TARGET
) $(BINARY
)
237 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
238 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" $(TARGET
) $(BINARY
)
241 $(SILENT
)find .
-name
"*.map" | xargs zip rockbox-maps.zip
244 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
245 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
2 -o rockbox-full.zip
$(TARGET
) $(BINARY
)
248 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
249 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -o
"rockbox.7z" -z
"7za a -mx=9" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" $(TARGET
) $(BINARY
)
252 $(SILENT
)rm -f rockbox.
tar
253 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
254 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -o
"rockbox.tar" -z
"tar -cf" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" $(TARGET
) $(BINARY
)
257 $(SILENT
)bzip2
-f9 rockbox.
tar
260 $(SILENT
)gzip
-f9 rockbox.
tar
263 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-pdf
265 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-html
266 manual-zhtml
: manual-zip
268 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-txt
270 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-txt-zip
272 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-zip
276 voice
: voicetools features
277 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
278 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 \
283 @echo
"Installing your build in your '$(PREFIX)' dir"
284 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
285 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
"$(MODELNAME)" -i
"$(TARGET_ID)" $(INSTALL
) -z
"zip -r0" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
0 $(TARGET
) $(BINARY
)
288 @echo
"Installing a full setup in your '$(PREFIX)' dir"
289 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
290 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
"$(MODELNAME)" -i
"$(TARGET_ID)" $(INSTALL
) -z
"zip -r0" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
2 $(TARGET
) $(BINARY
)
293 @echo
"A few helpful make targets"
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):
339 $(SILENT
)mkdir
-p
$(dir $@
)
340 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
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'."
352 $(SILENT
$)PREFIX
=$(PREFIX
) $(TOOLSDIR
)/configure
$(CONFIGURE_OPTIONS
)