Jörg Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 1 | # __________ __ ___. |
| 2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 6 | # \/ \/ \/ \/ \/ |
| 7 | # $Id$ |
| 8 | # |
| 9 | |
Jens Arnold | 860e387 | 2006-11-27 02:34:22 +0000 | [diff] [blame] | 10 | INCLUDES= $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(OBJDIR) \ |
Jörg Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 11 | -I$(BUILDDIR) |
| 12 | |
| 13 | DEPFILE = $(OBJDIR)/dep-bootbox |
Karl Kurbjun | bef8e8c | 2008-03-13 04:03:55 +0000 | [diff] [blame] | 14 | LDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds |
Jörg Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 15 | |
| 16 | ifdef DEBUG |
| 17 | DEFINES := -DDEBUG |
| 18 | CFLAGS += -g |
| 19 | endif |
| 20 | |
| 21 | SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P -include "config.h" - ) |
| 22 | DIRS = . |
| 23 | |
| 24 | ifdef APPEXTRA |
Linus Nielsen Feltzing | dc9e201 | 2005-10-27 14:39:00 +0000 | [diff] [blame] | 25 | DIRS += $(subst :, ,$(APPEXTRA)) |
| 26 | INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA))) |
Jörg Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 27 | endif |
| 28 | |
| 29 | CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) \ |
Rafaël Carré | 5d236b2 | 2010-05-27 09:41:46 +0000 | [diff] [blame] | 30 | $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE} |
Jörg Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 31 | |
| 32 | OBJS := $(SRC:%.c=$(OBJDIR)/%.o) |
| 33 | SOURCES = $(SRC) |
| 34 | LINKFILE = $(OBJDIR)/linkage.lds |
| 35 | MAXINFILE = $(OBJDIR)/romstart.temp |
| 36 | MAXOUTFILE = $(OBJDIR)/romstart |
| 37 | |
Jens Arnold | 5d9f67d | 2005-07-11 20:36:12 +0000 | [diff] [blame] | 38 | LIBROCKBOX = $(BUILDDIR)/librockbox.a |
| 39 | |
Jörg Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 40 | all: $(BUILDDIR)/$(BINARY) $(FLASHFILE) |
| 41 | |
| 42 | dep: $(DEPFILE) |
| 43 | |
| 44 | $(LINKFILE): $(LDS) |
Jens Arnold | f40f0de | 2006-10-30 01:40:20 +0000 | [diff] [blame] | 45 | $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@ |
Jörg Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 46 | |
| 47 | $(MAXOUTFILE): |
Jens Arnold | f40f0de | 2006-10-30 01:40:20 +0000 | [diff] [blame] | 48 | $(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 Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 52 | |
Jens Arnold | 5d9f67d | 2005-07-11 20:36:12 +0000 | [diff] [blame] | 53 | $(OBJDIR)/bootbox.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) |
Jens Arnold | f40f0de | 2006-10-30 01:40:20 +0000 | [diff] [blame] | 54 | $(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 Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 55 | |
| 56 | $(OBJDIR)/bootbox.bin : $(OBJDIR)/bootbox.elf |
Jens Arnold | f40f0de | 2006-10-30 01:40:20 +0000 | [diff] [blame] | 57 | $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@ |
Jörg Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 58 | |
| 59 | $(OBJDIR)/bootbox.asm: $(OBJDIR)/bootbox.bin |
| 60 | $(TOOLSDIR)/sh2d -sh1 $< > $@ |
| 61 | |
| 62 | $(BUILDDIR)/$(BINARY) : $(OBJDIR)/bootbox.bin |
Jens Arnold | f40f0de | 2006-10-30 01:40:20 +0000 | [diff] [blame] | 63 | $(call PRINTS,Build bootbox file)$(MKFIRMWARE) $< $@ |
Jörg Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 64 | |
| 65 | $(FLASHFILE): $(OBJDIR)/bootbox.bin |
Jens Arnold | f40f0de | 2006-10-30 01:40:20 +0000 | [diff] [blame] | 66 | $(call PRINTS,UCLPACK bootbox)$(TOOLSDIR)/uclpack --best --2e $< $@ >/dev/null 2>&1; |
Jörg Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 67 | |
| 68 | include $(TOOLSDIR)/make.inc |
| 69 | |
| 70 | clean: |
Jens Arnold | f40f0de | 2006-10-30 01:40:20 +0000 | [diff] [blame] | 71 | $(call PRINTS,cleaning bootbox)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/bootbox.asm $(OBJDIR)/rockbox.ucl \ |
Jörg Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 72 | $(OBJDIR)/bootbox.bin $(OBJDIR)/bootbox.elf $(OBJDIR)/*.map \ |
Jens Arnold | 204814f | 2005-07-11 20:55:31 +0000 | [diff] [blame] | 73 | $(LINKFILE) $(MAXOUTFILE) $(DEPFILE) $(FLASHFILE) |
Jörg Hohensohn | 9cfa47a | 2005-06-21 00:11:14 +0000 | [diff] [blame] | 74 | |
| 75 | -include $(DEPFILE) |