xref: /openbmc/linux/tools/perf/tests/make (revision 095ae69b890c5b9cc87a3160b489a617554d9848)
1*095ae69bSJiri OlsaPERF := .
2*095ae69bSJiri OlsaMK   := Makefile
3*095ae69bSJiri Olsa
4*095ae69bSJiri Olsa# standard single make variable specified
5*095ae69bSJiri Olsamake_clean_all      := clean all
6*095ae69bSJiri Olsamake_python_perf_so := python/perf.so
7*095ae69bSJiri Olsamake_debug          := DEBUG=1
8*095ae69bSJiri Olsamake_no_libperl     := NO_LIBPERL=1
9*095ae69bSJiri Olsamake_no_libpython   := NO_LIBPYTHON=1
10*095ae69bSJiri Olsamake_no_scripts     := NO_LIBPYTHON=1 NO_LIBPERL=1
11*095ae69bSJiri Olsamake_no_newt        := NO_NEWT=1
12*095ae69bSJiri Olsamake_no_slang       := NO_SLANG=1
13*095ae69bSJiri Olsamake_no_gtk2        := NO_GTK2=1
14*095ae69bSJiri Olsamake_no_ui          := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
15*095ae69bSJiri Olsamake_no_demangle    := NO_DEMANGLE=1
16*095ae69bSJiri Olsamake_no_libelf      := NO_LIBELF=1
17*095ae69bSJiri Olsamake_no_libunwind   := NO_LIBUNWIND=1
18*095ae69bSJiri Olsamake_no_backtrace   := NO_BACKTRACE=1
19*095ae69bSJiri Olsamake_no_libnuma     := NO_LIBNUMA=1
20*095ae69bSJiri Olsamake_no_libaudit    := NO_LIBAUDIT=1
21*095ae69bSJiri Olsamake_no_libbionic   := NO_LIBBIONIC=1
22*095ae69bSJiri Olsamake_tags           := tags
23*095ae69bSJiri Olsamake_cscope         := cscope
24*095ae69bSJiri Olsamake_help           := help
25*095ae69bSJiri Olsamake_doc            := doc
26*095ae69bSJiri Olsamake_perf_o         := perf.o
27*095ae69bSJiri Olsamake_util_map_o     := util/map.o
28*095ae69bSJiri Olsa
29*095ae69bSJiri Olsa# all the NO_* variable combined
30*095ae69bSJiri Olsamake_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
31*095ae69bSJiri Olsamake_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
32*095ae69bSJiri Olsamake_minimal        += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
33*095ae69bSJiri Olsa
34*095ae69bSJiri Olsa# $(run) contains all available tests
35*095ae69bSJiri Olsarun := make_pure
36*095ae69bSJiri Olsarun += make_clean_all
37*095ae69bSJiri Olsarun += make_python_perf_so
38*095ae69bSJiri Olsarun += make_debug
39*095ae69bSJiri Olsarun += make_no_libperl
40*095ae69bSJiri Olsarun += make_no_libpython
41*095ae69bSJiri Olsarun += make_no_scripts
42*095ae69bSJiri Olsarun += make_no_newt
43*095ae69bSJiri Olsarun += make_no_slang
44*095ae69bSJiri Olsarun += make_no_gtk2
45*095ae69bSJiri Olsarun += make_no_ui
46*095ae69bSJiri Olsarun += make_no_demangle
47*095ae69bSJiri Olsarun += make_no_libelf
48*095ae69bSJiri Olsarun += make_no_libunwind
49*095ae69bSJiri Olsarun += make_no_backtrace
50*095ae69bSJiri Olsarun += make_no_libnuma
51*095ae69bSJiri Olsarun += make_no_libaudit
52*095ae69bSJiri Olsarun += make_no_libbionic
53*095ae69bSJiri Olsarun += make_tags
54*095ae69bSJiri Olsarun += make_cscope
55*095ae69bSJiri Olsarun += make_help
56*095ae69bSJiri Olsarun += make_doc
57*095ae69bSJiri Olsarun += make_perf_o
58*095ae69bSJiri Olsarun += make_util_map_o
59*095ae69bSJiri Olsarun += make_minimal
60*095ae69bSJiri Olsa
61*095ae69bSJiri Olsa# $(run_O) contains same portion of $(run) tests with '_O' attached
62*095ae69bSJiri Olsa# to distinguish O=... tests
63*095ae69bSJiri Olsarun_O := $(addsuffix _O,$(run))
64*095ae69bSJiri Olsa
65*095ae69bSJiri Olsa# disable some tests for O=...
66*095ae69bSJiri Olsarun_O := $(filter-out make_python_perf_so_O,$(run_O))
67*095ae69bSJiri Olsa
68*095ae69bSJiri Olsa# define test for each compile as 'test_NAME' variable
69*095ae69bSJiri Olsa# with the test itself as a value
70*095ae69bSJiri Olsatest_make_tags   = test -f tags
71*095ae69bSJiri Olsatest_make_cscope = test -f cscope.out
72*095ae69bSJiri Olsa
73*095ae69bSJiri Olsatest_make_tags_O   := $(test_make_tags)
74*095ae69bSJiri Olsatest_make_cscope_O := $(test_make_cscope)
75*095ae69bSJiri Olsa
76*095ae69bSJiri Olsatest_ok          := true
77*095ae69bSJiri Olsatest_make_help   := $(test_ok)
78*095ae69bSJiri Olsatest_make_doc    := $(test_ok)
79*095ae69bSJiri Olsatest_make_help_O := $(test_ok)
80*095ae69bSJiri Olsatest_make_doc_O  := $(test_ok)
81*095ae69bSJiri Olsa
82*095ae69bSJiri Olsatest_make_python_perf_so := test -f $(PERF)/python/perf.so
83*095ae69bSJiri Olsa
84*095ae69bSJiri Olsatest_make_perf_o     := test -f $(PERF)/perf.o
85*095ae69bSJiri Olsatest_make_util_map_o := test -f $(PERF)/util/map.o
86*095ae69bSJiri Olsa
87*095ae69bSJiri Olsa# Kbuild tests only
88*095ae69bSJiri Olsa#test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so
89*095ae69bSJiri Olsa#test_make_perf_o_O         := test -f $$TMP/tools/perf/perf.o
90*095ae69bSJiri Olsa#test_make_util_map_o_O     := test -f $$TMP/tools/perf/util/map.o
91*095ae69bSJiri Olsa
92*095ae69bSJiri Olsatest_make_perf_o_O     := true
93*095ae69bSJiri Olsatest_make_util_map_o_O := true
94*095ae69bSJiri Olsa
95*095ae69bSJiri Olsatest_default = test -x $(PERF)/perf
96*095ae69bSJiri Olsatest = $(if $(test_$1),$(test_$1),$(test_default))
97*095ae69bSJiri Olsa
98*095ae69bSJiri Olsatest_default_O = test -x $$TMP/perf
99*095ae69bSJiri Olsatest_O = $(if $(test_$1),$(test_$1),$(test_default_O))
100*095ae69bSJiri Olsa
101*095ae69bSJiri Olsaall:
102*095ae69bSJiri Olsa
103*095ae69bSJiri Olsaifdef DEBUG
104*095ae69bSJiri Olsad := $(info run   $(run))
105*095ae69bSJiri Olsad := $(info run_O $(run_O))
106*095ae69bSJiri Olsaendif
107*095ae69bSJiri Olsa
108*095ae69bSJiri OlsaMAKEFLAGS := --no-print-directory
109*095ae69bSJiri Olsa
110*095ae69bSJiri Olsaclean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
111*095ae69bSJiri Olsa
112*095ae69bSJiri Olsa$(run):
113*095ae69bSJiri Olsa	$(call clean)
114*095ae69bSJiri Olsa	@cmd="cd $(PERF) && make -f $(MK) $($@)"; \
115*095ae69bSJiri Olsa	echo "- $@: $$cmd" && echo $$cmd > $@ && \
116*095ae69bSJiri Olsa	( eval $$cmd ) >> $@ 2>&1; \
117*095ae69bSJiri Olsa	echo "  test: $(call test,$@)"; \
118*095ae69bSJiri Olsa	$(call test,$@) && \
119*095ae69bSJiri Olsa	rm -f $@
120*095ae69bSJiri Olsa
121*095ae69bSJiri Olsa$(run_O):
122*095ae69bSJiri Olsa	$(call clean)
123*095ae69bSJiri Olsa	@TMP=$$(mktemp -d); \
124*095ae69bSJiri Olsa	cmd="cd $(PERF) && make -f $(MK) $($(patsubst %_O,%,$@)) O=$$TMP"; \
125*095ae69bSJiri Olsa	echo "- $@: $$cmd" && echo $$cmd > $@ && \
126*095ae69bSJiri Olsa	( eval $$cmd ) >> $@ 2>&1 && \
127*095ae69bSJiri Olsa	echo "  test: $(call test_O,$@)"; \
128*095ae69bSJiri Olsa	$(call test_O,$@) && \
129*095ae69bSJiri Olsa	rm -f $@ && \
130*095ae69bSJiri Olsa	rm -rf $$TMP
131*095ae69bSJiri Olsa
132*095ae69bSJiri Olsaall: $(run) $(run_O)
133*095ae69bSJiri Olsa	@echo OK
134*095ae69bSJiri Olsa
135*095ae69bSJiri Olsaout: $(run_O)
136*095ae69bSJiri Olsa	@echo OK
137*095ae69bSJiri Olsa
138*095ae69bSJiri Olsa.PHONY: all $(run) $(run_O) clean
139