Moved LCD_WIDHT/HEIGHT from lcd driver to config file.
[kugel-rb.git] / apps / Makefile
blob7afcdc35bdde36c3b85f88da546b9e9fc577a846
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 # $@ is the name to the left of the colon
11 # $> is the first name to the right of the colon
13 CC = sh-elf-gcc
14 LD = sh-elf-ld
15 AR = sh-elf-ar
16 AS = sh-elf-as
17 OC = sh-elf-objcopy
19 LANGUAGE = english
21 FIRMWARE := ../firmware
22 DOCSDIR := ../docs
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))
37 # scramble tool
38 TOOL = scramble
40 ifndef MEM
41 # if MEM is not set, assume 2MB
42 MEM=2
43 endif
45 ifdef ARCHOS_ROM
46 ROMBUILD=-DARCHOS_ROM
47 endif
49 LDS := $(FIRMWARE)/app.lds
50 ROMLDS := $(FIRMWARE)/rom.lds
52 ifdef DEBUG
53 DEFINES := -DDEBUG
54 CFLAGS += -g
55 endif
57 SRC := $(wildcard *.c)
59 ifeq ($(TARGET), -DARCHOS_FMRECORDER)
60 TOOL_OPT = -fm
61 endif
62 ifeq ($(TARGET), -DARCHOS_RECORDERV2)
63 TOOL_OPT = -v2
64 endif
65 ifeq ($(TARGET), -DARCHOS_ONDIOSP)
66 TOOL_OPT = -osp
67 endif
68 ifeq ($(TARGET), -DARCHOS_ONDIOFM)
69 TOOL_OPT = -ofm
70 endif
73 ifeq ($(ANYREC), RECORDER)
74 SRC += $(wildcard recorder/*.c)
75 CFLAGS += -Irecorder
76 OUTNAME = ajbrec.ajz
77 # set the ROMTARGET here to make this get built only on recorders
78 ROMTARGET := $(OBJDIR)/rombox.ucl
79 else
80 ifeq ($(TARGET), -DARCHOS_PLAYER)
81 SRC += $(wildcard player/*.c)
82 CFLAGS += -Iplayer
83 OUTNAME = archos.mod
84 else
85 ifeq ($(ANYONDIO), ONDIO)
86 # use the recorder tree for now
87 SRC += $(wildcard recorder/*.c)
88 CFLAGS += -Irecorder
89 OUTNAME = ajbrec.ajz
90 else
91 # some kind of Neo
92 SRC += $(wildcard neo/*.c)
93 CFLAGS += -Ineo
94 OUTNAME = Rockbox.bin
95 TOOL_OPT = -neo
96 endif
97 endif
98 endif
100 OBJS := $(OBJDIR)/lang.o $(SRC:%.c=$(OBJDIR)/%.o)
102 LINKFILE = $(OBJDIR)/linkage.lds
103 LINKROM = $(OBJDIR)/linkrom.lds
105 ifndef OBJDIR
106 no_configure:
107 @echo "Don't run make here. Run the tools/configure script from your own build"
108 @echo "directory, then run make there."
109 @echo
110 @echo "More help on how to build rockbox can be found here:"
111 @echo "http://rockbox.haxx.se/docs/how_to_compile.html"
112 endif
114 ifndef TOOLSDIR
115 TOOLSDIR=../tools
116 endif
118 MAXINFILE = $(OBJDIR)/romstart.temp
119 MAXOUTFILE = $(OBJDIR)/romstart
121 ifdef DEBUG
122 all : $(OBJDIR)/rockbox.elf rocks
123 else
124 all : $(OBJDIR)/$(OUTNAME) $(OBJDIR)/rockbox.ucl rocks $(ROMTARGET)
125 endif
127 rocks:
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
135 # in number of MB
136 $(LINKFILE): $(LDS)
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) - >$@
142 $(MAXOUTFILE):
143 @echo '#include "config.h"' > $(MAXINFILE)
144 @echo "ROM_START" >> $(MAXINFILE)
145 @cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEM) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
146 @rm $(MAXINFILE)
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
157 @echo "OBJCOPY $<"
158 @$(OC) -O binary $< $@
160 $(OBJDIR)/rombox.bin : $(OBJDIR)/rombox.elf
161 @echo "OBJCOPY $<"
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; \
175 else \
176 echo "no uclpack command found, makes a fake rockbox.ucl"; \
177 echo "fake" > $@; \
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"; \
189 echo "fake" > $@; \
190 fi \
191 else \
192 echo "Your uclpack seems to not support --none, making a fake ucl"; \
193 echo "fake" > $@; \
194 fi \
195 else \
196 echo "no uclpack command found, makes a fake rombox.ucl"; \
197 echo "fake" > $@; \
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 $@`
205 @echo "CC $<"
206 @$(CC) $(CFLAGS) -c $< -o $@
208 $(OBJDIR)/%.o: %.c
209 @mkdir -p `dirname $@`
210 @echo "CC $<"
211 @$(CC) $(CFLAGS) -c $< -o $@
213 $(OBJDIR)/build.lang: lang/$(LANGUAGE).lang $(TOOLSDIR)/uplang
214 @echo "UPLANG"
215 @perl $(TOOLSDIR)/uplang lang/english.lang $< > $@
217 $(OBJDIR)/lang.o: $(OBJDIR)/build.lang $(TOOLSDIR)/genlang
218 @echo "GENLANG"
219 @perl -s $(TOOLSDIR)/genlang -p=$(OBJDIR)/lang $<
220 @echo "CC lang.c"
221 @$(CC) $(CFLAGS) -c $(OBJDIR)/lang.c -o $@
223 clean:
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
234 DEPS:=.deps
235 DEPDIRS:=$(DEPS)
236 ifeq ($(ANYREC), RECORDER)
237 DEPDIRS += $(DEPS)/recorder
238 else
239 ifeq ($(TARGET), -DARCHOS_PLAYER)
240 DEPDIRS += $(DEPS)/player
241 else
242 ifeq ($(ANYONDIO), ONDIO)
243 # use the recorder tree for now
244 DEPDIRS += $(DEPS)/recorder
245 else
246 # some kind of Neo
247 DEPDIRS += $(DEPS)/neo
248 endif
249 endif
250 endif
252 DIRS = $(subst $(DEPS),".",$(DEPDIRS))
254 tags:
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 $@'
263 ifdef OBJDIR
264 -include $(SRC:%.c=$(OBJDIR)/$(DEPS)/%.d)
265 endif