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