tools/build/Makefile.feature

Source file repositories/reference/linux-study-clean/tools/build/Makefile.feature

File Facts

System
Linux kernel
Corpus path
tools/build/Makefile.feature
Extension
.feature
Size
10458 bytes
Lines
326
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: build/configuration rule
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

# SPDX-License-Identifier: GPL-2.0-only
feature_dir := $(srctree)/tools/build/feature

ifneq ($(OUTPUT),)
  OUTPUT_FEATURES = $(OUTPUT)feature/
  $(shell mkdir -p $(OUTPUT_FEATURES))
endif

feature_check = $(eval $(feature_check_code))
define feature_check_code
  feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC="$(CC)" CXX="$(CXX)" CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
endef

feature_set = $(eval $(feature_set_code))
define feature_set_code
  feature-$(1) := 1
endef

#
# Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output:
#

#
# Note that this is not a complete list of all feature tests, just
# those that are typically built on a fully configured system.
#
# [ Feature tests not mentioned here have to be built explicitly in
#   the rule that uses them - an example for that is the 'bionic'
#   feature check. ]
#
# These + the ones in FEATURE_TESTS_EXTRA are included in
# tools/build/feature/test-all.c and we try to build it all together
# then setting all those features to '1' meaning they are all enabled.
#
# There are things like fortify-source that will be set to 1 because test-all
# is built with the flags needed to test if its enabled, resulting in
#
#   $ rm -rf /tmp/b ; mkdir /tmp/b ; make -C tools/perf O=/tmp/b feature-dump
#   $ grep fortify-source /tmp/b/FEATURE-DUMP
#   feature-fortify-source=1
#   $
#
#   All the others should have lines in tools/build/feature/test-all.c like:
#
#    #define main main_test_disassembler_init_styled
#    # include "test-disassembler-init-styled.c"
#    #undef main
#
#    #define main main_test_libzstd
#    # include "test-libzstd.c"
#    #undef main
#
#    int main(int argc, char *argv[])
#    {
#      main_test_disassembler_four_args();
#      main_test_libzstd();
#      return 0;
#    }
#
#    If the sample above works, then we end up with these lines in the FEATURE-DUMP
#    file:
#
#    feature-disassembler-four-args=1
#    feature-libzstd=1
#
FEATURE_TESTS_BASIC :=                  \
        backtrace                       \
        libdw                           \
        eventfd                         \
        fortify-source                  \

Annotation

Implementation Notes