blob: 2d2495423be51d47038cceff6487a2da5d1b5ddc [file] [log] [blame]
Jiri Olsa095ae692013-03-29 16:11:02 +01001PERF := .
2MK := Makefile
3
Jiri Olsaf7c64472014-01-03 15:32:33 +01004include config/Makefile.arch
5
6# FIXME looks like x86 is the only arch running tests ;-)
7# we need some IS_(32/64) flag to make this generic
8ifeq ($(IS_X86_64),1)
9lib = lib64
10else
11lib = lib
12endif
13
Jiri Olsa0659e662013-07-22 14:43:30 +020014has = $(shell which $1 2>/dev/null)
15
Jiri Olsa095ae692013-03-29 16:11:02 +010016# standard single make variable specified
17make_clean_all := clean all
18make_python_perf_so := python/perf.so
19make_debug := DEBUG=1
20make_no_libperl := NO_LIBPERL=1
21make_no_libpython := NO_LIBPYTHON=1
22make_no_scripts := NO_LIBPYTHON=1 NO_LIBPERL=1
23make_no_newt := NO_NEWT=1
24make_no_slang := NO_SLANG=1
25make_no_gtk2 := NO_GTK2=1
26make_no_ui := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
27make_no_demangle := NO_DEMANGLE=1
28make_no_libelf := NO_LIBELF=1
29make_no_libunwind := NO_LIBUNWIND=1
30make_no_backtrace := NO_BACKTRACE=1
31make_no_libnuma := NO_LIBNUMA=1
32make_no_libaudit := NO_LIBAUDIT=1
33make_no_libbionic := NO_LIBBIONIC=1
34make_tags := tags
35make_cscope := cscope
36make_help := help
37make_doc := doc
Jiri Olsa2a94f6c2014-02-19 11:21:39 +010038make_perf_o := perf.o
39make_util_map_o := util/map.o
40make_util_pmu_bison_o := util/pmu-bison.o
Jiri Olsac0ec1102013-07-22 14:43:33 +020041make_install := install
42make_install_bin := install-bin
Jiri Olsadbad4182013-07-22 14:43:34 +020043make_install_doc := install-doc
44make_install_man := install-man
45make_install_html := install-html
46make_install_info := install-info
47make_install_pdf := install-pdf
Jiri Olsa095ae692013-03-29 16:11:02 +010048
49# all the NO_* variable combined
50make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
51make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
52make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
53
54# $(run) contains all available tests
55run := make_pure
56run += make_clean_all
57run += make_python_perf_so
58run += make_debug
59run += make_no_libperl
60run += make_no_libpython
61run += make_no_scripts
62run += make_no_newt
63run += make_no_slang
64run += make_no_gtk2
65run += make_no_ui
66run += make_no_demangle
67run += make_no_libelf
68run += make_no_libunwind
69run += make_no_backtrace
70run += make_no_libnuma
71run += make_no_libaudit
72run += make_no_libbionic
Jiri Olsa095ae692013-03-29 16:11:02 +010073run += make_help
74run += make_doc
75run += make_perf_o
76run += make_util_map_o
Jiri Olsa2a94f6c2014-02-19 11:21:39 +010077run += make_util_pmu_bison_o
Jiri Olsac0ec1102013-07-22 14:43:33 +020078run += make_install
79run += make_install_bin
Jiri Olsadbad4182013-07-22 14:43:34 +020080# FIXME 'install-*' commented out till they're fixed
81# run += make_install_doc
82# run += make_install_man
83# run += make_install_html
84# run += make_install_info
85# run += make_install_pdf
Jiri Olsa095ae692013-03-29 16:11:02 +010086run += make_minimal
87
Jiri Olsa0659e662013-07-22 14:43:30 +020088ifneq ($(call has,ctags),)
89run += make_tags
90endif
91ifneq ($(call has,cscope),)
92run += make_cscope
93endif
94
Jiri Olsa095ae692013-03-29 16:11:02 +010095# $(run_O) contains same portion of $(run) tests with '_O' attached
96# to distinguish O=... tests
97run_O := $(addsuffix _O,$(run))
98
99# disable some tests for O=...
100run_O := $(filter-out make_python_perf_so_O,$(run_O))
101
102# define test for each compile as 'test_NAME' variable
103# with the test itself as a value
104test_make_tags = test -f tags
105test_make_cscope = test -f cscope.out
106
107test_make_tags_O := $(test_make_tags)
108test_make_cscope_O := $(test_make_cscope)
109
110test_ok := true
111test_make_help := $(test_ok)
112test_make_doc := $(test_ok)
113test_make_help_O := $(test_ok)
114test_make_doc_O := $(test_ok)
115
116test_make_python_perf_so := test -f $(PERF)/python/perf.so
117
Jiri Olsa2a94f6c2014-02-19 11:21:39 +0100118test_make_perf_o := test -f $(PERF)/perf.o
119test_make_util_map_o := test -f $(PERF)/util/map.o
120test_make_util_pmu_bison_o := test -f $(PERF)/util/pmu-bison.o
Jiri Olsa095ae692013-03-29 16:11:02 +0100121
Jiri Olsaee4ad932013-12-19 14:41:59 +0100122define test_dest_files
123 for file in $(1); do \
124 if [ ! -x $$TMP_DEST/$$file ]; then \
125 echo " failed to find: $$file"; \
126 fi \
127 done
128endef
129
130installed_files_bin := bin/perf
131installed_files_bin += etc/bash_completion.d/perf
132installed_files_bin += libexec/perf-core/perf-archive
133
Jiri Olsaf7c64472014-01-03 15:32:33 +0100134installed_files_plugins := $(lib)/traceevent/plugins/plugin_cfg80211.so
135installed_files_plugins += $(lib)/traceevent/plugins/plugin_scsi.so
136installed_files_plugins += $(lib)/traceevent/plugins/plugin_xen.so
137installed_files_plugins += $(lib)/traceevent/plugins/plugin_function.so
138installed_files_plugins += $(lib)/traceevent/plugins/plugin_sched_switch.so
139installed_files_plugins += $(lib)/traceevent/plugins/plugin_mac80211.so
140installed_files_plugins += $(lib)/traceevent/plugins/plugin_kvm.so
141installed_files_plugins += $(lib)/traceevent/plugins/plugin_kmem.so
142installed_files_plugins += $(lib)/traceevent/plugins/plugin_hrtimer.so
143installed_files_plugins += $(lib)/traceevent/plugins/plugin_jbd2.so
Jiri Olsaee4ad932013-12-19 14:41:59 +0100144
145installed_files_all := $(installed_files_bin)
146installed_files_all += $(installed_files_plugins)
147
148test_make_install := $(call test_dest_files,$(installed_files_all))
149test_make_install_O := $(call test_dest_files,$(installed_files_all))
150test_make_install_bin := $(call test_dest_files,$(installed_files_bin))
151test_make_install_bin_O := $(call test_dest_files,$(installed_files_bin))
Jiri Olsac0ec1102013-07-22 14:43:33 +0200152
Jiri Olsadbad4182013-07-22 14:43:34 +0200153# FIXME nothing gets installed
154test_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1
155test_make_install_man_O := $(test_make_install_man)
156
157# FIXME nothing gets installed
158test_make_install_doc := $(test_ok)
159test_make_install_doc_O := $(test_ok)
160
161# FIXME nothing gets installed
162test_make_install_html := $(test_ok)
163test_make_install_html_O := $(test_ok)
164
165# FIXME nothing gets installed
166test_make_install_info := $(test_ok)
167test_make_install_info_O := $(test_ok)
168
169# FIXME nothing gets installed
170test_make_install_pdf := $(test_ok)
171test_make_install_pdf_O := $(test_ok)
172
Jiri Olsa04b01a12014-02-19 11:21:38 +0100173test_make_python_perf_so_O := test -f $$TMP_O/python/perf.so
174test_make_perf_o_O := test -f $$TMP_O/perf.o
175test_make_util_map_o_O := test -f $$TMP_O/util/map.o
Jiri Olsa2a94f6c2014-02-19 11:21:39 +0100176test_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o
Jiri Olsa095ae692013-03-29 16:11:02 +0100177
178test_default = test -x $(PERF)/perf
179test = $(if $(test_$1),$(test_$1),$(test_default))
180
Jiri Olsa8ba7cde2013-07-22 14:43:31 +0200181test_default_O = test -x $$TMP_O/perf
Jiri Olsa095ae692013-03-29 16:11:02 +0100182test_O = $(if $(test_$1),$(test_$1),$(test_default_O))
183
184all:
185
186ifdef DEBUG
187d := $(info run $(run))
188d := $(info run_O $(run_O))
189endif
190
191MAKEFLAGS := --no-print-directory
192
193clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
194
195$(run):
196 $(call clean)
Jiri Olsac9311672013-07-22 14:43:32 +0200197 @TMP_DEST=$$(mktemp -d); \
198 cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100199 echo "- $@: $$cmd" && echo $$cmd > $@ && \
200 ( eval $$cmd ) >> $@ 2>&1; \
Jiri Olsaee4ad932013-12-19 14:41:59 +0100201 echo " test: $(call test,$@)" >> $@ 2>&1; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100202 $(call test,$@) && \
Jiri Olsac9311672013-07-22 14:43:32 +0200203 rm -f $@ \
204 rm -rf $$TMP_DEST
Jiri Olsa095ae692013-03-29 16:11:02 +0100205
206$(run_O):
207 $(call clean)
Jiri Olsa8ba7cde2013-07-22 14:43:31 +0200208 @TMP_O=$$(mktemp -d); \
Jiri Olsac9311672013-07-22 14:43:32 +0200209 TMP_DEST=$$(mktemp -d); \
210 cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100211 echo "- $@: $$cmd" && echo $$cmd > $@ && \
212 ( eval $$cmd ) >> $@ 2>&1 && \
Jiri Olsaee4ad932013-12-19 14:41:59 +0100213 echo " test: $(call test_O,$@)" >> $@ 2>&1; \
Jiri Olsa095ae692013-03-29 16:11:02 +0100214 $(call test_O,$@) && \
215 rm -f $@ && \
Jiri Olsac9311672013-07-22 14:43:32 +0200216 rm -rf $$TMP_O \
217 rm -rf $$TMP_DEST
Jiri Olsa095ae692013-03-29 16:11:02 +0100218
Arnaldo Carvalho de Melo48878052014-01-10 16:46:45 -0300219tarpkg:
220 @cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \
221 echo "- $@: $$cmd" && echo $$cmd > $@ && \
222 ( eval $$cmd ) >> $@ 2>&1
223
224
225all: $(run) $(run_O) tarpkg
Jiri Olsa095ae692013-03-29 16:11:02 +0100226 @echo OK
227
228out: $(run_O)
229 @echo OK
230
Arnaldo Carvalho de Melo48878052014-01-10 16:46:45 -0300231.PHONY: all $(run) $(run_O) tarpkg clean