Jiri Olsa | 970e87b | 2015-03-01 21:12:25 +0100 | [diff] [blame^] | 1 | feature_dir := $(srctree)/tools/perf/config/feature-checks |
| 2 | |
Jiri Olsa | 0afc5ca | 2015-03-01 21:04:01 +0100 | [diff] [blame] | 3 | ifneq ($(OUTPUT),) |
| 4 | OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/ |
| 5 | $(shell mkdir -p $(OUTPUT_FEATURES)) |
| 6 | endif |
| 7 | |
| 8 | feature_check = $(eval $(feature_check_code)) |
| 9 | define feature_check_code |
Jiri Olsa | 970e87b | 2015-03-01 21:12:25 +0100 | [diff] [blame^] | 10 | feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) |
Jiri Olsa | 0afc5ca | 2015-03-01 21:04:01 +0100 | [diff] [blame] | 11 | endef |
| 12 | |
| 13 | feature_set = $(eval $(feature_set_code)) |
| 14 | define feature_set_code |
| 15 | feature-$(1) := 1 |
| 16 | endef |
| 17 | |
| 18 | # |
| 19 | # Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output: |
| 20 | # |
| 21 | |
| 22 | # |
| 23 | # Note that this is not a complete list of all feature tests, just |
| 24 | # those that are typically built on a fully configured system. |
| 25 | # |
| 26 | # [ Feature tests not mentioned here have to be built explicitly in |
| 27 | # the rule that uses them - an example for that is the 'bionic' |
| 28 | # feature check. ] |
| 29 | # |
| 30 | FEATURE_TESTS = \ |
| 31 | backtrace \ |
| 32 | dwarf \ |
| 33 | fortify-source \ |
| 34 | sync-compare-and-swap \ |
| 35 | glibc \ |
| 36 | gtk2 \ |
| 37 | gtk2-infobar \ |
| 38 | libaudit \ |
| 39 | libbfd \ |
| 40 | libelf \ |
| 41 | libelf-getphdrnum \ |
| 42 | libelf-mmap \ |
| 43 | libnuma \ |
| 44 | libperl \ |
| 45 | libpython \ |
| 46 | libpython-version \ |
| 47 | libslang \ |
| 48 | libunwind \ |
| 49 | pthread-attr-setaffinity-np \ |
| 50 | stackprotector-all \ |
| 51 | timerfd \ |
| 52 | libdw-dwarf-unwind \ |
| 53 | zlib |
| 54 | |
| 55 | FEATURE_DISPLAY = \ |
| 56 | dwarf \ |
| 57 | glibc \ |
| 58 | gtk2 \ |
| 59 | libaudit \ |
| 60 | libbfd \ |
| 61 | libelf \ |
| 62 | libnuma \ |
| 63 | libperl \ |
| 64 | libpython \ |
| 65 | libslang \ |
| 66 | libunwind \ |
| 67 | libdw-dwarf-unwind \ |
| 68 | zlib |
| 69 | |
| 70 | # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features. |
| 71 | # If in the future we need per-feature checks/flags for features not |
| 72 | # mentioned in this list we need to refactor this ;-). |
| 73 | set_test_all_flags = $(eval $(set_test_all_flags_code)) |
| 74 | define set_test_all_flags_code |
| 75 | FEATURE_CHECK_CFLAGS-all += $(FEATURE_CHECK_CFLAGS-$(1)) |
| 76 | FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1)) |
| 77 | endef |
| 78 | |
| 79 | $(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat))) |
| 80 | |
| 81 | # |
| 82 | # Special fast-path for the 'all features are available' case: |
| 83 | # |
| 84 | $(call feature_check,all,$(MSG)) |
| 85 | |
| 86 | # |
| 87 | # Just in case the build freshly failed, make sure we print the |
| 88 | # feature matrix: |
| 89 | # |
| 90 | ifeq ($(feature-all), 1) |
| 91 | # |
| 92 | # test-all.c passed - just set all the core feature flags to 1: |
| 93 | # |
| 94 | $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat))) |
| 95 | else |
Jiri Olsa | 970e87b | 2015-03-01 21:12:25 +0100 | [diff] [blame^] | 96 | $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C $(feature_dir) $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1) |
Jiri Olsa | 0afc5ca | 2015-03-01 21:04:01 +0100 | [diff] [blame] | 97 | $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat))) |
| 98 | endif |
| 99 | |
| 100 | # |
| 101 | # Print the result of the feature test: |
| 102 | # |
| 103 | feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG)) |
| 104 | |
| 105 | define feature_print_status_code |
| 106 | ifeq ($(feature-$(1)), 1) |
| 107 | MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1)) |
| 108 | else |
| 109 | MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1)) |
| 110 | endif |
| 111 | endef |
| 112 | |
| 113 | feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG)) |
| 114 | define feature_print_text_code |
| 115 | MSG = $(shell printf '...%30s: %s' $(1) $(2)) |
| 116 | endef |
| 117 | |
| 118 | FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat)))) |
| 119 | FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP) |
| 120 | |
| 121 | ifeq ($(dwarf-post-unwind),1) |
| 122 | FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text)) |
| 123 | endif |
| 124 | |
| 125 | # The $(feature_display) controls the default detection message |
| 126 | # output. It's set if: |
| 127 | # - detected features differes from stored features from |
| 128 | # last build (in FEATURE-DUMP file) |
| 129 | # - one of the $(FEATURE_DISPLAY) is not detected |
| 130 | # - VF is enabled |
| 131 | |
| 132 | ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)") |
| 133 | $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP) |
| 134 | feature_display := 1 |
| 135 | endif |
| 136 | |
| 137 | feature_display_check = $(eval $(feature_check_code)) |
| 138 | define feature_display_check_code |
| 139 | ifneq ($(feature-$(1)), 1) |
| 140 | feature_display := 1 |
| 141 | endif |
| 142 | endef |
| 143 | |
| 144 | $(foreach feat,$(FEATURE_DISPLAY),$(call feature_display_check,$(feat))) |
| 145 | |
| 146 | ifeq ($(VF),1) |
| 147 | feature_display := 1 |
| 148 | feature_verbose := 1 |
| 149 | endif |
| 150 | |
| 151 | ifeq ($(feature_display),1) |
| 152 | $(info ) |
| 153 | $(info Auto-detecting system features:) |
| 154 | $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),)) |
| 155 | |
| 156 | ifeq ($(dwarf-post-unwind),1) |
| 157 | $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) |
| 158 | endif |
| 159 | |
| 160 | ifneq ($(feature_verbose),1) |
| 161 | $(info ) |
| 162 | endif |
| 163 | endif |
| 164 | |
| 165 | ifeq ($(feature_verbose),1) |
| 166 | TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS)) |
| 167 | $(foreach feat,$(TMP),$(call feature_print_status,$(feat),)) |
| 168 | $(info ) |
| 169 | endif |