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