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