blob: d1f580a52ef6d88cdb331978115c7be8afd038f3 [file] [log] [blame]
Björn Stenbergc6b3d382008-11-20 11:27:31 +00001# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
Björn Stenberga091d202008-11-25 19:54:23 +00007# $Id$
Björn Stenbergc6b3d382008-11-20 11:27:31 +00008#
9
10INCLUDES += -I$(APPSDIR)
11SRC += $(call preprocess, $(APPSDIR)/SOURCES)
12
Jens Arnold91ce4b22011-06-19 17:23:18 +000013CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h
Björn Stenbergc6b3d382008-11-20 11:27:31 +000014BOOTLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/boot.lds
15BOOTLINK := $(BUILDDIR)/boot.link
16
17CLEANOBJS += $(BUILDDIR)/bootloader.*
18
19.SECONDEXPANSION:
20
Jens Arnold91ce4b22011-06-19 17:23:18 +000021$(BOOTLINK): $(BOOTLDS) $(CONFIGFILE)
Björn Stenbergc6b3d382008-11-20 11:27:31 +000022 $(call PRINTS,PP $(@F))
23 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
24
Thomas Martitz045c69c2012-03-26 23:55:02 +020025$(BUILDDIR)/bootloader.elf: $$(OBJ) $(FIRMLIB) $(CORE_LIBS) $$(BOOTLINK)
Björn Stenbergc6b3d382008-11-20 11:27:31 +000026 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
Thomas Martitz045c69c2012-03-26 23:55:02 +020027 -L$(BUILDDIR)/firmware -lfirmware \
28 -L$(BUILDDIR)/lib $(call a2lnk, $(CORE_LIBS)) \
29 -lgcc -T$(BOOTLINK) $(GLOBAL_LDOPTS) \
Marcin Bukat164cb212012-02-22 09:01:09 +010030 -Wl,--gc-sections -Wl,-Map,$(BUILDDIR)/bootloader.map
Björn Stenbergc6b3d382008-11-20 11:27:31 +000031
32$(BUILDDIR)/bootloader.bin : $(BUILDDIR)/bootloader.elf
Thomas Martitz4b56ee02012-04-04 21:43:22 +020033 $(call PRINTS,OC $(@F))$(call objcopy,$<,$@)
Björn Stenbergc6b3d382008-11-20 11:27:31 +000034
35$(BUILDDIR)/bootloader.asm: $(BUILDDIR)/bootloader.bin
36 $(TOOLSDIR)/sh2d -sh1 $< > $@
37
38$(BUILDDIR)/$(BINARY) : $(BUILDDIR)/bootloader.bin
39 $(call PRINTS,Build bootloader file)$(MKFIRMWARE) $< $@
40