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