Update the Swedish translation.
[kugel-rb.git] / apps / Makefile
blob69de3a0f7823bca565d9efce7f714bb3c4f273e4
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 INCLUDES= $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(BUILDDIR) \
11 -I$(BUILDDIR)/bitmaps -I$(OBJDIR)
13 DEPFILE = $(OBJDIR)/dep-apps
14 LDS := $(FIRMDIR)/app.lds
15 ROMLDS := $(FIRMDIR)/rom.lds
17 ifdef ENABLEDPLUGINS
18 ROCKS=rocks
19 endif
21 ifdef SOFTWARECODECS
22 CODECS=build-codecs
23 endif
25 # Set up the bitmap libraries
26 BITMAPLIBS =
27 LINKBITMAPS =
28 ifneq ($(strip $(BMP2RB_MONO)),)
29 BITMAPLIBS += $(BUILDDIR)/libbitmapsmono.a
30 LINKBITMAPS += -lbitmapsmono
31 endif
32 ifneq ($(strip $(BMP2RB_NATIVE)),)
33 BITMAPLIBS += $(BUILDDIR)/libbitmapsnative.a
34 LINKBITMAPS += -lbitmapsnative
35 endif
36 ifneq ($(strip $(BMP2RB_REMOTEMONO)),)
37 BITMAPLIBS += $(BUILDDIR)/libbitmapsremotemono.a
38 LINKBITMAPS += -lbitmapsremotemono
39 endif
40 ifneq ($(strip $(BMP2RB_REMOTENATIVE)),)
41 BITMAPLIBS += $(BUILDDIR)/libbitmapsremotenative.a
42 LINKBITMAPS += -lbitmapsremotenative
43 endif
45 # This sets up 'SRC' based on the files mentioned in SOURCES
46 include $(TOOLSDIR)/makesrc.inc
48 DEFINES = $(DEBUG)
50 DIRS = .
52 ifdef APPEXTRA
53 DIRS += $(subst :, ,$(APPEXTRA))
54 INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA)))
55 endif
57 CFLAGS = $(INCLUDES) $(GCCOPTS) $(TARGET) $(BUILDDATE) $(DEFINES) -DTARGET_ID=$(TARGET_ID) \
58 -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE} \
59 -DTARGET_NAME=\"$(ARCHOS)\"
61 OBJS2 := $(OBJDIR)/lang.o $(patsubst %.c, $(OBJDIR)/%.o, $(SRC))
62 OBJS = $(patsubst %.S, $(OBJDIR)/%.o, $(OBJS2))
63 SOURCES = $(SRC)
64 LINKFILE = $(OBJDIR)/linkage.lds
65 LINKROM = $(OBJDIR)/linkrom.lds
66 MAXINFILE = $(OBJDIR)/romstart.temp
67 MAXOUTFILE = $(OBJDIR)/romstart
69 LIBROCKBOX = $(BUILDDIR)/librockbox.a
71 ifdef SIMVER
72 # this is a sim build
74 all: $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS)
76 else
77 # regular target build
79 ifdef DEBUG
80 REALBIN = $(OBJDIR)/rockbox.elf
81 else
82 # this is not needed to get built when doing debug builds
83 REALBIN = $(BUILDDIR)/$(BINARY)
84 endif
86 all: $(REALBIN) $(FLASHFILE) $(CODECS) $(ROCKS) $(ARCHOSROM)
87 endif
89 $(DEPFILE): $(BITMAPLIBS)
91 dep: $(DEPFILE)
93 build-codecs:
94 $(SILENT)$(MAKE) -C codecs/lib OBJDIR=$(OBJDIR)/codecs/lib
95 $(SILENT)$(MAKE) -C codecs OBJDIR=$(OBJDIR)/codecs
97 build-bitmapsmono:
98 $(call PRINTS,MAKE in bitmaps/mono)$(MAKE) -C bitmaps/mono OBJDIR=$(OBJDIR)/bitmaps/mono
100 build-bitmapsnative:
101 $(call PRINTS,MAKE in bitmaps/native)$(MAKE) -C bitmaps/native OBJDIR=$(OBJDIR)/bitmaps/native
103 build-bitmapsremotemono:
104 $(call PRINTS,MAKE in bitmaps/remote_mono)$(MAKE) -C bitmaps/remote_mono OBJDIR=$(OBJDIR)/bitmaps/remote_mono
106 build-bitmapsremotenative:
107 $(call PRINTS,MAKE in bitmaps/remote_native)$(MAKE) -C bitmaps/remote_native OBJDIR=$(OBJDIR)/bitmaps/remote_native
109 $(BITMAPLIBS): $(BUILDDIR)/lib%.a: build-%
111 rocks: build-codecs
112 $(SILENT)$(MAKE) -C plugins/lib OBJDIR=$(OBJDIR)/plugins/lib
113 $(SILENT)$(MAKE) -C plugins OBJDIR=$(OBJDIR)/plugins
115 $(LINKFILE): $(LDS)
116 $(call PRINTS,Build $(@F))cat $< | $(CC) -DLOADADDRESS=$(LOADADDRESS) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
118 $(LINKROM): $(ROMLDS)
119 $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
121 $(MAXOUTFILE):
122 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
123 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
124 $(SILENT)cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
125 $(SILENT)rm $(MAXINFILE)
127 $(OBJDIR)/rombox.elf : $(OBJS) $(LINKROM) $(DEPFILE) $(LIBROCKBOX) $(BITMAPLIBS)
128 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -lrockbox -lgcc $(LINKBITMAPS) -L$(BUILDDIR)/firmware -T$(LINKROM) -Wl,-Map,$(OBJDIR)/rombox.map
130 ifndef SIMVER
132 $(OBJDIR)/rockbox.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) $(BITMAPLIBS)
133 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR)/firmware -L$(BUILDDIR) -lrockbox $(LINKBITMAPS) -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/rockbox.map
135 $(OBJDIR)/rockbox.bin : $(OBJDIR)/rockbox.elf
136 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
138 $(OBJDIR)/rombox.bin : $(OBJDIR)/rombox.elf
139 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
141 $(OBJDIR)/rockbox.asm: $(OBJDIR)/rockbox.bin
142 $(TOOLSDIR)/sh2d -sh1 $< > $@
145 # If there's a flashfile defined for this target (rockbox.ucl for Archos
146 # models) Then check if the mkfirmware script fails, as then it is (likely)
147 # because the image is too big and we need to create a compressed image
148 # instead.
150 $(BUILDDIR)/$(BINARY) : $(OBJDIR)/rockbox.bin $(FLASHFILE)
151 $(call PRINTS,Build firmware file)($(MKFIRMWARE) $< $@; \
152 stat=$$?; \
153 if test -n "$(FLASHFILE)"; then \
154 if test "$$stat" -ne 0; then \
155 echo "Image too big, making a compressed version!"; \
156 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
157 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
158 fi \
159 fi )
161 else
162 # this is a simulator build
164 ifeq ($(SIMVER), win32)
165 # OK, this is ugly but we need it on the link line to make it do right
166 EXTRAOBJ = $(BUILDDIR)/sim/uisw32-res.o
167 LDOPTS += -lwinmm
168 endif
170 # OS X's ld does not support -Map
171 ifeq ($(UNAME), Darwin)
172 SIMULATOR_MAP=
173 else
174 #SIMULATOR_MAP=-Wl,-Map,$(OBJDIR)/rockbox.map
175 endif
177 $(BUILDDIR)/$(BINARY) : $(OBJS) $(DEPFILE) $(BUILDDIR)/libsim.a \
178 $(BUILDDIR)/libcomsim.a $(LIBROCKBOX) $(BITMAPLIBS)
179 $(call PRINTS,LD $(BINARY))$(CC) $(GCCOPTS) -o $@ $(OBJS) -L$(BUILDDIR) -lrockbox -lsim -lcomsim $(LINKBITMAPS) $(LDOPTS) $(EXTRAOBJ) $(SIMULATOR_MAP)
180 endif
182 $(BUILDDIR)/rockbox.ucl: $(OBJDIR)/rockbox.bin
183 $(call PRINTS,UCLPACK rockbox)$(TOOLSDIR)/uclpack --best --2e $< $@ >/dev/null 2>&1
185 $(BUILDDIR)/rombox.ucl: $(OBJDIR)/rombox.bin $(MAXOUTFILE)
186 $(call PRINTS,UCLPACK rombox)$(TOOLSDIR)/uclpack --none $< $@ >/dev/null 2>&1; \
187 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
188 if test $$? -ne 0; then \
189 echo "removing UCL file again, making it a fake one"; \
190 echo "fake" > $@; \
193 $(BUILDDIR)/rombox.iriver: $(OBJDIR)/rombox.bin
194 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
196 include $(TOOLSDIR)/make.inc
198 $(OBJDIR)/lang.o: lang/$(LANGUAGE).lang
199 @mkdir -p $(dir $@)
200 $(call PRINTS,GENLANG)perl -s $(TOOLSDIR)/genlang -p=$(BUILDDIR)/lang -t=$(ARCHOS) $<
201 $(call PRINTS,CC lang.c)$(CC) $(CFLAGS) -c $(BUILDDIR)/lang.c -o $@
203 clean:
204 $(call PRINTS,cleaning apps)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/rockbox.asm \
205 $(OBJDIR)/rockbox.bin $(OBJDIR)/rockbox.elf $(OBJDIR)/*.map \
206 $(OBJDIR)/lang.o $(OBJDIR)/build.lang $(BUILDDIR)/lang.[ch] \
207 $(LINKFILE) $(BUILDDIR)/rockbox.ucl $(LINKROM) \
208 $(BUILDDIR)/rombox.ucl $(OBJDIR)/rombox.bin $(OBJDIR)/rombox.elf \
209 $(MAXOUTFILE) $(DEPFILE)
210 $(SILENT)$(MAKE) -C bitmaps/mono clean OBJDIR=$(OBJDIR)/bitmaps/mono
211 $(SILENT)$(MAKE) -C bitmaps/native clean OBJDIR=$(OBJDIR)/bitmaps/native
212 $(SILENT)$(MAKE) -C bitmaps/remote_mono clean OBJDIR=$(OBJDIR)/bitmaps/remote_mono
213 $(SILENT)$(MAKE) -C bitmaps/remote_native clean OBJDIR=$(OBJDIR)/bitmaps/remote_native
214 $(SILENT)$(MAKE) -C plugins clean OBJDIR=$(OBJDIR)/plugins
215 $(SILENT)$(MAKE) -C codecs clean OBJDIR=$(OBJDIR)/codecs
216 $(SILENT)rm -rf $(OBJDIR)/recorder $(OBJDIR)/player
217 $(SILENT)rm -rf $(BUILDDIR)/bitmaps
218 ifdef SIMVER
219 $(SILENT)$(MAKE) -C $(SIMDIR) clean
220 endif
222 ifneq ($(MAKECMDGOALS),clean)
223 -include $(DEPFILE)
224 endif