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