xref: /linux/tools/perf/tests/make (revision eb807730c034090599135bc03578015ebf8974af)
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
8*eb807730SWang 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 := .
16*eb807730SWang NanO_OPT :=
17*eb807730SWang Nan
18*eb807730SWang Nanifneq ($(O),)
19*eb807730SWang Nan  FULL_O := $(shell readlink -f $(O) || echo $(O))
20*eb807730SWang Nan  ifeq ($(SET_O),1)
21*eb807730SWang Nan    O_OPT := 'O=$(FULL_O)'
22*eb807730SWang Nan  endif
23*eb807730SWang Nanendif
24095ae69bSJiri Olsa
257be43dfbSWang NanPARALLEL_OPT=
267be43dfbSWang Nanifeq ($(SET_PARALLEL),1)
277be43dfbSWang Nan  cores := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
287be43dfbSWang Nan  ifeq ($(cores),0)
297be43dfbSWang Nan    cores := 1
307be43dfbSWang Nan  endif
317be43dfbSWang Nan  PARALLEL_OPT="-j$(cores)"
327be43dfbSWang Nanendif
337be43dfbSWang Nan
34935e6bd3SWang Nan# As per kernel Makefile, avoid funny character set dependencies
35935e6bd3SWang Nanunexport LC_ALL
36935e6bd3SWang NanLC_COLLATE=C
37935e6bd3SWang NanLC_NUMERIC=C
38935e6bd3SWang Nanexport LC_COLLATE LC_NUMERIC
39935e6bd3SWang Nan
40935e6bd3SWang Nanifeq ($(srctree),)
41935e6bd3SWang Nansrctree := $(patsubst %/,%,$(dir $(shell pwd)))
42935e6bd3SWang Nansrctree := $(patsubst %/,%,$(dir $(srctree)))
43935e6bd3SWang Nan#$(info Determined 'srctree' to be $(srctree))
44935e6bd3SWang Nanendif
45935e6bd3SWang Nan
46935e6bd3SWang Naninclude $(srctree)/tools/scripts/Makefile.arch
47f7c64474SJiri Olsa
48f7c64474SJiri Olsa# FIXME looks like x86 is the only arch running tests ;-)
49f7c64474SJiri Olsa# we need some IS_(32/64) flag to make this generic
5076aea773SH.J. Luifeq ($(ARCH)$(IS_64_BIT), x861)
51f7c64474SJiri Olsalib = lib64
52f7c64474SJiri Olsaelse
53f7c64474SJiri Olsalib = lib
54f7c64474SJiri Olsaendif
55f7c64474SJiri Olsa
560659e669SJiri Olsahas = $(shell which $1 2>/dev/null)
570659e669SJiri Olsa
58095ae69bSJiri Olsa# standard single make variable specified
59095ae69bSJiri Olsamake_clean_all      := clean all
60095ae69bSJiri Olsamake_python_perf_so := python/perf.so
61095ae69bSJiri Olsamake_debug          := DEBUG=1
62095ae69bSJiri Olsamake_no_libperl     := NO_LIBPERL=1
63095ae69bSJiri Olsamake_no_libpython   := NO_LIBPYTHON=1
64095ae69bSJiri Olsamake_no_scripts     := NO_LIBPYTHON=1 NO_LIBPERL=1
65095ae69bSJiri Olsamake_no_newt        := NO_NEWT=1
66095ae69bSJiri Olsamake_no_slang       := NO_SLANG=1
67095ae69bSJiri Olsamake_no_gtk2        := NO_GTK2=1
68095ae69bSJiri Olsamake_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
69095ae69bSJiri Olsamake_no_demangle    := NO_DEMANGLE=1
70095ae69bSJiri Olsamake_no_libelf      := NO_LIBELF=1
71095ae69bSJiri Olsamake_no_libunwind   := NO_LIBUNWIND=1
729e8c06eaSJiri Olsamake_no_libdw_dwarf_unwind := NO_LIBDW_DWARF_UNWIND=1
73095ae69bSJiri Olsamake_no_backtrace   := NO_BACKTRACE=1
74095ae69bSJiri Olsamake_no_libnuma     := NO_LIBNUMA=1
75095ae69bSJiri Olsamake_no_libaudit    := NO_LIBAUDIT=1
76095ae69bSJiri Olsamake_no_libbionic   := NO_LIBBIONIC=1
77e31f0d01SAdrian Huntermake_no_auxtrace    := NO_AUXTRACE=1
78ed63f34cSWang Nanmake_no_libbpf	    := NO_LIBBPF=1
79095ae69bSJiri Olsamake_tags           := tags
80095ae69bSJiri Olsamake_cscope         := cscope
81095ae69bSJiri Olsamake_help           := help
82095ae69bSJiri Olsamake_doc            := doc
83095ae69bSJiri Olsamake_perf_o           := perf.o
84095ae69bSJiri Olsamake_util_map_o       := util/map.o
852a94f6c4SJiri Olsamake_util_pmu_bison_o := util/pmu-bison.o
86c0ec1108SJiri Olsamake_install        := install
87c0ec1108SJiri Olsamake_install_bin    := install-bin
88dbad4189SJiri Olsamake_install_doc    := install-doc
89dbad4189SJiri Olsamake_install_man    := install-man
90dbad4189SJiri Olsamake_install_html   := install-html
91dbad4189SJiri Olsamake_install_info   := install-info
92dbad4189SJiri Olsamake_install_pdf    := install-pdf
93eb30d2c5SJiri Olsamake_install_prefix       := install prefix=/tmp/krava
94aa53c09eSJiri Olsamake_install_prefix_slash := install prefix=/tmp/krava/
95611ec127SJiri Olsamake_static         := LDFLAGS=-static
96095ae69bSJiri Olsa
97095ae69bSJiri Olsa# all the NO_* variable combined
98095ae69bSJiri Olsamake_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
99095ae69bSJiri Olsamake_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
100095ae69bSJiri Olsamake_minimal        += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
101ed63f34cSWang Nanmake_minimal        += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
102095ae69bSJiri Olsa
103095ae69bSJiri Olsa# $(run) contains all available tests
104095ae69bSJiri Olsarun := make_pure
105502819c5SJiri Olsa# Targets 'clean all' can be run together only through top level
106502819c5SJiri Olsa# Makefile because we detect clean target in Makefile.perf and
107502819c5SJiri Olsa# disable features detection
108502819c5SJiri Olsaifeq ($(MK),Makefile)
109095ae69bSJiri Olsarun += make_clean_all
110502819c5SJiri Olsaendif
111095ae69bSJiri Olsarun += make_python_perf_so
112095ae69bSJiri Olsarun += make_debug
113095ae69bSJiri Olsarun += make_no_libperl
114095ae69bSJiri Olsarun += make_no_libpython
115095ae69bSJiri Olsarun += make_no_scripts
116095ae69bSJiri Olsarun += make_no_newt
117095ae69bSJiri Olsarun += make_no_slang
118095ae69bSJiri Olsarun += make_no_gtk2
119095ae69bSJiri Olsarun += make_no_ui
120095ae69bSJiri Olsarun += make_no_demangle
121095ae69bSJiri Olsarun += make_no_libelf
122095ae69bSJiri Olsarun += make_no_libunwind
1239e8c06eaSJiri Olsarun += make_no_libdw_dwarf_unwind
124095ae69bSJiri Olsarun += make_no_backtrace
125095ae69bSJiri Olsarun += make_no_libnuma
126095ae69bSJiri Olsarun += make_no_libaudit
127095ae69bSJiri Olsarun += make_no_libbionic
128e31f0d01SAdrian Hunterrun += make_no_auxtrace
129ed63f34cSWang Nanrun += make_no_libbpf
130095ae69bSJiri Olsarun += make_help
131095ae69bSJiri Olsarun += make_doc
132095ae69bSJiri Olsarun += make_perf_o
133095ae69bSJiri Olsarun += make_util_map_o
1342a94f6c4SJiri Olsarun += make_util_pmu_bison_o
135c0ec1108SJiri Olsarun += make_install
136c0ec1108SJiri Olsarun += make_install_bin
137eb30d2c5SJiri Olsarun += make_install_prefix
138aa53c09eSJiri Olsarun += make_install_prefix_slash
139dbad4189SJiri Olsa# FIXME 'install-*' commented out till they're fixed
140dbad4189SJiri Olsa# run += make_install_doc
141dbad4189SJiri Olsa# run += make_install_man
142dbad4189SJiri Olsa# run += make_install_html
143dbad4189SJiri Olsa# run += make_install_info
144dbad4189SJiri Olsa# run += make_install_pdf
145095ae69bSJiri Olsarun += make_minimal
146611ec127SJiri Olsarun += make_static
147095ae69bSJiri Olsa
1480659e669SJiri Olsaifneq ($(call has,ctags),)
1490659e669SJiri Olsarun += make_tags
1500659e669SJiri Olsaendif
1510659e669SJiri Olsaifneq ($(call has,cscope),)
1520659e669SJiri Olsarun += make_cscope
1530659e669SJiri Olsaendif
1540659e669SJiri Olsa
155095ae69bSJiri Olsa# $(run_O) contains same portion of $(run) tests with '_O' attached
156095ae69bSJiri Olsa# to distinguish O=... tests
157095ae69bSJiri Olsarun_O := $(addsuffix _O,$(run))
158095ae69bSJiri Olsa
159095ae69bSJiri Olsa# disable some tests for O=...
160095ae69bSJiri Olsarun_O := $(filter-out make_python_perf_so_O,$(run_O))
161095ae69bSJiri Olsa
162095ae69bSJiri Olsa# define test for each compile as 'test_NAME' variable
163095ae69bSJiri Olsa# with the test itself as a value
164095ae69bSJiri Olsatest_make_tags   = test -f tags
165095ae69bSJiri Olsatest_make_cscope = test -f cscope.out
166095ae69bSJiri Olsa
167095ae69bSJiri Olsatest_make_tags_O   := $(test_make_tags)
168095ae69bSJiri Olsatest_make_cscope_O := $(test_make_cscope)
169095ae69bSJiri Olsa
170095ae69bSJiri Olsatest_ok          := true
171095ae69bSJiri Olsatest_make_help   := $(test_ok)
172095ae69bSJiri Olsatest_make_doc    := $(test_ok)
173095ae69bSJiri Olsatest_make_help_O := $(test_ok)
174095ae69bSJiri Olsatest_make_doc_O  := $(test_ok)
175095ae69bSJiri Olsa
176095ae69bSJiri Olsatest_make_python_perf_so := test -f $(PERF)/python/perf.so
177095ae69bSJiri Olsa
178095ae69bSJiri Olsatest_make_perf_o           := test -f $(PERF)/perf.o
179095ae69bSJiri Olsatest_make_util_map_o       := test -f $(PERF)/util/map.o
1802a94f6c4SJiri Olsatest_make_util_pmu_bison_o := test -f $(PERF)/util/pmu-bison.o
181095ae69bSJiri Olsa
182ee4ad93eSJiri Olsadefine test_dest_files
183ee4ad93eSJiri Olsa  for file in $(1); do				\
184ee4ad93eSJiri Olsa    if [ ! -x $$TMP_DEST/$$file ]; then		\
185ee4ad93eSJiri Olsa      echo "  failed to find: $$file";		\
186ee4ad93eSJiri Olsa    fi						\
187ee4ad93eSJiri Olsa  done
188ee4ad93eSJiri Olsaendef
189ee4ad93eSJiri Olsa
190ee4ad93eSJiri Olsainstalled_files_bin := bin/perf
191ee4ad93eSJiri Olsainstalled_files_bin += etc/bash_completion.d/perf
192ee4ad93eSJiri Olsainstalled_files_bin += libexec/perf-core/perf-archive
193ee4ad93eSJiri Olsa
194f7c64474SJiri Olsainstalled_files_plugins := $(lib)/traceevent/plugins/plugin_cfg80211.so
195f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_scsi.so
196f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_xen.so
197f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_function.so
198f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_sched_switch.so
199f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_mac80211.so
200f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_kvm.so
201f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_kmem.so
202f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_hrtimer.so
203f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_jbd2.so
204ee4ad93eSJiri Olsa
205ee4ad93eSJiri Olsainstalled_files_all := $(installed_files_bin)
206ee4ad93eSJiri Olsainstalled_files_all += $(installed_files_plugins)
207ee4ad93eSJiri Olsa
208ee4ad93eSJiri Olsatest_make_install       := $(call test_dest_files,$(installed_files_all))
209ee4ad93eSJiri Olsatest_make_install_O     := $(call test_dest_files,$(installed_files_all))
210ee4ad93eSJiri Olsatest_make_install_bin   := $(call test_dest_files,$(installed_files_bin))
211ee4ad93eSJiri Olsatest_make_install_bin_O := $(call test_dest_files,$(installed_files_bin))
212c0ec1108SJiri Olsa
213aa53c09eSJiri Olsa# We prefix all installed files for make_install_prefix(_slash)
214eb30d2c5SJiri Olsa# with '/tmp/krava' to match installed/prefix-ed files.
215eb30d2c5SJiri Olsainstalled_files_all_prefix := $(addprefix /tmp/krava/,$(installed_files_all))
216eb30d2c5SJiri Olsatest_make_install_prefix   :=  $(call test_dest_files,$(installed_files_all_prefix))
217eb30d2c5SJiri Olsatest_make_install_prefix_O :=  $(call test_dest_files,$(installed_files_all_prefix))
218eb30d2c5SJiri Olsa
219aa53c09eSJiri Olsatest_make_install_prefix_slash   := $(test_make_install_prefix)
220aa53c09eSJiri Olsatest_make_install_prefix_slash_O := $(test_make_install_prefix_O)
221aa53c09eSJiri Olsa
222dbad4189SJiri Olsa# FIXME nothing gets installed
223dbad4189SJiri Olsatest_make_install_man    := test -f $$TMP_DEST/share/man/man1/perf.1
224dbad4189SJiri Olsatest_make_install_man_O  := $(test_make_install_man)
225dbad4189SJiri Olsa
226dbad4189SJiri Olsa# FIXME nothing gets installed
227dbad4189SJiri Olsatest_make_install_doc    := $(test_ok)
228dbad4189SJiri Olsatest_make_install_doc_O  := $(test_ok)
229dbad4189SJiri Olsa
230dbad4189SJiri Olsa# FIXME nothing gets installed
231dbad4189SJiri Olsatest_make_install_html   := $(test_ok)
232dbad4189SJiri Olsatest_make_install_html_O := $(test_ok)
233dbad4189SJiri Olsa
234dbad4189SJiri Olsa# FIXME nothing gets installed
235dbad4189SJiri Olsatest_make_install_info   := $(test_ok)
236dbad4189SJiri Olsatest_make_install_info_O := $(test_ok)
237dbad4189SJiri Olsa
238dbad4189SJiri Olsa# FIXME nothing gets installed
239dbad4189SJiri Olsatest_make_install_pdf    := $(test_ok)
240dbad4189SJiri Olsatest_make_install_pdf_O  := $(test_ok)
241dbad4189SJiri Olsa
24204b01a1dSJiri Olsatest_make_python_perf_so_O    := test -f $$TMP_O/python/perf.so
24304b01a1dSJiri Olsatest_make_perf_o_O            := test -f $$TMP_O/perf.o
24404b01a1dSJiri Olsatest_make_util_map_o_O        := test -f $$TMP_O/util/map.o
2452a94f6c4SJiri Olsatest_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o
246095ae69bSJiri Olsa
247095ae69bSJiri Olsatest_default = test -x $(PERF)/perf
248095ae69bSJiri Olsatest = $(if $(test_$1),$(test_$1),$(test_default))
249095ae69bSJiri Olsa
2508ba7cdeaSJiri Olsatest_default_O = test -x $$TMP_O/perf
251095ae69bSJiri Olsatest_O = $(if $(test_$1),$(test_$1),$(test_default_O))
252095ae69bSJiri Olsa
253095ae69bSJiri Olsaall:
254095ae69bSJiri Olsa
25598916392SArnaldo Carvalho de Meloifdef SHUF
25698916392SArnaldo Carvalho de Melorun := $(shell shuf -e $(run))
25798916392SArnaldo Carvalho de Melorun_O := $(shell shuf -e $(run_O))
25898916392SArnaldo Carvalho de Meloendif
25998916392SArnaldo Carvalho de Melo
260095ae69bSJiri Olsaifdef DEBUG
261095ae69bSJiri Olsad := $(info run   $(run))
262095ae69bSJiri Olsad := $(info run_O $(run_O))
263095ae69bSJiri Olsaendif
264095ae69bSJiri Olsa
265095ae69bSJiri OlsaMAKEFLAGS := --no-print-directory
266095ae69bSJiri Olsa
267*eb807730SWang Nanclean := @(cd $(PERF); make -s -f $(MK) $(O_OPT) clean >/dev/null)
268095ae69bSJiri Olsa
269095ae69bSJiri Olsa$(run):
270095ae69bSJiri Olsa	$(call clean)
271c9311674SJiri Olsa	@TMP_DEST=$$(mktemp -d); \
272*eb807730SWang Nan	cmd="cd $(PERF) && make -f $(MK) $(PARALLEL_OPT) $(O_OPT) DESTDIR=$$TMP_DEST $($@)"; \
273095ae69bSJiri Olsa	echo "- $@: $$cmd" && echo $$cmd > $@ && \
274095ae69bSJiri Olsa	( eval $$cmd ) >> $@ 2>&1; \
275ee4ad93eSJiri Olsa	echo "  test: $(call test,$@)" >> $@ 2>&1; \
276095ae69bSJiri Olsa	$(call test,$@) && \
277a5c5009fSArnaldo Carvalho de Melo	rm -rf $@ $$TMP_DEST || (cat $@ ; false)
278095ae69bSJiri Olsa
279095ae69bSJiri Olsa$(run_O):
280095ae69bSJiri Olsa	$(call clean)
2818ba7cdeaSJiri Olsa	@TMP_O=$$(mktemp -d); \
282c9311674SJiri Olsa	TMP_DEST=$$(mktemp -d); \
2837be43dfbSWang Nan	cmd="cd $(PERF) && make -f $(MK) $(PARALLEL_OPT) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \
284095ae69bSJiri Olsa	echo "- $@: $$cmd" && echo $$cmd > $@ && \
285095ae69bSJiri Olsa	( eval $$cmd ) >> $@ 2>&1 && \
286ee4ad93eSJiri Olsa	echo "  test: $(call test_O,$@)" >> $@ 2>&1; \
287095ae69bSJiri Olsa	$(call test_O,$@) && \
288a5c5009fSArnaldo Carvalho de Melo	rm -rf $@ $$TMP_O $$TMP_DEST || (cat $@ ; false)
289095ae69bSJiri Olsa
29048878053SArnaldo Carvalho de Melotarpkg:
29148878053SArnaldo Carvalho de Melo	@cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \
29248878053SArnaldo Carvalho de Melo	echo "- $@: $$cmd" && echo $$cmd > $@ && \
293004bd89dSJosh Poimboeuf	( eval $$cmd ) >> $@ 2>&1 && \
294004bd89dSJosh Poimboeuf	rm -f $@
29548878053SArnaldo Carvalho de Melo
296c41c6647SJiri Olsamake_kernelsrc:
2977be43dfbSWang Nan	@echo "- make -C <kernelsrc> $(PARALLEL_OPT) tools/perf"
298c41c6647SJiri Olsa	$(call clean); \
2997be43dfbSWang Nan	(make -C ../.. $(PARALLEL_OPT) tools/perf) > $@ 2>&1 && \
300c41c6647SJiri Olsa	test -x perf && rm -f $@ || (cat $@ ; false)
301c41c6647SJiri Olsa
302c41c6647SJiri Olsamake_kernelsrc_tools:
3037be43dfbSWang Nan	@echo "- make -C <kernelsrc>/tools $(PARALLEL_OPT) perf"
304c41c6647SJiri Olsa	$(call clean); \
3057be43dfbSWang Nan	(make -C ../../tools $(PARALLEL_OPT) perf) > $@ 2>&1 && \
306c41c6647SJiri Olsa	test -x perf && rm -f $@ || (cat $@ ; false)
307c41c6647SJiri Olsa
308c41c6647SJiri Olsaall: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools
309095ae69bSJiri Olsa	@echo OK
310095ae69bSJiri Olsa
311095ae69bSJiri Olsaout: $(run_O)
312095ae69bSJiri Olsa	@echo OK
313095ae69bSJiri Olsa
3143167eea2SWang Nan.PHONY: all $(run) $(run_O) tarpkg clean make_kernelsrc make_kernelsrc_tools
315502819c5SJiri Olsaendif # ifndef MK
316