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 | |
Linus Nielsen Feltzing | eed02be | 2006-03-07 12:45:45 +0000 | [diff] [blame] | 10 | INCLUDES= $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(OBJDIR) \ |
Daniel Stenberg | 001f52b | 2005-05-07 23:16:25 +0000 | [diff] [blame] | 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 | |
Jonathan Gordon | 9db22ef | 2007-09-09 11:20:20 +0000 | [diff] [blame] | 21 | SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - ) |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 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))) |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 27 | endif |
| 28 | |
Linus Nielsen Feltzing | a2e8cf7 | 2005-07-15 07:42:25 +0000 | [diff] [blame] | 29 | ifndef VERSION |
| 30 | VERSION=$(shell date +%y%m%d-%H%M) |
| 31 | endif |
| 32 | |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 33 | CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) \ |
| 34 | -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE} |
| 35 | |
| 36 | OBJS := $(SRC:%.c=$(OBJDIR)/%.o) |
| 37 | SOURCES = $(SRC) |
| 38 | LINKFILE = $(OBJDIR)/linkage.lds |
| 39 | MAXINFILE = $(OBJDIR)/romstart.temp |
| 40 | MAXOUTFILE = $(OBJDIR)/romstart |
| 41 | |
Jens Arnold | 5d9f67d | 2005-07-11 20:36:12 +0000 | [diff] [blame] | 42 | LIBROCKBOX = $(BUILDDIR)/librockbox.a |
| 43 | |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 44 | ifdef DEBUG |
| 45 | all: $(OBJDIR)/bootloader.elf |
| 46 | else |
Daniel Stenberg | 001f52b | 2005-05-07 23:16:25 +0000 | [diff] [blame] | 47 | all: $(BUILDDIR)/$(BINARY) $(FLASHFILE) |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 48 | endif |
| 49 | |
| 50 | dep: $(DEPFILE) |
| 51 | |
| 52 | $(LINKFILE): $(LDS) |
Jonathan Gordon | 9db22ef | 2007-09-09 11:20:20 +0000 | [diff] [blame] | 53 | $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) $(DEFINES) -E -P $(ROMBUILD) - >$@ |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 54 | |
| 55 | $(MAXOUTFILE): |
Jens Arnold | f40f0de | 2006-10-30 01:40:20 +0000 | [diff] [blame] | 56 | $(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 Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 60 | |
Jens Arnold | 5d9f67d | 2005-07-11 20:36:12 +0000 | [diff] [blame] | 61 | $(OBJDIR)/bootloader.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) |
Linus Nielsen Feltzing | b58e4e7 | 2007-02-22 10:05:39 +0000 | [diff] [blame] | 62 | $(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 Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 63 | |
| 64 | $(OBJDIR)/bootloader.bin : $(OBJDIR)/bootloader.elf |
Jens Arnold | f40f0de | 2006-10-30 01:40:20 +0000 | [diff] [blame] | 65 | $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@ |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 66 | |
| 67 | $(OBJDIR)/bootloader.asm: $(OBJDIR)/bootloader.bin |
| 68 | $(TOOLSDIR)/sh2d -sh1 $< > $@ |
| 69 | |
Daniel Stenberg | 001f52b | 2005-05-07 23:16:25 +0000 | [diff] [blame] | 70 | $(BUILDDIR)/$(BINARY) : $(OBJDIR)/bootloader.bin |
Jens Arnold | f40f0de | 2006-10-30 01:40:20 +0000 | [diff] [blame] | 71 | $(call PRINTS,Build bootloader file)$(MKFIRMWARE) $< $@ |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 72 | |
| 73 | include $(TOOLSDIR)/make.inc |
| 74 | |
| 75 | clean: |
Jens Arnold | f40f0de | 2006-10-30 01:40:20 +0000 | [diff] [blame] | 76 | $(call PRINTS,cleaning bootloader)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/bootloader.asm \ |
Linus Nielsen Feltzing | d397145 | 2005-01-28 12:51:10 +0000 | [diff] [blame] | 77 | $(OBJDIR)/bootloader.bin $(OBJDIR)/bootloader.elf $(OBJDIR)/*.map \ |
| 78 | $(LINKFILE) $(MAXOUTFILE) $(DEPFILE) |
| 79 | |
| 80 | -include $(DEPFILE) |