blob: 4c63cfea18d13ba6e3718a2fbd3b5f1525b85ee8 [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) \
Daniel Stenberg001f52b2005-05-07 23:16:25 +000011 -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
Jonathan Gordon9db22ef2007-09-09 11:20:20 +000021SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - )
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000022DIRS = .
23
24ifdef APPEXTRA
Linus Nielsen Feltzingdc9e2012005-10-27 14:39:00 +000025 DIRS += $(subst :, ,$(APPEXTRA))
26 INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA)))
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000027endif
28
Linus Nielsen Feltzinga2e8cf72005-07-15 07:42:25 +000029ifndef VERSION
30VERSION=$(shell date +%y%m%d-%H%M)
31endif
32
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000033CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) \
34 -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE}
35
36OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
37SOURCES = $(SRC)
38LINKFILE = $(OBJDIR)/linkage.lds
39MAXINFILE = $(OBJDIR)/romstart.temp
40MAXOUTFILE = $(OBJDIR)/romstart
41
Jens Arnold5d9f67d2005-07-11 20:36:12 +000042LIBROCKBOX = $(BUILDDIR)/librockbox.a
43
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000044ifdef DEBUG
45all: $(OBJDIR)/bootloader.elf
46else
Daniel Stenberg001f52b2005-05-07 23:16:25 +000047all: $(BUILDDIR)/$(BINARY) $(FLASHFILE)
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000048endif
49
50dep: $(DEPFILE)
51
52$(LINKFILE): $(LDS)
Jonathan Gordon9db22ef2007-09-09 11:20:20 +000053 $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) $(DEFINES) -E -P $(ROMBUILD) - >$@
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000054
55$(MAXOUTFILE):
Jens Arnoldf40f0de2006-10-30 01:40:20 +000056 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
57 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
58 $(SILENT)cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
59 $(SILENT)rm $(MAXINFILE)
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000060
Jens Arnold5d9f67d2005-07-11 20:36:12 +000061$(OBJDIR)/bootloader.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX)
Linus Nielsen Feltzingb58e4e72007-02-22 10:05:39 +000062 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Wl,--gc-sections -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 +000063
64$(OBJDIR)/bootloader.bin : $(OBJDIR)/bootloader.elf
Jens Arnoldf40f0de2006-10-30 01:40:20 +000065 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000066
67$(OBJDIR)/bootloader.asm: $(OBJDIR)/bootloader.bin
68 $(TOOLSDIR)/sh2d -sh1 $< > $@
69
Daniel Stenberg001f52b2005-05-07 23:16:25 +000070$(BUILDDIR)/$(BINARY) : $(OBJDIR)/bootloader.bin
Jens Arnoldf40f0de2006-10-30 01:40:20 +000071 $(call PRINTS,Build bootloader file)$(MKFIRMWARE) $< $@
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000072
73include $(TOOLSDIR)/make.inc
74
75clean:
Jens Arnoldf40f0de2006-10-30 01:40:20 +000076 $(call PRINTS,cleaning bootloader)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/bootloader.asm \
Linus Nielsen Feltzingd3971452005-01-28 12:51:10 +000077 $(OBJDIR)/bootloader.bin $(OBJDIR)/bootloader.elf $(OBJDIR)/*.map \
78 $(LINKFILE) $(MAXOUTFILE) $(DEPFILE)
79
80-include $(DEPFILE)