diff options
author | Jiri Olsa <jolsa@kernel.org> | 2015-03-01 15:04:01 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-03-21 13:53:33 -0400 |
commit | 0afc5cad387db56054b09bb14baf0e6e49df2fd2 (patch) | |
tree | a91aba508d73c247fbe882e2cdde81d94dfcfac7 /tools | |
parent | 58d4f00ff13f20468f8fa8edcb57a195c31af46d (diff) |
perf build: Separate feature make support into config/Makefile.feature
Move feature related code into separate makefile. The new
Makefile.feature is included from config/Makefile. It will be moved
later into tools/build.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <david.ahern@oracle.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-kj76wphg05x83n6d5ff85ybx@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/config/Makefile | 165 | ||||
-rw-r--r-- | tools/perf/config/Makefile.feature | 167 |
2 files changed, 168 insertions, 164 deletions
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 81d8c2bbc4df..01278429965a 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile | |||
@@ -176,102 +176,7 @@ LDFLAGS += -Wl,-z,noexecstack | |||
176 | 176 | ||
177 | EXTLIBS = -lpthread -lrt -lm -ldl | 177 | EXTLIBS = -lpthread -lrt -lm -ldl |
178 | 178 | ||
179 | ifneq ($(OUTPUT),) | 179 | include $(src-perf)/config/Makefile.feature |
180 | OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/ | ||
181 | $(shell mkdir -p $(OUTPUT_FEATURES)) | ||
182 | endif | ||
183 | |||
184 | feature_check = $(eval $(feature_check_code)) | ||
185 | define feature_check_code | ||
186 | 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) | ||
187 | endef | ||
188 | |||
189 | feature_set = $(eval $(feature_set_code)) | ||
190 | define feature_set_code | ||
191 | feature-$(1) := 1 | ||
192 | endef | ||
193 | |||
194 | # | ||
195 | # Build the feature check binaries in parallel, ignore errors, ignore return value and suppress output: | ||
196 | # | ||
197 | |||
198 | # | ||
199 | # Note that this is not a complete list of all feature tests, just | ||
200 | # those that are typically built on a fully configured system. | ||
201 | # | ||
202 | # [ Feature tests not mentioned here have to be built explicitly in | ||
203 | # the rule that uses them - an example for that is the 'bionic' | ||
204 | # feature check. ] | ||
205 | # | ||
206 | FEATURE_TESTS = \ | ||
207 | backtrace \ | ||
208 | dwarf \ | ||
209 | fortify-source \ | ||
210 | sync-compare-and-swap \ | ||
211 | glibc \ | ||
212 | gtk2 \ | ||
213 | gtk2-infobar \ | ||
214 | libaudit \ | ||
215 | libbfd \ | ||
216 | libelf \ | ||
217 | libelf-getphdrnum \ | ||
218 | libelf-mmap \ | ||
219 | libnuma \ | ||
220 | libperl \ | ||
221 | libpython \ | ||
222 | libpython-version \ | ||
223 | libslang \ | ||
224 | libunwind \ | ||
225 | pthread-attr-setaffinity-np \ | ||
226 | stackprotector-all \ | ||
227 | timerfd \ | ||
228 | libdw-dwarf-unwind \ | ||
229 | zlib | ||
230 | |||
231 | FEATURE_DISPLAY = \ | ||
232 | dwarf \ | ||
233 | glibc \ | ||
234 | gtk2 \ | ||
235 | libaudit \ | ||
236 | libbfd \ | ||
237 | libelf \ | ||
238 | libnuma \ | ||
239 | libperl \ | ||
240 | libpython \ | ||
241 | libslang \ | ||
242 | libunwind \ | ||
243 | libdw-dwarf-unwind \ | ||
244 | zlib | ||
245 | |||
246 | # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features. | ||
247 | # If in the future we need per-feature checks/flags for features not | ||
248 | # mentioned in this list we need to refactor this ;-). | ||
249 | set_test_all_flags = $(eval $(set_test_all_flags_code)) | ||
250 | define set_test_all_flags_code | ||
251 | FEATURE_CHECK_CFLAGS-all += $(FEATURE_CHECK_CFLAGS-$(1)) | ||
252 | FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1)) | ||
253 | endef | ||
254 | |||
255 | $(foreach feat,$(FEATURE_TESTS),$(call set_test_all_flags,$(feat))) | ||
256 | |||
257 | # | ||
258 | # Special fast-path for the 'all features are available' case: | ||
259 | # | ||
260 | $(call feature_check,all,$(MSG)) | ||
261 | |||
262 | # | ||
263 | # Just in case the build freshly failed, make sure we print the | ||
264 | # feature matrix: | ||
265 | # | ||
266 | ifeq ($(feature-all), 1) | ||
267 | # | ||
268 | # test-all.c passed - just set all the core feature flags to 1: | ||
269 | # | ||
270 | $(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat))) | ||
271 | else | ||
272 | $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS=$(LDFLAGS) -i -j -C config/feature-checks $(addsuffix .bin,$(FEATURE_TESTS)) >/dev/null 2>&1) | ||
273 | $(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat))) | ||
274 | endif | ||
275 | 180 | ||
276 | ifeq ($(feature-stackprotector-all), 1) | 181 | ifeq ($(feature-stackprotector-all), 1) |
277 | CFLAGS += -fstack-protector-all | 182 | CFLAGS += -fstack-protector-all |
@@ -763,80 +668,12 @@ plugindir=$(libdir)/traceevent/plugins | |||
763 | plugindir_SQ= $(subst ','\'',$(plugindir)) | 668 | plugindir_SQ= $(subst ','\'',$(plugindir)) |
764 | endif | 669 | endif |
765 | 670 | ||
766 | # | ||
767 | # Print the result of the feature test: | ||
768 | # | ||
769 | feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG)) | ||
770 | |||
771 | define feature_print_status_code | ||
772 | ifeq ($(feature-$(1)), 1) | ||
773 | MSG = $(shell printf '...%30s: [ \033[32mon\033[m ]' $(1)) | ||
774 | else | ||
775 | MSG = $(shell printf '...%30s: [ \033[31mOFF\033[m ]' $(1)) | ||
776 | endif | ||
777 | endef | ||
778 | |||
779 | print_var = $(eval $(print_var_code)) $(info $(MSG)) | 671 | print_var = $(eval $(print_var_code)) $(info $(MSG)) |
780 | define print_var_code | 672 | define print_var_code |
781 | MSG = $(shell printf '...%30s: %s' $(1) $($(1))) | 673 | MSG = $(shell printf '...%30s: %s' $(1) $($(1))) |
782 | endef | 674 | endef |
783 | 675 | ||
784 | feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG)) | ||
785 | define feature_print_text_code | ||
786 | MSG = $(shell printf '...%30s: %s' $(1) $(2)) | ||
787 | endef | ||
788 | |||
789 | FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat)))) | ||
790 | FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP) | ||
791 | |||
792 | ifeq ($(dwarf-post-unwind),1) | ||
793 | FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text)) | ||
794 | endif | ||
795 | |||
796 | # The $(feature_display) controls the default detection message | ||
797 | # output. It's set if: | ||
798 | # - detected features differes from stored features from | ||
799 | # last build (in FEATURE-DUMP file) | ||
800 | # - one of the $(FEATURE_DISPLAY) is not detected | ||
801 | # - VF is enabled | ||
802 | |||
803 | ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)") | ||
804 | $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP) | ||
805 | feature_display := 1 | ||
806 | endif | ||
807 | |||
808 | feature_display_check = $(eval $(feature_check_code)) | ||
809 | define feature_display_check_code | ||
810 | ifneq ($(feature-$(1)), 1) | ||
811 | feature_display := 1 | ||
812 | endif | ||
813 | endef | ||
814 | |||
815 | $(foreach feat,$(FEATURE_DISPLAY),$(call feature_display_check,$(feat))) | ||
816 | |||
817 | ifeq ($(VF),1) | 676 | ifeq ($(VF),1) |
818 | feature_display := 1 | ||
819 | feature_verbose := 1 | ||
820 | endif | ||
821 | |||
822 | ifeq ($(feature_display),1) | ||
823 | $(info ) | ||
824 | $(info Auto-detecting system features:) | ||
825 | $(foreach feat,$(FEATURE_DISPLAY),$(call feature_print_status,$(feat),)) | ||
826 | |||
827 | ifeq ($(dwarf-post-unwind),1) | ||
828 | $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text)) | ||
829 | endif | ||
830 | |||
831 | ifneq ($(feature_verbose),1) | ||
832 | $(info ) | ||
833 | endif | ||
834 | endif | ||
835 | |||
836 | ifeq ($(feature_verbose),1) | ||
837 | TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS)) | ||
838 | $(foreach feat,$(TMP),$(call feature_print_status,$(feat),)) | ||
839 | $(info ) | ||
840 | $(call print_var,prefix) | 677 | $(call print_var,prefix) |
841 | $(call print_var,bindir) | 678 | $(call print_var,bindir) |
842 | $(call print_var,libdir) | 679 | $(call print_var,libdir) |
diff --git a/tools/perf/config/Makefile.feature b/tools/perf/config/Makefile.feature new file mode 100644 index 000000000000..8c98bbce6031 --- /dev/null +++ b/tools/perf/config/Makefile.feature | |||
@@ -0,0 +1,167 @@ | |||
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 | ||