Merge branch 'master' into pandora-port
[maemo-rb.git] / bootloader / Makefile
blob07f347ee165e4e6cee261d63a95a703b8c2580a4
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 INCLUDES= $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(OBJDIR) \
11 -I$(BUILDDIR) -I$(BUILDDIR)/bitmaps
13 DEPFILE = $(OBJDIR)/dep-bootloader
14 LDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/boot.lds
16 # Set up the bitmap libraries
17 BITMAPLIBS =
18 LINKBITMAPS =
19 ifneq ($(strip $(BMP2RB_MONO)),)
20 BITMAPLIBS += $(BUILDDIR)/libbitmapsmono.a
21 LINKBITMAPS += -lbitmapsmono
22 endif
23 ifneq ($(strip $(BMP2RB_NATIVE)),)
24 BITMAPLIBS += $(BUILDDIR)/libbitmapsnative.a
25 LINKBITMAPS += -lbitmapsnative
26 endif
27 ifneq ($(strip $(BMP2RB_REMOTEMONO)),)
28 BITMAPLIBS += $(BUILDDIR)/libbitmapsremotemono.a
29 LINKBITMAPS += -lbitmapsremotemono
30 endif
31 ifneq ($(strip $(BMP2RB_REMOTENATIVE)),)
32 BITMAPLIBS += $(BUILDDIR)/libbitmapsremotenative.a
33 LINKBITMAPS += -lbitmapsremotenative
34 endif
36 ifdef DEBUG
37 DEFINES := -DDEBUG
38 CFLAGS += -g
39 endif
41 SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - )
42 DIRS = .
44 ifdef APPEXTRA
45 DIRS += $(subst :, ,$(APPEXTRA))
46 INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA)))
47 endif
49 CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) $(EXTRA_DEFINES) \
50 -DMEM=${MEMORYSIZE}
52 OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
53 SOURCES = $(SRC)
54 LINKFILE = $(OBJDIR)/linkage.lds
55 MAXINFILE = $(OBJDIR)/romstart.temp
56 MAXOUTFILE = $(OBJDIR)/romstart
58 LIBROCKBOX = $(BUILDDIR)/librockbox.a
60 ifdef DEBUG
61 all: $(OBJDIR)/bootloader.elf
62 else
63 all: $(BUILDDIR)/$(BINARY) $(FLASHFILE)
64 endif
66 $(DEPFILE): $(BITMAPLIBS)
68 dep: $(DEPFILE)
70 $(LINKFILE): $(LDS)
71 $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) $(DEFINES) -E -P $(ROMBUILD) - >$@
73 $(MAXOUTFILE):
74 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
75 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
76 $(SILENT)cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
77 $(SILENT)rm $(MAXINFILE)
79 build-bitmapsmono:
80 $(call PRINTS,MAKE in bitmaps/mono)$(MAKE) -C ../apps/bitmaps/mono OBJDIR=$(OBJDIR)/bitmaps/mono
82 build-bitmapsnative:
83 $(call PRINTS,MAKE in bitmaps/native)$(MAKE) -C ../apps/bitmaps/native OBJDIR=$(OBJDIR)/bitmaps/native
85 build-bitmapsremotemono:
86 $(call PRINTS,MAKE in bitmaps/remote_mono)$(MAKE) -C ../apps/bitmaps/remote_mono OBJDIR=$(OBJDIR)/bitmaps/remote_mono
88 build-bitmapsremotenative:
89 $(call PRINTS,MAKE in bitmaps/remote_native)$(MAKE) -C ../apps/bitmaps/remote_native OBJDIR=$(OBJDIR)/bitmaps/remote_native
91 $(BITMAPLIBS): $(BUILDDIR)/lib%.a: build-%
93 $(OBJDIR)/bootloader.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) $(BITMAPLIBS)
94 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Wl,--gc-sections -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -L$(BUILDDIR)/firmware -lrockbox $(LINKBITMAPS) -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/bootloader.map
96 $(OBJDIR)/bootloader.bin : $(OBJDIR)/bootloader.elf
97 $(call PRINTS,OBJCOPY $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
99 $(OBJDIR)/bootloader.asm: $(OBJDIR)/bootloader.bin
100 $(TOOLSDIR)/sh2d -sh1 $< > $@
102 $(BUILDDIR)/$(BINARY) : $(OBJDIR)/bootloader.bin
103 $(call PRINTS,Build bootloader file)$(MKFIRMWARE) $< $@
105 include $(TOOLSDIR)/make.inc
107 clean:
108 $(call PRINTS,cleaning bootloader)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/bootloader.asm \
109 $(OBJDIR)/bootloader.bin $(OBJDIR)/bootloader.elf $(OBJDIR)/*.map \
110 $(LINKFILE) $(MAXOUTFILE) $(DEPFILE)
111 $(SILENT)$(MAKE) -C bitmaps/mono clean OBJDIR=$(OBJDIR)/bitmaps/mono
112 $(SILENT)$(MAKE) -C bitmaps/native clean OBJDIR=$(OBJDIR)/bitmaps/native
113 $(SILENT)$(MAKE) -C bitmaps/remote_mono clean OBJDIR=$(OBJDIR)/bitmaps/remote_mono
114 $(SILENT)$(MAKE) -C bitmaps/remote_native clean OBJDIR=$(OBJDIR)/bitmaps/remote_native
116 -include $(DEPFILE)