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