diff options
Diffstat (limited to 'arch/powerpc/boot/Makefile')
-rw-r--r-- | arch/powerpc/boot/Makefile | 224 |
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 | ||
23 | all: $(obj)/zImage | ||
23 | 24 | ||
24 | HOSTCC := gcc | 25 | HOSTCC := gcc |
25 | BOOTCFLAGS := $(HOSTCFLAGS) -fno-builtin -nostdinc -isystem \ | 26 | BOOTCFLAGS := $(HOSTCFLAGS) -fno-builtin -nostdinc -isystem \ |
26 | $(shell $(CROSS32CC) -print-file-name=include) -fPIC | 27 | $(shell $(CROSS32CC) -print-file-name=include) -fPIC |
27 | BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc | 28 | BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc |
28 | OBJCOPYFLAGS := contents,alloc,load,readonly,data | 29 | |
29 | OBJCOPY_COFF_ARGS := -O aixcoff-rs6000 --set-start 0x500000 | 30 | ifeq ($(call cc-option-yn, -fstack-protector),y) |
30 | OBJCOPY_MIB_ARGS := -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment | 31 | BOOTCFLAGS += -fno-stack-protector |
32 | endif | ||
33 | |||
34 | BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj) | ||
31 | 35 | ||
32 | zlib := inffast.c inflate.c inftrees.c | 36 | zlib := inffast.c inflate.c inftrees.c |
33 | zlibheader := inffast.h inffixed.h inflate.h inftrees.h infutil.h | 37 | zlibheader := inffast.h inffixed.h inflate.h inftrees.h infutil.h |
34 | zliblinuxheader := zlib.h zconf.h zutil.h | 38 | zliblinuxheader := 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 | |||
43 | src-wlib := string.S stdio.c main.c div64.S $(zlib) | ||
44 | src-plat := of.c | ||
45 | src-boot := crt0.S $(src-wlib) $(src-plat) empty.c | ||
38 | 46 | ||
39 | src-boot-$(CONFIG_PPC_MULTIPLATFORM) := of.c | ||
40 | src-boot := crt0.S string.S stdio.c main.c div64.S $(src-boot-y) | ||
41 | src-boot += $(zlib) | ||
42 | src-boot := $(addprefix $(obj)/, $(src-boot)) | 47 | src-boot := $(addprefix $(obj)/, $(src-boot)) |
43 | obj-boot := $(addsuffix .o, $(basename $(src-boot))) | 48 | obj-boot := $(addsuffix .o, $(basename $(src-boot))) |
44 | 49 | obj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib)))) | |
45 | ifeq ($(call cc-option-yn, -fstack-protector),y) | 50 | obj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat)))) |
46 | BOOTCFLAGS += -fno-stack-protector | ||
47 | endif | ||
48 | |||
49 | BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj) | ||
50 | 51 | ||
51 | quiet_cmd_copy_zlib = COPY $@ | 52 | quiet_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 | ||
69 | clean-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 | ||
76 | clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \ | ||
77 | $(obj)/empty.c | ||
71 | 78 | ||
72 | quiet_cmd_bootcc = BOOTCC $@ | 79 | quiet_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 $@ | |||
75 | quiet_cmd_bootas = BOOTAS $@ | 82 | quiet_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 | ||
78 | quiet_cmd_bootld = BOOTLD $@ | 85 | quiet_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 | #----------------------------------------------------------- | ||
89 | required := vmlinux.strip | ||
90 | initrd := initrd | ||
91 | 95 | ||
92 | obj-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.o, $(section))) | 96 | hostprogs-y := addnote addRamDisk hack-coff |
93 | src-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.c, $(section))) | ||
94 | gz-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.gz, $(section))) | ||
95 | 97 | ||
96 | hostprogs-y := addnote addRamDisk hack-coff | 98 | extra-y := $(obj)/crt0.o $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \ |
99 | $(obj)/zImage.lds $(obj)/zImage.coff.lds | ||
97 | 100 | ||
98 | targets += zImage.vmode zImage.initrd.vmode zImage zImage.initrd \ | 101 | wrapper :=$(srctree)/$(src)/wrapper |
99 | zImage.coff zImage.initrd.coff miboot.image miboot.initrd.image \ | 102 | wrapperbits := $(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 | ||
104 | extra-y := initrd.o | ||
105 | 103 | ||
106 | quiet_cmd_ramdisk = RAMDISK $@ | 104 | ############# |
107 | cmd_ramdisk = $(obj)/addRamDisk $(obj)/ramdisk.image.gz $< $@ | 105 | # Bits for building various flavours of zImage |
108 | 106 | ||
109 | quiet_cmd_stripvm = STRIP $@ | 107 | ifneq ($(CROSS32_COMPILE),) |
110 | cmd_stripvm = $(STRIP) -s -R .comment $< -o $@ | 108 | CROSSWRAP := -C $(CROSS32_COMPILE) |
109 | else | ||
110 | ifneq ($(CROSS_COMPILE),) | ||
111 | CROSSWRAP := -C $(CROSS_COMPILE) | ||
112 | endif | ||
113 | endif | ||
111 | 114 | ||
112 | vmlinux.strip: vmlinux | 115 | quiet_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 | 117 | quiet_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 | ||
117 | quiet_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 | ||
122 | quiet_cmd_addnote = ADDNOTE $@ | 124 | $(obj)/zImage.initrd.chrp: vmlinux $(wrapperbits) |
123 | cmd_addnote = $(obj)/addnote $@ | 125 | $(call cmd,wrap_initrd,chrp) |
124 | 126 | ||
125 | quiet_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 | ||
129 | quiet_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 | |
154 | image-$(CONFIG_PPC_PSERIES) += zImage.pseries | ||
155 | image-$(CONFIG_PPC_MAPLE) += zImage.pseries | ||
156 | image-$(CONFIG_PPC_CELL) += zImage.pseries | ||
157 | image-$(CONFIG_PPC_CHRP) += zImage.chrp | ||
158 | image-$(CONFIG_PPC_PMAC) += zImage.pmac | ||
159 | image-$(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. |
156 | coffimage-$(CONFIG_PPC_PMAC)-$(CONFIG_PPC32) := $(obj)/zImage.coff | 163 | ifeq ($(CONFIG_PPC32),y) |
157 | coffrdimg-$(CONFIG_PPC_PMAC)-$(CONFIG_PPC32) := $(obj)/zImage.initrd.coff | 164 | image-$(CONFIG_PPC_PMAC) += zImage.coff zImage.miboot |
158 | mibootimg-$(CONFIG_PPC_PMAC)-$(CONFIG_PPC32) := $(obj)/miboot.image | 165 | endif |
159 | mibrdimg-$(CONFIG_PPC_PMAC)-$(CONFIG_PPC32) := $(obj)/miboot.initrd.image | 166 | |
160 | 167 | initrd-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) | 174 | install: $(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 | 177 | clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip.gz) | |
171 | $(obj)/zImage.coff: $(call obj-sec, $(required)) $(obj-boot) \ | 178 | clean-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 | #----------------------------------------------------------- | ||
190 | quiet_cmd_mygzip = GZIP $@ | ||
191 | cmd_mygzip = gzip -f -9 < $< > $@.$$$$ && mv $@.$$$$ $@ | ||
192 | |||
193 | quiet_cmd_objbin = OBJCOPY $@ | ||
194 | cmd_objbin = $(OBJCOPY) -O binary $< $@ | ||
195 | |||
196 | quiet_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 | |||
201 | MKIMAGE := $(srctree)/scripts/mkuboot.sh | ||
202 | targets += uImage | ||
203 | extra-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 | |||
217 | install: $(CONFIGURE) $(BOOTIMAGE) | ||
218 | sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" "$(BOOTIMAGE)" | ||
219 | |||
220 | clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip) | ||