ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / ppc / boot / openfirmware / Makefile
1 # 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
13 zImage.initrd znetboot.initrd: del-ramdisk-sec  := -R .ramdisk
14 zImage.initrd znetboot.initrd: initrd           := .initrd
15
16
17 boot    := arch/ppc/boot
18 common  := $(boot)/common
19 utils   := $(boot)/utils
20 bootlib := $(boot)/lib
21 of1275  := $(boot)/of1275
22 images  := $(boot)/images
23
24 OBJCOPY_ARGS    := -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment
25 COFF_LD_ARGS    := -T $(boot)/ld.script -e _start -Ttext 0x00500000 -Bstatic
26 CHRP_LD_ARGS    := -T $(boot)/ld.script -e _start -Ttext 0x00800000
27 NEWWORLD_LD_ARGS:= -T $(boot)/ld.script -e _start -Ttext 0x01000000
28
29 COMMONOBJS      := start.o misc.o common.o
30 COFFOBJS        := coffcrt0.o $(COMMONOBJS) coffmain.o
31 CHRPOBJS        := crt0.o     $(COMMONOBJS) chrpmain.o
32 NEWWORLDOBJS    := crt0.o     $(COMMONOBJS) newworldmain.o
33
34 targets         := $(COFFOBJS) $(CHRPOBJS) $(NEWWORLDOBJS) dummy.o
35 COFFOBJS        := $(addprefix $(obj)/, $(COFFOBJS))
36 CHRPOBJS        := $(addprefix $(obj)/, $(CHRPOBJS))
37 NEWWORLDOBJS    := $(addprefix $(obj)/, $(NEWWORLDOBJS))
38
39 LIBS            := lib/lib.a $(bootlib)/lib.a $(of1275)/lib.a $(common)/lib.a
40
41 HACKCOFF := $(utils)/hack-coff
42
43 ifdef CONFIG_SMP
44 END := .smp
45 endif
46 ifdef CONFIG_PPC64BRIDGE
47 END += .64
48 endif
49
50
51 $(images)/ramdisk.image.gz:
52         @echo '  MISSING $@'
53         @echo '          RAM disk image must be provided separately'
54         @/bin/false
55
56 objcpxmon-$(CONFIG_XMON) := --add-section=.sysmap=System.map \
57         --set-section-flags=.sysmap=contents,alloc,load,readonly,data
58 quiet_cmd_genimage = GEN     $@
59       cmd_genimage = $(OBJCOPY) -R .comment       \
60         --add-section=.image=$(images)/vmlinux.gz \
61         --set-section-flags=.image=contents,alloc,load,readonly,data \
62         $(objcpxmon-y) $< $@
63
64 targets += image.o
65 $(obj)/image.o: $(obj)/dummy.o $(images)/vmlinux.gz FORCE
66         $(call if_changed,genimage)
67
68 # Place the ramdisk in the initrd image.
69 quiet_cmd_genimage-initrd = GEN     $@
70       cmd_genimage-initrd = $(OBJCOPY) $< $@ \
71         --add-section=.ramdisk=$(images)/ramdisk.image.gz \
72         --set-section-flags=.ramdisk=contents,alloc,load,readonly,data
73 targets += image.initrd.o
74 $(obj)/image.initrd.o: $(obj)/image.o $(images)/ramdisk.image.gz FORCE
75         $(call if_changed,genimage-initrd)
76
77 # Create the note section for New-World PowerMacs.
78 quiet_cmd_mknote = MKNOTE  $@
79      cmd_mknote  = $(utils)/mknote > $@
80 targets         += note
81 $(obj)/note: $(utils)/mknote FORCE
82         $(call if_changed,mknote)
83
84
85 $(obj)/coffcrt0.o: EXTRA_AFLAGS := -traditional -DXCOFF
86 $(obj)/crt0.o:     EXTRA_AFLAGS := -traditional
87 targets += coffcrt0.o crt0.o
88 $(obj)/coffcrt0.o $(obj)/crt0.o: $(common)/crt0.S FORCE
89         $(call if_changed_dep,as_o_S)
90
91 quiet_cmd_gencoffb = COFF    $@
92       cmd_gencoffb = $(LD) -o $@ $(COFF_LD_ARGS) $(COFFOBJS) $< $(LIBS) && \
93                      $(OBJCOPY) $@ $@ -R .comment $(del-ramdisk-sec)
94 targets += coffboot
95 $(obj)/coffboot: $(obj)/image.o $(COFFOBJS) $(LIBS) $(boot)/ld.script FORCE
96         $(call if_changed,gencoffb)
97 targets += coffboot.initrd
98 $(obj)/coffboot.initrd: $(obj)/image.initrd.o $(COFFOBJS) $(LIBS) \
99                         $(boot)/ld.script FORCE
100         $(call if_changed,gencoffb)
101
102
103 quiet_cmd_gen-coff = COFF    $@
104       cmd_gen-coff = $(OBJCOPY) $(OBJCOPY_ARGS) $< $@ && \
105                         $(HACKCOFF) $@ && \
106                         ln -sf $(notdir $@) $(images)/zImage$(initrd).pmac
107
108 $(images)/vmlinux.coff: $(obj)/coffboot
109         $(call cmd,gen-coff)
110
111 $(images)/vmlinux.initrd.coff: $(obj)/coffboot.initrd
112         $(call cmd,gen-coff)
113
114 quiet_cmd_gen-elf-pmac = ELF     $@
115       cmd_gen-elf-pmac = $(LD) $(NEWWORLD_LD_ARGS) -o $@ \
116                                 $(NEWWORLDOBJS) $(LIBS) $< && \
117                         $(OBJCOPY) $@ $@ --add-section=.note=$(obj)/note \
118                                          -R .comment $(del-ramdisk-sec)
119
120 $(images)/vmlinux.elf-pmac: $(obj)/image.o $(NEWWORLDOBJS) $(LIBS) \
121                         $(obj)/note $(boot)/ld.script
122         $(call cmd,gen-elf-pmac)
123 $(images)/vmlinux.initrd.elf-pmac: $(obj)/image.initrd.o $(NEWWORLDOBJS) \
124                                    $(LIBS) $(obj)/note $(boot)/ld.script
125         $(call cmd,gen-elf-pmac)
126
127 quiet_cmd_gen-chrp = CHRP    $@
128       cmd_gen-chrp = $(LD) $(CHRP_LD_ARGS) -o $@ $(CHRPOBJS) $< $(LIBS) && \
129                         $(OBJCOPY) $@ $@ -R .comment $(del-ramdisk-sec)
130
131 $(images)/zImage.chrp: $(obj)/image.o $(CHRPOBJS) $(LIBS) $(boot)/ld.script
132         $(call cmd,gen-chrp)
133 $(images)/zImage.initrd.chrp: $(obj)/image.initrd.o $(CHRPOBJS) $(LIBS) \
134                         $(boot)/ld.script
135         $(call cmd,gen-chrp)
136
137 quiet_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
143 quiet_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
155 zImage:          $(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 ($<)'
161 zImage.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
168 TFTPIMAGE       := /tftpboot/zImage
169
170 .PHONY: znetboot znetboot.initrd
171 znetboot:       $(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 ($<)'
178 znetboot.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