blob: 03415238fabf67791bd084775aacf22997ff9370 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001# Makefile for making bootable images on various OpenFirmware machines.
2#
3# Paul Mackerras January 1997
4# XCOFF bootable images for PowerMacs
5# Geert Uytterhoeven September 1997
6# ELF bootable iamges for CHRP machines.
7# Tom Rini January 2001
8# Cleaned up, moved into arch/ppc/boot/pmac
9# Tom Rini July/August 2002
10# Merged 'chrp' and 'pmac' into 'openfirmware', and cleaned up the
11# rules.
12
13zImage.initrd znetboot.initrd: del-ramdisk-sec := -R .ramdisk
14zImage.initrd znetboot.initrd: initrd := .initrd
15
16
17boot := arch/ppc/boot
18common := $(boot)/common
19utils := $(boot)/utils
20bootlib := $(boot)/lib
21of1275 := $(boot)/of1275
22images := $(boot)/images
23
24OBJCOPY_ARGS := -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment
25COFF_LD_ARGS := -T $(srctree)/$(boot)/ld.script -e _start -Ttext 0x00500000 \
26 -Bstatic
27CHRP_LD_ARGS := -T $(srctree)/$(boot)/ld.script -e _start -Ttext 0x00800000
28NEWWORLD_LD_ARGS:= -T $(srctree)/$(boot)/ld.script -e _start -Ttext 0x01000000
29
30COMMONOBJS := start.o misc.o common.o
31COFFOBJS := coffcrt0.o $(COMMONOBJS) coffmain.o
32CHRPOBJS := crt0.o $(COMMONOBJS) chrpmain.o
33NEWWORLDOBJS := crt0.o $(COMMONOBJS) newworldmain.o
34
35targets := $(COFFOBJS) $(CHRPOBJS) $(NEWWORLDOBJS) dummy.o
36COFFOBJS := $(addprefix $(obj)/, $(COFFOBJS))
37CHRPOBJS := $(addprefix $(obj)/, $(CHRPOBJS))
38NEWWORLDOBJS := $(addprefix $(obj)/, $(NEWWORLDOBJS))
39
40LIBS := lib/lib.a $(bootlib)/lib.a $(of1275)/lib.a $(common)/lib.a
41
42HACKCOFF := $(utils)/hack-coff
43
44ifdef CONFIG_SMP
45END := .smp
46endif
47ifdef CONFIG_PPC64BRIDGE
48END += .64
49endif
50
51
52$(images)/ramdisk.image.gz:
53 @echo ' MISSING $@'
54 @echo ' RAM disk image must be provided separately'
55 @/bin/false
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057quiet_cmd_genimage = GEN $@
58 cmd_genimage = $(OBJCOPY) -R .comment \
59 --add-section=.image=$(images)/vmlinux.gz \
Benjamin Herrenschmidt6879dc12005-06-21 17:15:30 -070060 --set-section-flags=.image=contents,alloc,load,readonly,data $< $@
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62targets += image.o
63$(obj)/image.o: $(obj)/dummy.o $(images)/vmlinux.gz FORCE
64 $(call if_changed,genimage)
65
66# Place the ramdisk in the initrd image.
67quiet_cmd_genimage-initrd = GEN $@
68 cmd_genimage-initrd = $(OBJCOPY) $< $@ \
69 --add-section=.ramdisk=$(images)/ramdisk.image.gz \
70 --set-section-flags=.ramdisk=contents,alloc,load,readonly,data
71targets += image.initrd.o
72$(obj)/image.initrd.o: $(obj)/image.o $(images)/ramdisk.image.gz FORCE
73 $(call if_changed,genimage-initrd)
74
75# Create the note section for New-World PowerMacs.
76quiet_cmd_mknote = MKNOTE $@
77 cmd_mknote = $(utils)/mknote > $@
78targets += note
79$(obj)/note: $(utils)/mknote FORCE
80 $(call if_changed,mknote)
81
82
83$(obj)/coffcrt0.o: EXTRA_AFLAGS := -traditional -DXCOFF
84$(obj)/crt0.o: EXTRA_AFLAGS := -traditional
85targets += coffcrt0.o crt0.o
86$(obj)/coffcrt0.o $(obj)/crt0.o: $(common)/crt0.S FORCE
87 $(call if_changed_dep,as_o_S)
88
89quiet_cmd_gencoffb = COFF $@
90 cmd_gencoffb = $(LD) -o $@ $(COFF_LD_ARGS) $(COFFOBJS) $< $(LIBS) && \
91 $(OBJCOPY) $@ $@ -R .comment $(del-ramdisk-sec)
92targets += coffboot
93$(obj)/coffboot: $(obj)/image.o $(COFFOBJS) $(LIBS) $(srctree)/$(boot)/ld.script FORCE
94 $(call if_changed,gencoffb)
95targets += coffboot.initrd
96$(obj)/coffboot.initrd: $(obj)/image.initrd.o $(COFFOBJS) $(LIBS) \
97 $(srctree)/$(boot)/ld.script FORCE
98 $(call if_changed,gencoffb)
99
100
101quiet_cmd_gen-coff = COFF $@
102 cmd_gen-coff = $(OBJCOPY) $(OBJCOPY_ARGS) $< $@ && \
103 $(HACKCOFF) $@ && \
104 ln -sf $(notdir $@) $(images)/zImage$(initrd).pmac
105
106$(images)/vmlinux.coff: $(obj)/coffboot
107 $(call cmd,gen-coff)
108
109$(images)/vmlinux.initrd.coff: $(obj)/coffboot.initrd
110 $(call cmd,gen-coff)
111
112quiet_cmd_gen-elf-pmac = ELF $@
113 cmd_gen-elf-pmac = $(LD) $(NEWWORLD_LD_ARGS) -o $@ \
114 $(NEWWORLDOBJS) $(LIBS) $< && \
115 $(OBJCOPY) $@ $@ --add-section=.note=$(obj)/note \
116 -R .comment $(del-ramdisk-sec)
117
118$(images)/vmlinux.elf-pmac: $(obj)/image.o $(NEWWORLDOBJS) $(LIBS) \
119 $(obj)/note $(srctree)/$(boot)/ld.script
120 $(call cmd,gen-elf-pmac)
121$(images)/vmlinux.initrd.elf-pmac: $(obj)/image.initrd.o $(NEWWORLDOBJS) \
122 $(LIBS) $(obj)/note \
123 $(srctree)/$(boot)/ld.script
124 $(call cmd,gen-elf-pmac)
125
126quiet_cmd_gen-chrp = CHRP $@
127 cmd_gen-chrp = $(LD) $(CHRP_LD_ARGS) -o $@ $(CHRPOBJS) $< $(LIBS) && \
128 $(OBJCOPY) $@ $@ -R .comment $(del-ramdisk-sec)
129
130$(images)/zImage.chrp: $(obj)/image.o $(CHRPOBJS) $(LIBS) \
131 $(srctree)/$(boot)/ld.script
132 $(call cmd,gen-chrp)
133$(images)/zImage.initrd.chrp: $(obj)/image.initrd.o $(CHRPOBJS) $(LIBS) \
134 $(srctree)/$(boot)/ld.script
135 $(call cmd,gen-chrp)
136
137quiet_cmd_addnote = ADDNOTE $@
138 cmd_addnote = cat $< > $@ && $(utils)/addnote $@
139$(images)/zImage.chrp-rs6k $(images)/zImage.initrd.chrp-rs6k: \
140 %-rs6k: %
141 $(call cmd,addnote)
142
143quiet_cmd_gen-miboot = GEN $@
144 cmd_gen-miboot = $(OBJCOPY) $(OBJCOPY_ARGS) \
145 --add-section=$1=$(word 2, $^) $< $@
146$(images)/miboot.image: $(obj)/dummy.o $(images)/vmlinux.gz
147 $(call cmd,gen-miboot,image)
148
149$(images)/miboot.initrd.image: $(images)/miboot.image $(images)/ramdisk.image.gz
150 $(call cmd,gen-miboot,initrd)
151
152# The targets used on the make command-line
153
154.PHONY: zImage zImage.initrd
155zImage: $(images)/vmlinux.coff \
156 $(images)/vmlinux.elf-pmac \
157 $(images)/zImage.chrp \
158 $(images)/zImage.chrp-rs6k \
159 $(images)/miboot.image
160 @echo ' kernel: $@ is ready ($<)'
161zImage.initrd: $(images)/vmlinux.initrd.coff \
162 $(images)/vmlinux.initrd.elf-pmac \
163 $(images)/zImage.initrd.chrp \
164 $(images)/zImage.initrd.chrp-rs6k \
165 $(images)/miboot.initrd.image
166 @echo ' kernel: $@ is ready ($<)'
167
168TFTPIMAGE := /tftpboot/zImage
169
170.PHONY: znetboot znetboot.initrd
171znetboot: $(images)/vmlinux.coff \
172 $(images)/vmlinux.elf-pmac \
173 $(images)/zImage.chrp
174 cp $(images)/vmlinux.coff $(TFTPIMAGE).pmac$(END)
175 cp $(images)/vmlinux.elf-pmac $(TFTPIMAGE).pmac$(END).elf
176 cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END)
177 @echo ' kernel: $@ is ready ($<)'
178znetboot.initrd:$(images)/vmlinux.initrd.coff \
179 $(images)/vmlinux.initrd.elf-pmac \
180 $(images)/zImage.initrd.chrp
181 cp $(images)/vmlinux.initrd.coff $(TFTPIMAGE).pmac$(END)
182 cp $(images)/vmlinux.initrd.elf-pmac $(TFTPIMAGE).pmac$(END).elf
183 cp $(images)/zImage.initrd.chrp $(TFTPIMAGE).chrp$(END)
184 @echo ' kernel: $@ is ready ($<)'
185