blob: 6039680096ed968c2c2dee5de235e88fe27e9a5c [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
Daniel Stenberg001f52b2005-05-07 23:16:25 +000010INCLUDES= -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(OBJDIR) \
11 -I$(BUILDDIR)
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000012
Daniel Stenberge2c140e2005-01-28 23:25:40 +000013DEPFILE = $(OBJDIR)/dep-bootloader
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000014LDS := $(FIRMDIR)/boot.lds
15
16ifdef DEBUG
17 DEFINES := -DDEBUG
18 CFLAGS += -g
19endif
20
21SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P -include "config.h" - )
22DIRS = .
23
24ifdef APPEXTRA
25 DIRS += $(APPEXTRA)
26 INCLUDES += -I$(APPEXTRA)
27endif
28
29CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) \
30 -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE}
31
32OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
33SOURCES = $(SRC)
34LINKFILE = $(OBJDIR)/linkage.lds
35MAXINFILE = $(OBJDIR)/romstart.temp
36MAXOUTFILE = $(OBJDIR)/romstart
37
38ifdef DEBUG
39all: $(OBJDIR)/bootloader.elf
40else
Daniel Stenberg001f52b2005-05-07 23:16:25 +000041all: $(BUILDDIR)/$(BINARY) $(FLASHFILE)
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000042endif
43
44dep: $(DEPFILE)
45
46$(LINKFILE): $(LDS)
47 @echo "Build LDS file"
48 @cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
49
50$(MAXOUTFILE):
51 @echo '#include "config.h"' > $(MAXINFILE)
52 @echo "ROM_START" >> $(MAXINFILE)
53 @cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
54 @rm $(MAXINFILE)
55
Daniel Stenberg001f52b2005-05-07 23:16:25 +000056$(OBJDIR)/bootloader.elf : $(OBJS) $(LINKFILE) $(DEPFILE)
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000057 @echo "LD bootloader.elf"
Daniel Stenberg001f52b2005-05-07 23:16:25 +000058 $(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -L$(BUILDDIR)/firmware -lrockbox -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/bootloader.map
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000059
60$(OBJDIR)/bootloader.bin : $(OBJDIR)/bootloader.elf
61 @echo "OBJCOPY $<"
62 @$(OC) -O binary $< $@
63
64$(OBJDIR)/bootloader.asm: $(OBJDIR)/bootloader.bin
65 $(TOOLSDIR)/sh2d -sh1 $< > $@
66
Daniel Stenberg001f52b2005-05-07 23:16:25 +000067$(BUILDDIR)/$(BINARY) : $(OBJDIR)/bootloader.bin
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000068 @echo "Build bootloader file"
69 @$(MKFIRMWARE) $< $@
70
71include $(TOOLSDIR)/make.inc
72
73clean:
74 @echo "cleaning bootloader"
Daniel Stenberg001f52b2005-05-07 23:16:25 +000075 @-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/bootloader.asm \
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000076 $(OBJDIR)/bootloader.bin $(OBJDIR)/bootloader.elf $(OBJDIR)/*.map \
77 $(LINKFILE) $(MAXOUTFILE) $(DEPFILE)
78
79-include $(DEPFILE)