summaryrefslogtreecommitdiff
path: root/utils/mks5lboot/dualboot/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'utils/mks5lboot/dualboot/Makefile')
-rw-r--r--utils/mks5lboot/dualboot/Makefile97
1 files changed, 97 insertions, 0 deletions
diff --git a/utils/mks5lboot/dualboot/Makefile b/utils/mks5lboot/dualboot/Makefile
new file mode 100644
index 0000000000..51ce816ca0
--- /dev/null
+++ b/utils/mks5lboot/dualboot/Makefile
@@ -0,0 +1,97 @@
1# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
7# $Id$
8#
9ifndef V
10SILENT = @
11endif
12
13CC = gcc
14LD = ld
15OC = objcopy
16CROSS ?= arm-elf-eabi-
17
18ROOTDIR = ../../..
19FIRMDIR = $(ROOTDIR)/firmware
20FWARM = $(FIRMDIR)/target/arm
21FW8702 = $(FWARM)/s5l8702
22BUILDDIR = build/
23LINKFILE = dualboot.lds
24
25# Edit the following variables when adding a new target.
26# mks5lboot.c also needs to be edited to refer to these
27# To add a new target x you need to:
28# 1) add x to the list in TARGETS
29# 2) create a variable named OPT_x of the form:
30# OPT_x=target specific defines
31TARGETS = ipod6g
32OPT_ipod6g = -DIPOD_6G -DMEMORYSIZE=64
33
34LOADERS = install uninstall
35OPT_install =
36OPT_uninstall = -DDUALBOOT_UNINSTALL
37
38# target/loader specific options
39$(foreach l, $(LOADERS),$(foreach t, $(TARGETS),\
40 $(eval OPT_$(l)_$(t) = $(OPT_$(l)) $(OPT_$(t)))))
41
42DEFINES = -DBOOTLOADER
43
44SOURCES = init.S dualboot.c
45SOURCES += $(ROOTDIR)/lib/arm_support/support-arm.S
46SOURCES += $(wildcard $(FIRMDIR)/asm/mem*.c $(FIRMDIR)/libc/mem*.c)
47SOURCES += $(addprefix $(FWARM)/, mmu-arm.S)
48SOURCES += $(addprefix $(FW8702)/, clocking-s5l8702.c spi-s5l8702.c nor-s5l8702.c crypto-s5l8702.c)
49# target/loader specific sources
50SRCTARGET = piezo-.c
51$(foreach l, $(LOADERS), $(foreach t, $(TARGETS),\
52 $(eval SRC_$(l)_$(t) = $(addprefix $(FW8702)/$(t)/, $(subst -.,-$(subst ipod,,$(t)).,$(SRCTARGET))))))
53
54INCLUDES += -I. -I.. -I$(FIRMDIR) -I$(FWARM) -I$(FW8702)
55INCLUDES += $(addprefix -I$(FIRMDIR)/, export include libc/include kernel/include)
56# target/loader specific includes
57$(foreach l,$(LOADERS),$(foreach t,$(TARGETS),$(eval INC_$(l)_$(t) = -I$(FW8702)/$(t))))
58
59CFLAGS = $(INCLUDES) -mcpu=arm926ej-s -std=gnu99 -nostdlib -ffreestanding -Os -W -Wall\
60 -Wundef -Wstrict-prototypes -ffunction-sections -fdata-sections -Wl,--gc-sections $(DEFINES)
61
62# Build filenames prefix
63PFX = dualboot_
64
65BOOTBINS = $(foreach l, $(LOADERS),$(foreach t, $(TARGETS),$(PFX)$(l)_$(t).arm-bin))
66
67OUTPUTDUALBOOT = ../dualboot.h ../dualboot.c
68OUTPUTDEBUG = $(BOOTBINS:%.arm-bin=$(BUILDDIR)%.arm-elf) $(BOOTBINS:%.arm-bin=$(BUILDDIR)%.lds)
69
70
71all: $(BUILDDIR) $(OUTPUTDUALBOOT)
72
73$(BUILDDIR)$(PFX)%.lds: $(LINKFILE)
74 @echo Creating $@
75 $(SILENT)$(CROSS)$(CC) $(INC_$*) $(CFLAGS) $(OPT_$*) -E -x c - < $< | sed '/#/d' > $@
76
77$(BUILDDIR)$(PFX)%.arm-elf: $(BUILDDIR)$(PFX)%.lds $(SOURCES)
78 @echo CC -T $(notdir $^ $(SRC_$*))
79 $(SILENT)$(CROSS)$(CC) $(INC_$*) $(CFLAGS) $(OPT_$*) -o $@ -T$^ $(SRC_$*)
80
81$(PFX)%.arm-bin: $(BUILDDIR)$(PFX)%.arm-elf
82 @echo OC $<
83 $(SILENT)$(CROSS)$(OC) -O binary $< $@
84
85bin2c: bin2c.c
86 $(CC) -o $@ $<
87
88$(OUTPUTDUALBOOT): bin2c $(BOOTBINS)
89 ./bin2c ../dualboot $(BOOTBINS)
90
91$(BUILDDIR):
92 mkdir -p $@
93
94clean:
95 rm -rf bin2c $(BOOTBINS) $(BUILDDIR)
96
97.PRECIOUS: $(OUTPUTDEBUG)