blob: 3272510051781863bb0ab4bf94207858fe7a80c8 [file] [log] [blame]
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +00001# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
7# $Id$
8#
9
Linus Nielsen Feltzingeed02be2006-03-07 12:45:45 +000010INCLUDES= $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(OBJDIR) \
Barry Wardell940091a2008-05-05 12:05:00 +000011 -I$(BUILDDIR) -I$(BUILDDIR)/bitmaps
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000012
Daniel Stenberge2c140e2005-01-28 23:25:40 +000013DEPFILE = $(OBJDIR)/dep-bootloader
Marcoen Hirschberg82c52302008-03-27 23:58:03 +000014LDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/boot.lds
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000015
Barry Wardell940091a2008-05-05 12:05:00 +000016# Set up the bitmap libraries
17BITMAPLIBS =
18LINKBITMAPS =
19ifneq ($(strip $(BMP2RB_MONO)),)
20 BITMAPLIBS += $(BUILDDIR)/libbitmapsmono.a
21 LINKBITMAPS += -lbitmapsmono
22endif
23ifneq ($(strip $(BMP2RB_NATIVE)),)
24 BITMAPLIBS += $(BUILDDIR)/libbitmapsnative.a
25 LINKBITMAPS += -lbitmapsnative
26endif
27ifneq ($(strip $(BMP2RB_REMOTEMONO)),)
28 BITMAPLIBS += $(BUILDDIR)/libbitmapsremotemono.a
29 LINKBITMAPS += -lbitmapsremotemono
30endif
31ifneq ($(strip $(BMP2RB_REMOTENATIVE)),)
32 BITMAPLIBS += $(BUILDDIR)/libbitmapsremotenative.a
33 LINKBITMAPS += -lbitmapsremotenative
34endif
35
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000036ifdef DEBUG
37 DEFINES := -DDEBUG
38 CFLAGS += -g
39endif
40
Jonathan Gordon9db22ef2007-09-09 11:20:20 +000041SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - )
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000042DIRS = .
43
44ifdef APPEXTRA
Linus Nielsen Feltzingdc9e2012005-10-27 14:39:00 +000045 DIRS += $(subst :, ,$(APPEXTRA))
46 INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA)))
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000047endif
48
Linus Nielsen Feltzinga2e8cf72005-07-15 07:42:25 +000049ifndef VERSION
50VERSION=$(shell date +%y%m%d-%H%M)
51endif
52
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000053CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) \
54 -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE}
55
56OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
57SOURCES = $(SRC)
58LINKFILE = $(OBJDIR)/linkage.lds
59MAXINFILE = $(OBJDIR)/romstart.temp
60MAXOUTFILE = $(OBJDIR)/romstart
61
Jens Arnold5d9f67d2005-07-11 20:36:12 +000062LIBROCKBOX = $(BUILDDIR)/librockbox.a
63
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000064ifdef DEBUG
65all: $(OBJDIR)/bootloader.elf
66else
Daniel Stenberg001f52b2005-05-07 23:16:25 +000067all: $(BUILDDIR)/$(BINARY) $(FLASHFILE)
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000068endif
69
Barry Wardell940091a2008-05-05 12:05:00 +000070$(DEPFILE): $(BITMAPLIBS)
71
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000072dep: $(DEPFILE)
73
74$(LINKFILE): $(LDS)
Jonathan Gordon9db22ef2007-09-09 11:20:20 +000075 $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) $(DEFINES) -E -P $(ROMBUILD) - >$@
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000076
77$(MAXOUTFILE):
Jens Arnoldf40f0de2006-10-30 01:40:20 +000078 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
79 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
80 $(SILENT)cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
81 $(SILENT)rm $(MAXINFILE)
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000082
Barry Wardell940091a2008-05-05 12:05:00 +000083build-bitmapsmono:
84 $(call PRINTS,MAKE in bitmaps/mono)$(MAKE) -C ../apps/bitmaps/mono OBJDIR=$(OBJDIR)/bitmaps/mono
85
86build-bitmapsnative:
87 $(call PRINTS,MAKE in bitmaps/native)$(MAKE) -C ../apps/bitmaps/native OBJDIR=$(OBJDIR)/bitmaps/native
88
89build-bitmapsremotemono:
90 $(call PRINTS,MAKE in bitmaps/remote_mono)$(MAKE) -C ../apps/bitmaps/remote_mono OBJDIR=$(OBJDIR)/bitmaps/remote_mono
91
92build-bitmapsremotenative:
93 $(call PRINTS,MAKE in bitmaps/remote_native)$(MAKE) -C ../apps/bitmaps/remote_native OBJDIR=$(OBJDIR)/bitmaps/remote_native
94
95$(BITMAPLIBS): $(BUILDDIR)/lib%.a: build-%
96
97$(OBJDIR)/bootloader.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) $(BITMAPLIBS)
98 $(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
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000099
100$(OBJDIR)/bootloader.bin : $(OBJDIR)/bootloader.elf
Maurus Cuelenaere06e3c662008-08-03 19:32:14 +0000101 $(call PRINTS,OBJCOPY $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +0000102
103$(OBJDIR)/bootloader.asm: $(OBJDIR)/bootloader.bin
104 $(TOOLSDIR)/sh2d -sh1 $< > $@
105
Daniel Stenberg001f52b2005-05-07 23:16:25 +0000106$(BUILDDIR)/$(BINARY) : $(OBJDIR)/bootloader.bin
Jens Arnoldf40f0de2006-10-30 01:40:20 +0000107 $(call PRINTS,Build bootloader file)$(MKFIRMWARE) $< $@
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +0000108
109include $(TOOLSDIR)/make.inc
110
111clean:
Jens Arnoldf40f0de2006-10-30 01:40:20 +0000112 $(call PRINTS,cleaning bootloader)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/bootloader.asm \
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +0000113 $(OBJDIR)/bootloader.bin $(OBJDIR)/bootloader.elf $(OBJDIR)/*.map \
114 $(LINKFILE) $(MAXOUTFILE) $(DEPFILE)
Barry Wardell940091a2008-05-05 12:05:00 +0000115 $(SILENT)$(MAKE) -C bitmaps/mono clean OBJDIR=$(OBJDIR)/bitmaps/mono
116 $(SILENT)$(MAKE) -C bitmaps/native clean OBJDIR=$(OBJDIR)/bitmaps/native
117 $(SILENT)$(MAKE) -C bitmaps/remote_mono clean OBJDIR=$(OBJDIR)/bitmaps/remote_mono
118 $(SILENT)$(MAKE) -C bitmaps/remote_native clean OBJDIR=$(OBJDIR)/bitmaps/remote_native
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +0000119
120-include $(DEPFILE)