Back to home page

LXR

 
 

    


0001 # This file is included by the global makefile so that you can add your own
0002 # architecture-specific flags and dependencies. Remember to do have actions
0003 # for "archclean" and "archdep" for cleaning up and making dependencies for
0004 # this architecture.
0005 #
0006 # This file is subject to the terms and conditions of the GNU General Public
0007 # License.  See the file "COPYING" in the main directory of this archive
0008 # for more details.
0009 #
0010 # Copyright (C) 1994 by Linus Torvalds
0011 # Changes for PPC by Gary Thomas
0012 # Rewritten by Cort Dougan and Paul Mackerras
0013 #
0014 
0015 HAS_BIARCH      := $(call cc-option-yn, -m32)
0016 
0017 # Set default 32 bits cross compilers for vdso and boot wrapper
0018 CROSS32_COMPILE ?=
0019 
0020 CROSS32CC               := $(CROSS32_COMPILE)gcc
0021 CROSS32AR               := $(CROSS32_COMPILE)ar
0022 
0023 ifeq ($(HAS_BIARCH),y)
0024 ifeq ($(CROSS32_COMPILE),)
0025 CROSS32CC       := $(CC) -m32
0026 KBUILD_ARFLAGS  += --target=elf32-powerpc
0027 endif
0028 endif
0029 
0030 export CROSS32CC CROSS32AR
0031 
0032 ifeq ($(CROSS_COMPILE),)
0033 KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
0034 else
0035 KBUILD_DEFCONFIG := ppc64_defconfig
0036 endif
0037 
0038 ifeq ($(CONFIG_PPC64),y)
0039 new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
0040 
0041 ifeq ($(new_nm),y)
0042 NM              := $(NM) --synthetic
0043 endif
0044 endif
0045 
0046 # BITS is used as extension for files which are available in a 32 bit
0047 # and a 64 bit version to simplify shared Makefiles.
0048 # e.g.: obj-y += foo_$(BITS).o
0049 export BITS
0050 
0051 ifdef CONFIG_PPC64
0052         BITS := 64
0053 else
0054         BITS := 32
0055 endif
0056 
0057 machine-y = ppc
0058 machine-$(CONFIG_PPC64) += 64
0059 machine-$(CONFIG_CPU_LITTLE_ENDIAN) += le
0060 UTS_MACHINE := $(subst $(space),,$(machine-y))
0061 
0062 ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
0063 override LD     += -EL
0064 LDEMULATION     := lppc
0065 GNUTARGET       := powerpcle
0066 MULTIPLEWORD    := -mno-multiple
0067 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
0068 else
0069 override LD     += -EB
0070 LDEMULATION     := ppc
0071 GNUTARGET       := powerpc
0072 MULTIPLEWORD    := -mmultiple
0073 endif
0074 
0075 cflags-$(CONFIG_CPU_BIG_ENDIAN)         += $(call cc-option,-mbig-endian)
0076 cflags-$(CONFIG_CPU_LITTLE_ENDIAN)      += -mlittle-endian
0077 ifneq ($(cc-name),clang)
0078   cflags-$(CONFIG_CPU_LITTLE_ENDIAN)    += -mno-strict-align
0079 endif
0080 
0081 aflags-$(CONFIG_CPU_BIG_ENDIAN)         += $(call cc-option,-mbig-endian)
0082 aflags-$(CONFIG_CPU_LITTLE_ENDIAN)      += -mlittle-endian
0083 
0084 ifeq ($(HAS_BIARCH),y)
0085 override AS     += -a$(BITS)
0086 override LD     += -m elf$(BITS)$(LDEMULATION)
0087 override CC     += -m$(BITS)
0088 KBUILD_ARFLAGS  += --target=elf$(BITS)-$(GNUTARGET)
0089 endif
0090 
0091 LDFLAGS_vmlinux-y := -Bstatic
0092 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
0093 LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y)
0094 
0095 ifeq ($(CONFIG_PPC64),y)
0096 ifeq ($(call cc-option-yn,-mcmodel=medium),y)
0097         # -mcmodel=medium breaks modules because it uses 32bit offsets from
0098         # the TOC pointer to create pointers where possible. Pointers into the
0099         # percpu data area are created by this method.
0100         #
0101         # The kernel module loader relocates the percpu data section from the
0102         # original location (starting with 0xd...) to somewhere in the base
0103         # kernel percpu data space (starting with 0xc...). We need a full
0104         # 64bit relocation for this to work, hence -mcmodel=large.
0105         KBUILD_CFLAGS_MODULE += -mcmodel=large
0106 else
0107         export NO_MINIMAL_TOC := -mno-minimal-toc
0108 endif
0109 endif
0110 
0111 CFLAGS-$(CONFIG_PPC64)  := $(call cc-option,-mtraceback=no)
0112 ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
0113 CFLAGS-$(CONFIG_PPC64)  += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
0114 AFLAGS-$(CONFIG_PPC64)  += $(call cc-option,-mabi=elfv2)
0115 else
0116 CFLAGS-$(CONFIG_PPC64)  += $(call cc-option,-mcall-aixdesc)
0117 endif
0118 CFLAGS-$(CONFIG_PPC64)  += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
0119 CFLAGS-$(CONFIG_PPC64)  += $(call cc-option,-mno-pointers-to-nested-functions)
0120 CFLAGS-$(CONFIG_PPC32)  := -ffixed-r2 $(MULTIPLEWORD)
0121 
0122 ifeq ($(CONFIG_PPC_BOOK3S_64),y)
0123 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,-mtune=power4)
0124 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power4
0125 else
0126 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
0127 endif
0128 
0129 ifdef CONFIG_MPROFILE_KERNEL
0130     ifeq ($(shell $(srctree)/arch/powerpc/scripts/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__),OK)
0131         CC_FLAGS_FTRACE := -pg -mprofile-kernel
0132         KBUILD_CPPFLAGS += -DCC_USING_MPROFILE_KERNEL
0133     else
0134         # If the user asked for mprofile-kernel but the toolchain doesn't
0135         # support it, emit a warning and deliberately break the build later
0136         # with mprofile-kernel-not-supported. We would prefer to make this an
0137         # error right here, but then the user would never be able to run
0138         # oldconfig to change their configuration.
0139         $(warning Compiler does not support mprofile-kernel, set CONFIG_DISABLE_MPROFILE_KERNEL)
0140         CC_FLAGS_FTRACE := -mprofile-kernel-not-supported
0141     endif
0142 endif
0143 
0144 CFLAGS-$(CONFIG_CELL_CPU) += $(call cc-option,-mcpu=cell)
0145 CFLAGS-$(CONFIG_POWER4_CPU) += $(call cc-option,-mcpu=power4)
0146 CFLAGS-$(CONFIG_POWER5_CPU) += $(call cc-option,-mcpu=power5)
0147 CFLAGS-$(CONFIG_POWER6_CPU) += $(call cc-option,-mcpu=power6)
0148 CFLAGS-$(CONFIG_POWER7_CPU) += $(call cc-option,-mcpu=power7)
0149 CFLAGS-$(CONFIG_POWER8_CPU) += $(call cc-option,-mcpu=power8)
0150 
0151 # Altivec option not allowed with e500mc64 in GCC.
0152 ifeq ($(CONFIG_ALTIVEC),y)
0153 E5500_CPU := -mcpu=powerpc64
0154 else
0155 E5500_CPU := $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
0156 endif
0157 CFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU)
0158 CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
0159 
0160 ifeq ($(CONFIG_PPC32),y)
0161 ifeq ($(CONFIG_PPC_E500MC),y)
0162 CFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
0163 else
0164 CFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
0165 endif
0166 endif
0167 
0168 asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
0169 
0170 KBUILD_CPPFLAGS += -Iarch/$(ARCH) $(asinstr)
0171 KBUILD_AFLAGS   += -Iarch/$(ARCH) $(AFLAGS-y)
0172 KBUILD_CFLAGS   += $(call cc-option,-msoft-float)
0173 KBUILD_CFLAGS   += -pipe -Iarch/$(ARCH) $(CFLAGS-y)
0174 CPP             = $(CC) -E $(KBUILD_CFLAGS)
0175 
0176 CHECKFLAGS      += -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
0177 ifdef CONFIG_CPU_BIG_ENDIAN
0178 CHECKFLAGS      += -D__BIG_ENDIAN__
0179 else
0180 CHECKFLAGS      += -D__LITTLE_ENDIAN__
0181 endif
0182 
0183 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
0184 
0185 ifeq ($(CONFIG_476FPE_ERR46),y)
0186         KBUILD_LDFLAGS_MODULE += --ppc476-workaround \
0187                 -T $(srctree)/arch/powerpc/platforms/44x/ppc476_modules.lds
0188 endif
0189 
0190 # No AltiVec or VSX instructions when building kernel
0191 KBUILD_CFLAGS += $(call cc-option,-mno-altivec)
0192 KBUILD_CFLAGS += $(call cc-option,-mno-vsx)
0193 
0194 # No SPE instruction when building kernel
0195 # (We use all available options to help semi-broken compilers)
0196 KBUILD_CFLAGS += $(call cc-option,-mno-spe)
0197 KBUILD_CFLAGS += $(call cc-option,-mspe=no)
0198 
0199 # Enable unit-at-a-time mode when possible. It shrinks the
0200 # kernel considerably.
0201 KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
0202 
0203 # FIXME: the module load should be taught about the additional relocs
0204 # generated by this.
0205 # revert to pre-gcc-4.4 behaviour of .eh_frame
0206 KBUILD_CFLAGS   += $(call cc-option,-fno-dwarf2-cfi-asm)
0207 
0208 # Never use string load/store instructions as they are
0209 # often slow when they are implemented at all
0210 KBUILD_CFLAGS           += $(call cc-option,-mno-string)
0211 
0212 ifeq ($(CONFIG_6xx),y)
0213 KBUILD_CFLAGS           += -mcpu=powerpc
0214 endif
0215 
0216 # Work around a gcc code-gen bug with -fno-omit-frame-pointer.
0217 ifeq ($(CONFIG_FUNCTION_TRACER),y)
0218 KBUILD_CFLAGS           += -mno-sched-epilog
0219 endif
0220 
0221 cpu-as-$(CONFIG_4xx)            += -Wa,-m405
0222 cpu-as-$(CONFIG_ALTIVEC)        += $(call as-option,-Wa$(comma)-maltivec)
0223 cpu-as-$(CONFIG_E200)           += -Wa,-me200
0224 
0225 KBUILD_AFLAGS += $(cpu-as-y)
0226 KBUILD_CFLAGS += $(cpu-as-y)
0227 
0228 KBUILD_AFLAGS += $(aflags-y)
0229 KBUILD_CFLAGS += $(cflags-y)
0230 
0231 head-y                          := arch/powerpc/kernel/head_$(BITS).o
0232 head-$(CONFIG_8xx)              := arch/powerpc/kernel/head_8xx.o
0233 head-$(CONFIG_40x)              := arch/powerpc/kernel/head_40x.o
0234 head-$(CONFIG_44x)              := arch/powerpc/kernel/head_44x.o
0235 head-$(CONFIG_FSL_BOOKE)        := arch/powerpc/kernel/head_fsl_booke.o
0236 
0237 head-$(CONFIG_PPC64)            += arch/powerpc/kernel/entry_64.o
0238 head-$(CONFIG_PPC_FPU)          += arch/powerpc/kernel/fpu.o
0239 head-$(CONFIG_ALTIVEC)          += arch/powerpc/kernel/vector.o
0240 head-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)  += arch/powerpc/kernel/prom_init.o
0241 
0242 core-y                          += arch/powerpc/kernel/ \
0243                                    arch/powerpc/mm/ \
0244                                    arch/powerpc/lib/ \
0245                                    arch/powerpc/sysdev/ \
0246                                    arch/powerpc/platforms/ \
0247                                    arch/powerpc/math-emu/ \
0248                                    arch/powerpc/crypto/ \
0249                                    arch/powerpc/net/
0250 core-$(CONFIG_XMON)             += arch/powerpc/xmon/
0251 core-$(CONFIG_KVM)              += arch/powerpc/kvm/
0252 core-$(CONFIG_PERF_EVENTS)      += arch/powerpc/perf/
0253 core-$(CONFIG_KEXEC_FILE)       += arch/powerpc/purgatory/
0254 
0255 drivers-$(CONFIG_OPROFILE)      += arch/powerpc/oprofile/
0256 
0257 # Default to zImage, override when needed
0258 all: zImage
0259 
0260 # With make 3.82 we cannot mix normal and wildcard targets
0261 BOOT_TARGETS1 := zImage zImage.initrd uImage
0262 BOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.% uImage.%
0263 
0264 PHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2)
0265 
0266 boot := arch/$(ARCH)/boot
0267 
0268 ifeq ($(CONFIG_RELOCATABLE),y)
0269 quiet_cmd_relocs_check = CALL    $<
0270       cmd_relocs_check = $(CONFIG_SHELL) $< "$(OBJDUMP)" "$(obj)/vmlinux"
0271 
0272 PHONY += relocs_check
0273 relocs_check: arch/powerpc/relocs_check.sh vmlinux
0274         $(call cmd,relocs_check)
0275 
0276 zImage: relocs_check
0277 endif
0278 
0279 $(BOOT_TARGETS1): vmlinux
0280         $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
0281 $(BOOT_TARGETS2): vmlinux
0282         $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
0283 
0284 
0285 bootwrapper_install:
0286         $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
0287 
0288 %.dtb: scripts
0289         $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
0290 
0291 # Used to create 'merged defconfigs'
0292 # To use it $(call) it with the first argument as the base defconfig
0293 # and the second argument as a space separated list of .config files to merge,
0294 # without the .config suffix.
0295 define merge_into_defconfig
0296         $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
0297                 -m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/$(1) \
0298                 $(foreach config,$(2),$(srctree)/arch/$(ARCH)/configs/$(config).config)
0299         +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
0300 endef
0301 
0302 PHONY += pseries_le_defconfig
0303 pseries_le_defconfig:
0304         $(call merge_into_defconfig,pseries_defconfig,le)
0305 
0306 PHONY += ppc64le_defconfig
0307 ppc64le_defconfig:
0308         $(call merge_into_defconfig,ppc64_defconfig,le)
0309 
0310 PHONY += mpc85xx_defconfig
0311 mpc85xx_defconfig:
0312         $(call merge_into_defconfig,mpc85xx_basic_defconfig,\
0313                 85xx-32bit 85xx-hw fsl-emb-nonhw)
0314 
0315 PHONY += mpc85xx_smp_defconfig
0316 mpc85xx_smp_defconfig:
0317         $(call merge_into_defconfig,mpc85xx_basic_defconfig,\
0318                 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw)
0319 
0320 PHONY += corenet32_smp_defconfig
0321 corenet32_smp_defconfig:
0322         $(call merge_into_defconfig,corenet_basic_defconfig,\
0323                 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa)
0324 
0325 PHONY += corenet64_smp_defconfig
0326 corenet64_smp_defconfig:
0327         $(call merge_into_defconfig,corenet_basic_defconfig,\
0328                 85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa)
0329 
0330 PHONY += mpc86xx_defconfig
0331 mpc86xx_defconfig:
0332         $(call merge_into_defconfig,mpc86xx_basic_defconfig,\
0333                 86xx-hw fsl-emb-nonhw)
0334 
0335 PHONY += mpc86xx_smp_defconfig
0336 mpc86xx_smp_defconfig:
0337         $(call merge_into_defconfig,mpc86xx_basic_defconfig,\
0338                 86xx-smp 86xx-hw fsl-emb-nonhw)
0339 
0340 define archhelp
0341   @echo '* zImage          - Build default images selected by kernel config'
0342   @echo '  zImage.*        - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)'
0343   @echo '  uImage          - U-Boot native image format'
0344   @echo '  cuImage.<dt>    - Backwards compatible U-Boot image for older'
0345   @echo '                    versions which do not support device trees'
0346   @echo '  dtbImage.<dt>   - zImage with an embedded device tree blob'
0347   @echo '  simpleImage.<dt> - Firmware independent image.'
0348   @echo '  treeImage.<dt>  - Support for older IBM 4xx firmware (not U-Boot)'
0349   @echo '  install         - Install kernel using'
0350   @echo '                    (your) ~/bin/$(INSTALLKERNEL) or'
0351   @echo '                    (distribution) /sbin/$(INSTALLKERNEL) or'
0352   @echo '                    install to $$(INSTALL_PATH) and run lilo'
0353   @echo '  *_defconfig     - Select default config from arch/$(ARCH)/configs'
0354   @echo ''
0355   @echo '  Targets with <dt> embed a device tree blob inside the image'
0356   @echo '  These targets support board with firmware that does not'
0357   @echo '  support passing a device tree directly.  Replace <dt> with the'
0358   @echo '  name of a dts file from the arch/$(ARCH)/boot/dts/ directory'
0359   @echo '  (minus the .dts extension).'
0360 endef
0361 
0362 install:
0363         $(Q)$(MAKE) $(build)=$(boot) install
0364 
0365 vdso_install:
0366 ifeq ($(CONFIG_PPC64),y)
0367         $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
0368 endif
0369         $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
0370 
0371 archclean:
0372         $(Q)$(MAKE) $(clean)=$(boot)
0373 
0374 archprepare: checkbin
0375 
0376 # Use the file '.tmp_gas_check' for binutils tests, as gas won't output
0377 # to stdout and these checks are run even on install targets.
0378 TOUT    := .tmp_gas_check
0379 
0380 # Check gcc and binutils versions:
0381 # - gcc-3.4 and binutils-2.14 are a fatal combination
0382 # - Require gcc 4.0 or above on 64-bit
0383 # - gcc-4.2.0 has issues compiling modules on 64-bit
0384 checkbin:
0385         @if test "$(cc-name)" != "clang" \
0386             && test "$(cc-version)" = "0304" ; then \
0387                 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \
0388                         echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \
0389                         echo 'correctly with gcc-3.4 and your version of binutils.'; \
0390                         echo '*** Please upgrade your binutils or downgrade your gcc'; \
0391                         false; \
0392                 fi ; \
0393         fi
0394         @if test "$(cc-name)" != "clang" \
0395             && test "$(cc-version)" -lt "0400" \
0396             && test "x${CONFIG_PPC64}" = "xy" ; then \
0397                 echo -n "Sorry, GCC v4.0 or above is required to build " ; \
0398                 echo "the 64-bit powerpc kernel." ; \
0399                 false ; \
0400         fi
0401         @if test "$(cc-name)" != "clang" \
0402             && test "$(cc-fullversion)" = "040200" \
0403             && test "x${CONFIG_MODULES}${CONFIG_PPC64}" = "xyy" ; then \
0404                 echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \
0405                 echo 'kernel with modules enabled.' ; \
0406                 echo -n '*** Please use a different GCC version or ' ; \
0407                 echo 'disable kernel modules' ; \
0408                 false ; \
0409         fi
0410         @if test "x${CONFIG_CPU_LITTLE_ENDIAN}" = "xy" \
0411             && $(LD) --version | head -1 | grep ' 2\.24$$' >/dev/null ; then \
0412                 echo -n '*** binutils 2.24 miscompiles weak symbols ' ; \
0413                 echo 'in some circumstances.' ; \
0414                 echo -n '*** Please use a different binutils version.' ; \
0415                 false ; \
0416         fi
0417 
0418 
0419 CLEAN_FILES += $(TOUT)
0420