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 \
29 # for sims, set simdisk/ as default
31 INSTALL
= --install="$(PREFIX)"
33 # /dev/null as magic to tell it wasn't set, error out later in buildzip.pl
34 INSTALL
= --install=/dev
/null
37 INSTALL
= --install="$(PREFIX)"
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
)))
49 DEPFILE
= $(BUILDDIR
)/make.dep
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
58 include $(FIRMDIR
)/firmware.make
59 include $(ROOTDIR
)/apps
/bitmaps
/bitmaps.make
61 ifneq (,$(findstring bootloader
,$(APPSDIR
)))
62 include $(APPSDIR
)/bootloader.make
63 else ifneq (,$(findstring bootbox
,$(APPSDIR
)))
64 BOOTBOXLDOPTS
= -Wl
,--gc-sections
65 include $(APPSDIR
)/bootbox.make
66 else ifneq (,$(findstring checkwps
,$(APPSDIR
)))
67 include $(APPSDIR
)/checkwps.make
69 include $(APPSDIR
)/apps.make
70 include $(APPSDIR
)/lang
/lang.make
73 include $(APPSDIR
)/codecs
/codecs.make
77 include $(APPSDIR
)/plugins
/bitmaps
/pluginbitmaps.make
78 include $(APPSDIR
)/plugins
/plugins.make
82 include $(ROOTDIR
)/uisimulator
/uisimulator.make
89 OBJ
:= $(subst $(ROOTDIR
),$(BUILDDIR
),$(OBJ
))
91 build
: $(TOOLS
) $(BUILDDIR
)/$(BINARY
) $(CODECS
) $(ROCKS
) $(ARCHOSROM
) $(RBINFO
)
93 $(RBINFO
): $(BUILDDIR
)/$(BINARY
)
94 $(SILENT
)echo Creating
$(@F
)
95 $(SILENT
)$(TOOLSDIR
)/mkinfo.pl
$@
98 $(call PRINTS
,Generating dependencies
)
99 @echo foo
> /dev
/null
# there must be a "real" command in the rule
100 $(call mkdepfile
,$(DEPFILE
),$(SRC
))
101 $(call mkdepfile
,$(DEPFILE
),$(OTHER_SRC
))
102 $(call mkdepfile
,$(DEPFILE
),$(ASMDEFS_SRC
))
103 @mv
$(DEPFILE
)_
$(DEPFILE
)
104 $(call bmpdepfile
,$(DEPFILE
),$(BMP
) $(PBMP
))
106 bin
: $(DEPFILE
) $(TOOLS
) $(BUILDDIR
)/$(BINARY
) $(RBINFO
)
107 rocks
: $(DEPFILE
) $(TOOLS
) $(ROCKS
)
108 codecs
: $(DEPFILE
) $(TOOLS
) $(CODECS
)
114 $(SILENT
)rm -rf
$(TOOLS
)
117 $(SILENT
)echo Cleaning build directory
118 $(SILENT
)rm -rf rockbox.zip rockbox
.7z rockbox.
tar rockbox.
tar.gz \
119 rockbox.
tar.bz2 TAGS apps firmware comsim sim lang \
120 manual
*.pdf
*.a credits.raw rockbox.ipod bitmaps \
121 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
122 rockbox-manual
*.zip sysfont.h rockbox-info.txt voicefontids \
123 *.wav
*.mp3
*.voice
$(CLEANOBJS
) \
124 $(LINKRAM
) $(LINKROM
) rockbox.elf rockbox.map rockbox.bin \
125 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
126 $(BINARY
) $(FLASHFILE
) uisimulator bootloader flash
$(BOOTLINK
)
128 #### linking the binaries: ####
132 ifeq (,$(findstring bootloader
,$(APPSDIR
)))
140 RAMLDS
:= $(FIRMDIR
)/target
/$(CPU
)/$(MANUFACTURER
)/app.lds
141 LINKRAM
:= $(BUILDDIR
)/ram.link
142 ROMLDS
:= $(FIRMDIR
)/rom.lds
143 LINKROM
:= $(BUILDDIR
)/rom.link
146 $(LINKRAM
): $(RAMLDS
)
147 $(call PRINTS
,PP
$(@F
))
148 $(call preprocess2file
,$<,$@
,-DLOADADDRESS
=$(LOADADDRESS
))
150 $(LINKROM
): $(ROMLDS
)
151 $(call PRINTS
,PP
$(@F
))
152 $(call preprocess2file
,$<,$@
,-DLOADADDRESS
=$(LOADADDRESS
))
154 $(BUILDDIR
)/rockbox.elf
: $$(OBJ
) $$(FIRMLIB
) $$(VOICESPEEXLIB
) $$(LINKRAM
)
155 $(call PRINTS
,LD
$(@F
))$(CC
) $(GCCOPTS
) -Os
-nostdlib
-o
$@
$(OBJ
) \
156 -L
$(BUILDDIR
)/firmware
-lfirmware \
157 -L
$(BUILDDIR
)/apps
/codecs
$(VOICESPEEXLIB
:lib
%.a
=-l
%) \
158 -lgcc
$(BOOTBOXLDOPTS
) \
159 -T
$(LINKRAM
) -Wl
,-Map
,$(BUILDDIR
)/rockbox.map
161 $(BUILDDIR
)/rombox.elf
: $$(OBJ
) $$(FIRMLIB
) $$(VOICESPEEXLIB
) $$(LINKROM
)
162 $(call PRINTS
,LD
$(@F
))$(CC
) $(GCCOPTS
) -Os
-nostdlib
-o
$@
$(OBJ
) \
163 $(VOICESPEEXLIB
) $(FIRMLIB
) -lgcc
-L
$(BUILDDIR
)/firmware \
164 -T
$(LINKROM
) -Wl
,-Map
,$(BUILDDIR
)/rombox.map
166 $(BUILDDIR
)/rockbox.bin
: $(BUILDDIR
)/rockbox.elf
167 $(call PRINTS
,OC
$(@F
))$(OC
) $(if
$(filter yes
, $(USE_ELF
)), -S
-x
, -O binary
) $< $@
169 $(BUILDDIR
)/rombox.bin
: $(BUILDDIR
)/rombox.elf
170 $(call PRINTS
,OC
$(@F
))$(OC
) -O binary
$< $@
173 # If there's a flashfile defined for this target (rockbox.ucl for Archos
174 # models) Then check if the mkfirmware script fails, as then it is (likely)
175 # because the image is too big and we need to create a compressed image
178 $(BUILDDIR
)/$(BINARY
) : $(BUILDDIR
)/rockbox.bin
$(FLASHFILE
)
179 $(call PRINTS
,SCRAMBLE
$(notdir $@
))($(MKFIRMWARE
) $< $@
; \
181 if
test -n
"$(FLASHFILE)"; then \
182 if
test "$$stat" -ne
0; then \
183 echo
"Image too big, making a compressed version!"; \
184 $(MAKE
) -C
$(FIRMDIR
)/decompressor OBJDIR
=$(BUILDDIR
)/firmware
/decompressor
; \
185 $(MKFIRMWARE
) $(BUILDDIR
)/firmware
/decompressor
/compressed.bin
$@
; \
190 $(BUILDDIR
)/rockbox.ucl
: $(BUILDDIR
)/rockbox.bin
191 $(call PRINTS
,UCLPACK
$(@F
))$(TOOLSDIR
)/uclpack
--best
--2e
-b1048576
$< $@
>/dev
/null
193 MAXINFILE
= $(BUILDDIR
)/temp.txt
194 MAXOUTFILE
= $(BUILDDIR
)/romstart.txt
196 $(BUILDDIR
)/rombox.ucl
: $(BUILDDIR
)/rombox.bin
$(MAXOUTFILE
)
197 $(call PRINTS
,UCLPACK
$(@F
))$(TOOLSDIR
)/uclpack
--none
$< $@
>/dev
/null
; \
198 perl
$(TOOLSDIR
)/romsizetest.pl
`cat $(MAXOUTFILE)` $<; \
199 if
test $$?
-ne
0; then \
200 echo
"removing UCL file again, making it a fake one"; \
205 $(call PRINTS
,Creating
$(@F
))
206 $(SILENT
)$(shell echo
'#include "config.h"' > $(MAXINFILE
))
207 $(SILENT
)$(shell echo
"ROM_START" >> $(MAXINFILE
))
208 $(call preprocess2file
,$(MAXINFILE
),$(MAXOUTFILE
))
209 $(SILENT
)rm $(MAXINFILE
)
212 $(BUILDDIR
)/rombox.iriver
: $(BUILDDIR
)/rombox.bin
213 $(call PRINTS
,Build ROM file
)$(MKFIRMWARE
) $< $@
220 $(SILENT
)$(MAKE
) -C
$(TOOLSDIR
) CC
=$(HOSTCC
) AR
=$(HOSTAR
) rbspeexenc voicefont wavtrim
224 $(SILENT
)etags
-o
$(BUILDDIR
)/TAGS
$(filter-out %.o
,$(SRC
) $(OTHER_SRC
))
227 $(SILENT
)$(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
1 -o rockbox-fonts.zip
$(TARGET
) $(BINARY
)
230 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
231 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" $(TARGET
) $(BINARY
)
234 $(SILENT
)find .
-name
"*.map" | xargs zip rockbox-maps.zip
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)" -f
2 -o rockbox-full.zip
$(TARGET
) $(BINARY
)
241 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
242 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -o
"rockbox.7z" -z
"7za a -mx=9" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" $(TARGET
) $(BINARY
)
245 $(SILENT
)rm -f rockbox.
tar
246 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
247 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
\"$(MODELNAME
)\" -i
\"$(TARGET_ID
)\" -o
"rockbox.tar" -z
"tar -cf" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" $(TARGET
) $(BINARY
)
250 $(SILENT
)bzip2
-f9 rockbox.
tar
253 $(SILENT
)gzip
-f9 rockbox.
tar
256 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-pdf
258 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-html
259 manual-zhtml
: manual-zip
261 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-txt
263 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-txt-zip
265 $(SILENT
)$(MAKE
) -C
$(MANUALDIR
) OBJDIR
=$(BUILDDIR
)/manual manual-zip
269 voice
: voicetools features
270 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
271 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 \
276 @echo
"Installing your build in your '$(PREFIX)' dir"
277 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
278 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
"$(MODELNAME)" -i
"$(TARGET_ID)" $(INSTALL
) -z
"zip -r0" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
0 $(TARGET
) $(BINARY
)
281 @echo
"Installing a full setup in your '$(PREFIX)' dir"
282 $(SILENT
)for f in
`cat $(BUILDDIR)/apps/features`; do feat
="$$feat:$$f" ; done
; \
283 $(TOOLSDIR
)/buildzip.pl
$(VERBOSEOPT
) -m
"$(MODELNAME)" -i
"$(TARGET_ID)" $(INSTALL
) -z
"zip -r0" -r
"$(ROOTDIR)" --rbdir
="$(RBDIR)" -f
2 $(TARGET
) $(BINARY
)
286 @echo
"A few helpful make targets"
288 @echo
"all - builds a full Rockbox (default), including tools"
289 @echo
"bin - builds only the Rockbox.<target name> file"
290 @echo
"rocks - builds only plugins"
291 @echo
"codecs - builds only codecs"
292 @echo
"dep - regenerates make dependency database"
293 @echo
"clean - cleans a build directory (not tools)"
294 @echo
"veryclean - cleans the build and tools directories"
295 @echo
"manual - builds a manual (pdf)"
296 @echo
"manual-html - HTML manual"
297 @echo
"manual-zip - HTML manual (zipped)"
298 @echo
"manual-txt - txt manual"
299 @echo
"fullzip - creates a rockbox.zip of your build with fonts"
300 @echo
"zip - creates a rockbox.zip of your build (no fonts)"
301 @echo
"gzip - creates a rockbox.tar.gz of your build (no fonts)"
302 @echo
"bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
303 @echo
"7zip - creates a rockbox.7z of your build (no fonts)"
304 @echo
"fontzip - creates rockbox-fonts.zip"
305 @echo
"mapzip - creates rockbox-maps.zip with all .map files"
306 @echo
"tools - builds the tools only"
307 @echo
"voice - creates the voice clips (voice builds only)"
308 @echo
"voicetools - builds the voice tools only"
309 @echo
"install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
310 @echo
"fullinstall - installs your build (like install, but with fonts)"
311 @echo
"reconf - rerun configure with the same selection"
313 ### general compile rules:
315 # when source and object are in different locations (normal):
316 $(BUILDDIR
)/%.o
: $(ROOTDIR
)/%.c
317 $(SILENT
)mkdir
-p
$(dir $@
)
318 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
320 $(BUILDDIR
)/%.o
: $(ROOTDIR
)/%.S
321 $(SILENT
)mkdir
-p
$(dir $@
)
322 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
324 # generated definitions for use in .S files
325 $(BUILDDIR
)/%_asmdefs.h
: $(ROOTDIR
)/%_asmdefs.c
326 $(call PRINTS
,ASMDEFS
$(@F
))
327 $(SILENT
)mkdir
-p
$(dir $@
)
328 $(call asmdefs2file
,$<,$@
)
330 # when source and object are both in BUILDDIR (generated code):
332 $(SILENT
)mkdir
-p
$(dir $@
)
333 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
336 $(SILENT
)mkdir
-p
$(dir $@
)
337 $(call PRINTS
,CC
$(subst $(ROOTDIR
)/,,$<))$(CC
) $(CFLAGS
) -c
$< -o
$@
339 Makefile
: $(TOOLSDIR
)/configure
340 ifneq (reconf
,$(MAKECMDGOALS
))
341 $(SILENT
)echo
"*** tools/configure is newer than Makefile. You should run 'make reconf'."
345 $(SILENT
$)PREFIX
=$(PREFIX
) $(TOOLSDIR
)/configure
$(CONFIGURE_OPTIONS
)