2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 # $@ is the name to the left of the colon
11 # $> is the first name to the right of the colon
21 FIRMWARE
:= ..
/firmware
24 INCLUDES
= -I
$(FIRMWARE
)/include -I
$(FIRMWARE
)/export -I.
-I
$(OBJDIR
)
26 CFLAGS
= -O
-W
-Wall
-m1
-nostdlib
-ffreestanding
-Wstrict-prototypes \
27 -fomit-frame-pointer
-fschedule-insns
$(INCLUDES
) $(TARGET
) $(DEFINES
) \
28 -DAPPSVERSION
=\"$(VERSION
)\" $(EXTRA_DEFINES
) -DMEM
=${MEM}
29 AFLAGS
+= -small
-relax
31 # Check if this is a kind of Recorder
32 ANYREC
= $(findstring RECORDER
, $(TARGET
))
34 # Check if this is an Ondio model
35 ANYONDIO
= $(findstring ONDIO
, $(TARGET
))
41 # if MEM is not set, assume 2MB
49 LDS
:= $(FIRMWARE
)/app.lds
50 ROMLDS
:= $(FIRMWARE
)/rom.lds
57 SRC
:= $(wildcard *.c
)
59 ifeq ($(TARGET
), -DARCHOS_FMRECORDER
)
62 ifeq ($(TARGET
), -DARCHOS_RECORDERV2
)
65 ifeq ($(TARGET
), -DARCHOS_ONDIOSP
)
68 ifeq ($(TARGET
), -DARCHOS_ONDIOFM
)
73 ifeq ($(ANYREC
), RECORDER
)
74 SRC
+= $(wildcard recorder
/*.c
)
77 # set the ROMTARGET here to make this get built only on recorders
78 ROMTARGET
:= $(OBJDIR
)/rombox.ucl
80 ifeq ($(TARGET
), -DARCHOS_PLAYER
)
81 SRC
+= $(wildcard player
/*.c
)
85 ifeq ($(ANYONDIO
), ONDIO
)
86 # use the recorder tree for now
87 SRC
+= $(wildcard recorder
/*.c
)
92 SRC
+= $(wildcard neo
/*.c
)
100 OBJS
:= $(OBJDIR
)/lang.o
$(SRC
:%.c
=$(OBJDIR
)/%.o
)
102 LINKFILE
= $(OBJDIR
)/linkage.lds
103 LINKROM
= $(OBJDIR
)/linkrom.lds
107 @echo
"Don't run make here. Run the tools/configure script from your own build"
108 @echo
"directory, then run make there."
110 @echo
"More help on how to build rockbox can be found here:"
111 @echo
"http://rockbox.haxx.se/docs/how_to_compile.html"
118 MAXINFILE
= $(OBJDIR
)/romstart.temp
119 MAXOUTFILE
= $(OBJDIR
)/romstart
122 all : $(OBJDIR
)/rockbox.elf rocks
124 all : $(OBJDIR
)/$(OUTNAME
) $(OBJDIR
)/rockbox.ucl rocks
$(ROMTARGET
)
128 $(MAKE
) -C plugins
/lib TARGET
=$(TARGET
) DEBUG
=$(DEBUG
) OBJDIR
=$(OBJDIR
) VERSION
=$(VERSION
) EXTRA_DEFINES
="$(EXTRA_DEFINES)" MEM
=${MEM}
129 $(MAKE
) -C plugins TARGET
=$(TARGET
) DEBUG
=$(DEBUG
) OBJDIR
=$(OBJDIR
) VERSION
=$(VERSION
) EXTRA_DEFINES
="$(EXTRA_DEFINES)" MEM
=${MEM}
131 $(OBJDIR
)/librockbox.a
:
132 make
-C
$(FIRMWARE
) TARGET
=$(TARGET
) DEBUG
=$(DEBUG
) OBJDIR
=$(OBJDIR
)
134 # MEM should be passed on to this makefile with the chosen memory size given
137 cat
$< |
$(CC
) -DMEMORYSIZE
=$(MEM
) $(INCLUDES
) $(TARGET
) $(DEFINES
) -E
-P
$(ROMBUILD
) - >$@
139 $(LINKROM
): $(ROMLDS
)
140 cat
$< |
$(CC
) -DMEMORYSIZE
=$(MEM
) $(INCLUDES
) $(TARGET
) $(DEFINES
) -E
-P
$(ROMBUILD
) - >$@
143 @echo
'#include "config.h"' > $(MAXINFILE
)
144 @echo
"ROM_START" >> $(MAXINFILE
)
145 @cat
$(MAXINFILE
) |
$(CC
) -DMEMORYSIZE
=$(MEM
) $(INCLUDES
) $(TARGET
) $(DEFINES
) -E
-P
$(ROMBUILD
) - > $(MAXOUTFILE
)
148 $(OBJDIR
)/rombox.elf
: $(OBJS
) $(LINKROM
) $(OBJDIR
)/librockbox.a
149 @echo
"LD rombox.elf"
150 @
$(CC
) -Os
-nostdlib
-o
$@
$(OBJS
) -L
$(OBJDIR
) -lrockbox
-lgcc
-L
$(FIRMWARE
) -T
$(LINKROM
) -Wl
,-Map
,$(OBJDIR
)/rombox.map
152 $(OBJDIR
)/rockbox.elf
: $(OBJS
) $(LINKFILE
) $(OBJDIR
)/librockbox.a
153 @echo
"LD rockbox.elf"
154 @
$(CC
) -Os
-nostdlib
-o
$@
$(OBJS
) -L
$(OBJDIR
) -lrockbox
-lgcc
-L
$(FIRMWARE
) -T
$(LINKFILE
) -Wl
,-Map
,$(OBJDIR
)/rockbox.map
156 $(OBJDIR
)/rockbox.bin
: $(OBJDIR
)/rockbox.elf
158 @
$(OC
) -O binary
$< $@
160 $(OBJDIR
)/rombox.bin
: $(OBJDIR
)/rombox.elf
162 @
$(OC
) -O binary
$< $@
164 $(OBJDIR
)/rockbox.asm
: $(OBJDIR
)/rockbox.bin
165 $(TOOLSDIR
)/sh2d
-sh1
$< > $@
167 $(OBJDIR
)/$(OUTNAME
) : $(OBJDIR
)/rockbox.bin
168 $(TOOLSDIR
)/$(TOOL
) $(TOOL_OPT
) $< $@
170 $(OBJDIR
)/rockbox.ucl
: $(OBJDIR
)/rockbox.bin
171 @a
=`uclpack -h 2>/dev/null`; \
172 if
test -n
"$$a"; then \
173 echo
"UCLPACK rockbox" ; \
174 uclpack
--best
--2e
$< $@
>/dev
/null
2>&1; \
176 echo
"no uclpack command found, makes a fake rockbox.ucl"; \
180 $(OBJDIR
)/rombox.ucl
: $(OBJDIR
)/rombox.bin
$(MAXOUTFILE
)
181 @a
=`uclpack -h 2>/dev/null`; \
182 if
test -n
"$$a"; then \
183 echo
"UCLPACK rombox" ; \
184 uclpack
--none
$< $@
>/dev
/null
2>&1; \
185 if
test -s
$@
; then \
186 perl
$(TOOLSDIR
)/romsizetest.pl
`cat $(MAXOUTFILE)` $<; \
187 if
test $$?
-ne
0; then \
188 echo
"removing UCL file again, making it a fake one"; \
192 echo
"Your uclpack seems to not support --none, making a fake ucl"; \
196 echo
"no uclpack command found, makes a fake rombox.ucl"; \
200 $(OBJDIR
)/credits.raw
: $(DOCSDIR
)/CREDITS
201 perl credits.pl
< $< > $@
203 $(OBJDIR
)/credits.o
: credits.c credits.h
$(OBJDIR
)/credits.raw
204 @mkdir
-p
`dirname $@`
206 @
$(CC
) $(CFLAGS
) -c
$< -o
$@
209 @mkdir
-p
`dirname $@`
211 @
$(CC
) $(CFLAGS
) -c
$< -o
$@
213 $(OBJDIR
)/build.lang
: lang
/$(LANGUAGE
).lang
$(TOOLSDIR
)/uplang
215 @perl
$(TOOLSDIR
)/uplang lang
/english.lang
$< > $@
217 $(OBJDIR
)/lang.o
: $(OBJDIR
)/build.lang
$(TOOLSDIR
)/genlang
219 @perl
-s
$(TOOLSDIR
)/genlang
-p
=$(OBJDIR
)/lang
$<
221 @
$(CC
) $(CFLAGS
) -c
$(OBJDIR
)/lang.c
-o
$@
224 @echo
"cleaning apps"
225 @
-rm -f
$(OBJS
) $(OBJDIR
)/$(OUTNAME
) $(OBJDIR
)/rockbox.asm \
226 $(OBJDIR
)/rockbox.bin
$(OBJDIR
)/rockbox.elf
$(OBJDIR
)/*.map \
227 $(OBJDIR
)/lang.o
$(OBJDIR
)/build.lang
$(OBJDIR
)/lang.
[ch
] \
228 $(OBJDIR
)/credits.raw
$(LINKFILE
) $(OBJDIR
)/rockbox.ucl \
229 $(LINKROM
) $(OBJDIR
)/rombox.ucl
$(OBJDIR
)/rombox.bin \
230 $(OBJDIR
)/rombox.elf
$(MAXOUTFILE
)
231 @
-$(RM
) -r
$(OBJDIR
)/$(DEPS
)
232 @
$(MAKE
) -C plugins
clean
236 ifeq ($(ANYREC
), RECORDER
)
237 DEPDIRS
+= $(DEPS
)/recorder
239 ifeq ($(TARGET
), -DARCHOS_PLAYER
)
240 DEPDIRS
+= $(DEPS
)/player
242 ifeq ($(ANYONDIO
), ONDIO
)
243 # use the recorder tree for now
244 DEPDIRS
+= $(DEPS
)/recorder
247 DEPDIRS
+= $(DEPS
)/neo
252 DIRS
= $(subst $(DEPS
),".",$(DEPDIRS
))
255 @
$(SHELL
) -c
'for d in $(DIRS); do { etags -o $(OBJDIR)/TAGS -a $$d/*.[ch]; }; done'
257 $(OBJDIR
)/$(DEPS
)/%.d
: %.c
258 @
$(SHELL
) -c
'for d in $(DEPDIRS); do { if [ ! -d $(OBJDIR)/$$d ]; then mkdir $(OBJDIR)/$$d; fi; }; done'
259 @
$(SHELL
) -ec
'$(CC) -MM $(CFLAGS) $< 2>/dev/null \
260 |sed '\''s|\($*\)\.o[ :]*|$(OBJDIR)/\1.o $(<:%.c=%.d) : |g'\'' > $@; \
261 [ -s $@ ] || rm -f $@'
264 -include $(SRC
:%.c
=$(OBJDIR
)/$(DEPS
)/%.d
)