Merge master.kernel.org:/home/rmk/linux-2.6-arm
[firefly-linux-kernel-4.4.55.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 $(srctree)/$(boot)/ld.script -e _start -Ttext 0x00500000 \
26                         -Bstatic
27 CHRP_LD_ARGS    := -T $(srctree)/$(boot)/ld.script -e _start -Ttext 0x00800000
28 NEWWORLD_LD_ARGS:= -T $(srctree)/$(boot)/ld.script -e _start -Ttext 0x01000000
29
30 COMMONOBJS      := start.o misc.o common.o
31 COFFOBJS        := coffcrt0.o $(COMMONOBJS) coffmain.o
32 CHRPOBJS        := crt0.o     $(COMMONOBJS) chrpmain.o
33 NEWWORLDOBJS    := crt0.o     $(COMMONOBJS) newworldmain.o
34
35 targets         := $(COFFOBJS) $(CHRPOBJS) $(NEWWORLDOBJS) dummy.o
36 COFFOBJS        := $(addprefix $(obj)/, $(COFFOBJS))
37 CHRPOBJS        := $(addprefix $(obj)/, $(CHRPOBJS))
38 NEWWORLDOBJS    := $(addprefix $(obj)/, $(NEWWORLDOBJS))
39
40 LIBS            := lib/lib.a $(bootlib)/lib.a $(of1275)/lib.a $(common)/lib.a
41
42 HACKCOFF := $(utils)/hack-coff
43
44 ifdef CONFIG_SMP
45 END := .smp
46 endif
47 ifdef CONFIG_PPC64BRIDGE
48 END += .64
49 endif
50
51
52 $(images)/ramdisk.image.gz:
53         @echo '  MISSING $@'
54         @echo '          RAM disk image must be provided separately'
55         @/bin/false
56
57 quiet_cmd_genimage = GEN     $@
58       cmd_genimage = $(OBJCOPY) -R .comment       \
59         --add-section=.image=$(images)/vmlinux.gz \
60         --set-section-flags=.image=contents,alloc,load,readonly,data $< $@
61
62 targets += 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.
67 quiet_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
71 targets += 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.
76 quiet_cmd_mknote = MKNOTE  $@
77      cmd_mknote  = $(utils)/mknote > $@
78 targets         += note
79 $(obj)/note: $(utils)/mknote FORCE
80         $(call if_changed,mknote)
81
82
83 $(obj)/coffcrt0.o: EXTRA_AFLAGS := -DXCOFF
84 targets += coffcrt0.o crt0.o
85 $(obj)/coffcrt0.o $(obj)/crt0.o: $(common)/crt0.S FORCE
86         $(call if_changed_dep,as_o_S)
87
88 quiet_cmd_gencoffb = COFF    $@
89       cmd_gencoffb = $(LD) -o $@ $(COFF_LD_ARGS) $(COFFOBJS) $< $(LIBS) && \
90                      $(OBJCOPY) $@ $@ -R .comment $(del-ramdisk-sec)
91 targets += coffboot
92 $(obj)/coffboot: $(obj)/image.o $(COFFOBJS) $(LIBS) $(srctree)/$(boot)/ld.script FORCE
93         $(call if_changed,gencoffb)
94 targets += coffboot.initrd
95 $(obj)/coffboot.initrd: $(obj)/image.initrd.o $(COFFOBJS) $(LIBS) \
96                         $(srctree)/$(boot)/ld.script FORCE
97         $(call if_changed,gencoffb)
98
99
100 quiet_cmd_gen-coff = COFF    $@
101       cmd_gen-coff = $(OBJCOPY) $(OBJCOPY_ARGS) $< $@ && \
102                         $(HACKCOFF) $@ && \
103                         ln -sf $(notdir $@) $(images)/zImage$(initrd).pmac
104
105 $(images)/vmlinux.coff: $(obj)/coffboot
106         $(call cmd,gen-coff)
107
108 $(images)/vmlinux.initrd.coff: $(obj)/coffboot.initrd
109         $(call cmd,gen-coff)
110
111 quiet_cmd_gen-elf-pmac = ELF     $@
112       cmd_gen-elf-pmac = $(LD) $(NEWWORLD_LD_ARGS) -o $@ \
113                                 $(NEWWORLDOBJS) $(LIBS) $< && \
114                         $(OBJCOPY) $@ $@ --add-section=.note=$(obj)/note \
115                                          -R .comment $(del-ramdisk-sec)
116
117 $(images)/vmlinux.elf-pmac: $(obj)/image.o $(NEWWORLDOBJS) $(LIBS) \
118                         $(obj)/note $(srctree)/$(boot)/ld.script
119         $(call cmd,gen-elf-pmac)
120 $(images)/vmlinux.initrd.elf-pmac: $(obj)/image.initrd.o $(NEWWORLDOBJS) \
121                                    $(LIBS) $(obj)/note \
122                                    $(srctree)/$(boot)/ld.script
123         $(call cmd,gen-elf-pmac)
124
125 quiet_cmd_gen-chrp = CHRP    $@
126       cmd_gen-chrp = $(LD) $(CHRP_LD_ARGS) -o $@ $(CHRPOBJS) $< $(LIBS) && \
127                         $(OBJCOPY) $@ $@ -R .comment $(del-ramdisk-sec)
128
129 $(images)/zImage.chrp: $(obj)/image.o $(CHRPOBJS) $(LIBS) \
130                                    $(srctree)/$(boot)/ld.script
131         $(call cmd,gen-chrp)
132 $(images)/zImage.initrd.chrp: $(obj)/image.initrd.o $(CHRPOBJS) $(LIBS) \
133                                    $(srctree)/$(boot)/ld.script
134         $(call cmd,gen-chrp)
135
136 quiet_cmd_addnote = ADDNOTE $@
137       cmd_addnote = cat $< > $@ && $(utils)/addnote $@
138 $(images)/zImage.chrp-rs6k $(images)/zImage.initrd.chrp-rs6k: \
139         %-rs6k: %
140         $(call cmd,addnote)
141
142 quiet_cmd_gen-miboot = GEN     $@
143       cmd_gen-miboot = $(OBJCOPY) $(OBJCOPY_ARGS) \
144                        --add-section=$1=$(word 2, $^) $< $@
145 $(images)/miboot.image: $(obj)/dummy.o $(images)/vmlinux.gz
146         $(call cmd,gen-miboot,image)
147
148 $(images)/miboot.initrd.image: $(images)/miboot.image $(images)/ramdisk.image.gz
149         $(call cmd,gen-miboot,initrd)
150
151 # The targets used on the make command-line
152
153 .PHONY: zImage zImage.initrd
154 zImage:          $(images)/vmlinux.coff         \
155                  $(images)/vmlinux.elf-pmac     \
156                  $(images)/zImage.chrp          \
157                  $(images)/zImage.chrp-rs6k     \
158                  $(images)/miboot.image
159         @echo '  kernel: $@ is ready ($<)'
160 zImage.initrd:   $(images)/vmlinux.initrd.coff          \
161                  $(images)/vmlinux.initrd.elf-pmac      \
162                  $(images)/zImage.initrd.chrp           \
163                  $(images)/zImage.initrd.chrp-rs6k      \
164                  $(images)/miboot.initrd.image
165         @echo '  kernel: $@ is ready ($<)'
166
167 TFTPIMAGE       := /tftpboot/zImage
168
169 .PHONY: znetboot znetboot.initrd
170 znetboot:       $(images)/vmlinux.coff          \
171                 $(images)/vmlinux.elf-pmac      \
172                 $(images)/zImage.chrp
173         cp $(images)/vmlinux.coff     $(TFTPIMAGE).pmac$(END)
174         cp $(images)/vmlinux.elf-pmac $(TFTPIMAGE).pmac$(END).elf
175         cp $(images)/zImage.chrp      $(TFTPIMAGE).chrp$(END)
176         @echo '  kernel: $@ is ready ($<)'
177 znetboot.initrd:$(images)/vmlinux.initrd.coff           \
178                 $(images)/vmlinux.initrd.elf-pmac       \
179                 $(images)/zImage.initrd.chrp
180         cp $(images)/vmlinux.initrd.coff     $(TFTPIMAGE).pmac$(END)
181         cp $(images)/vmlinux.initrd.elf-pmac $(TFTPIMAGE).pmac$(END).elf
182         cp $(images)/zImage.initrd.chrp      $(TFTPIMAGE).chrp$(END)
183         @echo '  kernel: $@ is ready ($<)'
184