Wavview plugin: minor speed increase
[maemo-rb.git] / bootloader / Makefile
blob342cdc5861f7d659385cdf10bd95acb473bc2e89
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 INCLUDES= $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(OBJDIR) \
11 -I$(BUILDDIR)
13 DEPFILE = $(OBJDIR)/dep-bootloader
14 LDS := $(FIRMDIR)/boot.lds
16 ifdef DEBUG
17 DEFINES := -DDEBUG
18 CFLAGS += -g
19 endif
21 SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P -include "config.h" - )
22 DIRS = .
24 ifdef APPEXTRA
25 DIRS += $(subst :, ,$(APPEXTRA))
26 INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA)))
27 endif
29 ifndef VERSION
30 VERSION=$(shell date +%y%m%d-%H%M)
31 endif
33 CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) \
34 -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE}
36 OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
37 SOURCES = $(SRC)
38 LINKFILE = $(OBJDIR)/linkage.lds
39 MAXINFILE = $(OBJDIR)/romstart.temp
40 MAXOUTFILE = $(OBJDIR)/romstart
42 LIBROCKBOX = $(BUILDDIR)/librockbox.a
44 ifdef DEBUG
45 all: $(OBJDIR)/bootloader.elf
46 else
47 all: $(BUILDDIR)/$(BINARY) $(FLASHFILE)
48 endif
50 dep: $(DEPFILE)
52 $(LINKFILE): $(LDS)
53 $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
55 $(MAXOUTFILE):
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)
61 $(OBJDIR)/bootloader.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX)
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
64 $(OBJDIR)/bootloader.bin : $(OBJDIR)/bootloader.elf
65 $(call PRINTS,OBJCOPY $(@F))$(OC) -O binary $< $@
67 $(OBJDIR)/bootloader.asm: $(OBJDIR)/bootloader.bin
68 $(TOOLSDIR)/sh2d -sh1 $< > $@
70 $(BUILDDIR)/$(BINARY) : $(OBJDIR)/bootloader.bin
71 $(call PRINTS,Build bootloader file)$(MKFIRMWARE) $< $@
73 include $(TOOLSDIR)/make.inc
75 clean:
76 $(call PRINTS,cleaning bootloader)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/bootloader.asm \
77 $(OBJDIR)/bootloader.bin $(OBJDIR)/bootloader.elf $(OBJDIR)/*.map \
78 $(LINKFILE) $(MAXOUTFILE) $(DEPFILE)
80 -include $(DEPFILE)