]> asedeno.scripts.mit.edu Git - linux.git/blob - arch/powerpc/Makefile
45b8eb4d8fe7934c18b1be4414ce12a66b39395d
[linux.git] / arch / powerpc / Makefile
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
15 HAS_BIARCH      := $(call cc-option-yn, -m32)
16
17 # Set default 32 bits cross compilers for vdso and boot wrapper
18 CROSS32_COMPILE ?=
19
20 ifeq ($(HAS_BIARCH),y)
21 ifeq ($(CROSS32_COMPILE),)
22 ifdef CONFIG_PPC32
23 # These options will be overridden by any -mcpu option that the CPU
24 # or platform code sets later on the command line, but they are needed
25 # to set a sane 32-bit cpu target for the 64-bit cross compiler which
26 # may default to the wrong ISA.
27 KBUILD_CFLAGS           += -mcpu=powerpc
28 KBUILD_AFLAGS           += -mcpu=powerpc
29 endif
30 endif
31 endif
32
33 ifeq ($(CROSS_COMPILE),)
34 KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
35 else
36 KBUILD_DEFCONFIG := ppc64_defconfig
37 endif
38
39 ifdef CONFIG_PPC64
40 new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
41
42 ifeq ($(new_nm),y)
43 NM              := $(NM) --synthetic
44 endif
45 endif
46
47 # BITS is used as extension for files which are available in a 32 bit
48 # and a 64 bit version to simplify shared Makefiles.
49 # e.g.: obj-y += foo_$(BITS).o
50 export BITS
51
52 ifdef CONFIG_PPC64
53         BITS := 64
54 else
55         BITS := 32
56 endif
57
58 machine-y = ppc
59 machine-$(CONFIG_PPC64) += 64
60 machine-$(CONFIG_CPU_LITTLE_ENDIAN) += le
61 UTS_MACHINE := $(subst $(space),,$(machine-y))
62
63 # XXX This needs to be before we override LD below
64 ifdef CONFIG_PPC32
65 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
66 else
67 KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/powerpc/kernel/module.lds
68 ifeq ($(call ld-ifversion, -ge, 225000000, y),y)
69 # Have the linker provide sfpr if possible.
70 # There is a corresponding test in arch/powerpc/lib/Makefile
71 KBUILD_LDFLAGS_MODULE += --save-restore-funcs
72 else
73 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
74 endif
75 endif
76
77 ifdef CONFIG_CPU_LITTLE_ENDIAN
78 KBUILD_CFLAGS   += -mlittle-endian
79 KBUILD_LDFLAGS  += -EL
80 LDEMULATION     := lppc
81 GNUTARGET       := powerpcle
82 MULTIPLEWORD    := -mno-multiple
83 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
84 else
85 KBUILD_CFLAGS += $(call cc-option,-mbig-endian)
86 KBUILD_LDFLAGS  += -EB
87 LDEMULATION     := ppc
88 GNUTARGET       := powerpc
89 MULTIPLEWORD    := -mmultiple
90 endif
91
92 ifdef CONFIG_PPC64
93 cflags-$(CONFIG_CPU_BIG_ENDIAN)         += $(call cc-option,-mabi=elfv1)
94 cflags-$(CONFIG_CPU_BIG_ENDIAN)         += $(call cc-option,-mcall-aixdesc)
95 aflags-$(CONFIG_CPU_BIG_ENDIAN)         += $(call cc-option,-mabi=elfv1)
96 aflags-$(CONFIG_CPU_LITTLE_ENDIAN)      += -mabi=elfv2
97 endif
98
99 ifneq ($(cc-name),clang)
100   cflags-$(CONFIG_CPU_LITTLE_ENDIAN)    += -mno-strict-align
101 endif
102
103 cflags-$(CONFIG_CPU_BIG_ENDIAN)         += $(call cc-option,-mbig-endian)
104 cflags-$(CONFIG_CPU_LITTLE_ENDIAN)      += -mlittle-endian
105 aflags-$(CONFIG_CPU_BIG_ENDIAN)         += $(call cc-option,-mbig-endian)
106 aflags-$(CONFIG_CPU_LITTLE_ENDIAN)      += -mlittle-endian
107
108 ifeq ($(HAS_BIARCH),y)
109 KBUILD_CFLAGS   += -m$(BITS)
110 KBUILD_AFLAGS   += -m$(BITS) -Wl,-a$(BITS)
111 KBUILD_LDFLAGS  += -m elf$(BITS)$(LDEMULATION)
112 KBUILD_ARFLAGS  += --target=elf$(BITS)-$(GNUTARGET)
113 endif
114
115 cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard=tls
116 cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r2
117
118 LDFLAGS_vmlinux-y := -Bstatic
119 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
120 LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y)
121 LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn)
122
123 ifdef CONFIG_PPC64
124 ifeq ($(call cc-option-yn,-mcmodel=medium),y)
125         # -mcmodel=medium breaks modules because it uses 32bit offsets from
126         # the TOC pointer to create pointers where possible. Pointers into the
127         # percpu data area are created by this method.
128         #
129         # The kernel module loader relocates the percpu data section from the
130         # original location (starting with 0xd...) to somewhere in the base
131         # kernel percpu data space (starting with 0xc...). We need a full
132         # 64bit relocation for this to work, hence -mcmodel=large.
133         KBUILD_CFLAGS_MODULE += -mcmodel=large
134 else
135         export NO_MINIMAL_TOC := -mno-minimal-toc
136 endif
137 endif
138
139 CFLAGS-$(CONFIG_PPC64)  := $(call cc-option,-mtraceback=no)
140 ifdef CONFIG_CPU_LITTLE_ENDIAN
141 CFLAGS-$(CONFIG_PPC64)  += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
142 AFLAGS-$(CONFIG_PPC64)  += $(call cc-option,-mabi=elfv2)
143 else
144 CFLAGS-$(CONFIG_PPC64)  += $(call cc-option,-mabi=elfv1)
145 CFLAGS-$(CONFIG_PPC64)  += $(call cc-option,-mcall-aixdesc)
146 AFLAGS-$(CONFIG_PPC64)  += $(call cc-option,-mabi=elfv1)
147 endif
148 CFLAGS-$(CONFIG_PPC64)  += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
149 CFLAGS-$(CONFIG_PPC64)  += $(call cc-option,-mno-pointers-to-nested-functions)
150
151 CFLAGS-$(CONFIG_PPC32)  := -ffixed-r2 $(MULTIPLEWORD)
152 CFLAGS-$(CONFIG_PPC32)  += $(call cc-option,-mno-readonly-in-sdata)
153
154 ifdef CONFIG_PPC_BOOK3S_64
155 ifdef CONFIG_CPU_LITTLE_ENDIAN
156 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power8
157 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power9,-mtune=power8)
158 else
159 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,$(call cc-option,-mtune=power5))
160 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mcpu=power5,-mcpu=power4)
161 endif
162 else
163 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
164 endif
165
166 ifdef CONFIG_FUNCTION_TRACER
167 CC_FLAGS_FTRACE := -pg
168 ifdef CONFIG_MPROFILE_KERNEL
169 CC_FLAGS_FTRACE += -mprofile-kernel
170 endif
171 # Work around gcc code-gen bugs with -pg / -fno-omit-frame-pointer in gcc <= 4.8
172 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44199
173 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52828
174 ifneq ($(cc-name),clang)
175 CC_FLAGS_FTRACE += $(call cc-ifversion, -lt, 0409, -mno-sched-epilog)
176 endif
177 endif
178
179 CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
180
181 # Altivec option not allowed with e500mc64 in GCC.
182 ifdef CONFIG_ALTIVEC
183 E5500_CPU := -mcpu=powerpc64
184 else
185 E5500_CPU := $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
186 endif
187 CFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU)
188 CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
189
190 ifdef CONFIG_PPC32
191 ifdef CONFIG_PPC_E500MC
192 CFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
193 else
194 CFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
195 endif
196 endif
197
198 asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
199
200 KBUILD_CPPFLAGS += -Iarch/$(ARCH) $(asinstr)
201 KBUILD_AFLAGS   += -Iarch/$(ARCH) $(AFLAGS-y)
202 KBUILD_CFLAGS   += $(call cc-option,-msoft-float)
203 KBUILD_CFLAGS   += -pipe -Iarch/$(ARCH) $(CFLAGS-y)
204 CPP             = $(CC) -E $(KBUILD_CFLAGS)
205
206 CHECKFLAGS      += -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
207 ifdef CONFIG_CPU_BIG_ENDIAN
208 CHECKFLAGS      += -D__BIG_ENDIAN__
209 else
210 CHECKFLAGS      += -D__LITTLE_ENDIAN__
211 endif
212
213 ifdef CONFIG_476FPE_ERR46
214         KBUILD_LDFLAGS_MODULE += --ppc476-workaround \
215                 -T $(srctree)/arch/powerpc/platforms/44x/ppc476_modules.lds
216 endif
217
218 # No AltiVec or VSX instructions when building kernel
219 KBUILD_CFLAGS += $(call cc-option,-mno-altivec)
220 KBUILD_CFLAGS += $(call cc-option,-mno-vsx)
221
222 # No SPE instruction when building kernel
223 # (We use all available options to help semi-broken compilers)
224 KBUILD_CFLAGS += $(call cc-option,-mno-spe)
225 KBUILD_CFLAGS += $(call cc-option,-mspe=no)
226
227 # Enable unit-at-a-time mode when possible. It shrinks the
228 # kernel considerably.
229 KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
230
231 # FIXME: the module load should be taught about the additional relocs
232 # generated by this.
233 # revert to pre-gcc-4.4 behaviour of .eh_frame
234 KBUILD_CFLAGS   += $(call cc-option,-fno-dwarf2-cfi-asm)
235
236 # Never use string load/store instructions as they are
237 # often slow when they are implemented at all
238 KBUILD_CFLAGS           += $(call cc-option,-mno-string)
239
240 ifdef CONFIG_6xx
241 KBUILD_CFLAGS           += -mcpu=powerpc
242 endif
243
244 cpu-as-$(CONFIG_4xx)            += -Wa,-m405
245 cpu-as-$(CONFIG_ALTIVEC)        += $(call as-option,-Wa$(comma)-maltivec)
246 cpu-as-$(CONFIG_E200)           += -Wa,-me200
247 cpu-as-$(CONFIG_E500)           += -Wa,-me500
248 cpu-as-$(CONFIG_PPC_BOOK3S_64)  += -Wa,-mpower4
249 cpu-as-$(CONFIG_PPC_E500MC)     += $(call as-option,-Wa$(comma)-me500mc)
250
251 KBUILD_AFLAGS += $(cpu-as-y)
252 KBUILD_CFLAGS += $(cpu-as-y)
253
254 KBUILD_AFLAGS += $(aflags-y)
255 KBUILD_CFLAGS += $(cflags-y)
256
257 head-y                          := arch/powerpc/kernel/head_$(BITS).o
258 head-$(CONFIG_PPC_8xx)          := arch/powerpc/kernel/head_8xx.o
259 head-$(CONFIG_40x)              := arch/powerpc/kernel/head_40x.o
260 head-$(CONFIG_44x)              := arch/powerpc/kernel/head_44x.o
261 head-$(CONFIG_FSL_BOOKE)        := arch/powerpc/kernel/head_fsl_booke.o
262
263 head-$(CONFIG_PPC64)            += arch/powerpc/kernel/entry_64.o
264 head-$(CONFIG_PPC_FPU)          += arch/powerpc/kernel/fpu.o
265 head-$(CONFIG_ALTIVEC)          += arch/powerpc/kernel/vector.o
266 head-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)  += arch/powerpc/kernel/prom_init.o
267
268 core-y                          += arch/powerpc/kernel/ \
269                                    arch/powerpc/mm/ \
270                                    arch/powerpc/lib/ \
271                                    arch/powerpc/sysdev/ \
272                                    arch/powerpc/platforms/ \
273                                    arch/powerpc/math-emu/ \
274                                    arch/powerpc/crypto/ \
275                                    arch/powerpc/net/
276 core-$(CONFIG_XMON)             += arch/powerpc/xmon/
277 core-$(CONFIG_KVM)              += arch/powerpc/kvm/
278 core-$(CONFIG_PERF_EVENTS)      += arch/powerpc/perf/
279 core-$(CONFIG_KEXEC_FILE)       += arch/powerpc/purgatory/
280
281 drivers-$(CONFIG_OPROFILE)      += arch/powerpc/oprofile/
282
283 # Default to zImage, override when needed
284 all: zImage
285
286 # With make 3.82 we cannot mix normal and wildcard targets
287 BOOT_TARGETS1 := zImage zImage.initrd uImage
288 BOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.% uImage.%
289
290 PHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2)
291
292 boot := arch/$(ARCH)/boot
293
294 $(BOOT_TARGETS1): vmlinux
295         $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
296 $(BOOT_TARGETS2): vmlinux
297         $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
298
299
300 bootwrapper_install:
301         $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
302
303 %.dtb: scripts
304         $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
305
306 # Used to create 'merged defconfigs'
307 # To use it $(call) it with the first argument as the base defconfig
308 # and the second argument as a space separated list of .config files to merge,
309 # without the .config suffix.
310 define merge_into_defconfig
311         $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
312                 -m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/$(1) \
313                 $(foreach config,$(2),$(srctree)/arch/$(ARCH)/configs/$(config).config)
314         +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
315 endef
316
317 PHONY += pseries_le_defconfig
318 pseries_le_defconfig:
319         $(call merge_into_defconfig,pseries_defconfig,le)
320
321 PHONY += ppc64le_defconfig
322 ppc64le_defconfig:
323         $(call merge_into_defconfig,ppc64_defconfig,le)
324
325 PHONY += powernv_be_defconfig
326 powernv_be_defconfig:
327         $(call merge_into_defconfig,powernv_defconfig,be)
328
329 PHONY += mpc85xx_defconfig
330 mpc85xx_defconfig:
331         $(call merge_into_defconfig,mpc85xx_basic_defconfig,\
332                 85xx-32bit 85xx-hw fsl-emb-nonhw)
333
334 PHONY += mpc85xx_smp_defconfig
335 mpc85xx_smp_defconfig:
336         $(call merge_into_defconfig,mpc85xx_basic_defconfig,\
337                 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw)
338
339 PHONY += corenet32_smp_defconfig
340 corenet32_smp_defconfig:
341         $(call merge_into_defconfig,corenet_basic_defconfig,\
342                 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa)
343
344 PHONY += corenet64_smp_defconfig
345 corenet64_smp_defconfig:
346         $(call merge_into_defconfig,corenet_basic_defconfig,\
347                 85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa)
348
349 PHONY += mpc86xx_defconfig
350 mpc86xx_defconfig:
351         $(call merge_into_defconfig,mpc86xx_basic_defconfig,\
352                 86xx-hw fsl-emb-nonhw)
353
354 PHONY += mpc86xx_smp_defconfig
355 mpc86xx_smp_defconfig:
356         $(call merge_into_defconfig,mpc86xx_basic_defconfig,\
357                 86xx-smp 86xx-hw fsl-emb-nonhw)
358
359 PHONY += ppc32_allmodconfig
360 ppc32_allmodconfig:
361         $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/book3s_32.config \
362                 -f $(srctree)/Makefile allmodconfig
363
364 PHONY += ppc64le_allmodconfig
365 ppc64le_allmodconfig:
366         $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/le.config \
367                 -f $(srctree)/Makefile allmodconfig
368
369 PHONY += ppc64_book3e_allmodconfig
370 ppc64_book3e_allmodconfig:
371         $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/85xx-64bit.config \
372                 -f $(srctree)/Makefile allmodconfig
373
374 define archhelp
375   @echo '* zImage          - Build default images selected by kernel config'
376   @echo '  zImage.*        - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)'
377   @echo '  uImage          - U-Boot native image format'
378   @echo '  cuImage.<dt>    - Backwards compatible U-Boot image for older'
379   @echo '                    versions which do not support device trees'
380   @echo '  dtbImage.<dt>   - zImage with an embedded device tree blob'
381   @echo '  simpleImage.<dt> - Firmware independent image.'
382   @echo '  treeImage.<dt>  - Support for older IBM 4xx firmware (not U-Boot)'
383   @echo '  install         - Install kernel using'
384   @echo '                    (your) ~/bin/$(INSTALLKERNEL) or'
385   @echo '                    (distribution) /sbin/$(INSTALLKERNEL) or'
386   @echo '                    install to $$(INSTALL_PATH) and run lilo'
387   @echo '  *_defconfig     - Select default config from arch/$(ARCH)/configs'
388   @echo ''
389   @echo '  Targets with <dt> embed a device tree blob inside the image'
390   @echo '  These targets support board with firmware that does not'
391   @echo '  support passing a device tree directly.  Replace <dt> with the'
392   @echo '  name of a dts file from the arch/$(ARCH)/boot/dts/ directory'
393   @echo '  (minus the .dts extension).'
394 endef
395
396 install:
397         $(Q)$(MAKE) $(build)=$(boot) install
398
399 vdso_install:
400 ifdef CONFIG_PPC64
401         $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
402 endif
403         $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
404
405 archclean:
406         $(Q)$(MAKE) $(clean)=$(boot)
407
408 archprepare: checkbin
409
410 ifdef CONFIG_STACKPROTECTOR
411 prepare: stack_protector_prepare
412
413 stack_protector_prepare: prepare0
414         $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
415 endif
416
417 # Use the file '.tmp_gas_check' for binutils tests, as gas won't output
418 # to stdout and these checks are run even on install targets.
419 TOUT    := .tmp_gas_check
420
421 # Check toolchain versions:
422 # - gcc-4.6 is the minimum kernel-wide version so nothing required.
423 checkbin:
424         @if test "x${CONFIG_CPU_LITTLE_ENDIAN}" = "xy" \
425             && $(LD) --version | head -1 | grep ' 2\.24$$' >/dev/null ; then \
426                 echo -n '*** binutils 2.24 miscompiles weak symbols ' ; \
427                 echo 'in some circumstances.' ; \
428                 echo -n '*** Please use a different binutils version.' ; \
429                 false ; \
430         fi
431
432
433 CLEAN_FILES += $(TOUT)
434