aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/boot/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/boot/Makefile')
-rw-r--r--arch/powerpc/boot/Makefile224
1 files changed, 91 insertions, 133 deletions
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index e73774136b55..c383d56bbe18 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -20,33 +20,34 @@
20# CROSS32_COMPILE is setup as a prefix just like CROSS_COMPILE 20# CROSS32_COMPILE is setup as a prefix just like CROSS_COMPILE
21# in the toplevel makefile. 21# in the toplevel makefile.
22 22
23all: $(obj)/zImage
23 24
24HOSTCC := gcc 25HOSTCC := gcc
25BOOTCFLAGS := $(HOSTCFLAGS) -fno-builtin -nostdinc -isystem \ 26BOOTCFLAGS := $(HOSTCFLAGS) -fno-builtin -nostdinc -isystem \
26 $(shell $(CROSS32CC) -print-file-name=include) -fPIC 27 $(shell $(CROSS32CC) -print-file-name=include) -fPIC
27BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc 28BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
28OBJCOPYFLAGS := contents,alloc,load,readonly,data 29
29OBJCOPY_COFF_ARGS := -O aixcoff-rs6000 --set-start 0x500000 30ifeq ($(call cc-option-yn, -fstack-protector),y)
30OBJCOPY_MIB_ARGS := -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment 31BOOTCFLAGS += -fno-stack-protector
32endif
33
34BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj)
31 35
32zlib := inffast.c inflate.c inftrees.c 36zlib := inffast.c inflate.c inftrees.c
33zlibheader := inffast.h inffixed.h inflate.h inftrees.h infutil.h 37zlibheader := inffast.h inffixed.h inflate.h inftrees.h infutil.h
34zliblinuxheader := zlib.h zconf.h zutil.h 38zliblinuxheader := zlib.h zconf.h zutil.h
35 39
36$(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader)) 40$(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) \
37#$(addprefix $(obj)/,main.o): $(addprefix $(obj)/,zlib.h) 41 $(addprefix $(obj)/,$(zlibheader))
42
43src-wlib := string.S stdio.c main.c div64.S $(zlib)
44src-plat := of.c
45src-boot := crt0.S $(src-wlib) $(src-plat) empty.c
38 46
39src-boot-$(CONFIG_PPC_MULTIPLATFORM) := of.c
40src-boot := crt0.S string.S stdio.c main.c div64.S $(src-boot-y)
41src-boot += $(zlib)
42src-boot := $(addprefix $(obj)/, $(src-boot)) 47src-boot := $(addprefix $(obj)/, $(src-boot))
43obj-boot := $(addsuffix .o, $(basename $(src-boot))) 48obj-boot := $(addsuffix .o, $(basename $(src-boot)))
44 49obj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib))))
45ifeq ($(call cc-option-yn, -fstack-protector),y) 50obj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat))))
46BOOTCFLAGS += -fno-stack-protector
47endif
48
49BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj)
50 51
51quiet_cmd_copy_zlib = COPY $@ 52quiet_cmd_copy_zlib = COPY $@
52 cmd_copy_zlib = sed "s@__attribute_used__@@;s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@ 53 cmd_copy_zlib = sed "s@__attribute_used__@@;s@<linux/\([^>]\+\).*@\"\1\"@" $< > $@
@@ -66,8 +67,14 @@ $(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/%
66$(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/% 67$(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/%
67 $(call cmd,copy_zliblinuxheader) 68 $(call cmd,copy_zliblinuxheader)
68 69
69clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) 70$(obj)/empty.c:
71 @touch $@
72
73$(obj)/zImage.lds $(obj)/zImage.coff.lds: $(obj)/%: $(srctree)/$(src)/%.S
74 @cp $< $@
70 75
76clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \
77 $(obj)/empty.c
71 78
72quiet_cmd_bootcc = BOOTCC $@ 79quiet_cmd_bootcc = BOOTCC $@
73 cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $< 80 cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
@@ -75,146 +82,97 @@ quiet_cmd_bootcc = BOOTCC $@
75quiet_cmd_bootas = BOOTAS $@ 82quiet_cmd_bootas = BOOTAS $@
76 cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< 83 cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
77 84
78quiet_cmd_bootld = BOOTLD $@ 85quiet_cmd_bootar = BOOTAR $@
79 cmd_bootld = $(CROSS32LD) -T $(srctree)/$(src)/$(3) -o $@ $(2) 86 cmd_bootar = $(CROSS32AR) -cr $@.$$$$ $^; mv $@.$$$$ $@
80 87
81$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c 88$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c
82 $(call if_changed_dep,bootcc) 89 $(call if_changed_dep,bootcc)
83$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S 90$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S
84 $(call if_changed_dep,bootas) 91 $(call if_changed_dep,bootas)
85 92
86#----------------------------------------------------------- 93$(obj)/wrapper.a: $(obj-wlib)
87# ELF sections within the zImage bootloader/wrapper 94 $(call cmd,bootar)
88#-----------------------------------------------------------
89required := vmlinux.strip
90initrd := initrd
91 95
92obj-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.o, $(section))) 96hostprogs-y := addnote addRamDisk hack-coff
93src-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.c, $(section)))
94gz-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.gz, $(section)))
95 97
96hostprogs-y := addnote addRamDisk hack-coff 98extra-y := $(obj)/crt0.o $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
99 $(obj)/zImage.lds $(obj)/zImage.coff.lds
97 100
98targets += zImage.vmode zImage.initrd.vmode zImage zImage.initrd \ 101wrapper :=$(srctree)/$(src)/wrapper
99 zImage.coff zImage.initrd.coff miboot.image miboot.initrd.image \ 102wrapperbits := $(extra-y) $(addprefix $(obj)/,addnote hack-coff)
100 $(patsubst $(obj)/%,%, $(call obj-sec, $(required) $(initrd))) \
101 $(patsubst $(obj)/%,%, $(call src-sec, $(required) $(initrd))) \
102 $(patsubst $(obj)/%,%, $(call gz-sec, $(required) $(initrd))) \
103 vmlinux.initrd dummy.o
104extra-y := initrd.o
105 103
106quiet_cmd_ramdisk = RAMDISK $@ 104#############
107 cmd_ramdisk = $(obj)/addRamDisk $(obj)/ramdisk.image.gz $< $@ 105# Bits for building various flavours of zImage
108 106
109quiet_cmd_stripvm = STRIP $@ 107ifneq ($(CROSS32_COMPILE),)
110 cmd_stripvm = $(STRIP) -s -R .comment $< -o $@ 108CROSSWRAP := -C $(CROSS32_COMPILE)
109else
110ifneq ($(CROSS_COMPILE),)
111CROSSWRAP := -C $(CROSS_COMPILE)
112endif
113endif
111 114
112vmlinux.strip: vmlinux 115quiet_cmd_wrap = WRAP $@
113 $(call if_changed,stripvm) 116 cmd_wrap =$(wrapper) -c -o $@ -p $2 $(CROSSWRAP) vmlinux
114$(obj)/vmlinux.initrd: vmlinux.strip $(obj)/addRamDisk $(obj)/ramdisk.image.gz 117quiet_cmd_wrap_initrd = WRAP $@
115 $(call if_changed,ramdisk) 118 cmd_wrap_initrd =$(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
119 -i $(obj)/ramdisk.image.gz vmlinux
116 120
117quiet_cmd_addsection = ADDSEC $@ 121$(obj)/zImage.chrp: vmlinux $(wrapperbits)
118 cmd_addsection = $(CROSS32OBJCOPY) $@ \ 122 $(call cmd,wrap,chrp)
119 --add-section=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $@))=$(patsubst %.o,%.gz, $@) \
120 --set-section-flags=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $@))=$(OBJCOPYFLAGS)
121 123
122quiet_cmd_addnote = ADDNOTE $@ 124$(obj)/zImage.initrd.chrp: vmlinux $(wrapperbits)
123 cmd_addnote = $(obj)/addnote $@ 125 $(call cmd,wrap_initrd,chrp)
124 126
125quiet_cmd_gen-miboot = GEN $@ 127$(obj)/zImage.pseries: vmlinux $(wrapperbits)
126 cmd_gen-miboot = $(OBJCOPY) $(OBJCOPY_MIB_ARGS) \ 128 $(call cmd,wrap,pseries)
127 --add-section=$1=$(word 2, $^) $< $@
128 129
129quiet_cmd_gencoff = COFF $@ 130$(obj)/zImage.initrd.pseries: vmlinux $(wrapperbits)
130 cmd_gencoff = $(OBJCOPY) $(OBJCOPY_COFF_ARGS) $@ && \ 131 $(call cmd,wrap_initrd,pseries)
131 $(obj)/hack-coff $@
132 132
133$(call gz-sec, $(required)): $(obj)/kernel-%.gz: % 133$(obj)/zImage.pmac: vmlinux $(wrapperbits)
134 $(call if_changed,gzip) 134 $(call cmd,wrap,pmac)
135 135
136$(obj)/kernel-initrd.gz: $(obj)/ramdisk.image.gz 136$(obj)/zImage.initrd.pmac: vmlinux $(wrapperbits)
137 cp -f $(obj)/ramdisk.image.gz $@ 137 $(call cmd,wrap_initrd,pmac)
138 138
139$(call src-sec, $(required) $(initrd)): $(obj)/kernel-%.c: $(obj)/kernel-%.gz 139$(obj)/zImage.coff: vmlinux $(wrapperbits)
140 @touch $@ 140 $(call cmd,wrap,pmaccoff)
141 141
142$(call obj-sec, $(required) $(initrd)): $(obj)/kernel-%.o: $(obj)/kernel-%.c 142$(obj)/zImage.initrd.coff: vmlinux $(wrapperbits)
143 $(call if_changed_dep,bootcc) 143 $(call cmd,wrap_initrd,pmaccoff)
144 $(call cmd,addsection) 144
145$(obj)/zImage.miboot: vmlinux $(wrapperbits)
146 $(call cmd,wrap,miboot)
145 147
146$(obj)/zImage.vmode $(obj)/zImage.coff: obj-boot += $(call obj-sec, $(required)) 148$(obj)/zImage.initrd.miboot: vmlinux $(wrapperbits)
147$(obj)/zImage.vmode: $(call obj-sec, $(required)) $(obj-boot) $(srctree)/$(src)/zImage.lds 149 $(call cmd,wrap_initrd,miboot)
148 $(call cmd,bootld,$(obj-boot),zImage.lds)
149 150
150$(obj)/zImage.initrd.vmode $(obj)/zImage.initrd.coff: obj-boot += $(call obj-sec, $(required) $(initrd)) 151$(obj)/uImage: vmlinux $(wrapperbits)
151$(obj)/zImage.initrd.vmode: $(call obj-sec, $(required) $(initrd)) $(obj-boot) $(srctree)/$(src)/zImage.lds 152 $(call cmd,wrap,uboot)
152 $(call cmd,bootld,$(obj-boot),zImage.lds) 153
154image-$(CONFIG_PPC_PSERIES) += zImage.pseries
155image-$(CONFIG_PPC_MAPLE) += zImage.pseries
156image-$(CONFIG_PPC_CELL) += zImage.pseries
157image-$(CONFIG_PPC_CHRP) += zImage.chrp
158image-$(CONFIG_PPC_PMAC) += zImage.pmac
159image-$(CONFIG_DEFAULT_UIMAGE) += uImage
153 160
154# For 32-bit powermacs, build the COFF and miboot images 161# For 32-bit powermacs, build the COFF and miboot images
155# as well as the ELF images. 162# as well as the ELF images.
156coffimage-$(CONFIG_PPC_PMAC)-$(CONFIG_PPC32) := $(obj)/zImage.coff 163ifeq ($(CONFIG_PPC32),y)
157coffrdimg-$(CONFIG_PPC_PMAC)-$(CONFIG_PPC32) := $(obj)/zImage.initrd.coff 164image-$(CONFIG_PPC_PMAC) += zImage.coff zImage.miboot
158mibootimg-$(CONFIG_PPC_PMAC)-$(CONFIG_PPC32) := $(obj)/miboot.image 165endif
159mibrdimg-$(CONFIG_PPC_PMAC)-$(CONFIG_PPC32) := $(obj)/miboot.initrd.image 166
160 167initrd-y := $(patsubst zImage%, zImage.initrd%, $(image-y))
161$(obj)/zImage: $(obj)/zImage.vmode $(obj)/addnote $(coffimage-y-y) \ 168
162 $(mibootimg-y-y) 169$(obj)/zImage: $(addprefix $(obj)/, $(image-y))
163 @cp -f $< $@ 170 @rm -f $@; ln $< $@
164 $(call if_changed,addnote) 171$(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y))
165 172 @rm -f $@; ln $< $@
166$(obj)/zImage.initrd: $(obj)/zImage.initrd.vmode $(obj)/addnote \ 173
167 $(coffrdimg-y-y) $(mibrdimg-y-y) 174install: $(CONFIGURE) $(image-y)
168 @cp -f $< $@ 175 sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $<
169 $(call if_changed,addnote) 176
170 177clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip.gz)
171$(obj)/zImage.coff: $(call obj-sec, $(required)) $(obj-boot) \ 178clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.bin.gz)
172 $(srctree)/$(src)/zImage.coff.lds $(obj)/hack-coff
173 $(call cmd,bootld,$(obj-boot),zImage.coff.lds)
174 $(call cmd,gencoff)
175
176$(obj)/zImage.initrd.coff: $(call obj-sec, $(required) $(initrd)) $(obj-boot) \
177 $(srctree)/$(src)/zImage.coff.lds $(obj)/hack-coff
178 $(call cmd,bootld,$(obj-boot),zImage.coff.lds)
179 $(call cmd,gencoff)
180
181$(obj)/miboot.image: $(obj)/dummy.o $(obj)/vmlinux.gz
182 $(call cmd,gen-miboot,image)
183
184$(obj)/miboot.initrd.image: $(obj)/miboot.image $(images)/ramdisk.image.gz
185 $(call cmd,gen-miboot,initrd)
186
187#-----------------------------------------------------------
188# build u-boot images
189#-----------------------------------------------------------
190quiet_cmd_mygzip = GZIP $@
191cmd_mygzip = gzip -f -9 < $< > $@.$$$$ && mv $@.$$$$ $@
192
193quiet_cmd_objbin = OBJCOPY $@
194 cmd_objbin = $(OBJCOPY) -O binary $< $@
195
196quiet_cmd_uimage = UIMAGE $@
197 cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A ppc -O linux -T kernel \
198 -C gzip -a 00000000 -e 00000000 -n 'Linux-$(KERNELRELEASE)' \
199 -d $< $@
200
201MKIMAGE := $(srctree)/scripts/mkuboot.sh
202targets += uImage
203extra-y += vmlinux.bin vmlinux.gz
204
205$(obj)/vmlinux.bin: vmlinux FORCE
206 $(call if_changed,objbin)
207
208$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE
209 $(call if_changed,mygzip)
210
211$(obj)/uImage: $(obj)/vmlinux.gz
212 $(Q)rm -f $@
213 $(call cmd,uimage)
214 @echo -n ' Image: $@ '
215 @if [ -f $@ ]; then echo 'is ready' ; else echo 'not made'; fi
216
217install: $(CONFIGURE) $(BOOTIMAGE)
218 sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" "$(BOOTIMAGE)"
219
220clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip)