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
29 ifeq ($(APP_TYPE
),sdl-sim
)
31 else ifeq ($(APP_TYPE
),sdl-app
)
35 INSTALL
= --install="$(RBPREFIX)"
37 # /dev/null as magic to tell it wasn't set, error out later in buildzip.pl
38 INSTALL
= --install=/dev
/null
42 INSTALL
= --install="$(RBPREFIX)"
45 RBINFO
= $(BUILDDIR
)/rockbox-info.txt
47 # list suffixes to be understood by $*
48 .SUFFIXES
: .rock .codec .map .elf .c .S .o .bmp .a
50 .PHONY
: all clean tags zip tools manual bin build
info langs
52 ifeq (,$(filter clean veryclean reconf
tags voice voicetools manual manual-pdf manual-html manual-zhtml manual-txt manual-ztxt manual-zip help fontzip
,$(MAKECMDGOALS
)))
54 DEPFILE
= $(BUILDDIR
)/make.dep
60 # Subdir makefiles. their primary purpose is to populate SRC, OTHER_SRC &
61 # ASMDEFS_SRC but they also define special dependencies and compile rules
62 include $(TOOLSDIR
)/tools.make
64 ifeq (,$(findstring checkwps
,$(APPSDIR
)))
65 ifeq (,$(findstring database
,$(APPSDIR
)))
66 include $(FIRMDIR
)/firmware.make
67 include $(ROOTDIR
)/lib
/skin_parser
/skin_parser.make
68 include $(ROOTDIR
)/apps
/bitmaps
/bitmaps.make
72 ifneq (,$(findstring bootloader
,$(APPSDIR
)))
73 include $(APPSDIR
)/bootloader.make
74 else ifneq (,$(findstring bootbox
,$(APPSDIR
)))
75 BOOTBOXLDOPTS
= -Wl
,--gc-sections
76 include $(APPSDIR
)/bootbox.make
77 else ifneq (,$(findstring checkwps
,$(APPSDIR
)))
78 include $(APPSDIR
)/checkwps.make
79 include $(ROOTDIR
)/lib
/skin_parser
/skin_parser.make
80 else ifneq (,$(findstring database
,$(APPSDIR
)))
81 include $(APPSDIR
)/database.make
83 include $(APPSDIR
)/apps.make
84 include $(APPSDIR
)/lang
/lang.make
87 include $(APPSDIR
)/codecs
/codecs.make
91 include $(APPSDIR
)/plugins
/bitmaps
/pluginbitmaps.make
92 include $(APPSDIR
)/plugins
/plugins.make
96 include $(ROOTDIR
)/uisimulator
/uisimulator.make
102 OBJ
+= $(BMP
:.bmp
=.o
)
103 OBJ
:= $(subst $(ROOTDIR
),$(BUILDDIR
),$(OBJ
))
105 build
: $(TOOLS
) $(BUILDDIR
)/$(BINARY
) $(CODECS
) $(ROCKS
) $(ARCHOSROM
) $(RBINFO
)
107 $(RBINFO
): $(BUILDDIR
)/$(BINARY
)
108 $(SILENT
)echo Creating
$(@F
)
109 $(SILENT
)$(TOOLSDIR
)/mkinfo.pl
$@
112 $(call PRINTS
,Generating dependencies
)
113 @echo foo
> /dev
/null
# there must be a "real" command in the rule
114 $(call mkdepfile
,$(DEPFILE
),$(SRC
))
115 $(call mkdepfile
,$(DEPFILE
),$(OTHER_SRC
:%.lua
=))
116 $(call mkdepfile
,$(DEPFILE
),$(ASMDEFS_SRC
))
117 @mv
$(DEPFILE
)_
$(DEPFILE
)
118 $(call bmpdepfile
,$(DEPFILE
),$(BMP
) $(PBMP
))
120 bin
: $(DEPFILE
) $(TOOLS
) $(BUILDDIR
)/$(BINARY
) $(RBINFO
)
121 rocks
: $(DEPFILE
) $(TOOLS
) $(ROCKS
)
122 codecs
: $(DEPFILE
) $(TOOLS
) $(CODECS
)
128 $(SILENT
)rm -rf
$(TOOLS
)
131 $(SILENT
)echo Cleaning build directory
132 $(SILENT
)rm -rf rockbox.zip rockbox
.7z rockbox.
tar rockbox.
tar.gz \
133 rockbox.
tar.bz2 TAGS apps firmware tools comsim sim lang lib \
134 manual
*.pdf
*.a credits.raw rockbox.ipod bitmaps \
135 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
136 rockbox-manual
*.zip sysfont.h rockbox-info.txt voicefontids \
137 *.wav
*.mp3
*.voice
$(CLEANOBJS
) \
138 $(LINKRAM
) $(LINKROM
) rockbox.elf rockbox.map rockbox.bin \
139 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
140 $(BINARY
) $(FLASHFILE
) uisimulator bootloader flash
$(BOOTLINK
)
142 #### linking the binaries: ####
146 ifeq (,$(findstring bootloader
,$(APPSDIR
)))
154 CONFIGFILE
:= $(FIRMDIR
)/export/config
/$(MODELNAME
).h
155 RAMLDS
:= $(FIRMDIR
)/target
/$(CPU
)/$(MANUFACTURER
)/app.lds
156 LINKRAM
:= $(BUILDDIR
)/ram.link
157 ROMLDS
:= $(FIRMDIR
)/rom.lds
158 LINKROM
:= $(BUILDDIR
)/rom.link
161 $(LINKRAM
): $(RAMLDS
) $(CONFIGFILE
)
162 $(call PRINTS
,PP
$(@F
))
163 $(call preprocess2file
,$<,$@
,-DLOADADDRESS
=$(LOADADDRESS
))
165 $(LINKROM
): $(ROMLDS
)
166 $(call PRINTS
,PP
$(@F
))
167 $(call preprocess2file
,$<,$@
,-DLOADADDRESS
=$(LOADADDRESS
))
169 $(BUILDDIR
)/rockbox.elf
: $$(OBJ
) $$(FIRMLIB
) $$(VOICESPEEXLIB
) $$(SKINLIB
) $$(LINKRAM
)
170 $(call PRINTS
,LD
$(@F
))$(CC
) $(GCCOPTS
) -Os
-nostdlib
-o
$@
$(OBJ
) \
171 -L
$(BUILDDIR
)/firmware
-lfirmware \
172 -L
$(BUILDDIR
)/lib
-lskin_parser \
173 -L
$(BUILDDIR
)/apps
/codecs
$(VOICESPEEXLIB
:lib
%.a
=-l
%) \
174 -lgcc
$(BOOTBOXLDOPTS
) $(GLOBAL_LDOPTS
) \
175 -T
$(LINKRAM
) -Wl
,-Map
,$(BUILDDIR
)/rockbox.map
177 $(BUILDDIR
)/rombox.elf
: $$(OBJ
) $$(FIRMLIB
) $$(VOICESPEEXLIB
) $$(SKINLIB
) $$(LINKROM
)
178 $(call PRINTS
,LD
$(@F
))$(CC
) $(GCCOPTS
) -Os
-nostdlib
-o
$@
$(OBJ
) \
179 $(VOICESPEEXLIB
) $(FIRMLIB
) -lgcc
$(GLOBAL_LDOPTS
) \
180 -L
$(BUILDDIR
)/lib
-lskin_parser \
181 -L
$(BUILDDIR
)/firmware
-T
$(LINKROM
) -Wl
,-Map
,$(BUILDDIR
)/rombox.map
183 $(BUILDDIR
)/rockbox.bin
: $(BUILDDIR
)/rockbox.elf
184 $(call PRINTS
,OC
$(@F
))$(OC
) $(if
$(filter yes
, $(USE_ELF
)), -S
-x
, -O binary
) $< $@
186 $(BUILDDIR
)/rombox.bin
: $(BUILDDIR
)/rombox.elf
187 $(call PRINTS
,OC
$(@F
))$(OC
) -O binary
$< $@
190 # If there's a flashfile defined for this target (rockbox.ucl for Archos
191 # models) Then check if the mkfirmware script fails, as then it is (likely)
192 # because the image is too big and we need to create a compressed image
195 $(BUILDDIR
)/$(BINARY
) : $(BUILDDIR
)/rockbox.bin
$(FLASHFILE
)
196 $(call PRINTS
,SCRAMBLE
$(notdir $@
))($(MKFIRMWARE
) $< $@
; \
198 if
test -n
"$(FLASHFILE)"; then \
199 if
test "$$stat" -ne
0; then \
200 echo
"Image too big, making a compressed version!"; \
201 $(MAKE
) -C
$(FIRMDIR
)/decompressor OBJDIR
=$(BUILDDIR
)/firmware
/decompressor
; \
202 $(MKFIRMWARE
) $(BUILDDIR
)/firmware
/decompressor
/compressed.bin
$@
; \
207 $(BUILDDIR
)/rockbox.ucl
: $(BUILDDIR
)/rockbox.bin
208 $(call PRINTS
,UCLPACK
$(@F
))$(TOOLSDIR
)/uclpack
--best
--2e
-b1048576
$< $@
>/dev
/null
210 MAXINFILE
= $(BUILDDIR
)/temp.txt
211 MAXOUTFILE
= $(BUILDDIR
)/romstart.txt
213 $(BUILDDIR
)/rombox.ucl
: $(BUILDDIR
)/rombox.bin
$(MAXOUTFILE
)
214 $(call PRINTS
,UCLPACK
$(@F
))$(TOOLSDIR
)/uclpack
--none
$< $@
>/dev
/null
; \
215 perl
$(TOOLSDIR
)/romsizetest.pl
`cat $(MAXOUTFILE)` $<; \
216 if
test $$?
-ne
0; then \
217 echo
"removing UCL file again, making it a fake one"; \
222 $(call PRINTS
,Creating
$(@F
))
223 $(SILENT
)$(shell echo
'#include "config.h"' > $(MAXINFILE
))
224 $(SILENT
)$(shell echo
"ROM_START" >> $(MAXINFILE
))
225 $(call preprocess2file
,$(MAXINFILE
),$(MAXOUTFILE
))
226 $(SILENT
)rm $(MAXINFILE
)
229 $(BUILDDIR
)/rombox.iriver
: $(BUILDDIR
)/rombox.bin
230 $(call PRINTS
,Build ROM file
)$(MKFIRMWARE
) $< $@
237 $(SILENT
)$(MAKE
) -C
$(TOOLSDIR
) CC
=$(HOSTCC
) AR
=$(HOSTAR
) rbspeexenc voicefont wavtrim
241 $(SILENT
)etags
-o
$(BUILDDIR
)/TAGS
$(filter-out %.o
,$(SRC
) $(OTHER_SRC
))
244 $(SILENT
)$(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
1 -o rockbox-fonts.zip
$(TARGET
) $(BINARY
)
247 $(SILENT
)$(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" $(TARGET
) $(BINARY
)
250 $(SILENT
)find .
-name
"*.map" | xargs zip rockbox-maps.zip
253 $(SILENT
)$(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
2 -o rockbox-full.zip
$(TARGET
) $(BINARY
)
256 $(SILENT
)$(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -o
"rockbox.7z" -z
"7za a -mx=9" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" $(TARGET
) $(BINARY
)
259 $(SILENT
)rm -f rockbox.
tar
260 $(SILENT
)$(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -o
"rockbox.tar" -z
"tar -cf" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" $(TARGET
) $(BINARY
)
263 $(SILENT
)bzip2
-f9 rockbox.
tar
266 $(SILENT
)gzip
-f9 rockbox.
tar
269 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-pdf
271 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-html
272 manual-zhtml
: manual-zip
274 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-txt
276 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-txt-zip
278 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-zip
282 voice
: voicetools
$(BUILDDIR
)/apps
/features
283 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
284 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 \
288 bininstall
: $(BUILDDIR
)/$(BINARY
)
289 @echo
"Installing your rockbox binary in your '$(RBPREFIX)' dir"
290 $(SILENT
)cp
$(BINARY
) "$(RBPREFIX)/.rockbox/"
293 @echo
"Installing your build in your '$(PREFIX)' dir"
294 $(SILENT
)$(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
"$(MODELNAME)" -i
"$(TARGET_ID)" $(INSTALL
) -z
"zip -r0" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
0 $(TARGET
) $(BINARY
)
297 @echo
"Installing a full setup in your '$(PREFIX)' dir"
298 $(SILENT
)$(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
"$(MODELNAME)" -i
"$(TARGET_ID)" $(INSTALL
) -z
"zip -r0" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
2 $(TARGET
) $(BINARY
)
301 @echo
"A few helpful make targets"
303 @echo
"all - builds a full Rockbox (default), including tools"
304 @echo
"bin - builds only the Rockbox.<target name> file"
305 @echo
"rocks - builds only plugins"
306 @echo
"codecs - builds only codecs"
307 @echo
"dep - regenerates make dependency database"
308 @echo
"clean - cleans a build directory (not tools)"
309 @echo
"veryclean - cleans the build and tools directories"
310 @echo
"manual - builds a manual (pdf)"
311 @echo
"manual-html - HTML manual"
312 @echo
"manual-zip - HTML manual (zipped)"
313 @echo
"manual-txt - txt manual"
314 @echo
"fullzip - creates a rockbox.zip of your build with fonts"
315 @echo
"zip - creates a rockbox.zip of your build (no fonts)"
316 @echo
"gzip - creates a rockbox.tar.gz of your build (no fonts)"
317 @echo
"bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
318 @echo
"7zip - creates a rockbox.7z of your build (no fonts)"
319 @echo
"fontzip - creates rockbox-fonts.zip"
320 @echo
"mapzip - creates rockbox-maps.zip with all .map files"
321 @echo
"tools - builds the tools only"
322 @echo
"voice - creates the voice clips (voice builds only)"
323 @echo
"voicetools - builds the voice tools only"
324 @echo
"install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
325 @echo
"fullinstall - installs your build (like install, but with fonts)"
326 @echo
"reconf - rerun configure with the same selection"
328 ### general compile rules:
330 # when source and object are in different locations (normal):
331 $(BUILDDIR
)/%.o
: $(ROOTDIR
)/%.c
332 $(SILENT
)mkdir
-p
$(dir $@
)
333 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
335 $(BUILDDIR
)/%.o
: $(ROOTDIR
)/%.S
336 $(SILENT
)mkdir
-p
$(dir $@
)
337 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
339 # generated definitions for use in .S files
340 $(BUILDDIR
)/%_asmdefs.h
: $(ROOTDIR
)/%_asmdefs.c
341 $(call PRINTS
,ASMDEFS
$(@F
))
342 $(SILENT
)mkdir
-p
$(dir $@
)
343 $(call asmdefs2file
,$<,$@
)
345 # when source and object are both in BUILDDIR (generated code):
347 $(SILENT
)mkdir
-p
$(dir $@
)
348 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
351 $(SILENT
)mkdir
-p
$(dir $@
)
352 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
354 Makefile
: $(TOOLSDIR
)/configure
355 ifneq (reconf
,$(MAKECMDGOALS
))
356 $(SILENT
)echo
"*** tools/configure is newer than Makefile. You should run 'make reconf'."
360 $(SILENT
$)$(TOOLSDIR
)/configure
$(CONFIGURE_OPTIONS
)