xref: /openbmc/linux/tools/perf/tests/make (revision c15e758c4bd7fbe38983e36258541ffcf81e1500)
1935e6bd3SWang Naninclude ../scripts/Makefile.include
2935e6bd3SWang Nan
3502819c5SJiri Olsaifndef MK
4502819c5SJiri Olsaifeq ($(MAKECMDGOALS),)
5502819c5SJiri Olsa# no target specified, trigger the whole suite
6502819c5SJiri Olsaall:
7502819c5SJiri Olsa	@echo "Testing Makefile";      $(MAKE) -sf tests/make MK=Makefile
8eb807730SWang Nan	@echo "Testing Makefile.perf"; $(MAKE) -sf tests/make MK=Makefile.perf SET_PARALLEL=1 SET_O=1
9502819c5SJiri Olsaelse
10502819c5SJiri Olsa# run only specific test over 'Makefile'
11502819c5SJiri Olsa%:
12502819c5SJiri Olsa	@echo "Testing Makefile";      $(MAKE) -sf tests/make MK=Makefile $@
13502819c5SJiri Olsaendif
14502819c5SJiri Olsaelse
15095ae69bSJiri OlsaPERF := .
1668824de1SWang NanPERF_O := $(PERF)
17eb807730SWang NanO_OPT :=
18eb807730SWang Nan
19eb807730SWang Nanifneq ($(O),)
20eb807730SWang Nan  FULL_O := $(shell readlink -f $(O) || echo $(O))
2168824de1SWang Nan  PERF_O := $(FULL_O)
22eb807730SWang Nan  ifeq ($(SET_O),1)
23eb807730SWang Nan    O_OPT := 'O=$(FULL_O)'
24eb807730SWang Nan  endif
25*c15e758cSWang Nan  K_O_OPT := 'O=$(FULL_O)'
26eb807730SWang Nanendif
27095ae69bSJiri Olsa
287be43dfbSWang NanPARALLEL_OPT=
297be43dfbSWang Nanifeq ($(SET_PARALLEL),1)
307be43dfbSWang Nan  cores := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
317be43dfbSWang Nan  ifeq ($(cores),0)
327be43dfbSWang Nan    cores := 1
337be43dfbSWang Nan  endif
347be43dfbSWang Nan  PARALLEL_OPT="-j$(cores)"
357be43dfbSWang Nanendif
367be43dfbSWang Nan
37935e6bd3SWang Nan# As per kernel Makefile, avoid funny character set dependencies
38935e6bd3SWang Nanunexport LC_ALL
39935e6bd3SWang NanLC_COLLATE=C
40935e6bd3SWang NanLC_NUMERIC=C
41935e6bd3SWang Nanexport LC_COLLATE LC_NUMERIC
42935e6bd3SWang Nan
43935e6bd3SWang Nanifeq ($(srctree),)
44935e6bd3SWang Nansrctree := $(patsubst %/,%,$(dir $(shell pwd)))
45935e6bd3SWang Nansrctree := $(patsubst %/,%,$(dir $(srctree)))
46935e6bd3SWang Nan#$(info Determined 'srctree' to be $(srctree))
47935e6bd3SWang Nanendif
48935e6bd3SWang Nan
49935e6bd3SWang Naninclude $(srctree)/tools/scripts/Makefile.arch
50f7c64474SJiri Olsa
51f7c64474SJiri Olsa# FIXME looks like x86 is the only arch running tests ;-)
52f7c64474SJiri Olsa# we need some IS_(32/64) flag to make this generic
5376aea773SH.J. Luifeq ($(ARCH)$(IS_64_BIT), x861)
54f7c64474SJiri Olsalib = lib64
55f7c64474SJiri Olsaelse
56f7c64474SJiri Olsalib = lib
57f7c64474SJiri Olsaendif
58f7c64474SJiri Olsa
590659e669SJiri Olsahas = $(shell which $1 2>/dev/null)
600659e669SJiri Olsa
61095ae69bSJiri Olsa# standard single make variable specified
62095ae69bSJiri Olsamake_clean_all      := clean all
63095ae69bSJiri Olsamake_python_perf_so := python/perf.so
64095ae69bSJiri Olsamake_debug          := DEBUG=1
65095ae69bSJiri Olsamake_no_libperl     := NO_LIBPERL=1
66095ae69bSJiri Olsamake_no_libpython   := NO_LIBPYTHON=1
67095ae69bSJiri Olsamake_no_scripts     := NO_LIBPYTHON=1 NO_LIBPERL=1
68095ae69bSJiri Olsamake_no_newt        := NO_NEWT=1
69095ae69bSJiri Olsamake_no_slang       := NO_SLANG=1
70095ae69bSJiri Olsamake_no_gtk2        := NO_GTK2=1
71095ae69bSJiri Olsamake_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
72095ae69bSJiri Olsamake_no_demangle    := NO_DEMANGLE=1
73095ae69bSJiri Olsamake_no_libelf      := NO_LIBELF=1
74095ae69bSJiri Olsamake_no_libunwind   := NO_LIBUNWIND=1
759e8c06eaSJiri Olsamake_no_libdw_dwarf_unwind := NO_LIBDW_DWARF_UNWIND=1
76095ae69bSJiri Olsamake_no_backtrace   := NO_BACKTRACE=1
77095ae69bSJiri Olsamake_no_libnuma     := NO_LIBNUMA=1
78095ae69bSJiri Olsamake_no_libaudit    := NO_LIBAUDIT=1
79095ae69bSJiri Olsamake_no_libbionic   := NO_LIBBIONIC=1
80e31f0d01SAdrian Huntermake_no_auxtrace    := NO_AUXTRACE=1
81ed63f34cSWang Nanmake_no_libbpf	    := NO_LIBBPF=1
82095ae69bSJiri Olsamake_tags           := tags
83095ae69bSJiri Olsamake_cscope         := cscope
84095ae69bSJiri Olsamake_help           := help
85095ae69bSJiri Olsamake_doc            := doc
86095ae69bSJiri Olsamake_perf_o           := perf.o
87095ae69bSJiri Olsamake_util_map_o       := util/map.o
882a94f6c4SJiri Olsamake_util_pmu_bison_o := util/pmu-bison.o
89c0ec1108SJiri Olsamake_install        := install
90c0ec1108SJiri Olsamake_install_bin    := install-bin
91dbad4189SJiri Olsamake_install_doc    := install-doc
92dbad4189SJiri Olsamake_install_man    := install-man
93dbad4189SJiri Olsamake_install_html   := install-html
94dbad4189SJiri Olsamake_install_info   := install-info
95dbad4189SJiri Olsamake_install_pdf    := install-pdf
96eb30d2c5SJiri Olsamake_install_prefix       := install prefix=/tmp/krava
97aa53c09eSJiri Olsamake_install_prefix_slash := install prefix=/tmp/krava/
98611ec127SJiri Olsamake_static         := LDFLAGS=-static
99095ae69bSJiri Olsa
100095ae69bSJiri Olsa# all the NO_* variable combined
101095ae69bSJiri Olsamake_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
102095ae69bSJiri Olsamake_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
103095ae69bSJiri Olsamake_minimal        += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
104ed63f34cSWang Nanmake_minimal        += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
105095ae69bSJiri Olsa
106095ae69bSJiri Olsa# $(run) contains all available tests
107095ae69bSJiri Olsarun := make_pure
108502819c5SJiri Olsa# Targets 'clean all' can be run together only through top level
109502819c5SJiri Olsa# Makefile because we detect clean target in Makefile.perf and
110502819c5SJiri Olsa# disable features detection
111502819c5SJiri Olsaifeq ($(MK),Makefile)
112095ae69bSJiri Olsarun += make_clean_all
113502819c5SJiri Olsaendif
114095ae69bSJiri Olsarun += make_python_perf_so
115095ae69bSJiri Olsarun += make_debug
116095ae69bSJiri Olsarun += make_no_libperl
117095ae69bSJiri Olsarun += make_no_libpython
118095ae69bSJiri Olsarun += make_no_scripts
119095ae69bSJiri Olsarun += make_no_newt
120095ae69bSJiri Olsarun += make_no_slang
121095ae69bSJiri Olsarun += make_no_gtk2
122095ae69bSJiri Olsarun += make_no_ui
123095ae69bSJiri Olsarun += make_no_demangle
124095ae69bSJiri Olsarun += make_no_libelf
125095ae69bSJiri Olsarun += make_no_libunwind
1269e8c06eaSJiri Olsarun += make_no_libdw_dwarf_unwind
127095ae69bSJiri Olsarun += make_no_backtrace
128095ae69bSJiri Olsarun += make_no_libnuma
129095ae69bSJiri Olsarun += make_no_libaudit
130095ae69bSJiri Olsarun += make_no_libbionic
131e31f0d01SAdrian Hunterrun += make_no_auxtrace
132ed63f34cSWang Nanrun += make_no_libbpf
133095ae69bSJiri Olsarun += make_help
134095ae69bSJiri Olsarun += make_doc
135095ae69bSJiri Olsarun += make_perf_o
136095ae69bSJiri Olsarun += make_util_map_o
1372a94f6c4SJiri Olsarun += make_util_pmu_bison_o
138c0ec1108SJiri Olsarun += make_install
139c0ec1108SJiri Olsarun += make_install_bin
140eb30d2c5SJiri Olsarun += make_install_prefix
141aa53c09eSJiri Olsarun += make_install_prefix_slash
142dbad4189SJiri Olsa# FIXME 'install-*' commented out till they're fixed
143dbad4189SJiri Olsa# run += make_install_doc
144dbad4189SJiri Olsa# run += make_install_man
145dbad4189SJiri Olsa# run += make_install_html
146dbad4189SJiri Olsa# run += make_install_info
147dbad4189SJiri Olsa# run += make_install_pdf
148095ae69bSJiri Olsarun += make_minimal
149611ec127SJiri Olsarun += make_static
150095ae69bSJiri Olsa
1510659e669SJiri Olsaifneq ($(call has,ctags),)
1520659e669SJiri Olsarun += make_tags
1530659e669SJiri Olsaendif
1540659e669SJiri Olsaifneq ($(call has,cscope),)
1550659e669SJiri Olsarun += make_cscope
1560659e669SJiri Olsaendif
1570659e669SJiri Olsa
158095ae69bSJiri Olsa# $(run_O) contains same portion of $(run) tests with '_O' attached
159095ae69bSJiri Olsa# to distinguish O=... tests
160095ae69bSJiri Olsarun_O := $(addsuffix _O,$(run))
161095ae69bSJiri Olsa
162095ae69bSJiri Olsa# disable some tests for O=...
163095ae69bSJiri Olsarun_O := $(filter-out make_python_perf_so_O,$(run_O))
164095ae69bSJiri Olsa
165095ae69bSJiri Olsa# define test for each compile as 'test_NAME' variable
166095ae69bSJiri Olsa# with the test itself as a value
167095ae69bSJiri Olsatest_make_tags   = test -f tags
168095ae69bSJiri Olsatest_make_cscope = test -f cscope.out
169095ae69bSJiri Olsa
170095ae69bSJiri Olsatest_make_tags_O   := $(test_make_tags)
171095ae69bSJiri Olsatest_make_cscope_O := $(test_make_cscope)
172095ae69bSJiri Olsa
173095ae69bSJiri Olsatest_ok          := true
174095ae69bSJiri Olsatest_make_help   := $(test_ok)
175095ae69bSJiri Olsatest_make_doc    := $(test_ok)
176095ae69bSJiri Olsatest_make_help_O := $(test_ok)
177095ae69bSJiri Olsatest_make_doc_O  := $(test_ok)
178095ae69bSJiri Olsa
17968824de1SWang Nantest_make_python_perf_so := test -f $(PERF_O)/python/perf.so
180095ae69bSJiri Olsa
18168824de1SWang Nantest_make_perf_o           := test -f $(PERF_O)/perf.o
18268824de1SWang Nantest_make_util_map_o       := test -f $(PERF_O)/util/map.o
18368824de1SWang Nantest_make_util_pmu_bison_o := test -f $(PERF_O)/util/pmu-bison.o
184095ae69bSJiri Olsa
185ee4ad93eSJiri Olsadefine test_dest_files
186ee4ad93eSJiri Olsa  for file in $(1); do				\
187ee4ad93eSJiri Olsa    if [ ! -x $$TMP_DEST/$$file ]; then		\
188ee4ad93eSJiri Olsa      echo "  failed to find: $$file";		\
189ee4ad93eSJiri Olsa    fi						\
190ee4ad93eSJiri Olsa  done
191ee4ad93eSJiri Olsaendef
192ee4ad93eSJiri Olsa
193ee4ad93eSJiri Olsainstalled_files_bin := bin/perf
194ee4ad93eSJiri Olsainstalled_files_bin += etc/bash_completion.d/perf
195ee4ad93eSJiri Olsainstalled_files_bin += libexec/perf-core/perf-archive
196ee4ad93eSJiri Olsa
197f7c64474SJiri Olsainstalled_files_plugins := $(lib)/traceevent/plugins/plugin_cfg80211.so
198f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_scsi.so
199f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_xen.so
200f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_function.so
201f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_sched_switch.so
202f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_mac80211.so
203f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_kvm.so
204f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_kmem.so
205f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_hrtimer.so
206f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_jbd2.so
207ee4ad93eSJiri Olsa
208ee4ad93eSJiri Olsainstalled_files_all := $(installed_files_bin)
209ee4ad93eSJiri Olsainstalled_files_all += $(installed_files_plugins)
210ee4ad93eSJiri Olsa
211ee4ad93eSJiri Olsatest_make_install       := $(call test_dest_files,$(installed_files_all))
212ee4ad93eSJiri Olsatest_make_install_O     := $(call test_dest_files,$(installed_files_all))
213ee4ad93eSJiri Olsatest_make_install_bin   := $(call test_dest_files,$(installed_files_bin))
214ee4ad93eSJiri Olsatest_make_install_bin_O := $(call test_dest_files,$(installed_files_bin))
215c0ec1108SJiri Olsa
216aa53c09eSJiri Olsa# We prefix all installed files for make_install_prefix(_slash)
217eb30d2c5SJiri Olsa# with '/tmp/krava' to match installed/prefix-ed files.
218eb30d2c5SJiri Olsainstalled_files_all_prefix := $(addprefix /tmp/krava/,$(installed_files_all))
219eb30d2c5SJiri Olsatest_make_install_prefix   :=  $(call test_dest_files,$(installed_files_all_prefix))
220eb30d2c5SJiri Olsatest_make_install_prefix_O :=  $(call test_dest_files,$(installed_files_all_prefix))
221eb30d2c5SJiri Olsa
222aa53c09eSJiri Olsatest_make_install_prefix_slash   := $(test_make_install_prefix)
223aa53c09eSJiri Olsatest_make_install_prefix_slash_O := $(test_make_install_prefix_O)
224aa53c09eSJiri Olsa
225dbad4189SJiri Olsa# FIXME nothing gets installed
226dbad4189SJiri Olsatest_make_install_man    := test -f $$TMP_DEST/share/man/man1/perf.1
227dbad4189SJiri Olsatest_make_install_man_O  := $(test_make_install_man)
228dbad4189SJiri Olsa
229dbad4189SJiri Olsa# FIXME nothing gets installed
230dbad4189SJiri Olsatest_make_install_doc    := $(test_ok)
231dbad4189SJiri Olsatest_make_install_doc_O  := $(test_ok)
232dbad4189SJiri Olsa
233dbad4189SJiri Olsa# FIXME nothing gets installed
234dbad4189SJiri Olsatest_make_install_html   := $(test_ok)
235dbad4189SJiri Olsatest_make_install_html_O := $(test_ok)
236dbad4189SJiri Olsa
237dbad4189SJiri Olsa# FIXME nothing gets installed
238dbad4189SJiri Olsatest_make_install_info   := $(test_ok)
239dbad4189SJiri Olsatest_make_install_info_O := $(test_ok)
240dbad4189SJiri Olsa
241dbad4189SJiri Olsa# FIXME nothing gets installed
242dbad4189SJiri Olsatest_make_install_pdf    := $(test_ok)
243dbad4189SJiri Olsatest_make_install_pdf_O  := $(test_ok)
244dbad4189SJiri Olsa
24504b01a1dSJiri Olsatest_make_python_perf_so_O    := test -f $$TMP_O/python/perf.so
24604b01a1dSJiri Olsatest_make_perf_o_O            := test -f $$TMP_O/perf.o
24704b01a1dSJiri Olsatest_make_util_map_o_O        := test -f $$TMP_O/util/map.o
2482a94f6c4SJiri Olsatest_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o
249095ae69bSJiri Olsa
25068824de1SWang Nantest_default = test -x $(PERF_O)/perf
251095ae69bSJiri Olsatest = $(if $(test_$1),$(test_$1),$(test_default))
252095ae69bSJiri Olsa
2538ba7cdeaSJiri Olsatest_default_O = test -x $$TMP_O/perf
254095ae69bSJiri Olsatest_O = $(if $(test_$1),$(test_$1),$(test_default_O))
255095ae69bSJiri Olsa
256095ae69bSJiri Olsaall:
257095ae69bSJiri Olsa
25898916392SArnaldo Carvalho de Meloifdef SHUF
25998916392SArnaldo Carvalho de Melorun := $(shell shuf -e $(run))
26098916392SArnaldo Carvalho de Melorun_O := $(shell shuf -e $(run_O))
26198916392SArnaldo Carvalho de Meloendif
26298916392SArnaldo Carvalho de Melo
263095ae69bSJiri Olsaifdef DEBUG
264095ae69bSJiri Olsad := $(info run   $(run))
265095ae69bSJiri Olsad := $(info run_O $(run_O))
266095ae69bSJiri Olsaendif
267095ae69bSJiri Olsa
268095ae69bSJiri OlsaMAKEFLAGS := --no-print-directory
269095ae69bSJiri Olsa
270eb807730SWang Nanclean := @(cd $(PERF); make -s -f $(MK) $(O_OPT) clean >/dev/null)
271095ae69bSJiri Olsa
272095ae69bSJiri Olsa$(run):
273095ae69bSJiri Olsa	$(call clean)
274c9311674SJiri Olsa	@TMP_DEST=$$(mktemp -d); \
275eb807730SWang Nan	cmd="cd $(PERF) && make -f $(MK) $(PARALLEL_OPT) $(O_OPT) DESTDIR=$$TMP_DEST $($@)"; \
276095ae69bSJiri Olsa	echo "- $@: $$cmd" && echo $$cmd > $@ && \
277095ae69bSJiri Olsa	( eval $$cmd ) >> $@ 2>&1; \
278ee4ad93eSJiri Olsa	echo "  test: $(call test,$@)" >> $@ 2>&1; \
279095ae69bSJiri Olsa	$(call test,$@) && \
280a5c5009fSArnaldo Carvalho de Melo	rm -rf $@ $$TMP_DEST || (cat $@ ; false)
281095ae69bSJiri Olsa
282095ae69bSJiri Olsa$(run_O):
283095ae69bSJiri Olsa	$(call clean)
2848ba7cdeaSJiri Olsa	@TMP_O=$$(mktemp -d); \
285c9311674SJiri Olsa	TMP_DEST=$$(mktemp -d); \
2867be43dfbSWang Nan	cmd="cd $(PERF) && make -f $(MK) $(PARALLEL_OPT) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \
287095ae69bSJiri Olsa	echo "- $@: $$cmd" && echo $$cmd > $@ && \
288095ae69bSJiri Olsa	( eval $$cmd ) >> $@ 2>&1 && \
289ee4ad93eSJiri Olsa	echo "  test: $(call test_O,$@)" >> $@ 2>&1; \
290095ae69bSJiri Olsa	$(call test_O,$@) && \
291a5c5009fSArnaldo Carvalho de Melo	rm -rf $@ $$TMP_O $$TMP_DEST || (cat $@ ; false)
292095ae69bSJiri Olsa
29348878053SArnaldo Carvalho de Melotarpkg:
29448878053SArnaldo Carvalho de Melo	@cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \
29548878053SArnaldo Carvalho de Melo	echo "- $@: $$cmd" && echo $$cmd > $@ && \
296004bd89dSJosh Poimboeuf	( eval $$cmd ) >> $@ 2>&1 && \
297004bd89dSJosh Poimboeuf	rm -f $@
29848878053SArnaldo Carvalho de Melo
29968824de1SWang NanKERNEL_O := ../..
30068824de1SWang Nanifneq ($(O),)
30168824de1SWang Nan  KERNEL_O := $(O)
30268824de1SWang Nanendif
30368824de1SWang Nan
304c41c6647SJiri Olsamake_kernelsrc:
305*c15e758cSWang Nan	@echo "- make -C <kernelsrc> $(PARALLEL_OPT) $(K_O_OPT) tools/perf"
306c41c6647SJiri Olsa	$(call clean); \
307*c15e758cSWang Nan	(make -C ../.. $(PARALLEL_OPT) $(K_O_OPT) tools/perf) > $@ 2>&1 && \
30868824de1SWang Nan	test -x $(KERNEL_O)/tools/perf/perf && rm -f $@ || (cat $@ ; false)
309c41c6647SJiri Olsa
310c41c6647SJiri Olsamake_kernelsrc_tools:
311*c15e758cSWang Nan	@echo "- make -C <kernelsrc>/tools $(PARALLEL_OPT) $(K_O_OPT) perf"
312c41c6647SJiri Olsa	$(call clean); \
313*c15e758cSWang Nan	(make -C ../../tools $(PARALLEL_OPT) $(K_O_OPT) perf) > $@ 2>&1 && \
31468824de1SWang Nan	test -x $(KERNEL_O)/tools/perf/perf && rm -f $@ || (cat $@ ; false)
315c41c6647SJiri Olsa
316c41c6647SJiri Olsaall: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools
317095ae69bSJiri Olsa	@echo OK
318095ae69bSJiri Olsa
319095ae69bSJiri Olsaout: $(run_O)
320095ae69bSJiri Olsa	@echo OK
321095ae69bSJiri Olsa
3223167eea2SWang Nan.PHONY: all $(run) $(run_O) tarpkg clean make_kernelsrc make_kernelsrc_tools
323502819c5SJiri Olsaendif # ifndef MK
324