1#
2# Makefile for rescue code
3#
4ifndef TOPDIR
5TOPDIR = ../../../..
6HPATH = $(TOPDIR)/include
7export HPATH
8endif
9CC = gcc-cris -mlinux -I $(TOPDIR)/include
10CFLAGS = -O2
11LD = gcc-cris -mlinux -nostdlib
12OBJCOPY = objcopy-cris
13
14all: rescue.bin testrescue.bin kimagerescue.bin
15
16rescue: rescue.bin
17	# do nothing
18
19rescue.bin: head.o
20	$(LD) -T rescue.ld -o rescue.o head.o
21	$(OBJCOPY) -O binary --remove-section=.bss rescue.o rescue.bin
22	cp rescue.bin $(TOPDIR)
23
24testrescue.bin: testrescue.o
25	$(OBJCOPY) -O binary --remove-section=.bss testrescue.o tr.bin
26# Pad it to 784 bytes
27	dd if=/dev/zero of=tmp2423 bs=1 count=784
28	cat tr.bin tmp2423 >testrescue_tmp.bin
29	dd if=testrescue_tmp.bin of=testrescue.bin bs=1 count=784
30	rm tr.bin tmp2423 testrescue_tmp.bin
31
32kimagerescue.bin: kimagerescue.o
33	$(OBJCOPY) -O binary --remove-section=.bss kimagerescue.o ktr.bin
34# Pad it to 784 bytes, that's what the rescue loader expects
35	dd if=/dev/zero of=tmp2423 bs=1 count=784
36	cat ktr.bin tmp2423 >kimagerescue_tmp.bin
37	dd if=kimagerescue_tmp.bin of=kimagerescue.bin bs=1 count=784
38	rm ktr.bin tmp2423 kimagerescue_tmp.bin
39
40head.o: head.S
41	$(CC) -D__ASSEMBLY__ -traditional -c $< -o $*.o
42
43testrescue.o: testrescue.S
44	$(CC) -D__ASSEMBLY__ -traditional -c $< -o $*.o
45
46kimagerescue.o: kimagerescue.S
47	$(CC) -D__ASSEMBLY__ -traditional -c $< -o $*.o
48
49clean:
50	rm -f *.o *.bin
51
52fastdep:
53
54modules:
55
56modules_install:
57
58depend:
59	$(CC) -M *.S > .depend
60
61-include .depend
62