Merge remote-tracking branch 'georgi/icc-get-by-index' into opp/linux-next
[linux-2.6-microblaze.git] / scripts / Kconfig.include
1 # SPDX-License-Identifier: GPL-2.0-only
2 # Kconfig helper macros
3
4 # Convenient variables
5 comma       := ,
6 quote       := "
7 squote      := '
8 empty       :=
9 space       := $(empty) $(empty)
10 dollar      := $
11 right_paren := )
12 left_paren  := (
13
14 # $(if-success,<command>,<then>,<else>)
15 # Return <then> if <command> exits with 0, <else> otherwise.
16 if-success = $(shell,{ $(1); } >/dev/null 2>&1 && echo "$(2)" || echo "$(3)")
17
18 # $(success,<command>)
19 # Return y if <command> exits with 0, n otherwise
20 success = $(if-success,$(1),y,n)
21
22 # $(failure,<command>)
23 # Return n if <command> exits with 0, y otherwise
24 failure = $(if-success,$(1),n,y)
25
26 # $(cc-option,<flag>)
27 # Return y if the compiler supports <flag>, n otherwise
28 cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o /dev/null)
29
30 # $(ld-option,<flag>)
31 # Return y if the linker supports <flag>, n otherwise
32 ld-option = $(success,$(LD) -v $(1))
33
34 # $(as-option,<flag>)
35 # /dev/zero is used as output instead of /dev/null as some assembler cribs when
36 # both input and output are same. Also both of them have same write behaviour so
37 # can be easily substituted.
38 as-option = $(success, $(CC) $(CLANG_FLAGS) $(1) -c -x assembler /dev/null -o /dev/zero)
39
40 # $(as-instr,<instr>)
41 # Return y if the assembler supports <instr>, n otherwise
42 as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -c -x assembler -o /dev/null -)
43
44 # check if $(CC) and $(LD) exist
45 $(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found)
46 $(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found)
47
48 # Fail if the linker is gold as it's not capable of linking the kernel proper
49 $(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supported)
50
51 # machine bit flags
52 #  $(m32-flag): -m32 if the compiler supports it, or an empty string otherwise.
53 #  $(m64-flag): -m64 if the compiler supports it, or an empty string otherwise.
54 cc-option-bit = $(if-success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null,$(1))
55 m32-flag := $(cc-option-bit,-m32)
56 m64-flag := $(cc-option-bit,-m64)