]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | # Makefile for making ELF bootable images for booting on CHRP |
2 | # using Open Firmware. | |
3 | # | |
4 | # Geert Uytterhoeven September 1997 | |
5 | # | |
6 | # Based on coffboot by Paul Mackerras | |
7 | # Simplified for ppc64 by Todd Inglett | |
8 | # | |
9 | # NOTE: this code is built for 32 bit in ELF32 format even though | |
10 | # it packages a 64 bit kernel. We do this to simplify the | |
11 | # bootloader and increase compatibility with OpenFirmware. | |
12 | # | |
13 | # To this end we need to define BOOTCC, etc, as the tools | |
b610b978 DG |
14 | # needed to build the 32 bit image. That's normally the same |
15 | # compiler for the rest of the kernel, with the -m32 flag added. | |
1da177e4 LT |
16 | # To make it easier to setup a cross compiler, |
17 | # CROSS32_COMPILE is setup as a prefix just like CROSS_COMPILE | |
18 | # in the toplevel makefile. | |
19 | ||
2bf11819 | 20 | all: $(obj)/zImage |
1da177e4 | 21 | |
b610b978 DG |
22 | BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ |
23 | -fno-strict-aliasing -Os -msoft-float -pipe \ | |
24 | -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \ | |
25 | -isystem $(shell $(CROSS32CC) -print-file-name=include) | |
decd300b | 26 | BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc |
2bf11819 | 27 | |
105c13dd GL |
28 | ifdef CONFIG_DEBUG_INFO |
29 | BOOTCFLAGS += -g | |
30 | endif | |
31 | ||
2bf11819 PM |
32 | ifeq ($(call cc-option-yn, -fstack-protector),y) |
33 | BOOTCFLAGS += -fno-stack-protector | |
34 | endif | |
35 | ||
2f0dfeaa | 36 | BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj) -I$(srctree)/$(src)/libfdt |
1da177e4 | 37 | |
869680c1 | 38 | $(obj)/4xx.o: BOOTCFLAGS += -mcpu=440 |
988519ac | 39 | $(obj)/ebony.o: BOOTCFLAGS += -mcpu=440 |
2e71cc0d | 40 | $(obj)/treeboot-walnut.o: BOOTCFLAGS += -mcpu=405 |
60e41753 | 41 | |
4f3865fb RP |
42 | zlib := inffast.c inflate.c inftrees.c |
43 | zlibheader := inffast.h inffixed.h inflate.h inftrees.h infutil.h | |
7054036f OH |
44 | zliblinuxheader := zlib.h zconf.h zutil.h |
45 | ||
d25a9d66 DG |
46 | $(addprefix $(obj)/,$(zlib) gunzip_util.o main.o): \ |
47 | $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader)) | |
2bf11819 | 48 | |
2f0dfeaa | 49 | src-libfdt := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c |
430b01e8 | 50 | src-wlib := string.S crt0.S stdio.c main.c \ |
2f0dfeaa | 51 | $(addprefix libfdt/,$(src-libfdt)) libfdt-wrapper.c \ |
ad9d2716 | 52 | ns16550.c serial.c simple_alloc.c div64.S util.S \ |
2e601613 | 53 | gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \ |
d0f53faf | 54 | 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \ |
bbc6fac3 SW |
55 | cpm-serial.c stdlib.c mpc52xx-psc.c planetcore.c uartlite.c \ |
56 | fsl-soc.c mpc8xx.c pq2.c | |
85498ae8 | 57 | src-plat := of.c cuboot-52xx.c cuboot-83xx.c cuboot-85xx.c holly.c \ |
bafdb645 | 58 | cuboot-ebony.c treeboot-ebony.c prpmc2800.c \ |
606d08bc | 59 | ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \ |
11c146cc | 60 | cuboot-pq2.c cuboot-sequoia.c treeboot-walnut.c cuboot-bamboo.c \ |
c4e05bc5 | 61 | fixed-head.S ep88xc.c cuboot-hpc2.c |
cd197ffc | 62 | src-boot := $(src-wlib) $(src-plat) empty.c |
7054036f | 63 | |
1da177e4 LT |
64 | src-boot := $(addprefix $(obj)/, $(src-boot)) |
65 | obj-boot := $(addsuffix .o, $(basename $(src-boot))) | |
2bf11819 PM |
66 | obj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib)))) |
67 | obj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat)))) | |
7054036f OH |
68 | |
69 | quiet_cmd_copy_zlib = COPY $@ | |
67ccd2fc | 70 | cmd_copy_zlib = sed "s@__attribute_used__@@;s@<linux/\([^>]*\).*@\"\1\"@" $< > $@ |
7054036f OH |
71 | |
72 | quiet_cmd_copy_zlibheader = COPY $@ | |
67ccd2fc | 73 | cmd_copy_zlibheader = sed "s@<linux/\([^>]*\).*@\"\1\"@" $< > $@ |
7054036f OH |
74 | # stddef.h for NULL |
75 | quiet_cmd_copy_zliblinuxheader = COPY $@ | |
67ccd2fc | 76 | cmd_copy_zliblinuxheader = sed "s@<linux/string.h>@\"string.h\"@;s@<linux/kernel.h>@<stddef.h>@;s@<linux/\([^>]*\).*@\"\1\"@" $< > $@ |
7054036f OH |
77 | |
78 | $(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/% | |
79 | $(call cmd,copy_zlib) | |
80 | ||
81 | $(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/% | |
82 | $(call cmd,copy_zlibheader) | |
83 | ||
84 | $(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/% | |
85 | $(call cmd,copy_zliblinuxheader) | |
86 | ||
2bf11819 PM |
87 | $(obj)/empty.c: |
88 | @touch $@ | |
89 | ||
bafdb645 | 90 | $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds: $(obj)/%: $(srctree)/$(src)/%.S |
2bf11819 | 91 | @cp $< $@ |
7054036f | 92 | |
2bf11819 | 93 | clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \ |
bafdb645 | 94 | empty.c zImage zImage.coff.lds zImage.ps3.lds zImage.lds |
7054036f | 95 | |
1da177e4 LT |
96 | quiet_cmd_bootcc = BOOTCC $@ |
97 | cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $< | |
98 | ||
99 | quiet_cmd_bootas = BOOTAS $@ | |
100 | cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< | |
101 | ||
2bf11819 | 102 | quiet_cmd_bootar = BOOTAR $@ |
235fd835 | 103 | cmd_bootar = $(CROSS32AR) -cr $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ |
a24c8481 | 104 | |
235fd835 | 105 | $(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE |
2f0dfeaa | 106 | $(Q)mkdir -p $(dir $@) |
1da177e4 | 107 | $(call if_changed_dep,bootcc) |
235fd835 | 108 | $(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE |
2f0dfeaa | 109 | $(Q)mkdir -p $(dir $@) |
1da177e4 LT |
110 | $(call if_changed_dep,bootas) |
111 | ||
235fd835 MM |
112 | $(obj)/wrapper.a: $(obj-wlib) FORCE |
113 | $(call if_changed,bootar) | |
1da177e4 | 114 | |
0cfcccb4 | 115 | hostprogs-y := addnote addRamDisk hack-coff mktree |
1da177e4 | 116 | |
235fd835 | 117 | targets += $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a) |
cd197ffc | 118 | extra-y := $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \ |
bafdb645 | 119 | $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds |
66a45dd3 | 120 | |
2bf11819 | 121 | wrapper :=$(srctree)/$(src)/wrapper |
65b58039 | 122 | wrapperbits := $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) \ |
235fd835 | 123 | $(wrapper) FORCE |
1da177e4 | 124 | |
2bf11819 PM |
125 | ############# |
126 | # Bits for building various flavours of zImage | |
1da177e4 | 127 | |
2bf11819 | 128 | ifneq ($(CROSS32_COMPILE),) |
dcf90651 | 129 | CROSSWRAP := -C "$(CROSS32_COMPILE)" |
2bf11819 PM |
130 | else |
131 | ifneq ($(CROSS_COMPILE),) | |
dcf90651 | 132 | CROSSWRAP := -C "$(CROSS_COMPILE)" |
2bf11819 PM |
133 | endif |
134 | endif | |
1da177e4 | 135 | |
9da82a6d | 136 | # args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd |
2bf11819 | 137 | quiet_cmd_wrap = WRAP $@ |
9da82a6d MM |
138 | cmd_wrap =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \ |
139 | $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux | |
2bf11819 | 140 | |
020533ef GL |
141 | image-$(CONFIG_PPC_PSERIES) += zImage.pseries |
142 | image-$(CONFIG_PPC_MAPLE) += zImage.pseries | |
143 | image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries | |
8a8944aa | 144 | image-$(CONFIG_PPC_PS3) += zImage.ps3 |
c347b798 | 145 | image-$(CONFIG_PPC_CELLEB) += zImage.pseries |
020533ef | 146 | image-$(CONFIG_PPC_CHRP) += zImage.chrp |
7839af33 | 147 | image-$(CONFIG_PPC_EFIKA) += zImage.chrp |
020533ef | 148 | image-$(CONFIG_PPC_PMAC) += zImage.pmac |
b0e80206 | 149 | image-$(CONFIG_PPC_HOLLY) += zImage.holly |
c368d921 | 150 | image-$(CONFIG_PPC_PRPMC2800) += zImage.prpmc2800 |
0570d4ed | 151 | image-$(CONFIG_PPC_ISERIES) += zImage.iseries |
ac18c673 SW |
152 | image-$(CONFIG_DEFAULT_UIMAGE) += uImage |
153 | ||
154 | ifneq ($(CONFIG_DEVICE_TREE),"") | |
0b195812 | 155 | image-$(CONFIG_PPC_8xx) += cuImage.8xx |
11c146cc | 156 | image-$(CONFIG_PPC_EP88XC) += zImage.ep88xc |
e5d8d54d | 157 | image-$(CONFIG_8260) += cuImage.pq2 |
85498ae8 | 158 | image-$(CONFIG_PPC_MPC52xx) += cuImage.52xx |
a6afacb6 DG |
159 | image-$(CONFIG_PPC_83xx) += cuImage.83xx |
160 | image-$(CONFIG_PPC_85xx) += cuImage.85xx | |
c4e05bc5 | 161 | image-$(CONFIG_MPC7448HPC2) += cuImage.hpc2 |
f6dfc805 | 162 | image-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony |
658e8170 | 163 | image-$(CONFIG_BAMBOO) += treeImage.bamboo cuImage.bamboo |
606d08bc | 164 | image-$(CONFIG_SEQUOIA) += cuImage.sequoia |
5326152f | 165 | image-$(CONFIG_WALNUT) += treeImage.walnut |
ac18c673 | 166 | endif |
66a45dd3 | 167 | |
9216ad8c PM |
168 | # For 32-bit powermacs, build the COFF and miboot images |
169 | # as well as the ELF images. | |
2bf11819 PM |
170 | ifeq ($(CONFIG_PPC32),y) |
171 | image-$(CONFIG_PPC_PMAC) += zImage.coff zImage.miboot | |
172 | endif | |
173 | ||
5d7960ff | 174 | initrd- := $(patsubst zImage%, zImage.initrd%, $(image-n) $(image-)) |
f6dfc805 DG |
175 | initrd-y := $(patsubst zImage%, zImage.initrd%, \ |
176 | $(patsubst treeImage%, treeImage.initrd%, $(image-y))) | |
9da82a6d | 177 | initrd-y := $(filter-out $(image-y), $(initrd-y)) |
235fd835 | 178 | targets += $(image-y) $(initrd-y) |
2bf11819 | 179 | |
9da82a6d MM |
180 | $(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz |
181 | ||
a00cec48 MG |
182 | # If CONFIG_WANT_DEVICE_TREE is set and CONFIG_DEVICE_TREE isn't an |
183 | # empty string, define 'dts' to be path to the dts | |
184 | # CONFIG_DEVICE_TREE will have "" around it, make sure to strip them | |
185 | ifeq ($(CONFIG_WANT_DEVICE_TREE),y) | |
186 | ifneq ($(CONFIG_DEVICE_TREE),"") | |
187 | dts = $(if $(shell echo $(CONFIG_DEVICE_TREE) | grep '^/'),\ | |
188 | ,$(srctree)/$(src)/dts/)$(CONFIG_DEVICE_TREE:"%"=%) | |
189 | endif | |
190 | endif | |
191 | ||
9da82a6d MM |
192 | # Don't put the ramdisk on the pattern rule; when its missing make will try |
193 | # the pattern rule with less dependencies that also matches (even with the | |
194 | # hard dependency listed). | |
a00cec48 MG |
195 | $(obj)/zImage.initrd.%: vmlinux $(wrapperbits) $(dts) |
196 | $(call if_changed,wrap,$*,$(dts),,$(obj)/ramdisk.image.gz) | |
9da82a6d | 197 | |
a00cec48 MG |
198 | $(obj)/zImage.%: vmlinux $(wrapperbits) $(dts) |
199 | $(call if_changed,wrap,$*,$(dts)) | |
9da82a6d | 200 | |
4bb09281 TB |
201 | # This cannot be in the root of $(src) as the zImage rule always adds a $(obj) |
202 | # prefix | |
203 | $(obj)/vmlinux.strip: vmlinux | |
204 | $(STRIP) -s -R .comment $< -o $@ | |
205 | ||
0570d4ed SR |
206 | $(obj)/zImage.iseries: vmlinux |
207 | $(STRIP) -s -R .comment $< -o $@ | |
208 | ||
bafdb645 GL |
209 | $(obj)/zImage.ps3: vmlinux $(wrapper) $(wrapperbits) $(srctree)/$(src)/dts/ps3.dts |
210 | $(STRIP) -s -R .comment $< -o vmlinux.strip | |
211 | $(call cmd,wrap,ps3,$(srctree)/$(src)/dts/ps3.dts,,) | |
9da82a6d | 212 | |
bafdb645 GL |
213 | $(obj)/zImage.initrd.ps3: vmlinux $(wrapper) $(wrapperbits) $(srctree)/$(src)/dts/ps3.dts $(obj)/ramdisk.image.gz |
214 | $(call cmd,wrap,ps3,$(srctree)/$(src)/dts/ps3.dts,,$(obj)/ramdisk.image.gz) | |
9da82a6d MM |
215 | |
216 | $(obj)/uImage: vmlinux $(wrapperbits) | |
217 | $(call if_changed,wrap,uboot) | |
218 | ||
d25a9d66 | 219 | $(obj)/cuImage.%: vmlinux $(dts) $(wrapperbits) |
a6afacb6 | 220 | $(call if_changed,wrap,cuboot-$*,$(dts)) |
0fdd717e | 221 | |
f6dfc805 DG |
222 | $(obj)/treeImage.initrd.%: vmlinux $(dts) $(wrapperbits) |
223 | $(call if_changed,wrap,treeboot-$*,$(dts),,$(obj)/ramdisk.image.gz) | |
224 | ||
6a32d085 DG |
225 | $(obj)/treeImage.%: vmlinux $(dts) $(wrapperbits) |
226 | $(call if_changed,wrap,treeboot-$*,$(dts)) | |
227 | ||
4bb09281 TB |
228 | # If there isn't a platform selected then just strip the vmlinux. |
229 | ifeq (,$(image-y)) | |
230 | image-y := vmlinux.strip | |
231 | endif | |
232 | ||
2bf11819 PM |
233 | $(obj)/zImage: $(addprefix $(obj)/, $(image-y)) |
234 | @rm -f $@; ln $< $@ | |
235 | $(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y)) | |
236 | @rm -f $@; ln $< $@ | |
237 | ||
928370c6 | 238 | install: $(CONFIGURE) $(addprefix $(obj)/, $(image-y)) |
2bf11819 PM |
239 | sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $< |
240 | ||
1383a34f | 241 | # anything not in $(targets) |
bafdb645 GL |
242 | clean-files += $(image-) $(initrd-) zImage zImage.initrd cuImage.* treeImage.* \ |
243 | otheros.bld | |
1383a34f MM |
244 | |
245 | # clean up files cached by wrapper | |
246 | clean-kernel := vmlinux.strip vmlinux.bin | |
247 | clean-kernel += $(addsuffix .gz,$(clean-kernel)) | |
248 | # If not absolute clean-files are relative to $(obj). | |
249 | clean-files += $(addprefix $(objtree)/, $(clean-kernel)) | |
773f76b1 DW |
250 | |
251 | WRAPPER_OBJDIR := /usr/lib/kernel-wrapper | |
252 | WRAPPER_DTSDIR := /usr/lib/kernel-wrapper/dts | |
253 | WRAPPER_BINDIR := /usr/sbin | |
254 | INSTALL := install | |
255 | ||
256 | extra-installed := $(patsubst $(obj)/%, $(DESTDIR)$(WRAPPER_OBJDIR)/%, $(extra-y)) | |
257 | hostprogs-installed := $(patsubst %, $(DESTDIR)$(WRAPPER_BINDIR)/%, $(hostprogs-y)) | |
258 | wrapper-installed := $(DESTDIR)$(WRAPPER_BINDIR)/wrapper | |
259 | dts-installed := $(patsubst $(obj)/dts/%, $(DESTDIR)$(WRAPPER_DTSDIR)/%, $(wildcard $(obj)/dts/*.dts)) | |
260 | ||
261 | all-installed := $(extra-installed) $(hostprogs-installed) $(wrapper-installed) $(dts-installed) | |
262 | ||
263 | quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) | |
264 | cmd_mkdir = mkdir -p $@ | |
265 | ||
266 | quiet_cmd_install = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,%,$@) | |
267 | cmd_install = $(INSTALL) -m0644 $(patsubst $(DESTDIR)$(WRAPPER_OBJDIR)/%,$(obj)/%,$@) $@ | |
268 | ||
269 | quiet_cmd_install_dts = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,dts/%,$@) | |
270 | cmd_install_dts = $(INSTALL) -m0644 $(patsubst $(DESTDIR)$(WRAPPER_DTSDIR)/%,$(srctree)/$(obj)/dts/%,$@) $@ | |
271 | ||
272 | quiet_cmd_install_exe = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@) | |
273 | cmd_install_exe = $(INSTALL) -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(obj)/%,$@) $@ | |
274 | ||
275 | quiet_cmd_install_wrapper = INSTALL $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,%,$@) | |
276 | cmd_install_wrapper = $(INSTALL) -m0755 $(patsubst $(DESTDIR)$(WRAPPER_BINDIR)/%,$(srctree)/$(obj)/%,$@) $@ ;\ | |
277 | sed -i $@ -e 's%^object=.*%object=$(WRAPPER_OBJDIR)%' \ | |
278 | -e 's%^objbin=.*%objbin=$(WRAPPER_BINDIR)%' \ | |
279 | ||
280 | ||
281 | $(DESTDIR)$(WRAPPER_OBJDIR) $(DESTDIR)$(WRAPPER_DTSDIR) $(DESTDIR)$(WRAPPER_BINDIR): | |
282 | $(call cmd,mkdir) | |
283 | ||
284 | $(extra-installed) : $(DESTDIR)$(WRAPPER_OBJDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_OBJDIR) | |
285 | $(call cmd,install) | |
286 | ||
287 | $(hostprogs-installed) : $(DESTDIR)$(WRAPPER_BINDIR)/% : $(obj)/% | $(DESTDIR)$(WRAPPER_BINDIR) | |
288 | $(call cmd,install_exe) | |
289 | ||
290 | $(dts-installed) : $(DESTDIR)$(WRAPPER_DTSDIR)/% : $(srctree)/$(obj)/dts/% | $(DESTDIR)$(WRAPPER_DTSDIR) | |
291 | $(call cmd,install_dts) | |
292 | ||
293 | $(wrapper-installed): $(DESTDIR)$(WRAPPER_BINDIR) $(srctree)/$(obj)/wrapper | $(DESTDIR)$(WRAPPER_BINDIR) | |
294 | $(call cmd,install_wrapper) | |
295 | ||
296 | $(obj)/bootwrapper_install: $(all-installed) | |
297 |