blob: f641c35f2321485842557c52393ee96227a15513 [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 Olsadbad4182013-07-22 14:43:34 +020032make_install_doc := install-doc
33make_install_man := install-man
34make_install_html := install-html
35make_install_info := install-info
36make_install_pdf := install-pdf
Jiri Olsa095ae692013-03-29 16:11:02 +010037
38# all the NO_* variable combined
39make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
40make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
41make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
42
43# $(run) contains all available tests
44run := make_pure
45run += make_clean_all
46run += make_python_perf_so
47run += make_debug
48run += make_no_libperl
49run += make_no_libpython
50run += make_no_scripts
51run += make_no_newt
52run += make_no_slang
53run += make_no_gtk2
54run += make_no_ui
55run += make_no_demangle
56run += make_no_libelf
57run += make_no_libunwind
58run += make_no_backtrace
59run += make_no_libnuma
60run += make_no_libaudit
61run += make_no_libbionic
Jiri Olsa095ae692013-03-29 16:11:02 +010062run += make_help
63run += make_doc
64run += make_perf_o
65run += make_util_map_o
Jiri Olsac0ec1102013-07-22 14:43:33 +020066run += make_install
67run += make_install_bin
Jiri Olsadbad4182013-07-22 14:43:34 +020068# FIXME 'install-*' commented out till they're fixed
69# run += make_install_doc
70# run += make_install_man
71# run += make_install_html
72# run += make_install_info
73# run += make_install_pdf
Jiri Olsa095ae692013-03-29 16:11:02 +010074run += make_minimal
75
Jiri Olsa0659e662013-07-22 14:43:30 +020076ifneq ($(call has,ctags),)
77run += make_tags
78endif
79ifneq ($(call has,cscope),)
80run += make_cscope
81endif
82
Jiri Olsa095ae692013-03-29 16:11:02 +010083# $(run_O) contains same portion of $(run) tests with '_O' attached
84# to distinguish O=... tests
85run_O := $(addsuffix _O,$(run))
86
87# disable some tests for O=...
88run_O := $(filter-out make_python_perf_so_O,$(run_O))
89
90# define test for each compile as 'test_NAME' variable
91# with the test itself as a value
92test_make_tags = test -f tags
93test_make_cscope = test -f cscope.out
94
95test_make_tags_O := $(test_make_tags)
96test_make_cscope_O := $(test_make_cscope)
97
98test_ok := true
99test_make_help := $(test_ok)
100test_make_doc := $(test_ok)
101test_make_help_O := $(test_ok)
102test_make_doc_O := $(test_ok)
103
104test_make_python_perf_so := test -f $(PERF)/python/perf.so
105
106test_make_perf_o := test -f $(PERF)/perf.o
107test_make_util_map_o := test -f $(PERF)/util/map.o
108
Jiri Olsaee4ad932013-12-19 14:41:59 +0100109define test_dest_files
110 for file in $(1); do \
111 if [ ! -x $$TMP_DEST/$$file ]; then \
112 echo " failed to find: $$file"; \
113 fi \
114 done
115endef
116
117installed_files_bin := bin/perf
118installed_files_bin += etc/bash_completion.d/perf
119installed_files_bin += libexec/perf-core/perf-archive
120
121installed_files_plugins := lib64/traceevent/plugins/plugin_cfg80211.so
122installed_files_plugins += lib64/traceevent/plugins/plugin_scsi.so
123installed_files_plugins += lib64/traceevent/plugins/plugin_xen.so
124installed_files_plugins += lib64/traceevent/plugins/plugin_function.so
125installed_files_plugins += lib64/traceevent/plugins/plugin_sched_switch.so
126installed_files_plugins += lib64/traceevent/plugins/plugin_mac80211.so
127installed_files_plugins += lib64/traceevent/plugins/plugin_kvm.so
128installed_files_plugins += lib64/traceevent/plugins/plugin_kmem.so
129installed_files_plugins += lib64/traceevent/plugins/plugin_hrtimer.so
130installed_files_plugins += lib64/traceevent/plugins/plugin_jbd2.so
131
132installed_files_all := $(installed_files_bin)
133installed_files_all += $(installed_files_plugins)
134
135test_make_install := $(call test_dest_files,$(installed_files_all))
136test_make_install_O := $(call test_dest_files,$(installed_files_all))
137test_make_install_bin := $(call test_dest_files,$(installed_files_bin))
138test_make_install_bin_O := $(call test_dest_files,$(installed_files_bin))
Jiri Olsac0ec1102013-07-22 14:43:33 +0200139
Jiri Olsadbad4182013-07-22 14:43:34 +0200140# FIXME nothing gets installed
141test_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1
142test_make_install_man_O := $(test_make_install_man)
143
144# FIXME nothing gets installed
145test_make_install_doc := $(test_ok)
146test_make_install_doc_O := $(test_ok)
147
148# FIXME nothing gets installed
149test_make_install_html := $(test_ok)
150test_make_install_html_O := $(test_ok)
151
152# FIXME nothing gets installed
153test_make_install_info := $(test_ok)
154test_make_install_info_O := $(test_ok)
155
156# FIXME nothing gets installed
157test_make_install_pdf := $(test_ok)
158test_make_install_pdf_O := $(test_ok)
159
Jiri Olsa095ae692013-03-29 16:11:02 +0100160# Kbuild tests only
161#test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so
162#test_make_perf_o_O := test -f $$TMP/tools/perf/perf.o
163#test_make_util_map_o_O := test -f $$TMP/tools/perf/util/map.o
164
165test_make_perf_o_O := true
166test_make_util_map_o_O := true
167
168test_default = test -x $(PERF)/perf
169test = $(if $(test_$1),$(test_$1),$(test_default))
170
Jiri Olsa8ba7cde2013-07-22 14:43:31 +0200171test_default_O = test -x $$TMP_O/perf
Jiri Olsa095ae692013-03-29 16:11:02 +0100172test_O = $(if $(test_$1),$(test_$1),$(test_default_O))
173
174all:
175
176ifdef DEBUG
177d := $(info run $(run))
178d := $(info run_O $(run_O))
179endif
180
181MAKEFLAGS := --no-print-directory
182
183clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
184
185$(run):
186 $(call clean)
Jiri Olsac9311672013-07-22 14:43:32 +0200187 @TMP_DEST=$$(mktemp -d); \
188 cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100189 echo "- $@: $$cmd" && echo $$cmd > $@ && \
190 ( eval $$cmd ) >> $@ 2>&1; \
Jiri Olsaee4ad932013-12-19 14:41:59 +0100191 echo " test: $(call test,$@)" >> $@ 2>&1; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100192 $(call test,$@) && \
Jiri Olsac9311672013-07-22 14:43:32 +0200193 rm -f $@ \
194 rm -rf $$TMP_DEST
Jiri Olsa095ae692013-03-29 16:11:02 +0100195
196$(run_O):
197 $(call clean)
Jiri Olsa8ba7cde2013-07-22 14:43:31 +0200198 @TMP_O=$$(mktemp -d); \
Jiri Olsac9311672013-07-22 14:43:32 +0200199 TMP_DEST=$$(mktemp -d); \
200 cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100201 echo "- $@: $$cmd" && echo $$cmd > $@ && \
202 ( eval $$cmd ) >> $@ 2>&1 && \
Jiri Olsaee4ad932013-12-19 14:41:59 +0100203 echo " test: $(call test_O,$@)" >> $@ 2>&1; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100204 $(call test_O,$@) && \
205 rm -f $@ && \
Jiri Olsac9311672013-07-22 14:43:32 +0200206 rm -rf $$TMP_O \
207 rm -rf $$TMP_DEST
Jiri Olsa095ae692013-03-29 16:11:02 +0100208
209all: $(run) $(run_O)
210 @echo OK
211
212out: $(run_O)
213 @echo OK
214
215.PHONY: all $(run) $(run_O) clean