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