blob: 754f95dd4926553f7cbd350c6b4ba8cc9adef73e [file] [log] [blame]
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +00001# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
7# $Id$
8#
9
Jens Arnold860e3872006-11-27 02:34:22 +000010INCLUDES= $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(OBJDIR) \
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000011 -I$(BUILDDIR)
12
13DEPFILE = $(OBJDIR)/dep-bootbox
Karl Kurbjunbef8e8c2008-03-13 04:03:55 +000014LDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000015
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
Linus Nielsen Feltzingdc9e2012005-10-27 14:39:00 +000025 DIRS += $(subst :, ,$(APPEXTRA))
26 INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA)))
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000027endif
28
29CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) \
Rafaël Carré5d236b22010-05-27 09:41:46 +000030 $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE}
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000031
32OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
33SOURCES = $(SRC)
34LINKFILE = $(OBJDIR)/linkage.lds
35MAXINFILE = $(OBJDIR)/romstart.temp
36MAXOUTFILE = $(OBJDIR)/romstart
37
Jens Arnold5d9f67d2005-07-11 20:36:12 +000038LIBROCKBOX = $(BUILDDIR)/librockbox.a
39
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000040all: $(BUILDDIR)/$(BINARY) $(FLASHFILE)
41
42dep: $(DEPFILE)
43
44$(LINKFILE): $(LDS)
Jens Arnoldf40f0de2006-10-30 01:40:20 +000045 $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000046
47$(MAXOUTFILE):
Jens Arnoldf40f0de2006-10-30 01:40:20 +000048 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
49 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
50 $(SILENT)cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
51 $(SILENT)rm $(MAXINFILE)
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000052
Jens Arnold5d9f67d2005-07-11 20:36:12 +000053$(OBJDIR)/bootbox.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX)
Jens Arnoldf40f0de2006-10-30 01:40:20 +000054 $(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)/bootbox.map
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000055
56$(OBJDIR)/bootbox.bin : $(OBJDIR)/bootbox.elf
Jens Arnoldf40f0de2006-10-30 01:40:20 +000057 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000058
59$(OBJDIR)/bootbox.asm: $(OBJDIR)/bootbox.bin
60 $(TOOLSDIR)/sh2d -sh1 $< > $@
61
62$(BUILDDIR)/$(BINARY) : $(OBJDIR)/bootbox.bin
Jens Arnoldf40f0de2006-10-30 01:40:20 +000063 $(call PRINTS,Build bootbox file)$(MKFIRMWARE) $< $@
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000064
65$(FLASHFILE): $(OBJDIR)/bootbox.bin
Jens Arnoldf40f0de2006-10-30 01:40:20 +000066 $(call PRINTS,UCLPACK bootbox)$(TOOLSDIR)/uclpack --best --2e $< $@ >/dev/null 2>&1;
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000067
68include $(TOOLSDIR)/make.inc
69
70clean:
Jens Arnoldf40f0de2006-10-30 01:40:20 +000071 $(call PRINTS,cleaning bootbox)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/bootbox.asm $(OBJDIR)/rockbox.ucl \
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000072 $(OBJDIR)/bootbox.bin $(OBJDIR)/bootbox.elf $(OBJDIR)/*.map \
Jens Arnold204814f2005-07-11 20:55:31 +000073 $(LINKFILE) $(MAXOUTFILE) $(DEPFILE) $(FLASHFILE)
Jörg Hohensohn9cfa47a2005-06-21 00:11:14 +000074
75-include $(DEPFILE)