summaryrefslogtreecommitdiffstats
path: root/rbutil/mkamsboot/Makefile
blob: d643930915853a6fb106e39a2510200191b17a59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

# We use the UCL code available in the Rockbox tools/ directory

CFLAGS=-I../../tools/ucl/include
LIBUCL=../../tools/ucl/src/libucl.a

# Edit the following variables (plus copy/paste another set of rules) when
# adding a new target.  mkamsboot.c also needs to be edited to refer to these
# new images.
#
# If anyone reading this wants to improve this makefile, please do!

BOOTIMAGES = bootimg_clip.o bootimg_e200v2.o bootimg_m200v2.o
BOOTHEADERS = bootimg_clip.h bootimg_e200v2.h bootimg_m200v2.h

CLIPFILES = dualboot-clip.o dualboot-clip.elf dualboot-clip.o \
            dualboot-clip.bin bootimg_clip.c bootimg_clip.h

E200V2FILES = dualboot-e200v2.o dualboot-e200v2.elf dualboot-e200v2.o \
              dualboot-e200v2.bin bootimg_e200v2.c bootimg_e200v2.h

M200V2FILES = dualboot-m200v2.o dualboot-m200v2.elf dualboot-m200v2.o \
              dualboot-m200v2.bin bootimg_m200v2.c bootimg_m200v2.h              
              
all: mkamsboot

$(LIBUCL):
	make -C ../../tools/ucl/src libucl.a

mkamsboot.o: mkamsboot.c $(BOOTHEADERS) uclimg.h
	gcc $(CFLAGS) -c -o mkamsboot.o -W -Wall mkamsboot.c

mkamsboot: mkamsboot.o $(BOOTIMAGES) uclimg.o $(LIBUCL)
	gcc -o mkamsboot mkamsboot.o $(BOOTIMAGES) uclimg.o $(LIBUCL)

# Rules for our test ARM application - assemble, link, then extract
# the binary code

# CLIP

dualboot-clip.o: dualboot.S
	arm-elf-gcc -DSANSA_CLIP -c -o dualboot-clip.o dualboot.S

dualboot-clip.elf: dualboot-clip.o
	arm-elf-ld -e 0 -Ttext=0 -o dualboot-clip.elf dualboot-clip.o

dualboot-clip.bin: dualboot-clip.elf
	arm-elf-objcopy -O binary dualboot-clip.elf dualboot-clip.bin

bootimg_clip.c bootimg_clip.h: dualboot-clip.bin bin2c
	./bin2c dualboot-clip.bin bootimg_clip

bootimg_clip.o: bootimg_clip.c
	gcc -c -o bootimg_clip.o bootimg_clip.c

# E200V2

dualboot-e200v2.o: dualboot.S
	arm-elf-gcc -DSANSA_E200V2 -c -o dualboot-e200v2.o dualboot.S

dualboot-e200v2.elf: dualboot-e200v2.o
	arm-elf-ld -e 0 -Ttext=0 -o dualboot-e200v2.elf dualboot-e200v2.o

dualboot-e200v2.bin: dualboot-e200v2.elf
	arm-elf-objcopy -O binary dualboot-e200v2.elf dualboot-e200v2.bin

bootimg_e200v2.c bootimg_e200v2.h: dualboot-e200v2.bin bin2c
	./bin2c dualboot-e200v2.bin bootimg_e200v2

bootimg_e200v2.o: bootimg_e200v2.c
	gcc -c -o bootimg_e200v2.o bootimg_e200v2.c

# M200V2    
    
dualboot-m200v2.o: dualboot.S
	arm-elf-gcc -DSANSA_M200V2 -c -o dualboot-m200v2.o dualboot.S

dualboot-m200v2.elf: dualboot-m200v2.o
	arm-elf-ld -e 0 -Ttext=0 -o dualboot-m200v2.elf dualboot-m200v2.o

dualboot-m200v2.bin: dualboot-m200v2.elf
	arm-elf-objcopy -O binary dualboot-m200v2.elf dualboot-m200v2.bin

bootimg_m200v2.c bootimg_m200v2.h: dualboot-m200v2.bin bin2c
	./bin2c dualboot-m200v2.bin bootimg_m200v2

bootimg_m200v2.o: bootimg_m200v2.c
	gcc -c -o bootimg_m200v2.o bootimg_m200v2.c
        
# Rules for the ucl unpack function
nrv2e_d8.o: nrv2e_d8.S
	arm-elf-gcc -DPURE_THUMB -c -o nrv2e_d8.o nrv2e_d8.S

# NOTE: this function has no absolute references, so the link address (-e)
# is irrelevant.  We just link at address 0, but it can run from anywhere.
nrv2e_d8.elf: nrv2e_d8.o
	arm-elf-ld -e 0 -Ttext=0 -o nrv2e_d8.elf nrv2e_d8.o

nrv2e_d8.bin: nrv2e_d8.elf
	arm-elf-objcopy -O binary nrv2e_d8.elf nrv2e_d8.bin

uclimg.c uclimg.h: nrv2e_d8.bin bin2c
	./bin2c nrv2e_d8.bin uclimg

uclimg.o: uclimg.c
	gcc -c -o uclimg.o uclimg.c

bin2c: bin2c.c
	gcc -o bin2c bin2c.c

clean:
	rm -f mkamsboot mkamsboot.o nrv2e_d8.o nrv2e_d8.elf nrv2e_d8.bin *~ \
	bin2c uclimg.c uclimg.h uclimg.o \
	$(BOOTIMAGES) $(CLIPFILES) $(E200V2FILES) $(M200V2FILES)