blob: 65280d28662e4c72177a20a3cfa56f968a10c359 [file] [log] [blame]
Jiri Olsa095ae692013-03-29 16:11:02 +01001PERF := .
2MK := Makefile
3
Jiri Olsaf7c64472014-01-03 15:32:33 +01004include config/Makefile.arch
5
6# FIXME looks like x86 is the only arch running tests ;-)
7# we need some IS_(32/64) flag to make this generic
H.J. Lu76aea772015-03-17 15:27:48 -07008ifeq ($(ARCH)$(IS_64_BIT), x861)
Jiri Olsaf7c64472014-01-03 15:32:33 +01009lib = lib64
10else
11lib = lib
12endif
13
Jiri Olsa0659e662013-07-22 14:43:30 +020014has = $(shell which $1 2>/dev/null)
15
Jiri Olsa095ae692013-03-29 16:11:02 +010016# standard single make variable specified
17make_clean_all := clean all
18make_python_perf_so := python/perf.so
19make_debug := DEBUG=1
20make_no_libperl := NO_LIBPERL=1
21make_no_libpython := NO_LIBPYTHON=1
22make_no_scripts := NO_LIBPYTHON=1 NO_LIBPERL=1
23make_no_newt := NO_NEWT=1
24make_no_slang := NO_SLANG=1
25make_no_gtk2 := NO_GTK2=1
26make_no_ui := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
27make_no_demangle := NO_DEMANGLE=1
28make_no_libelf := NO_LIBELF=1
29make_no_libunwind := NO_LIBUNWIND=1
Jiri Olsa9e8c06e2014-02-19 16:52:59 +010030make_no_libdw_dwarf_unwind := NO_LIBDW_DWARF_UNWIND=1
Jiri Olsa095ae692013-03-29 16:11:02 +010031make_no_backtrace := NO_BACKTRACE=1
32make_no_libnuma := NO_LIBNUMA=1
33make_no_libaudit := NO_LIBAUDIT=1
34make_no_libbionic := NO_LIBBIONIC=1
Adrian Huntere31f0d02015-04-30 17:37:27 +030035make_no_auxtrace := NO_AUXTRACE=1
Jiri Olsa095ae692013-03-29 16:11:02 +010036make_tags := tags
37make_cscope := cscope
38make_help := help
39make_doc := doc
Jiri Olsa2a94f6c2014-02-19 11:21:39 +010040make_perf_o := perf.o
41make_util_map_o := util/map.o
42make_util_pmu_bison_o := util/pmu-bison.o
Jiri Olsac0ec1102013-07-22 14:43:33 +020043make_install := install
44make_install_bin := install-bin
Jiri Olsadbad4182013-07-22 14:43:34 +020045make_install_doc := install-doc
46make_install_man := install-man
47make_install_html := install-html
48make_install_info := install-info
49make_install_pdf := install-pdf
Jiri Olsa611ec122014-04-29 09:53:40 +020050make_static := LDFLAGS=-static
Jiri Olsa095ae692013-03-29 16:11:02 +010051
52# all the NO_* variable combined
53make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
54make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
55make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
Adrian Huntere31f0d02015-04-30 17:37:27 +030056make_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1
Jiri Olsa095ae692013-03-29 16:11:02 +010057
58# $(run) contains all available tests
59run := make_pure
60run += make_clean_all
61run += make_python_perf_so
62run += make_debug
63run += make_no_libperl
64run += make_no_libpython
65run += make_no_scripts
66run += make_no_newt
67run += make_no_slang
68run += make_no_gtk2
69run += make_no_ui
70run += make_no_demangle
71run += make_no_libelf
72run += make_no_libunwind
Jiri Olsa9e8c06e2014-02-19 16:52:59 +010073run += make_no_libdw_dwarf_unwind
Jiri Olsa095ae692013-03-29 16:11:02 +010074run += make_no_backtrace
75run += make_no_libnuma
76run += make_no_libaudit
77run += make_no_libbionic
Adrian Huntere31f0d02015-04-30 17:37:27 +030078run += make_no_auxtrace
Jiri Olsa095ae692013-03-29 16:11:02 +010079run += make_help
80run += make_doc
81run += make_perf_o
82run += make_util_map_o
Jiri Olsa2a94f6c2014-02-19 11:21:39 +010083run += make_util_pmu_bison_o
Jiri Olsac0ec1102013-07-22 14:43:33 +020084run += make_install
85run += make_install_bin
Jiri Olsadbad4182013-07-22 14:43:34 +020086# FIXME 'install-*' commented out till they're fixed
87# run += make_install_doc
88# run += make_install_man
89# run += make_install_html
90# run += make_install_info
91# run += make_install_pdf
Jiri Olsa095ae692013-03-29 16:11:02 +010092run += make_minimal
Jiri Olsa611ec122014-04-29 09:53:40 +020093run += make_static
Jiri Olsa095ae692013-03-29 16:11:02 +010094
Jiri Olsa0659e662013-07-22 14:43:30 +020095ifneq ($(call has,ctags),)
96run += make_tags
97endif
98ifneq ($(call has,cscope),)
99run += make_cscope
100endif
101
Jiri Olsa095ae692013-03-29 16:11:02 +0100102# $(run_O) contains same portion of $(run) tests with '_O' attached
103# to distinguish O=... tests
104run_O := $(addsuffix _O,$(run))
105
106# disable some tests for O=...
107run_O := $(filter-out make_python_perf_so_O,$(run_O))
108
109# define test for each compile as 'test_NAME' variable
110# with the test itself as a value
111test_make_tags = test -f tags
112test_make_cscope = test -f cscope.out
113
114test_make_tags_O := $(test_make_tags)
115test_make_cscope_O := $(test_make_cscope)
116
117test_ok := true
118test_make_help := $(test_ok)
119test_make_doc := $(test_ok)
120test_make_help_O := $(test_ok)
121test_make_doc_O := $(test_ok)
122
123test_make_python_perf_so := test -f $(PERF)/python/perf.so
124
Jiri Olsa2a94f6c2014-02-19 11:21:39 +0100125test_make_perf_o := test -f $(PERF)/perf.o
126test_make_util_map_o := test -f $(PERF)/util/map.o
127test_make_util_pmu_bison_o := test -f $(PERF)/util/pmu-bison.o
Jiri Olsa095ae692013-03-29 16:11:02 +0100128
Jiri Olsaee4ad932013-12-19 14:41:59 +0100129define test_dest_files
130 for file in $(1); do \
131 if [ ! -x $$TMP_DEST/$$file ]; then \
132 echo " failed to find: $$file"; \
133 fi \
134 done
135endef
136
137installed_files_bin := bin/perf
138installed_files_bin += etc/bash_completion.d/perf
139installed_files_bin += libexec/perf-core/perf-archive
140
Jiri Olsaf7c64472014-01-03 15:32:33 +0100141installed_files_plugins := $(lib)/traceevent/plugins/plugin_cfg80211.so
142installed_files_plugins += $(lib)/traceevent/plugins/plugin_scsi.so
143installed_files_plugins += $(lib)/traceevent/plugins/plugin_xen.so
144installed_files_plugins += $(lib)/traceevent/plugins/plugin_function.so
145installed_files_plugins += $(lib)/traceevent/plugins/plugin_sched_switch.so
146installed_files_plugins += $(lib)/traceevent/plugins/plugin_mac80211.so
147installed_files_plugins += $(lib)/traceevent/plugins/plugin_kvm.so
148installed_files_plugins += $(lib)/traceevent/plugins/plugin_kmem.so
149installed_files_plugins += $(lib)/traceevent/plugins/plugin_hrtimer.so
150installed_files_plugins += $(lib)/traceevent/plugins/plugin_jbd2.so
Jiri Olsaee4ad932013-12-19 14:41:59 +0100151
152installed_files_all := $(installed_files_bin)
153installed_files_all += $(installed_files_plugins)
154
155test_make_install := $(call test_dest_files,$(installed_files_all))
156test_make_install_O := $(call test_dest_files,$(installed_files_all))
157test_make_install_bin := $(call test_dest_files,$(installed_files_bin))
158test_make_install_bin_O := $(call test_dest_files,$(installed_files_bin))
Jiri Olsac0ec1102013-07-22 14:43:33 +0200159
Jiri Olsadbad4182013-07-22 14:43:34 +0200160# FIXME nothing gets installed
161test_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1
162test_make_install_man_O := $(test_make_install_man)
163
164# FIXME nothing gets installed
165test_make_install_doc := $(test_ok)
166test_make_install_doc_O := $(test_ok)
167
168# FIXME nothing gets installed
169test_make_install_html := $(test_ok)
170test_make_install_html_O := $(test_ok)
171
172# FIXME nothing gets installed
173test_make_install_info := $(test_ok)
174test_make_install_info_O := $(test_ok)
175
176# FIXME nothing gets installed
177test_make_install_pdf := $(test_ok)
178test_make_install_pdf_O := $(test_ok)
179
Jiri Olsa04b01a12014-02-19 11:21:38 +0100180test_make_python_perf_so_O := test -f $$TMP_O/python/perf.so
181test_make_perf_o_O := test -f $$TMP_O/perf.o
182test_make_util_map_o_O := test -f $$TMP_O/util/map.o
Jiri Olsa2a94f6c2014-02-19 11:21:39 +0100183test_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o
Jiri Olsa095ae692013-03-29 16:11:02 +0100184
185test_default = test -x $(PERF)/perf
186test = $(if $(test_$1),$(test_$1),$(test_default))
187
Jiri Olsa8ba7cde2013-07-22 14:43:31 +0200188test_default_O = test -x $$TMP_O/perf
Jiri Olsa095ae692013-03-29 16:11:02 +0100189test_O = $(if $(test_$1),$(test_$1),$(test_default_O))
190
191all:
192
193ifdef DEBUG
194d := $(info run $(run))
195d := $(info run_O $(run_O))
196endif
197
198MAKEFLAGS := --no-print-directory
199
200clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
201
202$(run):
203 $(call clean)
Jiri Olsac9311672013-07-22 14:43:32 +0200204 @TMP_DEST=$$(mktemp -d); \
205 cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100206 echo "- $@: $$cmd" && echo $$cmd > $@ && \
207 ( eval $$cmd ) >> $@ 2>&1; \
Jiri Olsaee4ad932013-12-19 14:41:59 +0100208 echo " test: $(call test,$@)" >> $@ 2>&1; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100209 $(call test,$@) && \
Arnaldo Carvalho de Meloa5c50092014-06-05 17:15:47 -0300210 rm -rf $@ $$TMP_DEST || (cat $@ ; false)
Jiri Olsa095ae692013-03-29 16:11:02 +0100211
212$(run_O):
213 $(call clean)
Jiri Olsa8ba7cde2013-07-22 14:43:31 +0200214 @TMP_O=$$(mktemp -d); \
Jiri Olsac9311672013-07-22 14:43:32 +0200215 TMP_DEST=$$(mktemp -d); \
216 cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100217 echo "- $@: $$cmd" && echo $$cmd > $@ && \
218 ( eval $$cmd ) >> $@ 2>&1 && \
Jiri Olsaee4ad932013-12-19 14:41:59 +0100219 echo " test: $(call test_O,$@)" >> $@ 2>&1; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100220 $(call test_O,$@) && \
Arnaldo Carvalho de Meloa5c50092014-06-05 17:15:47 -0300221 rm -rf $@ $$TMP_O $$TMP_DEST || (cat $@ ; false)
Jiri Olsa095ae692013-03-29 16:11:02 +0100222
Arnaldo Carvalho de Melo48878052014-01-10 16:46:45 -0300223tarpkg:
224 @cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \
225 echo "- $@: $$cmd" && echo $$cmd > $@ && \
226 ( eval $$cmd ) >> $@ 2>&1
Arnaldo Carvalho de Melo48878052014-01-10 16:46:45 -0300227
Jiri Olsac41c6642015-04-18 22:34:40 +0200228make_kernelsrc:
229 @echo " - make -C <kernelsrc> tools/perf"
230 $(call clean); \
231 (make -C ../.. tools/perf) > $@ 2>&1 && \
232 test -x perf && rm -f $@ || (cat $@ ; false)
233
234make_kernelsrc_tools:
235 @echo " - make -C <kernelsrc>/tools perf"
236 $(call clean); \
237 (make -C ../../tools perf) > $@ 2>&1 && \
238 test -x perf && rm -f $@ || (cat $@ ; false)
239
240all: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools
Jiri Olsa095ae692013-03-29 16:11:02 +0100241 @echo OK
242
243out: $(run_O)
244 @echo OK
245
Arnaldo Carvalho de Melo48878052014-01-10 16:46:45 -0300246.PHONY: all $(run) $(run_O) tarpkg clean