Fixes a problem where the sim would try to start the WPS on HAVE_RTC_ALARM sims ...
[Rockbox.git] / apps / Makefile
blob17087272737d3152c14ee171fec98360394f1714
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 features: $(OBJDIR)/features
95 build-codecs:
96 $(SILENT)$(MAKE) -C codecs/lib OBJDIR=$(OBJDIR)/codecs/lib
97 $(SILENT)$(MAKE) -C codecs OBJDIR=$(OBJDIR)/codecs
99 build-bitmapsmono:
100 $(call PRINTS,MAKE in bitmaps/mono)$(MAKE) -C bitmaps/mono OBJDIR=$(OBJDIR)/bitmaps/mono
102 build-bitmapsnative:
103 $(call PRINTS,MAKE in bitmaps/native)$(MAKE) -C bitmaps/native OBJDIR=$(OBJDIR)/bitmaps/native
105 build-bitmapsremotemono:
106 $(call PRINTS,MAKE in bitmaps/remote_mono)$(MAKE) -C bitmaps/remote_mono OBJDIR=$(OBJDIR)/bitmaps/remote_mono
108 build-bitmapsremotenative:
109 $(call PRINTS,MAKE in bitmaps/remote_native)$(MAKE) -C bitmaps/remote_native OBJDIR=$(OBJDIR)/bitmaps/remote_native
111 $(BITMAPLIBS): $(BUILDDIR)/lib%.a: build-%
113 rocks: build-codecs
114 $(SILENT)$(MAKE) -C plugins/lib OBJDIR=$(OBJDIR)/plugins/lib
115 $(SILENT)$(MAKE) -C plugins OBJDIR=$(OBJDIR)/plugins
117 $(LINKFILE): $(LDS)
118 $(call PRINTS,Build $(@F))cat $< | $(CC) -DLOADADDRESS=$(LOADADDRESS) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
120 $(LINKROM): $(ROMLDS)
121 $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
123 $(MAXOUTFILE):
124 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
125 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
126 $(SILENT)cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
127 $(SILENT)rm $(MAXINFILE)
129 $(OBJDIR)/rombox.elf : $(OBJS) $(LINKROM) $(DEPFILE) $(LIBROCKBOX) $(BITMAPLIBS)
130 $(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
132 ifndef SIMVER
134 $(OBJDIR)/rockbox.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) $(BITMAPLIBS)
135 $(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
137 $(OBJDIR)/rockbox.bin : $(OBJDIR)/rockbox.elf
138 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
140 $(OBJDIR)/rombox.bin : $(OBJDIR)/rombox.elf
141 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
143 $(OBJDIR)/rockbox.asm: $(OBJDIR)/rockbox.bin
144 $(TOOLSDIR)/sh2d -sh1 $< > $@
147 # If there's a flashfile defined for this target (rockbox.ucl for Archos
148 # models) Then check if the mkfirmware script fails, as then it is (likely)
149 # because the image is too big and we need to create a compressed image
150 # instead.
152 $(BUILDDIR)/$(BINARY) : $(OBJDIR)/rockbox.bin $(FLASHFILE)
153 $(call PRINTS,Build firmware file)($(MKFIRMWARE) $< $@; \
154 stat=$$?; \
155 if test -n "$(FLASHFILE)"; then \
156 if test "$$stat" -ne 0; then \
157 echo "Image too big, making a compressed version!"; \
158 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
159 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
160 fi \
161 fi )
163 else
164 # this is a simulator build
166 ifeq ($(SIMVER), win32)
167 # OK, this is ugly but we need it on the link line to make it do right
168 EXTRAOBJ = $(BUILDDIR)/sim/uisw32-res.o
169 LDOPTS += -lwinmm
170 endif
172 # OS X's ld does not support -Map
173 ifeq ($(UNAME), Darwin)
174 SIMULATOR_MAP=
175 else
176 #SIMULATOR_MAP=-Wl,-Map,$(OBJDIR)/rockbox.map
177 endif
179 $(BUILDDIR)/$(BINARY) : $(OBJS) $(DEPFILE) $(BUILDDIR)/libsim.a \
180 $(BUILDDIR)/libcomsim.a $(LIBROCKBOX) $(BITMAPLIBS)
181 $(call PRINTS,LD $(BINARY))$(CC) $(GCCOPTS) -o $@ $(OBJS) -L$(BUILDDIR) -lrockbox -lsim -lcomsim $(LINKBITMAPS) $(LDOPTS) $(EXTRAOBJ) $(SIMULATOR_MAP)
182 endif
184 $(BUILDDIR)/rockbox.ucl: $(OBJDIR)/rockbox.bin
185 $(call PRINTS,UCLPACK rockbox)$(TOOLSDIR)/uclpack --best --2e $< $@ >/dev/null 2>&1
187 $(BUILDDIR)/rombox.ucl: $(OBJDIR)/rombox.bin $(MAXOUTFILE)
188 $(call PRINTS,UCLPACK rombox)$(TOOLSDIR)/uclpack --none $< $@ >/dev/null 2>&1; \
189 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
190 if test $$? -ne 0; then \
191 echo "removing UCL file again, making it a fake one"; \
192 echo "fake" > $@; \
195 $(BUILDDIR)/rombox.iriver: $(OBJDIR)/rombox.bin
196 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
198 include $(TOOLSDIR)/make.inc
200 # apps/features.txt is a file that (is preprocessed and) lists named features
201 # based on defines in the config-*.h files. The named features will be passed
202 # to genlang and thus (translated) phrases can be used based on those names.
203 # button.h is included for the HAS_BUTTON_HOLD define.
206 $(OBJDIR)/features: features.txt
207 $(SILENT)mkdir -p `dirname $@`
208 $(SILENT)cat $< | $(HOSTCC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) \
209 $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -imacros "config.h" -imacros "button.h" - | \
210 grep -v "^\#" | grep -v "^$$" > $@; \
211 echo "" >/dev/null
213 $(OBJDIR)/lang.o: lang/$(LANGUAGE).lang $(OBJDIR)/features
214 $(SILENT)for f in `cat $(OBJDIR)/features`; do feat="$$feat:$$f" ; done; \
215 perl -s $(TOOLSDIR)/genlang -p=$(BUILDDIR)/lang -t=$(ARCHOS)$$feat $<
216 $(call PRINTS,CC lang.c)$(CC) $(CFLAGS) -c $(BUILDDIR)/lang.c -o $@
218 clean:
219 $(call PRINTS,cleaning apps)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/rockbox.asm \
220 $(OBJDIR)/rockbox.bin $(OBJDIR)/rockbox.elf $(OBJDIR)/*.map \
221 $(OBJDIR)/lang.o $(OBJDIR)/build.lang $(BUILDDIR)/lang.[ch] \
222 $(LINKFILE) $(BUILDDIR)/rockbox.ucl $(LINKROM) \
223 $(BUILDDIR)/rombox.ucl $(OBJDIR)/rombox.bin $(OBJDIR)/rombox.elf \
224 $(MAXOUTFILE) $(DEPFILE)
225 $(SILENT)$(MAKE) -C bitmaps/mono clean OBJDIR=$(OBJDIR)/bitmaps/mono
226 $(SILENT)$(MAKE) -C bitmaps/native clean OBJDIR=$(OBJDIR)/bitmaps/native
227 $(SILENT)$(MAKE) -C bitmaps/remote_mono clean OBJDIR=$(OBJDIR)/bitmaps/remote_mono
228 $(SILENT)$(MAKE) -C bitmaps/remote_native clean OBJDIR=$(OBJDIR)/bitmaps/remote_native
229 $(SILENT)$(MAKE) -C plugins clean OBJDIR=$(OBJDIR)/plugins
230 $(SILENT)$(MAKE) -C codecs clean OBJDIR=$(OBJDIR)/codecs
231 $(SILENT)rm -rf $(OBJDIR)/recorder $(OBJDIR)/player
232 $(SILENT)rm -rf $(BUILDDIR)/bitmaps
233 ifdef SIMVER
234 $(SILENT)$(MAKE) -C $(SIMDIR) clean
235 endif
237 ifneq ($(MAKECMDGOALS),clean)
238 -include $(DEPFILE)
239 endif