Tom Rini | a9610bd | 2020-05-14 08:30:01 -0400 | [diff] [blame] | 1 | # Kconfig helper macros |
| 2 | |
| 3 | # Convenient variables |
| 4 | comma := , |
| 5 | quote := " |
| 6 | squote := ' |
| 7 | empty := |
| 8 | space := $(empty) $(empty) |
| 9 | dollar := $ |
| 10 | right_paren := ) |
| 11 | left_paren := ( |
| 12 | |
| 13 | # $(if-success,<command>,<then>,<else>) |
| 14 | # Return <then> if <command> exits with 0, <else> otherwise. |
| 15 | if-success = $(shell,{ $(1); } >/dev/null 2>&1 && echo "$(2)" || echo "$(3)") |
| 16 | |
| 17 | # $(success,<command>) |
| 18 | # Return y if <command> exits with 0, n otherwise |
| 19 | success = $(if-success,$(1),y,n) |
| 20 | |
| 21 | # $(cc-option,<flag>) |
| 22 | # Return y if the compiler supports <flag>, n otherwise |
| 23 | cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null) |
| 24 | |
Michal Suchanek | 5bde2e0 | 2022-10-14 22:52:33 +0200 | [diff] [blame^] | 25 | # $(cc-define,<macro>) |
| 26 | # Return y if the compiler defines <macro>, n otherwise |
| 27 | cc-define = $(success,$(CC) -dM -E -x c /dev/null | grep -q '^#define \<$(1)\>') |
| 28 | |
Tom Rini | a9610bd | 2020-05-14 08:30:01 -0400 | [diff] [blame] | 29 | # $(ld-option,<flag>) |
| 30 | # Return y if the linker supports <flag>, n otherwise |
| 31 | ld-option = $(success,$(LD) -v $(1)) |
| 32 | |
| 33 | # gcc version including patch level |
| 34 | gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//') |