xref: /linux/arch/powerpc/Makefile (revision e1fc235d7425c25f4090438afb4df312c5de0d13)
114cf11afSPaul Mackerras# This file is included by the global makefile so that you can add your own
214cf11afSPaul Mackerras# architecture-specific flags and dependencies. Remember to do have actions
314cf11afSPaul Mackerras# for "archclean" and "archdep" for cleaning up and making dependencies for
414cf11afSPaul Mackerras# this architecture.
514cf11afSPaul Mackerras#
614cf11afSPaul Mackerras# This file is subject to the terms and conditions of the GNU General Public
714cf11afSPaul Mackerras# License.  See the file "COPYING" in the main directory of this archive
814cf11afSPaul Mackerras# for more details.
914cf11afSPaul Mackerras#
1014cf11afSPaul Mackerras# Copyright (C) 1994 by Linus Torvalds
1114cf11afSPaul Mackerras# Changes for PPC by Gary Thomas
1214cf11afSPaul Mackerras# Rewritten by Cort Dougan and Paul Mackerras
1314cf11afSPaul Mackerras#
1414cf11afSPaul Mackerras
1514cf11afSPaul MackerrasHAS_BIARCH	:= $(call cc-option-yn, -m32)
1614cf11afSPaul Mackerras
1714cf11afSPaul Mackerras# Set default 32 bits cross compilers for vdso and boot wrapper
1814cf11afSPaul MackerrasCROSS32_COMPILE ?=
1914cf11afSPaul Mackerras
2014cf11afSPaul MackerrasCROSS32CC		:= $(CROSS32_COMPILE)gcc
212bf11819SPaul MackerrasCROSS32AR		:= $(CROSS32_COMPILE)ar
2214cf11afSPaul Mackerras
2314cf11afSPaul Mackerrasifeq ($(HAS_BIARCH),y)
2414cf11afSPaul Mackerrasifeq ($(CROSS32_COMPILE),)
2514cf11afSPaul MackerrasCROSS32CC	:= $(CC) -m32
268995ac87SSegher BoessenkoolCROSS32AR	:= GNUTARGET=elf32-powerpc $(AR)
2714cf11afSPaul Mackerrasendif
2814cf11afSPaul Mackerrasendif
2914cf11afSPaul Mackerras
301976aef9SSegher Boessenkoolexport CROSS32CC CROSS32AR
3114cf11afSPaul Mackerras
32ca786f83SAdrian Bunkifeq ($(CROSS_COMPILE),)
338a5abdf8SPaul MackerrasKBUILD_DEFCONFIG := $(shell uname -m)_defconfig
34ca786f83SAdrian Bunkelse
35ca786f83SAdrian BunkKBUILD_DEFCONFIG := ppc64_defconfig
36ca786f83SAdrian Bunkendif
378a5abdf8SPaul Mackerras
3894b212c2SPaul Mackerrasifeq ($(CONFIG_PPC64),y)
3994b212c2SPaul MackerrasOLDARCH	:= ppc64
4094b212c2SPaul Mackerras
4114cf11afSPaul Mackerrasnew_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
4214cf11afSPaul Mackerras
4314cf11afSPaul Mackerrasifeq ($(new_nm),y)
4414cf11afSPaul MackerrasNM		:= $(NM) --synthetic
4514cf11afSPaul Mackerrasendif
4614cf11afSPaul Mackerras
4714cf11afSPaul Mackerraselse
48bbeb3f4cSStephen RothwellOLDARCH	:= ppc
492578bfaeSStephen Rothwellendif
502578bfaeSStephen Rothwell
512578bfaeSStephen Rothwell# It seems there are times we use this Makefile without
522578bfaeSStephen Rothwell# including the config file, but this replicates the old behaviour
532578bfaeSStephen Rothwellifeq ($(CONFIG_WORD_SIZE),)
542578bfaeSStephen RothwellCONFIG_WORD_SIZE := 32
5514cf11afSPaul Mackerrasendif
5614cf11afSPaul Mackerras
57190554dbSStephen RothwellUTS_MACHINE := $(OLDARCH)
58190554dbSStephen Rothwell
5914cf11afSPaul Mackerrasifeq ($(HAS_BIARCH),y)
602578bfaeSStephen Rothwelloverride AS	+= -a$(CONFIG_WORD_SIZE)
612578bfaeSStephen Rothwelloverride LD	+= -m elf$(CONFIG_WORD_SIZE)ppc
622578bfaeSStephen Rothwelloverride CC	+= -m$(CONFIG_WORD_SIZE)
632578bfaeSStephen Rothwelloverride AR	:= GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR)
6414cf11afSPaul Mackerrasendif
6514cf11afSPaul Mackerras
66549e8152SPaul MackerrasLDFLAGS_vmlinux-yy := -Bstatic
67549e8152SPaul MackerrasLDFLAGS_vmlinux-$(CONFIG_PPC64)$(CONFIG_RELOCATABLE) := -pie
68549e8152SPaul MackerrasLDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-yy)
6914cf11afSPaul Mackerras
70af9719c3SAnton BlanchardCFLAGS-$(CONFIG_PPC64)	:= -mminimal-toc -mtraceback=no -mcall-aixdesc
711993cbf4SKumar GalaCFLAGS-$(CONFIG_PPC32)	:= -ffixed-r2 -mmultiple
721993cbf4SKumar GalaKBUILD_CPPFLAGS	+= -Iarch/$(ARCH)
731993cbf4SKumar GalaKBUILD_AFLAGS	+= -Iarch/$(ARCH)
741993cbf4SKumar GalaKBUILD_CFLAGS	+= -msoft-float -pipe -Iarch/$(ARCH) $(CFLAGS-y)
75a0f97e06SSam RavnborgCPP		= $(CC) -E $(KBUILD_CFLAGS)
7614cf11afSPaul Mackerras
772578bfaeSStephen RothwellCHECKFLAGS	+= -m$(CONFIG_WORD_SIZE) -D__powerpc__ -D__powerpc$(CONFIG_WORD_SIZE)__
7814cf11afSPaul Mackerras
7914cf11afSPaul Mackerrasifeq ($(CONFIG_PPC64),y)
80f7d4f68dSFrans PopGCC_BROKEN_VEC	:= $(call cc-ifversion, -lt, 0400, y)
8114cf11afSPaul Mackerras
8214cf11afSPaul Mackerrasifeq ($(CONFIG_POWER4_ONLY),y)
8314cf11afSPaul Mackerrasifeq ($(CONFIG_ALTIVEC),y)
8414cf11afSPaul Mackerrasifeq ($(GCC_BROKEN_VEC),y)
85a0f97e06SSam Ravnborg	KBUILD_CFLAGS += $(call cc-option,-mcpu=970)
8614cf11afSPaul Mackerraselse
87a0f97e06SSam Ravnborg	KBUILD_CFLAGS += $(call cc-option,-mcpu=power4)
8814cf11afSPaul Mackerrasendif
8914cf11afSPaul Mackerraselse
90a0f97e06SSam Ravnborg	KBUILD_CFLAGS += $(call cc-option,-mcpu=power4)
9114cf11afSPaul Mackerrasendif
9214cf11afSPaul Mackerraselse
93a0f97e06SSam Ravnborg	KBUILD_CFLAGS += $(call cc-option,-mtune=power4)
9414cf11afSPaul Mackerrasendif
9514cf11afSPaul Mackerrasendif
9614cf11afSPaul Mackerras
97772320e8SMichal MarekKBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
987fca5dc8SStephen Rothwell
993164cccdSArnd Bergmannifeq ($(CONFIG_TUNE_CELL),y)
100a0f97e06SSam Ravnborg	KBUILD_CFLAGS += $(call cc-option,-mtune=cell)
1013164cccdSArnd Bergmannendif
1023164cccdSArnd Bergmann
103d3f67fbbSPaul Mackerras# No AltiVec instruction when building kernel
104a0f97e06SSam RavnborgKBUILD_CFLAGS += $(call cc-option,-mno-altivec)
105d3f67fbbSPaul Mackerras
1060197cd2eSKumar Gala# No SPE instruction when building kernel
107ce400c01SThiemo Seufer# (We use all available options to help semi-broken compilers)
1080197cd2eSKumar GalaKBUILD_CFLAGS += $(call cc-option,-mno-spe)
109ce400c01SThiemo SeuferKBUILD_CFLAGS += $(call cc-option,-mspe=no)
1100197cd2eSKumar Gala
11114cf11afSPaul Mackerras# Enable unit-at-a-time mode when possible. It shrinks the
11214cf11afSPaul Mackerras# kernel considerably.
113a0f97e06SSam RavnborgKBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
11414cf11afSPaul Mackerras
115d0679c73SAndi Kleen# FIXME: the module load should be taught about the additional relocs
116d0679c73SAndi Kleen# generated by this.
117d0679c73SAndi Kleen# revert to pre-gcc-4.4 behaviour of .eh_frame
118d0679c73SAndi KleenKBUILD_CFLAGS	+= $(call cc-option,-fno-dwarf2-cfi-asm)
119d0679c73SAndi Kleen
12057647a4dSBenjamin Herrenschmidt# Never use string load/store instructions as they are
12157647a4dSBenjamin Herrenschmidt# often slow when they are implemented at all
122a0f97e06SSam RavnborgKBUILD_CFLAGS		+= -mno-string
12314cf11afSPaul Mackerras
124f48b8296SOlaf Heringifeq ($(CONFIG_6xx),y)
125a0f97e06SSam RavnborgKBUILD_CFLAGS		+= -mcpu=powerpc
126f48b8296SOlaf Heringendif
127f48b8296SOlaf Hering
1287563dc64STony Breeds# Work around a gcc code-gen bug with -fno-omit-frame-pointer.
129606576ceSSteven Rostedtifeq ($(CONFIG_FUNCTION_TRACER),y)
1307563dc64STony BreedsKBUILD_CFLAGS		+= -mno-sched-epilog
1317563dc64STony Breedsendif
1327563dc64STony Breeds
13314cf11afSPaul Mackerrascpu-as-$(CONFIG_4xx)		+= -Wa,-m405
134*e1fc235dSMatthew McClintockcpu-as-$(CONFIG_ALTIVEC)	+= -Wa,-maltivec
13514cf11afSPaul Mackerrascpu-as-$(CONFIG_E500)		+= -Wa,-me500
13614cf11afSPaul Mackerrascpu-as-$(CONFIG_E200)		+= -Wa,-me200
13714cf11afSPaul Mackerras
138222d394dSSam RavnborgKBUILD_AFLAGS += $(cpu-as-y)
139a0f97e06SSam RavnborgKBUILD_CFLAGS += $(cpu-as-y)
14014cf11afSPaul Mackerras
1412578bfaeSStephen Rothwellhead-y				:= arch/powerpc/kernel/head_$(CONFIG_WORD_SIZE).o
14214cf11afSPaul Mackerrashead-$(CONFIG_8xx)		:= arch/powerpc/kernel/head_8xx.o
14315f6527eSJosh Boyerhead-$(CONFIG_40x)		:= arch/powerpc/kernel/head_40x.o
14414cf11afSPaul Mackerrashead-$(CONFIG_44x)		:= arch/powerpc/kernel/head_44x.o
14514cf11afSPaul Mackerrashead-$(CONFIG_FSL_BOOKE)	:= arch/powerpc/kernel/head_fsl_booke.o
14614cf11afSPaul Mackerras
1479994a338SPaul Mackerrashead-$(CONFIG_PPC64)		+= arch/powerpc/kernel/entry_64.o
14814cf11afSPaul Mackerrashead-$(CONFIG_PPC_FPU)		+= arch/powerpc/kernel/fpu.o
149e821ea70SBenjamin Herrenschmidthead-$(CONFIG_ALTIVEC)		+= arch/powerpc/kernel/vector.o
15014cf11afSPaul Mackerras
151daec962eSPaul Mackerrascore-y				+= arch/powerpc/kernel/ \
152daec962eSPaul Mackerras				   arch/powerpc/mm/ \
153daec962eSPaul Mackerras				   arch/powerpc/lib/ \
154daec962eSPaul Mackerras				   arch/powerpc/sysdev/ \
1551a3d1fc2SLiu Yu				   arch/powerpc/platforms/ \
1560ca87f05SMatt Evans				   arch/powerpc/math-emu/ \
1570ca87f05SMatt Evans				   arch/powerpc/net/
158f78541dcSPaul Mackerrascore-$(CONFIG_XMON)		+= arch/powerpc/xmon/
159bbf45ba5SHollis Blanchardcore-$(CONFIG_KVM) 		+= arch/powerpc/kvm/
16014cf11afSPaul Mackerras
16114cf11afSPaul Mackerrasdrivers-$(CONFIG_OPROFILE)	+= arch/powerpc/oprofile/
16214cf11afSPaul Mackerras
163135f0b17STom Rini# Default to zImage, override when needed
16425431333SGrant Likelyall: zImage
16514cf11afSPaul Mackerras
166e32e78c5SSam Ravnborg# With make 3.82 we cannot mix normal and wildcard targets
167c686ecf5SAnatolij GustschinBOOT_TARGETS1 := zImage zImage.initrd uImage
168e32e78c5SSam RavnborgBOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.%
169cabb5587SStephen Rothwell
170e32e78c5SSam RavnborgPHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2)
171cabb5587SStephen Rothwell
17294b212c2SPaul Mackerrasboot := arch/$(ARCH)/boot
17314cf11afSPaul Mackerras
174144ef909STony Breedsifeq ($(CONFIG_RELOCATABLE),y)
175144ef909STony Breedsquiet_cmd_relocs_check = CALL    $<
176144ef909STony Breeds      cmd_relocs_check = perl $< "$(OBJDUMP)" "$(obj)/vmlinux"
177144ef909STony Breeds
178144ef909STony BreedsPHONY += relocs_check
179144ef909STony Breedsrelocs_check: arch/powerpc/relocs_check.pl vmlinux
180144ef909STony Breeds	$(call cmd,relocs_check)
181144ef909STony Breeds
182144ef909STony BreedszImage: relocs_check
183144ef909STony Breedsendif
184144ef909STony Breeds
185e32e78c5SSam Ravnborg$(BOOT_TARGETS1): vmlinux
186e32e78c5SSam Ravnborg	$(Q)$(MAKE) ARCH=ppc64 $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
187e32e78c5SSam Ravnborg$(BOOT_TARGETS2): vmlinux
18820f62954SPaul Mackerras	$(Q)$(MAKE) ARCH=ppc64 $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
18914cf11afSPaul Mackerras
190e32e78c5SSam Ravnborg
191e32e78c5SSam Ravnborgbootwrapper_install:
192e32e78c5SSam Ravnborg	$(Q)$(MAKE) ARCH=ppc64 $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
193e32e78c5SSam Ravnborg
194e32e78c5SSam Ravnborg%.dtb:
195773f76b1SDavid Woodhouse	$(Q)$(MAKE) ARCH=ppc64 $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
196773f76b1SDavid Woodhouse
19714cf11afSPaul Mackerrasdefine archhelp
19870bf0333SGrant Likely  @echo '* zImage          - Build default images selected by kernel config'
19970bf0333SGrant Likely  @echo '  zImage.*        - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)'
20070bf0333SGrant Likely  @echo '  uImage          - U-Boot native image format'
20170bf0333SGrant Likely  @echo '  cuImage.<dt>    - Backwards compatible U-Boot image for older'
20270bf0333SGrant Likely  @echo '                    versions which do not support device trees'
20370bf0333SGrant Likely  @echo '  dtbImage.<dt>   - zImage with an embedded device tree blob'
20470bf0333SGrant Likely  @echo '  simpleImage.<dt> - Firmware independent image.'
20570bf0333SGrant Likely  @echo '  treeImage.<dt>  - Support for older IBM 4xx firmware (not U-Boot)'
20614cf11afSPaul Mackerras  @echo '  install         - Install kernel using'
207caa27b66SSam Ravnborg  @echo '                    (your) ~/bin/$(INSTALLKERNEL) or'
208caa27b66SSam Ravnborg  @echo '                    (distribution) /sbin/$(INSTALLKERNEL) or'
20914cf11afSPaul Mackerras  @echo '                    install to $$(INSTALL_PATH) and run lilo'
210437a58dbSPaul Mackerras  @echo '  *_defconfig     - Select default config from arch/$(ARCH)/configs'
21170bf0333SGrant Likely  @echo ''
21270bf0333SGrant Likely  @echo '  Targets with <dt> embed a device tree blob inside the image'
21370bf0333SGrant Likely  @echo '  These targets support board with firmware that does not'
21470bf0333SGrant Likely  @echo '  support passing a device tree directly.  Replace <dt> with the'
21570bf0333SGrant Likely  @echo '  name of a dts file from the arch/$(ARCH)/boot/dts/ directory'
21670bf0333SGrant Likely  @echo '  (minus the .dts extension).'
21714cf11afSPaul Mackerrasendef
21814cf11afSPaul Mackerras
2193f85d63eSSam Ravnborginstall:
22025431333SGrant Likely	$(Q)$(MAKE) $(build)=$(boot) install
221928370c6SAkinobu Mita
2228150caadSRoland McGrathvdso_install:
2238150caadSRoland McGrathifeq ($(CONFIG_PPC64),y)
2248150caadSRoland McGrath	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
2258150caadSRoland McGrathendif
2268150caadSRoland McGrath	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
2278150caadSRoland McGrath
22814cf11afSPaul Mackerrasarchclean:
229a3a9e99eSPaul Mackerras	$(Q)$(MAKE) $(clean)=$(boot)
23070567293SAndreas Gruenbacher
23114cf11afSPaul Mackerrasarchprepare: checkbin
23214cf11afSPaul Mackerras
23314cf11afSPaul Mackerras# Use the file '.tmp_gas_check' for binutils tests, as gas won't output
23414cf11afSPaul Mackerras# to stdout and these checks are run even on install targets.
23514cf11afSPaul MackerrasTOUT	:= .tmp_gas_check
23614cf11afSPaul Mackerras# Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec
23714cf11afSPaul Mackerras# instructions.
23814cf11afSPaul Mackerras# gcc-3.4 and binutils-2.14 are a fatal combination.
23914cf11afSPaul Mackerras
24014cf11afSPaul Mackerrascheckbin:
241ad14336dSSam Ravnborg	@if test "$(call cc-version)" = "0304" ; then \
24214cf11afSPaul Mackerras		if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \
24314cf11afSPaul Mackerras			echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \
24414cf11afSPaul Mackerras			echo 'correctly with gcc-3.4 and your version of binutils.'; \
24514cf11afSPaul Mackerras			echo '*** Please upgrade your binutils or downgrade your gcc'; \
24614cf11afSPaul Mackerras			false; \
24714cf11afSPaul Mackerras		fi ; \
24814cf11afSPaul Mackerras	fi
249f5e83fa4SSegher Boessenkool	@if test "$(call cc-fullversion)" = "040200" \
250f5e83fa4SSegher Boessenkool	    && test "x${CONFIG_MODULES}${CONFIG_PPC64}" = "xyy" ; then \
251f5e83fa4SSegher Boessenkool		echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \
252f5e83fa4SSegher Boessenkool		echo 'kernel with modules enabled.' ; \
253f5e83fa4SSegher Boessenkool		echo -n '*** Please use a different GCC version or ' ; \
254f5e83fa4SSegher Boessenkool		echo 'disable kernel modules' ; \
255f5e83fa4SSegher Boessenkool		false ; \
256f5e83fa4SSegher Boessenkool	fi
25714cf11afSPaul Mackerras
25814cf11afSPaul MackerrasCLEAN_FILES += $(TOUT)
25914cf11afSPaul Mackerras
260