blob: d3819f21087672c35e8cecab66a91fb3ab1723fd [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
Jiri Olsac0ec1102013-07-22 14:43:33 +020030make_install := install
31make_install_bin := install-bin
Jiri Olsa095ae692013-03-29 16:11:02 +010032
33# all the NO_* variable combined
34make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
35make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
36make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
37
38# $(run) contains all available tests
39run := make_pure
40run += make_clean_all
41run += make_python_perf_so
42run += make_debug
43run += make_no_libperl
44run += make_no_libpython
45run += make_no_scripts
46run += make_no_newt
47run += make_no_slang
48run += make_no_gtk2
49run += make_no_ui
50run += make_no_demangle
51run += make_no_libelf
52run += make_no_libunwind
53run += make_no_backtrace
54run += make_no_libnuma
55run += make_no_libaudit
56run += make_no_libbionic
Jiri Olsa095ae692013-03-29 16:11:02 +010057run += make_help
58run += make_doc
59run += make_perf_o
60run += make_util_map_o
Jiri Olsac0ec1102013-07-22 14:43:33 +020061run += make_install
62run += make_install_bin
Jiri Olsa095ae692013-03-29 16:11:02 +010063run += make_minimal
64
Jiri Olsa0659e662013-07-22 14:43:30 +020065ifneq ($(call has,ctags),)
66run += make_tags
67endif
68ifneq ($(call has,cscope),)
69run += make_cscope
70endif
71
Jiri Olsa095ae692013-03-29 16:11:02 +010072# $(run_O) contains same portion of $(run) tests with '_O' attached
73# to distinguish O=... tests
74run_O := $(addsuffix _O,$(run))
75
76# disable some tests for O=...
77run_O := $(filter-out make_python_perf_so_O,$(run_O))
78
79# define test for each compile as 'test_NAME' variable
80# with the test itself as a value
81test_make_tags = test -f tags
82test_make_cscope = test -f cscope.out
83
84test_make_tags_O := $(test_make_tags)
85test_make_cscope_O := $(test_make_cscope)
86
87test_ok := true
88test_make_help := $(test_ok)
89test_make_doc := $(test_ok)
90test_make_help_O := $(test_ok)
91test_make_doc_O := $(test_ok)
92
93test_make_python_perf_so := test -f $(PERF)/python/perf.so
94
95test_make_perf_o := test -f $(PERF)/perf.o
96test_make_util_map_o := test -f $(PERF)/util/map.o
97
Jiri Olsac0ec1102013-07-22 14:43:33 +020098test_make_install := test -x $$TMP_DEST/bin/perf
99test_make_install_O := $(test_make_install)
100test_make_install_bin := $(test_make_install)
101test_make_install_bin_O := $(test_make_install)
102
Jiri Olsa095ae692013-03-29 16:11:02 +0100103# Kbuild tests only
104#test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so
105#test_make_perf_o_O := test -f $$TMP/tools/perf/perf.o
106#test_make_util_map_o_O := test -f $$TMP/tools/perf/util/map.o
107
108test_make_perf_o_O := true
109test_make_util_map_o_O := true
110
111test_default = test -x $(PERF)/perf
112test = $(if $(test_$1),$(test_$1),$(test_default))
113
Jiri Olsa8ba7cde2013-07-22 14:43:31 +0200114test_default_O = test -x $$TMP_O/perf
Jiri Olsa095ae692013-03-29 16:11:02 +0100115test_O = $(if $(test_$1),$(test_$1),$(test_default_O))
116
117all:
118
119ifdef DEBUG
120d := $(info run $(run))
121d := $(info run_O $(run_O))
122endif
123
124MAKEFLAGS := --no-print-directory
125
126clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
127
128$(run):
129 $(call clean)
Jiri Olsac9311672013-07-22 14:43:32 +0200130 @TMP_DEST=$$(mktemp -d); \
131 cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100132 echo "- $@: $$cmd" && echo $$cmd > $@ && \
133 ( eval $$cmd ) >> $@ 2>&1; \
134 echo " test: $(call test,$@)"; \
135 $(call test,$@) && \
Jiri Olsac9311672013-07-22 14:43:32 +0200136 rm -f $@ \
137 rm -rf $$TMP_DEST
Jiri Olsa095ae692013-03-29 16:11:02 +0100138
139$(run_O):
140 $(call clean)
Jiri Olsa8ba7cde2013-07-22 14:43:31 +0200141 @TMP_O=$$(mktemp -d); \
Jiri Olsac9311672013-07-22 14:43:32 +0200142 TMP_DEST=$$(mktemp -d); \
143 cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100144 echo "- $@: $$cmd" && echo $$cmd > $@ && \
145 ( eval $$cmd ) >> $@ 2>&1 && \
146 echo " test: $(call test_O,$@)"; \
147 $(call test_O,$@) && \
148 rm -f $@ && \
Jiri Olsac9311672013-07-22 14:43:32 +0200149 rm -rf $$TMP_O \
150 rm -rf $$TMP_DEST
Jiri Olsa095ae692013-03-29 16:11:02 +0100151
152all: $(run) $(run_O)
153 @echo OK
154
155out: $(run_O)
156 @echo OK
157
158.PHONY: all $(run) $(run_O) clean