Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2023-2024, Arm Limited and Contributors. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | |
| 7 | # |
| 8 | # TF-A uses three toolchains: |
| 9 | # |
| 10 | # - The host toolchain (`host`) for building native tools |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 11 | # - The AArch32 toolchain (`aarch32`) for building Arm AArch32 images |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 12 | # - The AArch64 toolchain (`aarch64`) for building Arm AArch64 images |
| 13 | # |
| 14 | # In the main Makefile only one of the two Arm toolchains is enabled in any |
| 15 | # given build, but individual tools and libraries may need access to both. |
| 16 | # |
| 17 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 18 | ifndef toolchain-mk |
| 19 | toolchain-mk := $(lastword $(MAKEFILE_LIST)) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 20 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 21 | toolchains ?= host $(ARCH) |
Chris Kay | 2c09bf6 | 2024-04-09 16:30:52 +0000 | [diff] [blame] | 22 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 23 | include $(dir $(lastword $(MAKEFILE_LIST)))build_env.mk |
| 24 | include $(dir $(lastword $(MAKEFILE_LIST)))utilities.mk |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 25 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 26 | include $(addprefix $(dir $(lastword $(MAKEFILE_LIST)))toolchains/, \ |
| 27 | $(addsuffix .mk,$(toolchains))) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 28 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 29 | # |
| 30 | # Configure tool classes that we recognize. |
| 31 | # |
| 32 | # In the context of this build system, a tool class identifies a |
| 33 | # specific role or type of tool in the toolchain. |
| 34 | # |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 35 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 36 | tool-classes := cc |
| 37 | tool-class-name-cc := C compiler |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 38 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 39 | tool-classes += cpp |
| 40 | tool-class-name-cpp := C preprocessor |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 41 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 42 | tool-classes += as |
| 43 | tool-class-name-as := assembler |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 44 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 45 | tool-classes += ld |
| 46 | tool-class-name-ld := linker |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 47 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 48 | tool-classes += oc |
| 49 | tool-class-name-oc := object copier |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 50 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 51 | tool-classes += od |
| 52 | tool-class-name-od := object dumper |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 53 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 54 | tool-classes += ar |
| 55 | tool-class-name-ar := archiver |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 56 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 57 | tool-classes += dtc |
| 58 | tool-class-name-dtc := device tree compiler |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 59 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 60 | # |
| 61 | # Configure tools that we recognize. |
| 62 | # |
| 63 | # Here we declare the list of specific toolchain tools that we know how |
| 64 | # to interact with. We don't organize these into tool classes yet - that |
| 65 | # happens further down. |
| 66 | # |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 67 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 68 | # Arm® Compiler for Embedded |
| 69 | tools := arm-clang |
| 70 | tool-name-arm-clang := Arm® Compiler for Embedded `armclang` |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 71 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 72 | tools += arm-link |
| 73 | tool-name-arm-link := Arm® Compiler for Embedded `armlink` |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 74 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 75 | tools += arm-ar |
| 76 | tool-name-arm-ar := Arm® Compiler for Embedded `armar` |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 77 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 78 | tools += arm-fromelf |
| 79 | tool-name-arm-fromelf := Arm® Compiler for Embedded `fromelf` |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 80 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 81 | # LLVM Project |
| 82 | tools += llvm-clang |
| 83 | tool-name-llvm-clang := LLVM Clang (`clang`) |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 84 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 85 | tools += llvm-lld |
| 86 | tool-name-llvm-lld := LLVM LLD (`lld`) |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 87 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 88 | tools += llvm-objcopy |
| 89 | tool-name-llvm-objcopy := LLVM `llvm-objcopy` |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 90 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 91 | tools += llvm-objdump |
| 92 | tool-name-llvm-objdump := LLVM `llvm-objdump` |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 93 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 94 | tools += llvm-ar |
| 95 | tool-name-llvm-ar := LLVM `llvm-ar` |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 96 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 97 | # GNU Compiler Collection & GNU Binary Utilities |
| 98 | tools += gnu-gcc |
| 99 | tool-name-gnu-gcc := GNU GCC (`gcc`) |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 100 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 101 | tools += gnu-ld |
| 102 | tool-name-gnu-ld := GNU LD (`ld.bfd`) |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 103 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 104 | tools += gnu-objcopy |
| 105 | tool-name-gnu-objcopy := GNU `objcopy` |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 106 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 107 | tools += gnu-objdump |
| 108 | tool-name-gnu-objdump := GNU `objdump` |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 109 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 110 | tools += gnu-ar |
| 111 | tool-name-gnu-ar := GNU `ar` |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 112 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 113 | # Other tools |
| 114 | tools += generic-dtc |
| 115 | tool-name-generic-dtc := Device Tree Compiler (`dtc`) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 116 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 117 | # |
| 118 | # Assign tools to tool classes. |
| 119 | # |
| 120 | # Multifunctional tools, i.e. tools which can perform multiple roles in |
| 121 | # a toolchain, may be specified in multiple tool class lists. For |
| 122 | # example, a C compiler which can also perform the role of a linker may |
| 123 | # be placed in both `tools-cc` and `tools-ld`. |
| 124 | # |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 125 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 126 | # C-related tools |
| 127 | tools-cc := arm-clang llvm-clang gnu-gcc # C compilers |
| 128 | tools-cpp := arm-clang llvm-clang gnu-gcc # C preprocessors |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 129 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 130 | # Assembly-related tools |
| 131 | tools-as := arm-clang llvm-clang gnu-gcc # Assemblers |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 132 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 133 | # Linking and object-handling tools |
| 134 | tools-ld := arm-clang arm-link llvm-clang llvm-lld gnu-gcc gnu-ld # Linkers |
| 135 | tools-oc := arm-fromelf llvm-objcopy gnu-objcopy # Object copiers |
| 136 | tools-od := arm-fromelf llvm-objdump gnu-objdump # Object dumpers |
| 137 | tools-ar := arm-ar llvm-ar gnu-ar # Archivers |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 138 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 139 | # Other tools |
| 140 | tools-dtc := generic-dtc # Device tree compilers |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 141 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 142 | define check-tool-class-tools |
| 143 | $(eval tool-class := $(1)) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 144 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 145 | ifndef tools-$(tool-class) |
| 146 | $$(error no tools registered to handle tool class `$(tool-class)`) |
| 147 | endif |
| 148 | endef |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 149 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 150 | $(foreach tool-class,$(tool-classes), \ |
| 151 | $(eval $(call check-tool-class-tools,$(tool-class)))) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 152 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 153 | # |
| 154 | # Default tools for each toolchain. |
| 155 | # |
| 156 | # Toolchains can specify a default path to any given tool with a tool |
| 157 | # class. These values are used in the absence of user-specified values, |
| 158 | # and are configured by the makefile for each toolchain using variables |
| 159 | # of the form: |
| 160 | # |
| 161 | # - $(toolchain)-$(tool-class)-default |
| 162 | # |
| 163 | # For example, the default C compiler for the AArch32 and AArch64 |
| 164 | # toolchains could be configured with: |
| 165 | # |
| 166 | # - aarch32-cc-default |
| 167 | # - aarch64-cc-default |
| 168 | # |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 169 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 170 | define check-toolchain-tool-class-default |
| 171 | $(eval toolchain := $(1)) |
| 172 | $(eval tool-class := $(2)) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 173 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 174 | ifndef $(toolchain)-$(tool-class)-default |
| 175 | $$(error no default value specified for tool class `$(tool-class)` of toolchain `$(toolchain)`) |
| 176 | endif |
| 177 | endef |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 178 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 179 | define check-toolchain-tool-class-defaults |
| 180 | $(eval toolchain := $(1)) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 181 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 182 | $(foreach tool-class,$(tool-classes), \ |
| 183 | $(eval $(call check-toolchain-tool-class-default,$(toolchain),$(tool-class)))) |
| 184 | endef |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 185 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 186 | $(foreach toolchain,$(toolchains), \ |
| 187 | $(eval $(call check-toolchain-tool-class-defaults,$(toolchain)))) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 188 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 189 | # |
| 190 | # Helper functions to identify toolchain tools. |
| 191 | # |
| 192 | # The functions defined in this section return a tool identifier when |
| 193 | # given a path to a binary. We generally check a help or version string |
| 194 | # to more reliably identify tools than by looking at the path alone |
| 195 | # (e.g. `gcc` on macOS is actually Apple Clang). |
| 196 | # |
| 197 | # Each tool-guessing function (`guess-tool-$(tool)`) takes a single |
| 198 | # argument giving the path to the tool to guess, and returns a non-empty |
| 199 | # value if the tool corresponds to the tool identifier `$(tool)`: |
| 200 | # |
| 201 | # $(call guess-tool-llvm-clang,aarch64-none-elf-gcc) # <empty> |
| 202 | # $(call guess-tool-gnu-gcc,aarch64-none-elf-gcc) # <non-empty> |
| 203 | # |
| 204 | # The `guess-tool` function tries to find the corresponding tool |
| 205 | # identifier for a tool given its path. It takes two arguments: |
| 206 | # |
| 207 | # - $(1): a list of candidate tool identifiers to check |
| 208 | # - $(2): the path to the tool to identify |
| 209 | # |
| 210 | # If any of the guess functions corresponding to candidate tool |
| 211 | # identifiers return a non-empty value then the tool identifier of the |
| 212 | # first function to do so is returned: |
| 213 | # |
| 214 | # $(call guess-tool,gnu-gcc llvm-clang,armclang) # <empty> |
| 215 | # $(call guess-tool,gnu-gcc llvm-clang,clang-14) # llvm-clang |
| 216 | # $(call guess-tool,gnu-gcc llvm-clang,aarch64-none-elf-gcc-12) # gnu-gcc |
| 217 | # |
| 218 | # Tools are checked in the order that they appear in |
| 219 | # `tools-$(tool-class)`, and the first match is returned. |
| 220 | # |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 221 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 222 | # Arm Compiler for Embedded |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 223 | guess-tool-arm-clang = $(shell $(1) --version 2>&1 <$(nul) | grep -o "Tool: armclang") |
| 224 | guess-tool-arm-link = $(shell $(1) --help 2>&1 <$(nul) | grep -o "Tool: armlink") |
| 225 | guess-tool-arm-fromelf = $(shell $(1) --help 2>&1 <$(nul) | grep -o "Tool: fromelf") |
| 226 | guess-tool-arm-ar = $(shell $(1) --version 2>&1 <$(nul) | grep -o "Tool: armar") |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 227 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 228 | # LLVM Project |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 229 | guess-tool-llvm-clang = $(shell $(1) -v 2>&1 <$(nul) | grep -o "clang version") |
| 230 | guess-tool-llvm-lld = $(shell $(1) --help 2>&1 <$(nul) | grep -o "OVERVIEW: lld") |
| 231 | guess-tool-llvm-objcopy = $(shell $(1) --help 2>&1 <$(nul) | grep -o "llvm-objcopy tool") |
| 232 | guess-tool-llvm-objdump = $(shell $(1) --help 2>&1 <$(nul) | grep -o "llvm object file dumper") |
| 233 | guess-tool-llvm-ar = $(shell $(1) --help 2>&1 <$(nul) | grep -o "LLVM Archiver") |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 234 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 235 | # GNU Compiler Collection & GNU Binary Utilities |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 236 | guess-tool-gnu-gcc = $(shell $(1) -v 2>&1 <$(nul) | grep -o "gcc version") |
| 237 | guess-tool-gnu-ld = $(shell $(1) -v 2>&1 <$(nul) | grep -o "GNU ld") |
| 238 | guess-tool-gnu-objcopy = $(shell $(1) --version 2>&1 <$(nul) | grep -o "GNU objcopy") |
| 239 | guess-tool-gnu-objdump = $(shell $(1) --version 2>&1 <$(nul) | grep -o "GNU objdump") |
| 240 | guess-tool-gnu-ar = $(shell $(1) --version 2>&1 <$(nul) | grep -o "GNU ar") |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 241 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 242 | # Other tools |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 243 | guess-tool-generic-dtc = $(shell $(1) --version 2>&1 <$(nul) | grep -o "Version: DTC") |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 244 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 245 | guess-tool = $(firstword $(foreach candidate,$(1), \ |
| 246 | $(if $(call guess-tool-$(candidate),$(2)),$(candidate)))) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 247 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 248 | # |
| 249 | # Locate and identify tools belonging to each toolchain. |
| 250 | # |
| 251 | # Each tool class in each toolchain receives a variable of the form |
| 252 | # `$(toolchain)-$(tool)` giving the associated path to the program. For |
| 253 | # example: |
| 254 | # |
| 255 | # - `aarch64-ld` gives the linker for the AArch64 toolchain, |
| 256 | # - `aarch32-oc` gives the object copier for the AArch32 toolchain, and |
| 257 | # - `host-cc` gives the C compiler for the host toolchain. |
| 258 | # |
| 259 | # For each of these variables, if no program path is explicitly provided |
| 260 | # by the parent Makefile then the C compiler is queried (if supported) |
| 261 | # for its location. This is done via the `guess-$(tool)-$(tool-class)` |
| 262 | # set of functions. For example: |
| 263 | # |
| 264 | # - `guess-arm-clang-ld` guesses the linker via Arm Clang, |
| 265 | # - `guess-llvm-clang-as` guesses the assembler via LLVM Clang, and |
| 266 | # - `guess-gnu-gcc-od` guesses the object dumper via GNU GCC. |
| 267 | # |
| 268 | # If the C compiler cannot provide the location (or the tool class is |
| 269 | # the C compiler), then it is assigned the value of the |
| 270 | # `$(toolchain)-$(tool)-default` variable. |
| 271 | # |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 272 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 273 | guess-arm-clang-cpp = $(1) |
| 274 | guess-arm-clang-as = $(1) |
| 275 | guess-arm-clang-ld = # Fall back to `$(toolchain)-ld-default` |
| 276 | guess-arm-clang-oc = # Fall back to `$(toolchain)-oc-default` |
| 277 | guess-arm-clang-od = # Fall back to `$(toolchain)-od-default` |
| 278 | guess-arm-clang-ar = # Fall back to `$(toolchain)-ar-default` |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 279 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 280 | guess-llvm-clang-cpp = $(1) |
| 281 | guess-llvm-clang-as = $(1) |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 282 | guess-llvm-clang-ld = $(shell $(1) --print-prog-name ld.lld 2>$(nul)) |
| 283 | guess-llvm-clang-oc = $(shell $(1) --print-prog-name llvm-objcopy 2>$(nul)) |
| 284 | guess-llvm-clang-od = $(shell $(1) --print-prog-name llvm-objdump 2>$(nul)) |
| 285 | guess-llvm-clang-ar = $(shell $(1) --print-prog-name llvm-ar 2>$(nul)) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 286 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 287 | guess-gnu-gcc-cpp = $(1) |
| 288 | guess-gnu-gcc-as = $(1) |
| 289 | guess-gnu-gcc-ld = $(1) |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 290 | guess-gnu-gcc-oc = $(shell $(1) --print-prog-name objcopy 2>$(nul)) |
| 291 | guess-gnu-gcc-od = $(shell $(1) --print-prog-name objdump 2>$(nul)) |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 292 | guess-gnu-gcc-ar = $(call which,$(call decompat-path,$(patsubst %$(call file-name,$(1)),%$(subst gcc,gcc-ar,$(call file-name,$(1))),$(call compat-path,$(1))))) |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 293 | |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 294 | define toolchain-warn-unrecognized |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 295 | $$(warning ) |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 296 | $$(warning The configured $$($(1)-name) $$(tool-class-name-$(2)) could not be identified and may not be supported:) |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 297 | $$(warning ) |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 298 | $$(warning $$(space) $$($(1)-$(2))) |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 299 | $$(warning ) |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 300 | $$(warning The default $$($(1)-name) $$(tool-class-name-$(2)) is:) |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 301 | $$(warning ) |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 302 | $$(warning $$(space) $$($(1)-$(2)-default)) |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 303 | $$(warning ) |
| 304 | $$(warning The following tools are supported:) |
| 305 | $$(warning ) |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 306 | |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 307 | $$(foreach tool,$$(tools-$(2)), \ |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 308 | $$(warning $$(space) - $$(tool-name-$$(tool)))) |
Chris Kay | 24f3fb4 | 2024-04-16 17:19:20 +0000 | [diff] [blame] | 309 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 310 | $$(warning ) |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 311 | $$(warning The build system will treat this $$(tool-class-name-$(2)) as $$(tool-name-$$($(1)-$(2)-id-default)).) |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 312 | $$(warning ) |
| 313 | endef |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 314 | |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 315 | define toolchain-determine-tool |
| 316 | $(1)-$(2)-guess = $$(if $$(filter-out cc,$(2)),$\ |
| 317 | $$(call guess-$$($(1)-cc-id)-$(2),$$($(1)-cc))) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 318 | |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 319 | $(1)-$(2) := $$(or $$($(1)-$(2)),$$($(1)-$(2)-guess)) |
| 320 | $(1)-$(2) := $$(or $$($(1)-$(2)),$$($(1)-$(2)-default)) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 321 | |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 322 | ifneq ($$(call which,$$($(1)-$(2))),) |
| 323 | # If we can resolve this tool to a program on the `PATH` |
| 324 | # then escape it for use in a shell, which allows us to |
| 325 | # preserve spaces. |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 326 | |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 327 | $(1)-$(2) := $$(call escape-shell,$$($(1)-$(2))) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 328 | endif |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 329 | |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 330 | $(1)-$(2)-id := $$(call guess-tool,$$(tools-$(2)),$$($(1)-$(2))) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 331 | |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 332 | ifndef $(1)-$(2)-id |
| 333 | $(1)-$(2)-id := $$($(1)-$(2)-id-default) |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 334 | |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 335 | $$(eval $$(call toolchain-warn-unrecognized,$(1),$(2))) |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 336 | endif |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 337 | endef |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 338 | |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 339 | define toolchain-determine |
| 340 | $$(foreach tool-class,$$(tool-classes), \ |
| 341 | $$(eval $$(call toolchain-determine-tool,$(1),$$(tool-class)))) |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 342 | endef |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 343 | |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 344 | $(foreach toolchain,$(toolchains), \ |
Chris Kay | e8dcac3 | 2024-05-15 11:19:17 +0000 | [diff] [blame] | 345 | $(eval $(call toolchain-determine,$(toolchain)))) |
Chris Kay | 0adde4e | 2024-05-14 13:08:31 +0000 | [diff] [blame] | 346 | endif |