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 PM |
27 | |
28 | ifeq ($(call cc-option-yn, -fstack-protector),y) | |
29 | BOOTCFLAGS += -fno-stack-protector | |
30 | endif | |
31 | ||
32 | BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj) | |
1da177e4 | 33 | |
869680c1 | 34 | $(obj)/4xx.o: BOOTCFLAGS += -mcpu=440 |
988519ac | 35 | $(obj)/ebony.o: BOOTCFLAGS += -mcpu=440 |
60e41753 | 36 | |
4f3865fb RP |
37 | zlib := inffast.c inflate.c inftrees.c |
38 | zlibheader := inffast.h inffixed.h inflate.h inftrees.h infutil.h | |
7054036f OH |
39 | zliblinuxheader := zlib.h zconf.h zutil.h |
40 | ||
d25a9d66 DG |
41 | $(addprefix $(obj)/,$(zlib) gunzip_util.o main.o): \ |
42 | $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader)) | |
2bf11819 | 43 | |
cd197ffc | 44 | src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \ |
ad9d2716 | 45 | ns16550.c serial.c simple_alloc.c div64.S util.S \ |
2e601613 | 46 | gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \ |
d0f53faf | 47 | 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \ |
fec60470 | 48 | cpm-serial.c stdlib.c mpc52xx-psc.c planetcore.c |
85498ae8 | 49 | src-plat := of.c cuboot-52xx.c cuboot-83xx.c cuboot-85xx.c holly.c \ |
bafdb645 | 50 | cuboot-ebony.c treeboot-ebony.c prpmc2800.c \ |
606d08bc | 51 | ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \ |
658e8170 | 52 | cuboot-pq2.c cuboot-sequoia.c treeboot-walnut.c cuboot-bamboo.c |
cd197ffc | 53 | src-boot := $(src-wlib) $(src-plat) empty.c |
7054036f | 54 | |
1da177e4 LT |
55 | src-boot := $(addprefix $(obj)/, $(src-boot)) |
56 | obj-boot := $(addsuffix .o, $(basename $(src-boot))) | |
2bf11819 PM |
57 | obj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib)))) |
58 | obj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat)))) | |
7054036f OH |
59 | |
60 | quiet_cmd_copy_zlib = COPY $@ | |
67ccd2fc | 61 | cmd_copy_zlib = sed "s@__attribute_used__@@;s@<linux/\([^>]*\).*@\"\1\"@" $< > $@ |
7054036f OH |
62 | |
63 | quiet_cmd_copy_zlibheader = COPY $@ | |
67ccd2fc | 64 | cmd_copy_zlibheader = sed "s@<linux/\([^>]*\).*@\"\1\"@" $< > $@ |
7054036f OH |
65 | # stddef.h for NULL |
66 | quiet_cmd_copy_zliblinuxheader = COPY $@ | |
67ccd2fc | 67 | cmd_copy_zliblinuxheader = sed "s@<linux/string.h>@\"string.h\"@;s@<linux/kernel.h>@<stddef.h>@;s@<linux/\([^>]*\).*@\"\1\"@" $< > $@ |
7054036f OH |
68 | |
69 | $(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/% | |
70 | $(call cmd,copy_zlib) | |
71 | ||
72 | $(addprefix $(obj)/,$(zlibheader)): $(obj)/%: $(srctree)/lib/zlib_inflate/% | |
73 | $(call cmd,copy_zlibheader) | |
74 | ||
75 | $(addprefix $(obj)/,$(zliblinuxheader)): $(obj)/%: $(srctree)/include/linux/% | |
76 | $(call cmd,copy_zliblinuxheader) | |
77 | ||
2bf11819 PM |
78 | $(obj)/empty.c: |
79 | @touch $@ | |
80 | ||
bafdb645 | 81 | $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds: $(obj)/%: $(srctree)/$(src)/%.S |
2bf11819 | 82 | @cp $< $@ |
7054036f | 83 | |
2bf11819 | 84 | clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \ |
bafdb645 | 85 | empty.c zImage zImage.coff.lds zImage.ps3.lds zImage.lds |
7054036f | 86 | |
1da177e4 LT |
87 | quiet_cmd_bootcc = BOOTCC $@ |
88 | cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $< | |
89 | ||
90 | quiet_cmd_bootas = BOOTAS $@ | |
91 | cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< | |
92 | ||
2bf11819 | 93 | quiet_cmd_bootar = BOOTAR $@ |
235fd835 | 94 | cmd_bootar = $(CROSS32AR) -cr $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ |
a24c8481 | 95 | |
235fd835 | 96 | $(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE |
1da177e4 | 97 | $(call if_changed_dep,bootcc) |
235fd835 | 98 | $(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE |
1da177e4 LT |
99 | $(call if_changed_dep,bootas) |
100 | ||
235fd835 MM |
101 | $(obj)/wrapper.a: $(obj-wlib) FORCE |
102 | $(call if_changed,bootar) | |
1da177e4 | 103 | |
0cfcccb4 | 104 | hostprogs-y := addnote addRamDisk hack-coff mktree |
1da177e4 | 105 | |
235fd835 | 106 | targets += $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a) |
cd197ffc | 107 | extra-y := $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \ |
bafdb645 | 108 | $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds |
66a45dd3 | 109 | |
2bf11819 | 110 | wrapper :=$(srctree)/$(src)/wrapper |
65b58039 | 111 | wrapperbits := $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) \ |
235fd835 | 112 | $(wrapper) FORCE |
1da177e4 | 113 | |
2bf11819 PM |
114 | ############# |
115 | # Bits for building various flavours of zImage | |
1da177e4 | 116 | |
2bf11819 | 117 | ifneq ($(CROSS32_COMPILE),) |
dcf90651 | 118 | CROSSWRAP := -C "$(CROSS32_COMPILE)" |
2bf11819 PM |
119 | else |
120 | ifneq ($(CROSS_COMPILE),) | |
dcf90651 | 121 | CROSSWRAP := -C "$(CROSS_COMPILE)" |
2bf11819 PM |
122 | endif |
123 | endif | |
1da177e4 | 124 | |
9da82a6d | 125 | # args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd |
2bf11819 | 126 | quiet_cmd_wrap = WRAP $@ |
9da82a6d MM |
127 | cmd_wrap =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \ |
128 | $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux | |
2bf11819 | 129 | |
020533ef GL |
130 | image-$(CONFIG_PPC_PSERIES) += zImage.pseries |
131 | image-$(CONFIG_PPC_MAPLE) += zImage.pseries | |
132 | image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries | |
8a8944aa | 133 | image-$(CONFIG_PPC_PS3) += zImage.ps3 |
c347b798 | 134 | image-$(CONFIG_PPC_CELLEB) += zImage.pseries |
020533ef | 135 | image-$(CONFIG_PPC_CHRP) += zImage.chrp |
7839af33 | 136 | image-$(CONFIG_PPC_EFIKA) += zImage.chrp |
020533ef | 137 | image-$(CONFIG_PPC_PMAC) += zImage.pmac |
b0e80206 | 138 | image-$(CONFIG_PPC_HOLLY) += zImage.holly |
c368d921 | 139 | image-$(CONFIG_PPC_PRPMC2800) += zImage.prpmc2800 |
0570d4ed | 140 | image-$(CONFIG_PPC_ISERIES) += zImage.iseries |
ac18c673 SW |
141 | image-$(CONFIG_DEFAULT_UIMAGE) += uImage |
142 | ||
143 | ifneq ($(CONFIG_DEVICE_TREE),"") | |
0b195812 | 144 | image-$(CONFIG_PPC_8xx) += cuImage.8xx |
e5d8d54d | 145 | image-$(CONFIG_8260) += cuImage.pq2 |
85498ae8 | 146 | image-$(CONFIG_PPC_MPC52xx) += cuImage.52xx |
a6afacb6 DG |
147 | image-$(CONFIG_PPC_83xx) += cuImage.83xx |
148 | image-$(CONFIG_PPC_85xx) += cuImage.85xx | |
f6dfc805 | 149 | image-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony |
658e8170 | 150 | image-$(CONFIG_BAMBOO) += treeImage.bamboo cuImage.bamboo |
606d08bc | 151 | image-$(CONFIG_SEQUOIA) += cuImage.sequoia |
5326152f | 152 | image-$(CONFIG_WALNUT) += treeImage.walnut |
ac18c673 | 153 | endif |
66a45dd3 | 154 | |
9216ad8c PM |
155 | # For 32-bit powermacs, build the COFF and miboot images |
156 | # as well as the ELF images. | |
2bf11819 PM |
157 | ifeq ($(CONFIG_PPC32),y) |
158 | image-$(CONFIG_PPC_PMAC) += zImage.coff zImage.miboot | |
159 | endif | |
160 | ||
5d7960ff | 161 | initrd- := $(patsubst zImage%, zImage.initrd%, $(image-n) $(image-)) |
f6dfc805 DG |
162 | initrd-y := $(patsubst zImage%, zImage.initrd%, \ |
163 | $(patsubst treeImage%, treeImage.initrd%, $(image-y))) | |
9da82a6d | 164 | initrd-y := $(filter-out $(image-y), $(initrd-y)) |
235fd835 | 165 | targets += $(image-y) $(initrd-y) |
2bf11819 | 166 | |
9da82a6d MM |
167 | $(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz |
168 | ||
a00cec48 MG |
169 | # If CONFIG_WANT_DEVICE_TREE is set and CONFIG_DEVICE_TREE isn't an |
170 | # empty string, define 'dts' to be path to the dts | |
171 | # CONFIG_DEVICE_TREE will have "" around it, make sure to strip them | |
172 | ifeq ($(CONFIG_WANT_DEVICE_TREE),y) | |
173 | ifneq ($(CONFIG_DEVICE_TREE),"") | |
174 | dts = $(if $(shell echo $(CONFIG_DEVICE_TREE) | grep '^/'),\ | |
175 | ,$(srctree)/$(src)/dts/)$(CONFIG_DEVICE_TREE:"%"=%) | |
176 | endif | |
177 | endif | |
178 | ||
9da82a6d MM |
179 | # Don't put the ramdisk on the pattern rule; when its missing make will try |
180 | # the pattern rule with less dependencies that also matches (even with the | |
181 | # hard dependency listed). | |
a00cec48 MG |
182 | $(obj)/zImage.initrd.%: vmlinux $(wrapperbits) $(dts) |
183 | $(call if_changed,wrap,$*,$(dts),,$(obj)/ramdisk.image.gz) | |
9da82a6d | 184 | |
a00cec48 MG |
185 | $(obj)/zImage.%: vmlinux $(wrapperbits) $(dts) |
186 | $(call if_changed,wrap,$*,$(dts)) | |
9da82a6d | 187 | |
4bb09281 TB |
188 | # This cannot be in the root of $(src) as the zImage rule always adds a $(obj) |
189 | # prefix | |
190 | $(obj)/vmlinux.strip: vmlinux | |
191 | $(STRIP) -s -R .comment $< -o $@ | |
192 | ||
0570d4ed SR |
193 | $(obj)/zImage.iseries: vmlinux |
194 | $(STRIP) -s -R .comment $< -o $@ | |
195 | ||
bafdb645 GL |
196 | $(obj)/zImage.ps3: vmlinux $(wrapper) $(wrapperbits) $(srctree)/$(src)/dts/ps3.dts |
197 | $(STRIP) -s -R .comment $< -o vmlinux.strip | |
198 | $(call cmd,wrap,ps3,$(srctree)/$(src)/dts/ps3.dts,,) | |
9da82a6d | 199 | |
bafdb645 GL |
200 | $(obj)/zImage.initrd.ps3: vmlinux $(wrapper) $(wrapperbits) $(srctree)/$(src)/dts/ps3.dts $(obj)/ramdisk.image.gz |
201 | $(call cmd,wrap,ps3,$(srctree)/$(src)/dts/ps3.dts,,$(obj)/ramdisk.image.gz) | |
9da82a6d MM |
202 | |
203 | $(obj)/uImage: vmlinux $(wrapperbits) | |
204 | $(call if_changed,wrap,uboot) | |
205 | ||
d25a9d66 | 206 | $(obj)/cuImage.%: vmlinux $(dts) $(wrapperbits) |
a6afacb6 | 207 | $(call if_changed,wrap,cuboot-$*,$(dts)) |
0fdd717e | 208 | |
f6dfc805 DG |
209 | $(obj)/treeImage.initrd.%: vmlinux $(dts) $(wrapperbits) |
210 | $(call if_changed,wrap,treeboot-$*,$(dts),,$(obj)/ramdisk.image.gz) | |
211 | ||
6a32d085 DG |
212 | $(obj)/treeImage.%: vmlinux $(dts) $(wrapperbits) |
213 | $(call if_changed,wrap,treeboot-$*,$(dts)) | |
214 | ||
4bb09281 TB |
215 | # If there isn't a platform selected then just strip the vmlinux. |
216 | ifeq (,$(image-y)) | |
217 | image-y := vmlinux.strip | |
218 | endif | |
219 | ||
2bf11819 PM |
220 | $(obj)/zImage: $(addprefix $(obj)/, $(image-y)) |
221 | @rm -f $@; ln $< $@ | |
222 | $(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y)) | |
223 | @rm -f $@; ln $< $@ | |
224 | ||
928370c6 | 225 | install: $(CONFIGURE) $(addprefix $(obj)/, $(image-y)) |
2bf11819 PM |
226 | sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $< |
227 | ||
1383a34f | 228 | # anything not in $(targets) |
bafdb645 GL |
229 | clean-files += $(image-) $(initrd-) zImage zImage.initrd cuImage.* treeImage.* \ |
230 | otheros.bld | |
1383a34f MM |
231 | |
232 | # clean up files cached by wrapper | |
233 | clean-kernel := vmlinux.strip vmlinux.bin | |
234 | clean-kernel += $(addsuffix .gz,$(clean-kernel)) | |
235 | # If not absolute clean-files are relative to $(obj). | |
236 | clean-files += $(addprefix $(objtree)/, $(clean-kernel)) |