Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 1 | PERF := . |
| 2 | MK := Makefile |
| 3 | |
Jiri Olsa | f7c6447 | 2014-01-03 15:32:33 +0100 | [diff] [blame^] | 4 | include 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 |
| 8 | ifeq ($(IS_X86_64),1) |
| 9 | lib = lib64 |
| 10 | else |
| 11 | lib = lib |
| 12 | endif |
| 13 | |
Jiri Olsa | 0659e66 | 2013-07-22 14:43:30 +0200 | [diff] [blame] | 14 | has = $(shell which $1 2>/dev/null) |
| 15 | |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 16 | # standard single make variable specified |
| 17 | make_clean_all := clean all |
| 18 | make_python_perf_so := python/perf.so |
| 19 | make_debug := DEBUG=1 |
| 20 | make_no_libperl := NO_LIBPERL=1 |
| 21 | make_no_libpython := NO_LIBPYTHON=1 |
| 22 | make_no_scripts := NO_LIBPYTHON=1 NO_LIBPERL=1 |
| 23 | make_no_newt := NO_NEWT=1 |
| 24 | make_no_slang := NO_SLANG=1 |
| 25 | make_no_gtk2 := NO_GTK2=1 |
| 26 | make_no_ui := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1 |
| 27 | make_no_demangle := NO_DEMANGLE=1 |
| 28 | make_no_libelf := NO_LIBELF=1 |
| 29 | make_no_libunwind := NO_LIBUNWIND=1 |
| 30 | make_no_backtrace := NO_BACKTRACE=1 |
| 31 | make_no_libnuma := NO_LIBNUMA=1 |
| 32 | make_no_libaudit := NO_LIBAUDIT=1 |
| 33 | make_no_libbionic := NO_LIBBIONIC=1 |
| 34 | make_tags := tags |
| 35 | make_cscope := cscope |
| 36 | make_help := help |
| 37 | make_doc := doc |
| 38 | make_perf_o := perf.o |
| 39 | make_util_map_o := util/map.o |
Jiri Olsa | c0ec110 | 2013-07-22 14:43:33 +0200 | [diff] [blame] | 40 | make_install := install |
| 41 | make_install_bin := install-bin |
Jiri Olsa | dbad418 | 2013-07-22 14:43:34 +0200 | [diff] [blame] | 42 | make_install_doc := install-doc |
| 43 | make_install_man := install-man |
| 44 | make_install_html := install-html |
| 45 | make_install_info := install-info |
| 46 | make_install_pdf := install-pdf |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 47 | |
| 48 | # all the NO_* variable combined |
| 49 | make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 |
| 50 | make_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 |
| 51 | make_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 |
| 52 | |
| 53 | # $(run) contains all available tests |
| 54 | run := make_pure |
| 55 | run += make_clean_all |
| 56 | run += make_python_perf_so |
| 57 | run += make_debug |
| 58 | run += make_no_libperl |
| 59 | run += make_no_libpython |
| 60 | run += make_no_scripts |
| 61 | run += make_no_newt |
| 62 | run += make_no_slang |
| 63 | run += make_no_gtk2 |
| 64 | run += make_no_ui |
| 65 | run += make_no_demangle |
| 66 | run += make_no_libelf |
| 67 | run += make_no_libunwind |
| 68 | run += make_no_backtrace |
| 69 | run += make_no_libnuma |
| 70 | run += make_no_libaudit |
| 71 | run += make_no_libbionic |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 72 | run += make_help |
| 73 | run += make_doc |
| 74 | run += make_perf_o |
| 75 | run += make_util_map_o |
Jiri Olsa | c0ec110 | 2013-07-22 14:43:33 +0200 | [diff] [blame] | 76 | run += make_install |
| 77 | run += make_install_bin |
Jiri Olsa | dbad418 | 2013-07-22 14:43:34 +0200 | [diff] [blame] | 78 | # FIXME 'install-*' commented out till they're fixed |
| 79 | # run += make_install_doc |
| 80 | # run += make_install_man |
| 81 | # run += make_install_html |
| 82 | # run += make_install_info |
| 83 | # run += make_install_pdf |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 84 | run += make_minimal |
| 85 | |
Jiri Olsa | 0659e66 | 2013-07-22 14:43:30 +0200 | [diff] [blame] | 86 | ifneq ($(call has,ctags),) |
| 87 | run += make_tags |
| 88 | endif |
| 89 | ifneq ($(call has,cscope),) |
| 90 | run += make_cscope |
| 91 | endif |
| 92 | |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 93 | # $(run_O) contains same portion of $(run) tests with '_O' attached |
| 94 | # to distinguish O=... tests |
| 95 | run_O := $(addsuffix _O,$(run)) |
| 96 | |
| 97 | # disable some tests for O=... |
| 98 | run_O := $(filter-out make_python_perf_so_O,$(run_O)) |
| 99 | |
| 100 | # define test for each compile as 'test_NAME' variable |
| 101 | # with the test itself as a value |
| 102 | test_make_tags = test -f tags |
| 103 | test_make_cscope = test -f cscope.out |
| 104 | |
| 105 | test_make_tags_O := $(test_make_tags) |
| 106 | test_make_cscope_O := $(test_make_cscope) |
| 107 | |
| 108 | test_ok := true |
| 109 | test_make_help := $(test_ok) |
| 110 | test_make_doc := $(test_ok) |
| 111 | test_make_help_O := $(test_ok) |
| 112 | test_make_doc_O := $(test_ok) |
| 113 | |
| 114 | test_make_python_perf_so := test -f $(PERF)/python/perf.so |
| 115 | |
| 116 | test_make_perf_o := test -f $(PERF)/perf.o |
| 117 | test_make_util_map_o := test -f $(PERF)/util/map.o |
| 118 | |
Jiri Olsa | ee4ad93 | 2013-12-19 14:41:59 +0100 | [diff] [blame] | 119 | define test_dest_files |
| 120 | for file in $(1); do \ |
| 121 | if [ ! -x $$TMP_DEST/$$file ]; then \ |
| 122 | echo " failed to find: $$file"; \ |
| 123 | fi \ |
| 124 | done |
| 125 | endef |
| 126 | |
| 127 | installed_files_bin := bin/perf |
| 128 | installed_files_bin += etc/bash_completion.d/perf |
| 129 | installed_files_bin += libexec/perf-core/perf-archive |
| 130 | |
Jiri Olsa | f7c6447 | 2014-01-03 15:32:33 +0100 | [diff] [blame^] | 131 | installed_files_plugins := $(lib)/traceevent/plugins/plugin_cfg80211.so |
| 132 | installed_files_plugins += $(lib)/traceevent/plugins/plugin_scsi.so |
| 133 | installed_files_plugins += $(lib)/traceevent/plugins/plugin_xen.so |
| 134 | installed_files_plugins += $(lib)/traceevent/plugins/plugin_function.so |
| 135 | installed_files_plugins += $(lib)/traceevent/plugins/plugin_sched_switch.so |
| 136 | installed_files_plugins += $(lib)/traceevent/plugins/plugin_mac80211.so |
| 137 | installed_files_plugins += $(lib)/traceevent/plugins/plugin_kvm.so |
| 138 | installed_files_plugins += $(lib)/traceevent/plugins/plugin_kmem.so |
| 139 | installed_files_plugins += $(lib)/traceevent/plugins/plugin_hrtimer.so |
| 140 | installed_files_plugins += $(lib)/traceevent/plugins/plugin_jbd2.so |
Jiri Olsa | ee4ad93 | 2013-12-19 14:41:59 +0100 | [diff] [blame] | 141 | |
| 142 | installed_files_all := $(installed_files_bin) |
| 143 | installed_files_all += $(installed_files_plugins) |
| 144 | |
| 145 | test_make_install := $(call test_dest_files,$(installed_files_all)) |
| 146 | test_make_install_O := $(call test_dest_files,$(installed_files_all)) |
| 147 | test_make_install_bin := $(call test_dest_files,$(installed_files_bin)) |
| 148 | test_make_install_bin_O := $(call test_dest_files,$(installed_files_bin)) |
Jiri Olsa | c0ec110 | 2013-07-22 14:43:33 +0200 | [diff] [blame] | 149 | |
Jiri Olsa | dbad418 | 2013-07-22 14:43:34 +0200 | [diff] [blame] | 150 | # FIXME nothing gets installed |
| 151 | test_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1 |
| 152 | test_make_install_man_O := $(test_make_install_man) |
| 153 | |
| 154 | # FIXME nothing gets installed |
| 155 | test_make_install_doc := $(test_ok) |
| 156 | test_make_install_doc_O := $(test_ok) |
| 157 | |
| 158 | # FIXME nothing gets installed |
| 159 | test_make_install_html := $(test_ok) |
| 160 | test_make_install_html_O := $(test_ok) |
| 161 | |
| 162 | # FIXME nothing gets installed |
| 163 | test_make_install_info := $(test_ok) |
| 164 | test_make_install_info_O := $(test_ok) |
| 165 | |
| 166 | # FIXME nothing gets installed |
| 167 | test_make_install_pdf := $(test_ok) |
| 168 | test_make_install_pdf_O := $(test_ok) |
| 169 | |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 170 | # Kbuild tests only |
| 171 | #test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so |
| 172 | #test_make_perf_o_O := test -f $$TMP/tools/perf/perf.o |
| 173 | #test_make_util_map_o_O := test -f $$TMP/tools/perf/util/map.o |
| 174 | |
| 175 | test_make_perf_o_O := true |
| 176 | test_make_util_map_o_O := true |
| 177 | |
| 178 | test_default = test -x $(PERF)/perf |
| 179 | test = $(if $(test_$1),$(test_$1),$(test_default)) |
| 180 | |
Jiri Olsa | 8ba7cde | 2013-07-22 14:43:31 +0200 | [diff] [blame] | 181 | test_default_O = test -x $$TMP_O/perf |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 182 | test_O = $(if $(test_$1),$(test_$1),$(test_default_O)) |
| 183 | |
| 184 | all: |
| 185 | |
| 186 | ifdef DEBUG |
| 187 | d := $(info run $(run)) |
| 188 | d := $(info run_O $(run_O)) |
| 189 | endif |
| 190 | |
| 191 | MAKEFLAGS := --no-print-directory |
| 192 | |
| 193 | clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null) |
| 194 | |
| 195 | $(run): |
| 196 | $(call clean) |
Jiri Olsa | c931167 | 2013-07-22 14:43:32 +0200 | [diff] [blame] | 197 | @TMP_DEST=$$(mktemp -d); \ |
| 198 | cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \ |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 199 | echo "- $@: $$cmd" && echo $$cmd > $@ && \ |
| 200 | ( eval $$cmd ) >> $@ 2>&1; \ |
Jiri Olsa | ee4ad93 | 2013-12-19 14:41:59 +0100 | [diff] [blame] | 201 | echo " test: $(call test,$@)" >> $@ 2>&1; \ |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 202 | $(call test,$@) && \ |
Jiri Olsa | c931167 | 2013-07-22 14:43:32 +0200 | [diff] [blame] | 203 | rm -f $@ \ |
| 204 | rm -rf $$TMP_DEST |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 205 | |
| 206 | $(run_O): |
| 207 | $(call clean) |
Jiri Olsa | 8ba7cde | 2013-07-22 14:43:31 +0200 | [diff] [blame] | 208 | @TMP_O=$$(mktemp -d); \ |
Jiri Olsa | c931167 | 2013-07-22 14:43:32 +0200 | [diff] [blame] | 209 | TMP_DEST=$$(mktemp -d); \ |
| 210 | cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \ |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 211 | echo "- $@: $$cmd" && echo $$cmd > $@ && \ |
| 212 | ( eval $$cmd ) >> $@ 2>&1 && \ |
Jiri Olsa | ee4ad93 | 2013-12-19 14:41:59 +0100 | [diff] [blame] | 213 | echo " test: $(call test_O,$@)" >> $@ 2>&1; \ |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 214 | $(call test_O,$@) && \ |
| 215 | rm -f $@ && \ |
Jiri Olsa | c931167 | 2013-07-22 14:43:32 +0200 | [diff] [blame] | 216 | rm -rf $$TMP_O \ |
| 217 | rm -rf $$TMP_DEST |
Jiri Olsa | 095ae69 | 2013-03-29 16:11:02 +0100 | [diff] [blame] | 218 | |
| 219 | all: $(run) $(run_O) |
| 220 | @echo OK |
| 221 | |
| 222 | out: $(run_O) |
| 223 | @echo OK |
| 224 | |
| 225 | .PHONY: all $(run) $(run_O) clean |