1#
2# Makefile for making XCOFF bootable images for booting on PowerMacs
3# using Open Firmware.
4#
5# Paul Mackerras	January 1997
6#
7# Cleaned up, moved into arch/ppc/boot/pmac
8# Tom Rini		January 2001
9
10OBJCOPY_ARGS = -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment
11COFF_LD_ARGS = -T ../ld.script -e _start -Ttext 0x00500000 -Bstatic
12CHRP_LD_ARGS = -T ../ld.script -Ttext 0x01000000
13
14COMMONOBJS = start.o misc.o ../common/string.o ../common/ofcommon.o
15COFFOBJS = ../common/coffcrt0.o $(COMMONOBJS) coffmain.o
16CHRPOBJS = ../common/crt0.o $(COMMONOBJS) chrpmain.o
17LIBS = $(TOPDIR)/lib/lib.a ../lib/zlib.a ../of1275/of1275.a
18
19MKNOTE := ../utils/mknote
20SIZE := ../utils/size
21OFFSET := ../utils/offset
22HACKCOFF := ../utils/hack-coff
23
24ifdef CONFIG_SMP
25END := .smp
26endif
27ifdef CONFIG_PPC64BRIDGE
28END += .64
29endif
30
31TFTPIMAGE=/tftpboot/zImage.pmac$(END)
32
33../common/coffcrt0.o:
34	$(MAKE) -C ../common coffcrt0.o
35
36image.o: ../images/vmlinux.gz ../common/dummy.o
37	$(OBJCOPY) ../common/dummy.o $@ -R .comment \
38		--add-section=.image=../images/vmlinux.gz \
39		--set-section-flags=.image=contents,alloc,load,readonly,data
40ifdef CONFIG_XMON
41	$(OBJCOPY) $@ $@ \
42		--add-section=.sysmap=$(TOPDIR)/System.map \
43		--set-section-flags=.sysmap=contents,alloc,load,readonly,data
44endif
45
46znetboot: vmlinux.coff vmlinux.elf-pmac zImage
47	cp ../images/vmlinux.coff $(TFTPIMAGE)
48	cp ../images/vmlinux.elf-pmac $(TFTPIMAGE).elf
49
50znetboot.initrd: vmlinux.initrd.coff vmlinux.initrd.elf-pmac
51	cp ../images/vmlinux.initrd.coff $(TFTPIMAGE)
52	cp ../images/vmlinux.initrd.elf-pmac $(TFTPIMAGE).elf
53
54miboot.image: ../common/dummy.o ../images/vmlinux.gz
55	$(OBJCOPY) $(OBJCOPY_ARGS) --add-section=image=../images/vmlinux.gz \
56		../common/dummy.o ../images/$@
57
58miboot.initrd.image: miboot.image ../images/ramdisk.image.gz
59	$(OBJCOPY) $(OBJCOPY_ARGS) --add-section=initrd=../images/ramdisk.image.gz \
60		../images/miboot.image ../images/$@
61
62coffboot: $(COFFOBJS) image.o $(LIBS) ../ld.script
63	$(LD) -o $@ $(COFF_LD_ARGS) $(COFFOBJS) image.o $(LIBS)
64	$(OBJCOPY) $@ $@ -R .comment
65
66coffboot.initrd: $(COFFOBJS) image.o $(LIBS) ../ld.script \
67		../images/ramdisk.image.gz
68	$(OBJCOPY) image.o image-coff.o \
69		--add-section=.ramdisk=../images/ramdisk.image.gz \
70		--set-section-flags=.ramdisk=contents,alloc,load,readonly,data
71	$(LD) -o $@ $(COFF_LD_ARGS) $(COFFOBJS) image-coff.o $(LIBS)
72	$(OBJCOPY) $@ $@ -R .comment
73	rm -f image-coff.o
74
75vmlinux.coff: coffboot $(HACKCOFF)
76	$(OBJCOPY) $(OBJCOPY_ARGS) coffboot ../images/$@
77	$(HACKCOFF) ../images/$@
78	rm -f coffboot
79	ln -sf vmlinux.coff ../images/zImage.pmac
80
81vmlinux.initrd.coff: coffboot.initrd $(HACKCOFF)
82	$(OBJCOPY) $(OBJCOPY_ARGS) coffboot.initrd ../images/$@
83	$(HACKCOFF) ../images/$@
84	rm -f coffboot.initrd
85	ln -sf vmlinux.initrd.coff ../images/zImage.initrd.pmac
86
87vmlinux.elf-pmac: $(CHRPOBJS) $(LIBS) $(MKNOTE) image.o ../ld.script
88	$(LD) $(CHRP_LD_ARGS) -o ../images/$@ $(CHRPOBJS) $(LIBS) image.o
89	$(MKNOTE) > note
90	$(OBJCOPY) ../images/$@ ../images/$@ --add-section=.note=note \
91		-R .comment -R .ramdisk
92	rm -f note
93
94vmlinux.initrd.elf-pmac: $(CHRPOBJS) $(LIBS) $(MKNOTE) image.o \
95		../images/ramdisk.image.gz ../ld.script
96	$(OBJCOPY) image.o image-elf.o \
97		--add-section=.ramdisk=../images/ramdisk.image.gz \
98		--set-section-flags=.ramdisk=contents,alloc,load,readonly,data
99	$(LD) $(CHRP_LD_ARGS) -o ../images/$@ $(CHRPOBJS) $(LIBS) image-elf.o
100	$(MKNOTE) > note
101	$(OBJCOPY) ../images/$@ ../images/$@ --add-section=.note=note \
102		-R .comment
103	rm -f note image-elf.o
104
105zImage: vmlinux.coff vmlinux.elf-pmac miboot.image
106
107zImage.initrd: vmlinux.initrd.coff vmlinux.initrd.elf-pmac miboot.initrd.image
108
109include $(TOPDIR)/Rules.make
110