]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/powerpc/Makefile
powerpc: Fix module building for gcc 4.5 and 64 bit
[net-next-2.6.git] / arch / powerpc / Makefile
CommitLineData
14cf11af
PM
1# This file is included by the global makefile so that you can add your own
2# architecture-specific flags and dependencies. Remember to do have actions
3# for "archclean" and "archdep" for cleaning up and making dependencies for
4# this architecture.
5#
6# This file is subject to the terms and conditions of the GNU General Public
7# License. See the file "COPYING" in the main directory of this archive
8# for more details.
9#
10# Copyright (C) 1994 by Linus Torvalds
11# Changes for PPC by Gary Thomas
12# Rewritten by Cort Dougan and Paul Mackerras
13#
14
14cf11af
PM
15HAS_BIARCH := $(call cc-option-yn, -m32)
16
14cf11af
PM
17# Set default 32 bits cross compilers for vdso and boot wrapper
18CROSS32_COMPILE ?=
19
20CROSS32CC := $(CROSS32_COMPILE)gcc
2bf11819 21CROSS32AR := $(CROSS32_COMPILE)ar
14cf11af
PM
22
23ifeq ($(HAS_BIARCH),y)
24ifeq ($(CROSS32_COMPILE),)
25CROSS32CC := $(CC) -m32
8995ac87 26CROSS32AR := GNUTARGET=elf32-powerpc $(AR)
14cf11af
PM
27endif
28endif
29
1976aef9 30export CROSS32CC CROSS32AR
14cf11af 31
ca786f83 32ifeq ($(CROSS_COMPILE),)
8a5abdf8 33KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
ca786f83
AB
34else
35KBUILD_DEFCONFIG := ppc64_defconfig
36endif
8a5abdf8 37
94b212c2
PM
38ifeq ($(CONFIG_PPC64),y)
39OLDARCH := ppc64
94b212c2 40
14cf11af
PM
41new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
42
43ifeq ($(new_nm),y)
44NM := $(NM) --synthetic
45endif
46
47else
bbeb3f4c 48OLDARCH := ppc
2578bfae
SR
49endif
50
51# It seems there are times we use this Makefile without
52# including the config file, but this replicates the old behaviour
53ifeq ($(CONFIG_WORD_SIZE),)
54CONFIG_WORD_SIZE := 32
14cf11af
PM
55endif
56
190554db
SR
57UTS_MACHINE := $(OLDARCH)
58
14cf11af 59ifeq ($(HAS_BIARCH),y)
2578bfae
SR
60override AS += -a$(CONFIG_WORD_SIZE)
61override LD += -m elf$(CONFIG_WORD_SIZE)ppc
62override CC += -m$(CONFIG_WORD_SIZE)
63override AR := GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR)
14cf11af
PM
64endif
65
549e8152
PM
66LDFLAGS_vmlinux-yy := -Bstatic
67LDFLAGS_vmlinux-$(CONFIG_PPC64)$(CONFIG_RELOCATABLE) := -pie
68LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-yy)
14cf11af 69
bbeb3f4c 70CFLAGS-$(CONFIG_PPC64) := -mminimal-toc -mtraceback=none -mcall-aixdesc
1993cbf4
KG
71CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 -mmultiple
72KBUILD_CPPFLAGS += -Iarch/$(ARCH)
73KBUILD_AFLAGS += -Iarch/$(ARCH)
74KBUILD_CFLAGS += -msoft-float -pipe -Iarch/$(ARCH) $(CFLAGS-y)
a0f97e06 75CPP = $(CC) -E $(KBUILD_CFLAGS)
14cf11af 76
2578bfae 77CHECKFLAGS += -m$(CONFIG_WORD_SIZE) -D__powerpc__ -D__powerpc$(CONFIG_WORD_SIZE)__
14cf11af
PM
78
79ifeq ($(CONFIG_PPC64),y)
f7d4f68d 80GCC_BROKEN_VEC := $(call cc-ifversion, -lt, 0400, y)
14cf11af
PM
81
82ifeq ($(CONFIG_POWER4_ONLY),y)
83ifeq ($(CONFIG_ALTIVEC),y)
84ifeq ($(GCC_BROKEN_VEC),y)
a0f97e06 85 KBUILD_CFLAGS += $(call cc-option,-mcpu=970)
14cf11af 86else
a0f97e06 87 KBUILD_CFLAGS += $(call cc-option,-mcpu=power4)
14cf11af
PM
88endif
89else
a0f97e06 90 KBUILD_CFLAGS += $(call cc-option,-mcpu=power4)
14cf11af
PM
91endif
92else
a0f97e06 93 KBUILD_CFLAGS += $(call cc-option,-mtune=power4)
14cf11af
PM
94endif
95endif
96
7fca5dc8
SR
97LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
98
3164cccd 99ifeq ($(CONFIG_TUNE_CELL),y)
a0f97e06 100 KBUILD_CFLAGS += $(call cc-option,-mtune=cell)
3164cccd
AB
101endif
102
d3f67fbb 103# No AltiVec instruction when building kernel
a0f97e06 104KBUILD_CFLAGS += $(call cc-option,-mno-altivec)
d3f67fbb 105
0197cd2e 106# No SPE instruction when building kernel
ce400c01 107# (We use all available options to help semi-broken compilers)
0197cd2e 108KBUILD_CFLAGS += $(call cc-option,-mno-spe)
ce400c01 109KBUILD_CFLAGS += $(call cc-option,-mspe=no)
0197cd2e 110
14cf11af
PM
111# Enable unit-at-a-time mode when possible. It shrinks the
112# kernel considerably.
a0f97e06 113KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
14cf11af 114
d0679c73
AK
115# FIXME: the module load should be taught about the additional relocs
116# generated by this.
117# revert to pre-gcc-4.4 behaviour of .eh_frame
118KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
119
57647a4d
BH
120# Never use string load/store instructions as they are
121# often slow when they are implemented at all
a0f97e06 122KBUILD_CFLAGS += -mno-string
14cf11af 123
f48b8296 124ifeq ($(CONFIG_6xx),y)
a0f97e06 125KBUILD_CFLAGS += -mcpu=powerpc
f48b8296
OH
126endif
127
7563dc64 128# Work around a gcc code-gen bug with -fno-omit-frame-pointer.
606576ce 129ifeq ($(CONFIG_FUNCTION_TRACER),y)
7563dc64
TB
130KBUILD_CFLAGS += -mno-sched-epilog
131endif
132
14cf11af
PM
133cpu-as-$(CONFIG_4xx) += -Wa,-m405
134cpu-as-$(CONFIG_6xx) += -Wa,-maltivec
135cpu-as-$(CONFIG_POWER4) += -Wa,-maltivec
136cpu-as-$(CONFIG_E500) += -Wa,-me500
137cpu-as-$(CONFIG_E200) += -Wa,-me200
138
222d394d 139KBUILD_AFLAGS += $(cpu-as-y)
a0f97e06 140KBUILD_CFLAGS += $(cpu-as-y)
14cf11af 141
2578bfae 142head-y := arch/powerpc/kernel/head_$(CONFIG_WORD_SIZE).o
14cf11af 143head-$(CONFIG_8xx) := arch/powerpc/kernel/head_8xx.o
15f6527e 144head-$(CONFIG_40x) := arch/powerpc/kernel/head_40x.o
14cf11af
PM
145head-$(CONFIG_44x) := arch/powerpc/kernel/head_44x.o
146head-$(CONFIG_FSL_BOOKE) := arch/powerpc/kernel/head_fsl_booke.o
147
9994a338 148head-$(CONFIG_PPC64) += arch/powerpc/kernel/entry_64.o
14cf11af 149head-$(CONFIG_PPC_FPU) += arch/powerpc/kernel/fpu.o
e821ea70 150head-$(CONFIG_ALTIVEC) += arch/powerpc/kernel/vector.o
14cf11af 151
daec962e 152core-y += arch/powerpc/kernel/ \
daec962e
PM
153 arch/powerpc/mm/ \
154 arch/powerpc/lib/ \
155 arch/powerpc/sysdev/ \
1a3d1fc2
LY
156 arch/powerpc/platforms/ \
157 arch/powerpc/math-emu/
f78541dc 158core-$(CONFIG_XMON) += arch/powerpc/xmon/
bbf45ba5 159core-$(CONFIG_KVM) += arch/powerpc/kvm/
14cf11af
PM
160
161drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
162
135f0b17 163# Default to zImage, override when needed
25431333 164all: zImage
14cf11af 165
8d6bcd6e 166BOOT_TARGETS = zImage zImage.initrd uImage zImage% dtbImage% treeImage.% cuImage.% simpleImage.%
cabb5587 167
4f193362 168PHONY += $(BOOT_TARGETS)
cabb5587 169
94b212c2 170boot := arch/$(ARCH)/boot
14cf11af 171
144ef909
TB
172ifeq ($(CONFIG_RELOCATABLE),y)
173quiet_cmd_relocs_check = CALL $<
174 cmd_relocs_check = perl $< "$(OBJDUMP)" "$(obj)/vmlinux"
175
176PHONY += relocs_check
177relocs_check: arch/powerpc/relocs_check.pl vmlinux
178 $(call cmd,relocs_check)
179
180zImage: relocs_check
181endif
182
20f62954
PM
183$(BOOT_TARGETS): vmlinux
184 $(Q)$(MAKE) ARCH=ppc64 $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
773f76b1 185
e04018e8 186bootwrapper_install %.dtb:
773f76b1 187 $(Q)$(MAKE) ARCH=ppc64 $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
14cf11af
PM
188
189define archhelp
70bf0333
GL
190 @echo '* zImage - Build default images selected by kernel config'
191 @echo ' zImage.* - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)'
192 @echo ' uImage - U-Boot native image format'
193 @echo ' cuImage.<dt> - Backwards compatible U-Boot image for older'
194 @echo ' versions which do not support device trees'
195 @echo ' dtbImage.<dt> - zImage with an embedded device tree blob'
196 @echo ' simpleImage.<dt> - Firmware independent image.'
197 @echo ' treeImage.<dt> - Support for older IBM 4xx firmware (not U-Boot)'
14cf11af 198 @echo ' install - Install kernel using'
caa27b66
SR
199 @echo ' (your) ~/bin/$(INSTALLKERNEL) or'
200 @echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
14cf11af 201 @echo ' install to $$(INSTALL_PATH) and run lilo'
437a58db 202 @echo ' *_defconfig - Select default config from arch/$(ARCH)/configs'
70bf0333
GL
203 @echo ''
204 @echo ' Targets with <dt> embed a device tree blob inside the image'
205 @echo ' These targets support board with firmware that does not'
206 @echo ' support passing a device tree directly. Replace <dt> with the'
207 @echo ' name of a dts file from the arch/$(ARCH)/boot/dts/ directory'
208 @echo ' (minus the .dts extension).'
14cf11af
PM
209endef
210
3f85d63e 211install:
25431333 212 $(Q)$(MAKE) $(build)=$(boot) install
928370c6 213
8150caad
RM
214vdso_install:
215ifeq ($(CONFIG_PPC64),y)
216 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
217endif
218 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
219
14cf11af 220archclean:
a3a9e99e 221 $(Q)$(MAKE) $(clean)=$(boot)
70567293 222
14cf11af
PM
223archprepare: checkbin
224
14cf11af
PM
225# Use the file '.tmp_gas_check' for binutils tests, as gas won't output
226# to stdout and these checks are run even on install targets.
227TOUT := .tmp_gas_check
228# Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec
229# instructions.
230# gcc-3.4 and binutils-2.14 are a fatal combination.
14cf11af
PM
231
232checkbin:
ad14336d 233 @if test "$(call cc-version)" = "0304" ; then \
14cf11af
PM
234 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \
235 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \
236 echo 'correctly with gcc-3.4 and your version of binutils.'; \
237 echo '*** Please upgrade your binutils or downgrade your gcc'; \
238 false; \
239 fi ; \
240 fi
f5e83fa4
SB
241 @if test "$(call cc-fullversion)" = "040200" \
242 && test "x${CONFIG_MODULES}${CONFIG_PPC64}" = "xyy" ; then \
243 echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \
244 echo 'kernel with modules enabled.' ; \
245 echo -n '*** Please use a different GCC version or ' ; \
246 echo 'disable kernel modules' ; \
247 false ; \
248 fi
14cf11af
PM
249 @if ! /bin/echo dssall | $(AS) -many -o $(TOUT) >/dev/null 2>&1 ; then \
250 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build ' ; \
251 echo 'correctly with old versions of binutils.' ; \
252 echo '*** Please upgrade your binutils to 2.12.1 or newer' ; \
253 false ; \
254 fi
255
256CLEAN_FILES += $(TOUT)
257