1 # SPDX-License-Identifier: GPL-2.0-only 2 3 # cc-cross-prefix 4 # Usage: CROSS_COMPILE := $(call cc-cross-pref 5 # Return first <prefix> where a <prefix>gcc is 6 # If no gcc found in PATH with listed prefixes 7 # 8 # Note: '2>/dev/null' is here to force Make to 9 # would try to directly execute the shell buil 10 # should be kept for a long time since this is 11 # GNU Make 4.2.1 release. 12 cc-cross-prefix = $(firstword $(foreach c, $(1 13 $(if $(shell command - 14 15 # output directory for tests below 16 TMPOUT = $(if $(KBUILD_EXTMOD),$(firstword $(K 17 18 # try-run 19 # Usage: option = $(call try-run, $(CC)...-o " 20 # Exit code chooses option. "$$TMP" serves as 21 # automatically cleaned up. 22 try-run = $(shell set -e; \ 23 TMP=$(TMPOUT)/tmp; \ 24 trap "rm -rf $(TMPOUT)" EXIT; \ 25 mkdir -p $(TMPOUT); \ 26 if ($(1)) >/dev/null 2>&1; \ 27 then echo "$(2)"; \ 28 else echo "$(3)"; \ 29 fi) 30 31 # as-option 32 # Usage: aflags-y += $(call as-option,-Wa$(com 33 34 as-option = $(call try-run,\ 35 $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBU 36 37 # as-instr 38 # Usage: aflags-y += $(call as-instr,instr,opt 39 40 as-instr = $(call try-run,\ 41 printf "%b\n" "$(1)" | $(CC) -Werror $ 42 43 # __cc-option 44 # Usage: MY_CFLAGS += $(call __cc-option,$(CC) 45 __cc-option = $(call try-run,\ 46 $(1) -Werror $(2) $(3) -c -x c /dev/nu 47 48 # cc-option 49 # Usage: cflags-y += $(call cc-option,-march=w 50 51 cc-option = $(call __cc-option, $(CC),\ 52 $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$( 53 54 # cc-option-yn 55 # Usage: flag := $(call cc-option-yn,-march=wi 56 cc-option-yn = $(if $(call cc-option,$1),y,n) 57 58 # cc-disable-warning 59 # Usage: cflags-y += $(call cc-disable-warning 60 cc-disable-warning = $(if $(call cc-option,-W$ 61 62 # gcc-min-version 63 # Usage: cflags-$(call gcc-min-version, 70100) 64 gcc-min-version = $(call test-ge, $(CONFIG_GCC 65 66 # clang-min-version 67 # Usage: cflags-$(call clang-min-version, 1100 68 clang-min-version = $(call test-ge, $(CONFIG_C 69 70 # ld-option 71 # Usage: KBUILD_LDFLAGS += $(call ld-option, - 72 ld-option = $(call try-run, $(LD) $(KBUILD_LDF 73 74 # __rustc-option 75 # Usage: MY_RUSTFLAGS += $(call __rustc-option 76 # TODO: remove RUSTC_BOOTSTRAP=1 when we raise 77 __rustc-option = $(call try-run,\ 78 echo '#![allow(missing_docs)]#![featur 79 $(1) --sysroot=/dev/null $(filter-out 80 --crate-type=rlib --out-dir=$(TMPOUT) 81 82 # rustc-option 83 # Usage: rustflags-y += $(call rustc-option,-C 84 rustc-option = $(call __rustc-option, $(RUSTC) 85 $(KBUILD_RUSTFLAGS),$(1),$(2)) 86 87 # rustc-option-yn 88 # Usage: flag := $(call rustc-option-yn,-Cinst 89 rustc-option-yn = $(if $(call rustc-option,$1)
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.