blob: dbbb62c0d0f33737e525bea391d2f03f2b07e4a8 [file] [log] [blame]
Jiri Olsa095ae692013-03-29 16:11:02 +01001PERF := .
2MK := Makefile
3
Jiri Olsa0659e662013-07-22 14:43:30 +02004has = $(shell which $1 2>/dev/null)
5
Jiri Olsa095ae692013-03-29 16:11:02 +01006# standard single make variable specified
7make_clean_all := clean all
8make_python_perf_so := python/perf.so
9make_debug := DEBUG=1
10make_no_libperl := NO_LIBPERL=1
11make_no_libpython := NO_LIBPYTHON=1
12make_no_scripts := NO_LIBPYTHON=1 NO_LIBPERL=1
13make_no_newt := NO_NEWT=1
14make_no_slang := NO_SLANG=1
15make_no_gtk2 := NO_GTK2=1
16make_no_ui := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
17make_no_demangle := NO_DEMANGLE=1
18make_no_libelf := NO_LIBELF=1
19make_no_libunwind := NO_LIBUNWIND=1
20make_no_backtrace := NO_BACKTRACE=1
21make_no_libnuma := NO_LIBNUMA=1
22make_no_libaudit := NO_LIBAUDIT=1
23make_no_libbionic := NO_LIBBIONIC=1
24make_tags := tags
25make_cscope := cscope
26make_help := help
27make_doc := doc
28make_perf_o := perf.o
29make_util_map_o := util/map.o
30
31# all the NO_* variable combined
32make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
33make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
34make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
35
36# $(run) contains all available tests
37run := make_pure
38run += make_clean_all
39run += make_python_perf_so
40run += make_debug
41run += make_no_libperl
42run += make_no_libpython
43run += make_no_scripts
44run += make_no_newt
45run += make_no_slang
46run += make_no_gtk2
47run += make_no_ui
48run += make_no_demangle
49run += make_no_libelf
50run += make_no_libunwind
51run += make_no_backtrace
52run += make_no_libnuma
53run += make_no_libaudit
54run += make_no_libbionic
Jiri Olsa095ae692013-03-29 16:11:02 +010055run += make_help
56run += make_doc
57run += make_perf_o
58run += make_util_map_o
59run += make_minimal
60
Jiri Olsa0659e662013-07-22 14:43:30 +020061ifneq ($(call has,ctags),)
62run += make_tags
63endif
64ifneq ($(call has,cscope),)
65run += make_cscope
66endif
67
Jiri Olsa095ae692013-03-29 16:11:02 +010068# $(run_O) contains same portion of $(run) tests with '_O' attached
69# to distinguish O=... tests
70run_O := $(addsuffix _O,$(run))
71
72# disable some tests for O=...
73run_O := $(filter-out make_python_perf_so_O,$(run_O))
74
75# define test for each compile as 'test_NAME' variable
76# with the test itself as a value
77test_make_tags = test -f tags
78test_make_cscope = test -f cscope.out
79
80test_make_tags_O := $(test_make_tags)
81test_make_cscope_O := $(test_make_cscope)
82
83test_ok := true
84test_make_help := $(test_ok)
85test_make_doc := $(test_ok)
86test_make_help_O := $(test_ok)
87test_make_doc_O := $(test_ok)
88
89test_make_python_perf_so := test -f $(PERF)/python/perf.so
90
91test_make_perf_o := test -f $(PERF)/perf.o
92test_make_util_map_o := test -f $(PERF)/util/map.o
93
94# Kbuild tests only
95#test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so
96#test_make_perf_o_O := test -f $$TMP/tools/perf/perf.o
97#test_make_util_map_o_O := test -f $$TMP/tools/perf/util/map.o
98
99test_make_perf_o_O := true
100test_make_util_map_o_O := true
101
102test_default = test -x $(PERF)/perf
103test = $(if $(test_$1),$(test_$1),$(test_default))
104
Jiri Olsa8ba7cde2013-07-22 14:43:31 +0200105test_default_O = test -x $$TMP_O/perf
Jiri Olsa095ae692013-03-29 16:11:02 +0100106test_O = $(if $(test_$1),$(test_$1),$(test_default_O))
107
108all:
109
110ifdef DEBUG
111d := $(info run $(run))
112d := $(info run_O $(run_O))
113endif
114
115MAKEFLAGS := --no-print-directory
116
117clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
118
119$(run):
120 $(call clean)
121 @cmd="cd $(PERF) && make -f $(MK) $($@)"; \
122 echo "- $@: $$cmd" && echo $$cmd > $@ && \
123 ( eval $$cmd ) >> $@ 2>&1; \
124 echo " test: $(call test,$@)"; \
125 $(call test,$@) && \
126 rm -f $@
127
128$(run_O):
129 $(call clean)
Jiri Olsa8ba7cde2013-07-22 14:43:31 +0200130 @TMP_O=$$(mktemp -d); \
131 cmd="cd $(PERF) && make -f $(MK) $($(patsubst %_O,%,$@)) O=$$TMP_O"; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100132 echo "- $@: $$cmd" && echo $$cmd > $@ && \
133 ( eval $$cmd ) >> $@ 2>&1 && \
134 echo " test: $(call test_O,$@)"; \
135 $(call test_O,$@) && \
136 rm -f $@ && \
Jiri Olsa8ba7cde2013-07-22 14:43:31 +0200137 rm -rf $$TMP_O
Jiri Olsa095ae692013-03-29 16:11:02 +0100138
139all: $(run) $(run_O)
140 @echo OK
141
142out: $(run_O)
143 @echo OK
144
145.PHONY: all $(run) $(run_O) clean