aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-03-01 15:04:01 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-03-21 13:53:33 -0400
commit0afc5cad387db56054b09bb14baf0e6e49df2fd2 (patch)
treea91aba508d73c247fbe882e2cdde81d94dfcfac7 /tools
parent58d4f00ff13f20468f8fa8edcb57a195c31af46d (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/Makefile165
-rw-r--r--tools/perf/config/Makefile.feature167
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
177EXTLIBS = -lpthread -lrt -lm -ldl 177EXTLIBS = -lpthread -lrt -lm -ldl
178 178
179ifneq ($(OUTPUT),) 179include $(src-perf)/config/Makefile.feature
180 OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
181 $(shell mkdir -p $(OUTPUT_FEATURES))
182endif
183
184feature_check = $(eval $(feature_check_code))
185define 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)
187endef
188
189feature_set = $(eval $(feature_set_code))
190define feature_set_code
191 feature-$(1) := 1
192endef
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#
206FEATURE_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
231FEATURE_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 ;-).
249set_test_all_flags = $(eval $(set_test_all_flags_code))
250define set_test_all_flags_code
251 FEATURE_CHECK_CFLAGS-all += $(FEATURE_CHECK_CFLAGS-$(1))
252 FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
253endef
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#
266ifeq ($(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)))
271else
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)))
274endif
275 180
276ifeq ($(feature-stackprotector-all), 1) 181ifeq ($(feature-stackprotector-all), 1)
277 CFLAGS += -fstack-protector-all 182 CFLAGS += -fstack-protector-all
@@ -763,80 +668,12 @@ plugindir=$(libdir)/traceevent/plugins
763plugindir_SQ= $(subst ','\'',$(plugindir)) 668plugindir_SQ= $(subst ','\'',$(plugindir))
764endif 669endif
765 670
766#
767# Print the result of the feature test:
768#
769feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
770
771define 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
777endef
778
779print_var = $(eval $(print_var_code)) $(info $(MSG)) 671print_var = $(eval $(print_var_code)) $(info $(MSG))
780define print_var_code 672define print_var_code
781 MSG = $(shell printf '...%30s: %s' $(1) $($(1))) 673 MSG = $(shell printf '...%30s: %s' $(1) $($(1)))
782endef 674endef
783 675
784feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
785define feature_print_text_code
786 MSG = $(shell printf '...%30s: %s' $(1) $(2))
787endef
788
789FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
790FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
791
792ifeq ($(dwarf-post-unwind),1)
793 FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
794endif
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
803ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
804 $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
805 feature_display := 1
806endif
807
808feature_display_check = $(eval $(feature_check_code))
809define feature_display_check_code
810 ifneq ($(feature-$(1)), 1)
811 feature_display := 1
812 endif
813endef
814
815$(foreach feat,$(FEATURE_DISPLAY),$(call feature_display_check,$(feat)))
816
817ifeq ($(VF),1) 676ifeq ($(VF),1)
818 feature_display := 1
819 feature_verbose := 1
820endif
821
822ifeq ($(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
834endif
835
836ifeq ($(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 @@
1ifneq ($(OUTPUT),)
2 OUTPUT_FEATURES = $(OUTPUT)config/feature-checks/
3 $(shell mkdir -p $(OUTPUT_FEATURES))
4endif
5
6feature_check = $(eval $(feature_check_code))
7define 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)
9endef
10
11feature_set = $(eval $(feature_set_code))
12define feature_set_code
13 feature-$(1) := 1
14endef
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#
28FEATURE_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
53FEATURE_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 ;-).
71set_test_all_flags = $(eval $(set_test_all_flags_code))
72define set_test_all_flags_code
73 FEATURE_CHECK_CFLAGS-all += $(FEATURE_CHECK_CFLAGS-$(1))
74 FEATURE_CHECK_LDFLAGS-all += $(FEATURE_CHECK_LDFLAGS-$(1))
75endef
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#
88ifeq ($(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)))
93else
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)))
96endif
97
98#
99# Print the result of the feature test:
100#
101feature_print_status = $(eval $(feature_print_status_code)) $(info $(MSG))
102
103define 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
109endef
110
111feature_print_text = $(eval $(feature_print_text_code)) $(info $(MSG))
112define feature_print_text_code
113 MSG = $(shell printf '...%30s: %s' $(1) $(2))
114endef
115
116FEATURE_DUMP := $(foreach feat,$(FEATURE_DISPLAY),feature-$(feat)($(feature-$(feat))))
117FEATURE_DUMP_FILE := $(shell touch $(OUTPUT)FEATURE-DUMP; cat $(OUTPUT)FEATURE-DUMP)
118
119ifeq ($(dwarf-post-unwind),1)
120 FEATURE_DUMP += dwarf-post-unwind($(dwarf-post-unwind-text))
121endif
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
130ifneq ("$(FEATURE_DUMP)","$(FEATURE_DUMP_FILE)")
131 $(shell echo "$(FEATURE_DUMP)" > $(OUTPUT)FEATURE-DUMP)
132 feature_display := 1
133endif
134
135feature_display_check = $(eval $(feature_check_code))
136define feature_display_check_code
137 ifneq ($(feature-$(1)), 1)
138 feature_display := 1
139 endif
140endef
141
142$(foreach feat,$(FEATURE_DISPLAY),$(call feature_display_check,$(feat)))
143
144ifeq ($(VF),1)
145 feature_display := 1
146 feature_verbose := 1
147endif
148
149ifeq ($(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
161endif
162
163ifeq ($(feature_verbose),1)
164 TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS))
165 $(foreach feat,$(TMP),$(call feature_print_status,$(feat),))
166 $(info )
167endif