Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 1 | # __________ __ ___. |
| 2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 6 | # \/ \/ \/ \/ \/ |
| 7 | # $Id$ |
| 8 | # |
| 9 | |
Daniel Stenberg | 001f52b | 2005-05-07 23:16:25 +0000 | [diff] [blame] | 10 | INCLUDES= -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(OBJDIR) \ |
| 11 | -I$(BUILDDIR) |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 12 | |
Daniel Stenberg | e2c140e | 2005-01-28 23:25:40 +0000 | [diff] [blame] | 13 | DEPFILE = $(OBJDIR)/dep-bootloader |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 14 | LDS := $(FIRMDIR)/boot.lds |
| 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 |
| 25 | DIRS += $(APPEXTRA) |
| 26 | INCLUDES += -I$(APPEXTRA) |
| 27 | endif |
| 28 | |
| 29 | CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) \ |
| 30 | -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE} |
| 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 | |
| 38 | ifdef DEBUG |
| 39 | all: $(OBJDIR)/bootloader.elf |
| 40 | else |
Daniel Stenberg | 001f52b | 2005-05-07 23:16:25 +0000 | [diff] [blame] | 41 | all: $(BUILDDIR)/$(BINARY) $(FLASHFILE) |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 42 | endif |
| 43 | |
| 44 | dep: $(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 Stenberg | 001f52b | 2005-05-07 23:16:25 +0000 | [diff] [blame] | 56 | $(OBJDIR)/bootloader.elf : $(OBJS) $(LINKFILE) $(DEPFILE) |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 57 | @echo "LD bootloader.elf" |
Daniel Stenberg | 001f52b | 2005-05-07 23:16:25 +0000 | [diff] [blame] | 58 | $(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -L$(BUILDDIR)/firmware -lrockbox -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/bootloader.map |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 59 | |
| 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 Stenberg | 001f52b | 2005-05-07 23:16:25 +0000 | [diff] [blame] | 67 | $(BUILDDIR)/$(BINARY) : $(OBJDIR)/bootloader.bin |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 68 | @echo "Build bootloader file" |
| 69 | @$(MKFIRMWARE) $< $@ |
| 70 | |
| 71 | include $(TOOLSDIR)/make.inc |
| 72 | |
| 73 | clean: |
| 74 | @echo "cleaning bootloader" |
Daniel Stenberg | 001f52b | 2005-05-07 23:16:25 +0000 | [diff] [blame] | 75 | @-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/bootloader.asm \ |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 76 | $(OBJDIR)/bootloader.bin $(OBJDIR)/bootloader.elf $(OBJDIR)/*.map \ |
| 77 | $(LINKFILE) $(MAXOUTFILE) $(DEPFILE) |
| 78 | |
| 79 | -include $(DEPFILE) |