kbuild: fix CROSS_COMPILE settings in config.mk
[karo-tx-uboot.git] / arch / arm / config.mk
1 #
2 # (C) Copyright 2000-2002
3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 #
5 # SPDX-License-Identifier:      GPL-2.0+
6 #
7
8 ifeq ($(CROSS_COMPILE),)
9 CROSS_COMPILE := arm-linux-
10 endif
11
12 ifndef CONFIG_STANDALONE_LOAD_ADDR
13 ifneq ($(CONFIG_OMAP_COMMON),)
14 CONFIG_STANDALONE_LOAD_ADDR = 0x80300000
15 else
16 CONFIG_STANDALONE_LOAD_ADDR = 0xc100000
17 endif
18 endif
19
20 LDFLAGS_FINAL += --gc-sections
21 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections \
22                      -fno-common -ffixed-r9
23 PLATFORM_RELFLAGS += $(call cc-option, -msoft-float) \
24       $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
25
26 # Support generic board on ARM
27 __HAVE_ARCH_GENERIC_BOARD := y
28
29 PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
30
31 # Choose between ARM/Thumb instruction sets
32 ifeq ($(CONFIG_SYS_THUMB_BUILD),y)
33 PF_CPPFLAGS_ARM := $(call cc-option, -mthumb -mthumb-interwork,\
34                         $(call cc-option,-marm,)\
35                         $(call cc-option,-mno-thumb-interwork,)\
36                 )
37 else
38 PF_CPPFLAGS_ARM := $(call cc-option,-marm,) \
39                 $(call cc-option,-mno-thumb-interwork,)
40 endif
41
42 # Only test once
43 ifneq ($(CONFIG_SPL_BUILD),y)
44 ALL-$(CONFIG_SYS_THUMB_BUILD)   += checkthumb
45 endif
46
47 # Try if EABI is supported, else fall back to old API,
48 # i. e. for example:
49 # - with ELDK 4.2 (EABI supported), use:
50 #       -mabi=aapcs-linux
51 # - with ELDK 4.1 (gcc 4.x, no EABI), use:
52 #       -mabi=apcs-gnu
53 # - with ELDK 3.1 (gcc 3.x), use:
54 #       -mapcs-32
55 PF_CPPFLAGS_ABI := $(call cc-option,\
56                         -mabi=aapcs-linux,\
57                         $(call cc-option,\
58                                 -mapcs-32,\
59                                 $(call cc-option,\
60                                         -mabi=apcs-gnu,\
61                                 )\
62                         )\
63                 )
64 PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARM) $(PF_CPPFLAGS_ABI)
65
66 # For EABI, make sure to provide raise()
67 ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))
68 # This file is parsed many times, so the string may get added multiple
69 # times. Also, the prefix needs to be different based on whether
70 # CONFIG_SPL_BUILD is defined or not. 'filter-out' the existing entry
71 # before adding the correct one.
72 PLATFORM_LIBS := arch/arm/lib/eabi_compat.o \
73         $(filter-out arch/arm/lib/eabi_compat.o, $(PLATFORM_LIBS))
74 endif
75
76 # needed for relocation
77 LDFLAGS_u-boot += -pie
78
79 #
80 # FIXME: binutils versions < 2.22 have a bug in the assembler where
81 # branches to weak symbols can be incorrectly optimized in thumb mode
82 # to a short branch (b.n instruction) that won't reach when the symbol
83 # gets preempted
84 #
85 # http://sourceware.org/bugzilla/show_bug.cgi?id=12532
86 #
87 ifeq ($(CONFIG_SYS_THUMB_BUILD),y)
88 ifeq ($(GAS_BUG_12532),)
89 export GAS_BUG_12532:=$(shell if [ $(call binutils-version) -lt 0222 ] ; \
90         then echo y; else echo n; fi)
91 endif
92 ifeq ($(GAS_BUG_12532),y)
93 PLATFORM_RELFLAGS += -fno-optimize-sibling-calls
94 endif
95 endif
96
97 ifneq ($(CONFIG_SPL_BUILD),y)
98 # Check that only R_ARM_RELATIVE relocations are generated.
99 ALL-y += checkarmreloc
100 # The movt / movw can hardcode 16 bit parts of the addresses in the
101 # instruction. Relocation is not supported for that case, so disable
102 # such usage by requiring word relocations.
103 PLATFORM_CPPFLAGS += $(call cc-option, -mword-relocations)
104 endif
105
106 # limit ourselves to the sections we want in the .bin.
107 ifdef CONFIG_ARM64
108 OBJCOPYFLAGS += -j .text -j .rodata -j .data -j .u_boot_list -j .rela.dyn
109 else
110 OBJCOPYFLAGS += -j .text -j .rodata -j .hash -j .data -j .got.plt -j .u_boot_list -j .rel.dyn
111 endif
112
113 ifneq ($(CONFIG_IMX_CONFIG),)
114 ifdef CONFIG_SPL
115 ifndef CONFIG_SPL_BUILD
116 ALL-y += SPL
117 endif
118 else
119 ALL-y += u-boot.imx
120 endif
121 endif