xref: /openbmc/linux/tools/perf/tests/make (revision e31f0d017ea19fce9f12f084e1c750a0e3b43680)
1095ae69bSJiri OlsaPERF := .
2095ae69bSJiri OlsaMK   := Makefile
3095ae69bSJiri Olsa
4f7c64474SJiri Olsainclude config/Makefile.arch
5f7c64474SJiri Olsa
6f7c64474SJiri Olsa# FIXME looks like x86 is the only arch running tests ;-)
7f7c64474SJiri Olsa# we need some IS_(32/64) flag to make this generic
876aea773SH.J. Luifeq ($(ARCH)$(IS_64_BIT), x861)
9f7c64474SJiri Olsalib = lib64
10f7c64474SJiri Olsaelse
11f7c64474SJiri Olsalib = lib
12f7c64474SJiri Olsaendif
13f7c64474SJiri Olsa
140659e669SJiri Olsahas = $(shell which $1 2>/dev/null)
150659e669SJiri Olsa
16095ae69bSJiri Olsa# standard single make variable specified
17095ae69bSJiri Olsamake_clean_all      := clean all
18095ae69bSJiri Olsamake_python_perf_so := python/perf.so
19095ae69bSJiri Olsamake_debug          := DEBUG=1
20095ae69bSJiri Olsamake_no_libperl     := NO_LIBPERL=1
21095ae69bSJiri Olsamake_no_libpython   := NO_LIBPYTHON=1
22095ae69bSJiri Olsamake_no_scripts     := NO_LIBPYTHON=1 NO_LIBPERL=1
23095ae69bSJiri Olsamake_no_newt        := NO_NEWT=1
24095ae69bSJiri Olsamake_no_slang       := NO_SLANG=1
25095ae69bSJiri Olsamake_no_gtk2        := NO_GTK2=1
26095ae69bSJiri Olsamake_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
27095ae69bSJiri Olsamake_no_demangle    := NO_DEMANGLE=1
28095ae69bSJiri Olsamake_no_libelf      := NO_LIBELF=1
29095ae69bSJiri Olsamake_no_libunwind   := NO_LIBUNWIND=1
309e8c06eaSJiri Olsamake_no_libdw_dwarf_unwind := NO_LIBDW_DWARF_UNWIND=1
31095ae69bSJiri Olsamake_no_backtrace   := NO_BACKTRACE=1
32095ae69bSJiri Olsamake_no_libnuma     := NO_LIBNUMA=1
33095ae69bSJiri Olsamake_no_libaudit    := NO_LIBAUDIT=1
34095ae69bSJiri Olsamake_no_libbionic   := NO_LIBBIONIC=1
35*e31f0d01SAdrian Huntermake_no_auxtrace    := NO_AUXTRACE=1
36095ae69bSJiri Olsamake_tags           := tags
37095ae69bSJiri Olsamake_cscope         := cscope
38095ae69bSJiri Olsamake_help           := help
39095ae69bSJiri Olsamake_doc            := doc
40095ae69bSJiri Olsamake_perf_o           := perf.o
41095ae69bSJiri Olsamake_util_map_o       := util/map.o
422a94f6c4SJiri Olsamake_util_pmu_bison_o := util/pmu-bison.o
43c0ec1108SJiri Olsamake_install        := install
44c0ec1108SJiri Olsamake_install_bin    := install-bin
45dbad4189SJiri Olsamake_install_doc    := install-doc
46dbad4189SJiri Olsamake_install_man    := install-man
47dbad4189SJiri Olsamake_install_html   := install-html
48dbad4189SJiri Olsamake_install_info   := install-info
49dbad4189SJiri Olsamake_install_pdf    := install-pdf
50611ec127SJiri Olsamake_static         := LDFLAGS=-static
51095ae69bSJiri Olsa
52095ae69bSJiri Olsa# all the NO_* variable combined
53095ae69bSJiri Olsamake_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
54095ae69bSJiri Olsamake_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
55095ae69bSJiri Olsamake_minimal        += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
56*e31f0d01SAdrian Huntermake_minimal        += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1
57095ae69bSJiri Olsa
58095ae69bSJiri Olsa# $(run) contains all available tests
59095ae69bSJiri Olsarun := make_pure
60095ae69bSJiri Olsarun += make_clean_all
61095ae69bSJiri Olsarun += make_python_perf_so
62095ae69bSJiri Olsarun += make_debug
63095ae69bSJiri Olsarun += make_no_libperl
64095ae69bSJiri Olsarun += make_no_libpython
65095ae69bSJiri Olsarun += make_no_scripts
66095ae69bSJiri Olsarun += make_no_newt
67095ae69bSJiri Olsarun += make_no_slang
68095ae69bSJiri Olsarun += make_no_gtk2
69095ae69bSJiri Olsarun += make_no_ui
70095ae69bSJiri Olsarun += make_no_demangle
71095ae69bSJiri Olsarun += make_no_libelf
72095ae69bSJiri Olsarun += make_no_libunwind
739e8c06eaSJiri Olsarun += make_no_libdw_dwarf_unwind
74095ae69bSJiri Olsarun += make_no_backtrace
75095ae69bSJiri Olsarun += make_no_libnuma
76095ae69bSJiri Olsarun += make_no_libaudit
77095ae69bSJiri Olsarun += make_no_libbionic
78*e31f0d01SAdrian Hunterrun += make_no_auxtrace
79095ae69bSJiri Olsarun += make_help
80095ae69bSJiri Olsarun += make_doc
81095ae69bSJiri Olsarun += make_perf_o
82095ae69bSJiri Olsarun += make_util_map_o
832a94f6c4SJiri Olsarun += make_util_pmu_bison_o
84c0ec1108SJiri Olsarun += make_install
85c0ec1108SJiri Olsarun += make_install_bin
86dbad4189SJiri Olsa# FIXME 'install-*' commented out till they're fixed
87dbad4189SJiri Olsa# run += make_install_doc
88dbad4189SJiri Olsa# run += make_install_man
89dbad4189SJiri Olsa# run += make_install_html
90dbad4189SJiri Olsa# run += make_install_info
91dbad4189SJiri Olsa# run += make_install_pdf
92095ae69bSJiri Olsarun += make_minimal
93611ec127SJiri Olsarun += make_static
94095ae69bSJiri Olsa
950659e669SJiri Olsaifneq ($(call has,ctags),)
960659e669SJiri Olsarun += make_tags
970659e669SJiri Olsaendif
980659e669SJiri Olsaifneq ($(call has,cscope),)
990659e669SJiri Olsarun += make_cscope
1000659e669SJiri Olsaendif
1010659e669SJiri Olsa
102095ae69bSJiri Olsa# $(run_O) contains same portion of $(run) tests with '_O' attached
103095ae69bSJiri Olsa# to distinguish O=... tests
104095ae69bSJiri Olsarun_O := $(addsuffix _O,$(run))
105095ae69bSJiri Olsa
106095ae69bSJiri Olsa# disable some tests for O=...
107095ae69bSJiri Olsarun_O := $(filter-out make_python_perf_so_O,$(run_O))
108095ae69bSJiri Olsa
109095ae69bSJiri Olsa# define test for each compile as 'test_NAME' variable
110095ae69bSJiri Olsa# with the test itself as a value
111095ae69bSJiri Olsatest_make_tags   = test -f tags
112095ae69bSJiri Olsatest_make_cscope = test -f cscope.out
113095ae69bSJiri Olsa
114095ae69bSJiri Olsatest_make_tags_O   := $(test_make_tags)
115095ae69bSJiri Olsatest_make_cscope_O := $(test_make_cscope)
116095ae69bSJiri Olsa
117095ae69bSJiri Olsatest_ok          := true
118095ae69bSJiri Olsatest_make_help   := $(test_ok)
119095ae69bSJiri Olsatest_make_doc    := $(test_ok)
120095ae69bSJiri Olsatest_make_help_O := $(test_ok)
121095ae69bSJiri Olsatest_make_doc_O  := $(test_ok)
122095ae69bSJiri Olsa
123095ae69bSJiri Olsatest_make_python_perf_so := test -f $(PERF)/python/perf.so
124095ae69bSJiri Olsa
125095ae69bSJiri Olsatest_make_perf_o           := test -f $(PERF)/perf.o
126095ae69bSJiri Olsatest_make_util_map_o       := test -f $(PERF)/util/map.o
1272a94f6c4SJiri Olsatest_make_util_pmu_bison_o := test -f $(PERF)/util/pmu-bison.o
128095ae69bSJiri Olsa
129ee4ad93eSJiri Olsadefine test_dest_files
130ee4ad93eSJiri Olsa  for file in $(1); do				\
131ee4ad93eSJiri Olsa    if [ ! -x $$TMP_DEST/$$file ]; then		\
132ee4ad93eSJiri Olsa      echo "  failed to find: $$file";		\
133ee4ad93eSJiri Olsa    fi						\
134ee4ad93eSJiri Olsa  done
135ee4ad93eSJiri Olsaendef
136ee4ad93eSJiri Olsa
137ee4ad93eSJiri Olsainstalled_files_bin := bin/perf
138ee4ad93eSJiri Olsainstalled_files_bin += etc/bash_completion.d/perf
139ee4ad93eSJiri Olsainstalled_files_bin += libexec/perf-core/perf-archive
140ee4ad93eSJiri Olsa
141f7c64474SJiri Olsainstalled_files_plugins := $(lib)/traceevent/plugins/plugin_cfg80211.so
142f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_scsi.so
143f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_xen.so
144f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_function.so
145f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_sched_switch.so
146f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_mac80211.so
147f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_kvm.so
148f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_kmem.so
149f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_hrtimer.so
150f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_jbd2.so
151ee4ad93eSJiri Olsa
152ee4ad93eSJiri Olsainstalled_files_all := $(installed_files_bin)
153ee4ad93eSJiri Olsainstalled_files_all += $(installed_files_plugins)
154ee4ad93eSJiri Olsa
155ee4ad93eSJiri Olsatest_make_install       := $(call test_dest_files,$(installed_files_all))
156ee4ad93eSJiri Olsatest_make_install_O     := $(call test_dest_files,$(installed_files_all))
157ee4ad93eSJiri Olsatest_make_install_bin   := $(call test_dest_files,$(installed_files_bin))
158ee4ad93eSJiri Olsatest_make_install_bin_O := $(call test_dest_files,$(installed_files_bin))
159c0ec1108SJiri Olsa
160dbad4189SJiri Olsa# FIXME nothing gets installed
161dbad4189SJiri Olsatest_make_install_man    := test -f $$TMP_DEST/share/man/man1/perf.1
162dbad4189SJiri Olsatest_make_install_man_O  := $(test_make_install_man)
163dbad4189SJiri Olsa
164dbad4189SJiri Olsa# FIXME nothing gets installed
165dbad4189SJiri Olsatest_make_install_doc    := $(test_ok)
166dbad4189SJiri Olsatest_make_install_doc_O  := $(test_ok)
167dbad4189SJiri Olsa
168dbad4189SJiri Olsa# FIXME nothing gets installed
169dbad4189SJiri Olsatest_make_install_html   := $(test_ok)
170dbad4189SJiri Olsatest_make_install_html_O := $(test_ok)
171dbad4189SJiri Olsa
172dbad4189SJiri Olsa# FIXME nothing gets installed
173dbad4189SJiri Olsatest_make_install_info   := $(test_ok)
174dbad4189SJiri Olsatest_make_install_info_O := $(test_ok)
175dbad4189SJiri Olsa
176dbad4189SJiri Olsa# FIXME nothing gets installed
177dbad4189SJiri Olsatest_make_install_pdf    := $(test_ok)
178dbad4189SJiri Olsatest_make_install_pdf_O  := $(test_ok)
179dbad4189SJiri Olsa
18004b01a1dSJiri Olsatest_make_python_perf_so_O    := test -f $$TMP_O/python/perf.so
18104b01a1dSJiri Olsatest_make_perf_o_O            := test -f $$TMP_O/perf.o
18204b01a1dSJiri Olsatest_make_util_map_o_O        := test -f $$TMP_O/util/map.o
1832a94f6c4SJiri Olsatest_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o
184095ae69bSJiri Olsa
185095ae69bSJiri Olsatest_default = test -x $(PERF)/perf
186095ae69bSJiri Olsatest = $(if $(test_$1),$(test_$1),$(test_default))
187095ae69bSJiri Olsa
1888ba7cdeaSJiri Olsatest_default_O = test -x $$TMP_O/perf
189095ae69bSJiri Olsatest_O = $(if $(test_$1),$(test_$1),$(test_default_O))
190095ae69bSJiri Olsa
191095ae69bSJiri Olsaall:
192095ae69bSJiri Olsa
193095ae69bSJiri Olsaifdef DEBUG
194095ae69bSJiri Olsad := $(info run   $(run))
195095ae69bSJiri Olsad := $(info run_O $(run_O))
196095ae69bSJiri Olsaendif
197095ae69bSJiri Olsa
198095ae69bSJiri OlsaMAKEFLAGS := --no-print-directory
199095ae69bSJiri Olsa
200095ae69bSJiri Olsaclean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
201095ae69bSJiri Olsa
202095ae69bSJiri Olsa$(run):
203095ae69bSJiri Olsa	$(call clean)
204c9311674SJiri Olsa	@TMP_DEST=$$(mktemp -d); \
205c9311674SJiri Olsa	cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \
206095ae69bSJiri Olsa	echo "- $@: $$cmd" && echo $$cmd > $@ && \
207095ae69bSJiri Olsa	( eval $$cmd ) >> $@ 2>&1; \
208ee4ad93eSJiri Olsa	echo "  test: $(call test,$@)" >> $@ 2>&1; \
209095ae69bSJiri Olsa	$(call test,$@) && \
210a5c5009fSArnaldo Carvalho de Melo	rm -rf $@ $$TMP_DEST || (cat $@ ; false)
211095ae69bSJiri Olsa
212095ae69bSJiri Olsa$(run_O):
213095ae69bSJiri Olsa	$(call clean)
2148ba7cdeaSJiri Olsa	@TMP_O=$$(mktemp -d); \
215c9311674SJiri Olsa	TMP_DEST=$$(mktemp -d); \
216c9311674SJiri Olsa	cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \
217095ae69bSJiri Olsa	echo "- $@: $$cmd" && echo $$cmd > $@ && \
218095ae69bSJiri Olsa	( eval $$cmd ) >> $@ 2>&1 && \
219ee4ad93eSJiri Olsa	echo "  test: $(call test_O,$@)" >> $@ 2>&1; \
220095ae69bSJiri Olsa	$(call test_O,$@) && \
221a5c5009fSArnaldo Carvalho de Melo	rm -rf $@ $$TMP_O $$TMP_DEST || (cat $@ ; false)
222095ae69bSJiri Olsa
22348878053SArnaldo Carvalho de Melotarpkg:
22448878053SArnaldo Carvalho de Melo	@cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \
22548878053SArnaldo Carvalho de Melo	echo "- $@: $$cmd" && echo $$cmd > $@ && \
22648878053SArnaldo Carvalho de Melo	( eval $$cmd ) >> $@ 2>&1
22748878053SArnaldo Carvalho de Melo
228c41c6647SJiri Olsamake_kernelsrc:
229c41c6647SJiri Olsa	@echo " - make -C <kernelsrc> tools/perf"
230c41c6647SJiri Olsa	$(call clean); \
231c41c6647SJiri Olsa	(make -C ../.. tools/perf) > $@ 2>&1 && \
232c41c6647SJiri Olsa	test -x perf && rm -f $@ || (cat $@ ; false)
233c41c6647SJiri Olsa
234c41c6647SJiri Olsamake_kernelsrc_tools:
235c41c6647SJiri Olsa	@echo " - make -C <kernelsrc>/tools perf"
236c41c6647SJiri Olsa	$(call clean); \
237c41c6647SJiri Olsa	(make -C ../../tools perf) > $@ 2>&1 && \
238c41c6647SJiri Olsa	test -x perf && rm -f $@ || (cat $@ ; false)
239c41c6647SJiri Olsa
240c41c6647SJiri Olsaall: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools
241095ae69bSJiri Olsa	@echo OK
242095ae69bSJiri Olsa
243095ae69bSJiri Olsaout: $(run_O)
244095ae69bSJiri Olsa	@echo OK
245095ae69bSJiri Olsa
24648878053SArnaldo Carvalho de Melo.PHONY: all $(run) $(run_O) tarpkg clean
247