1095ae69bSJiri OlsaPERF := . 2095ae69bSJiri OlsaMK := Makefile 3095ae69bSJiri Olsa 40659e669SJiri Olsahas = $(shell which $1 2>/dev/null) 50659e669SJiri Olsa 6095ae69bSJiri Olsa# standard single make variable specified 7095ae69bSJiri Olsamake_clean_all := clean all 8095ae69bSJiri Olsamake_python_perf_so := python/perf.so 9095ae69bSJiri Olsamake_debug := DEBUG=1 10095ae69bSJiri Olsamake_no_libperl := NO_LIBPERL=1 11095ae69bSJiri Olsamake_no_libpython := NO_LIBPYTHON=1 12095ae69bSJiri Olsamake_no_scripts := NO_LIBPYTHON=1 NO_LIBPERL=1 13095ae69bSJiri Olsamake_no_newt := NO_NEWT=1 14095ae69bSJiri Olsamake_no_slang := NO_SLANG=1 15095ae69bSJiri Olsamake_no_gtk2 := NO_GTK2=1 16095ae69bSJiri Olsamake_no_ui := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1 17095ae69bSJiri Olsamake_no_demangle := NO_DEMANGLE=1 18095ae69bSJiri Olsamake_no_libelf := NO_LIBELF=1 19095ae69bSJiri Olsamake_no_libunwind := NO_LIBUNWIND=1 20095ae69bSJiri Olsamake_no_backtrace := NO_BACKTRACE=1 21095ae69bSJiri Olsamake_no_libnuma := NO_LIBNUMA=1 22095ae69bSJiri Olsamake_no_libaudit := NO_LIBAUDIT=1 23095ae69bSJiri Olsamake_no_libbionic := NO_LIBBIONIC=1 24095ae69bSJiri Olsamake_tags := tags 25095ae69bSJiri Olsamake_cscope := cscope 26095ae69bSJiri Olsamake_help := help 27095ae69bSJiri Olsamake_doc := doc 28095ae69bSJiri Olsamake_perf_o := perf.o 29095ae69bSJiri Olsamake_util_map_o := util/map.o 30c0ec1108SJiri Olsamake_install := install 31c0ec1108SJiri Olsamake_install_bin := install-bin 32dbad4189SJiri Olsamake_install_doc := install-doc 33dbad4189SJiri Olsamake_install_man := install-man 34dbad4189SJiri Olsamake_install_html := install-html 35dbad4189SJiri Olsamake_install_info := install-info 36dbad4189SJiri Olsamake_install_pdf := install-pdf 37095ae69bSJiri Olsa 38095ae69bSJiri Olsa# all the NO_* variable combined 39095ae69bSJiri Olsamake_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 40095ae69bSJiri Olsamake_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 41095ae69bSJiri Olsamake_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 42095ae69bSJiri Olsa 43095ae69bSJiri Olsa# $(run) contains all available tests 44095ae69bSJiri Olsarun := make_pure 45095ae69bSJiri Olsarun += make_clean_all 46095ae69bSJiri Olsarun += make_python_perf_so 47095ae69bSJiri Olsarun += make_debug 48095ae69bSJiri Olsarun += make_no_libperl 49095ae69bSJiri Olsarun += make_no_libpython 50095ae69bSJiri Olsarun += make_no_scripts 51095ae69bSJiri Olsarun += make_no_newt 52095ae69bSJiri Olsarun += make_no_slang 53095ae69bSJiri Olsarun += make_no_gtk2 54095ae69bSJiri Olsarun += make_no_ui 55095ae69bSJiri Olsarun += make_no_demangle 56095ae69bSJiri Olsarun += make_no_libelf 57095ae69bSJiri Olsarun += make_no_libunwind 58095ae69bSJiri Olsarun += make_no_backtrace 59095ae69bSJiri Olsarun += make_no_libnuma 60095ae69bSJiri Olsarun += make_no_libaudit 61095ae69bSJiri Olsarun += make_no_libbionic 62095ae69bSJiri Olsarun += make_help 63095ae69bSJiri Olsarun += make_doc 64095ae69bSJiri Olsarun += make_perf_o 65095ae69bSJiri Olsarun += make_util_map_o 66c0ec1108SJiri Olsarun += make_install 67c0ec1108SJiri Olsarun += make_install_bin 68dbad4189SJiri Olsa# FIXME 'install-*' commented out till they're fixed 69dbad4189SJiri Olsa# run += make_install_doc 70dbad4189SJiri Olsa# run += make_install_man 71dbad4189SJiri Olsa# run += make_install_html 72dbad4189SJiri Olsa# run += make_install_info 73dbad4189SJiri Olsa# run += make_install_pdf 74095ae69bSJiri Olsarun += make_minimal 75095ae69bSJiri Olsa 760659e669SJiri Olsaifneq ($(call has,ctags),) 770659e669SJiri Olsarun += make_tags 780659e669SJiri Olsaendif 790659e669SJiri Olsaifneq ($(call has,cscope),) 800659e669SJiri Olsarun += make_cscope 810659e669SJiri Olsaendif 820659e669SJiri Olsa 83095ae69bSJiri Olsa# $(run_O) contains same portion of $(run) tests with '_O' attached 84095ae69bSJiri Olsa# to distinguish O=... tests 85095ae69bSJiri Olsarun_O := $(addsuffix _O,$(run)) 86095ae69bSJiri Olsa 87095ae69bSJiri Olsa# disable some tests for O=... 88095ae69bSJiri Olsarun_O := $(filter-out make_python_perf_so_O,$(run_O)) 89095ae69bSJiri Olsa 90095ae69bSJiri Olsa# define test for each compile as 'test_NAME' variable 91095ae69bSJiri Olsa# with the test itself as a value 92095ae69bSJiri Olsatest_make_tags = test -f tags 93095ae69bSJiri Olsatest_make_cscope = test -f cscope.out 94095ae69bSJiri Olsa 95095ae69bSJiri Olsatest_make_tags_O := $(test_make_tags) 96095ae69bSJiri Olsatest_make_cscope_O := $(test_make_cscope) 97095ae69bSJiri Olsa 98095ae69bSJiri Olsatest_ok := true 99095ae69bSJiri Olsatest_make_help := $(test_ok) 100095ae69bSJiri Olsatest_make_doc := $(test_ok) 101095ae69bSJiri Olsatest_make_help_O := $(test_ok) 102095ae69bSJiri Olsatest_make_doc_O := $(test_ok) 103095ae69bSJiri Olsa 104095ae69bSJiri Olsatest_make_python_perf_so := test -f $(PERF)/python/perf.so 105095ae69bSJiri Olsa 106095ae69bSJiri Olsatest_make_perf_o := test -f $(PERF)/perf.o 107095ae69bSJiri Olsatest_make_util_map_o := test -f $(PERF)/util/map.o 108095ae69bSJiri Olsa 109*ee4ad93eSJiri Olsadefine test_dest_files 110*ee4ad93eSJiri Olsa for file in $(1); do \ 111*ee4ad93eSJiri Olsa if [ ! -x $$TMP_DEST/$$file ]; then \ 112*ee4ad93eSJiri Olsa echo " failed to find: $$file"; \ 113*ee4ad93eSJiri Olsa fi \ 114*ee4ad93eSJiri Olsa done 115*ee4ad93eSJiri Olsaendef 116*ee4ad93eSJiri Olsa 117*ee4ad93eSJiri Olsainstalled_files_bin := bin/perf 118*ee4ad93eSJiri Olsainstalled_files_bin += etc/bash_completion.d/perf 119*ee4ad93eSJiri Olsainstalled_files_bin += libexec/perf-core/perf-archive 120*ee4ad93eSJiri Olsa 121*ee4ad93eSJiri Olsainstalled_files_plugins := lib64/traceevent/plugins/plugin_cfg80211.so 122*ee4ad93eSJiri Olsainstalled_files_plugins += lib64/traceevent/plugins/plugin_scsi.so 123*ee4ad93eSJiri Olsainstalled_files_plugins += lib64/traceevent/plugins/plugin_xen.so 124*ee4ad93eSJiri Olsainstalled_files_plugins += lib64/traceevent/plugins/plugin_function.so 125*ee4ad93eSJiri Olsainstalled_files_plugins += lib64/traceevent/plugins/plugin_sched_switch.so 126*ee4ad93eSJiri Olsainstalled_files_plugins += lib64/traceevent/plugins/plugin_mac80211.so 127*ee4ad93eSJiri Olsainstalled_files_plugins += lib64/traceevent/plugins/plugin_kvm.so 128*ee4ad93eSJiri Olsainstalled_files_plugins += lib64/traceevent/plugins/plugin_kmem.so 129*ee4ad93eSJiri Olsainstalled_files_plugins += lib64/traceevent/plugins/plugin_hrtimer.so 130*ee4ad93eSJiri Olsainstalled_files_plugins += lib64/traceevent/plugins/plugin_jbd2.so 131*ee4ad93eSJiri Olsa 132*ee4ad93eSJiri Olsainstalled_files_all := $(installed_files_bin) 133*ee4ad93eSJiri Olsainstalled_files_all += $(installed_files_plugins) 134*ee4ad93eSJiri Olsa 135*ee4ad93eSJiri Olsatest_make_install := $(call test_dest_files,$(installed_files_all)) 136*ee4ad93eSJiri Olsatest_make_install_O := $(call test_dest_files,$(installed_files_all)) 137*ee4ad93eSJiri Olsatest_make_install_bin := $(call test_dest_files,$(installed_files_bin)) 138*ee4ad93eSJiri Olsatest_make_install_bin_O := $(call test_dest_files,$(installed_files_bin)) 139c0ec1108SJiri Olsa 140dbad4189SJiri Olsa# FIXME nothing gets installed 141dbad4189SJiri Olsatest_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1 142dbad4189SJiri Olsatest_make_install_man_O := $(test_make_install_man) 143dbad4189SJiri Olsa 144dbad4189SJiri Olsa# FIXME nothing gets installed 145dbad4189SJiri Olsatest_make_install_doc := $(test_ok) 146dbad4189SJiri Olsatest_make_install_doc_O := $(test_ok) 147dbad4189SJiri Olsa 148dbad4189SJiri Olsa# FIXME nothing gets installed 149dbad4189SJiri Olsatest_make_install_html := $(test_ok) 150dbad4189SJiri Olsatest_make_install_html_O := $(test_ok) 151dbad4189SJiri Olsa 152dbad4189SJiri Olsa# FIXME nothing gets installed 153dbad4189SJiri Olsatest_make_install_info := $(test_ok) 154dbad4189SJiri Olsatest_make_install_info_O := $(test_ok) 155dbad4189SJiri Olsa 156dbad4189SJiri Olsa# FIXME nothing gets installed 157dbad4189SJiri Olsatest_make_install_pdf := $(test_ok) 158dbad4189SJiri Olsatest_make_install_pdf_O := $(test_ok) 159dbad4189SJiri Olsa 160095ae69bSJiri Olsa# Kbuild tests only 161095ae69bSJiri Olsa#test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so 162095ae69bSJiri Olsa#test_make_perf_o_O := test -f $$TMP/tools/perf/perf.o 163095ae69bSJiri Olsa#test_make_util_map_o_O := test -f $$TMP/tools/perf/util/map.o 164095ae69bSJiri Olsa 165095ae69bSJiri Olsatest_make_perf_o_O := true 166095ae69bSJiri Olsatest_make_util_map_o_O := true 167095ae69bSJiri Olsa 168095ae69bSJiri Olsatest_default = test -x $(PERF)/perf 169095ae69bSJiri Olsatest = $(if $(test_$1),$(test_$1),$(test_default)) 170095ae69bSJiri Olsa 1718ba7cdeaSJiri Olsatest_default_O = test -x $$TMP_O/perf 172095ae69bSJiri Olsatest_O = $(if $(test_$1),$(test_$1),$(test_default_O)) 173095ae69bSJiri Olsa 174095ae69bSJiri Olsaall: 175095ae69bSJiri Olsa 176095ae69bSJiri Olsaifdef DEBUG 177095ae69bSJiri Olsad := $(info run $(run)) 178095ae69bSJiri Olsad := $(info run_O $(run_O)) 179095ae69bSJiri Olsaendif 180095ae69bSJiri Olsa 181095ae69bSJiri OlsaMAKEFLAGS := --no-print-directory 182095ae69bSJiri Olsa 183095ae69bSJiri Olsaclean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null) 184095ae69bSJiri Olsa 185095ae69bSJiri Olsa$(run): 186095ae69bSJiri Olsa $(call clean) 187c9311674SJiri Olsa @TMP_DEST=$$(mktemp -d); \ 188c9311674SJiri Olsa cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \ 189095ae69bSJiri Olsa echo "- $@: $$cmd" && echo $$cmd > $@ && \ 190095ae69bSJiri Olsa ( eval $$cmd ) >> $@ 2>&1; \ 191*ee4ad93eSJiri Olsa echo " test: $(call test,$@)" >> $@ 2>&1; \ 192095ae69bSJiri Olsa $(call test,$@) && \ 193c9311674SJiri Olsa rm -f $@ \ 194c9311674SJiri Olsa rm -rf $$TMP_DEST 195095ae69bSJiri Olsa 196095ae69bSJiri Olsa$(run_O): 197095ae69bSJiri Olsa $(call clean) 1988ba7cdeaSJiri Olsa @TMP_O=$$(mktemp -d); \ 199c9311674SJiri Olsa TMP_DEST=$$(mktemp -d); \ 200c9311674SJiri Olsa cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \ 201095ae69bSJiri Olsa echo "- $@: $$cmd" && echo $$cmd > $@ && \ 202095ae69bSJiri Olsa ( eval $$cmd ) >> $@ 2>&1 && \ 203*ee4ad93eSJiri Olsa echo " test: $(call test_O,$@)" >> $@ 2>&1; \ 204095ae69bSJiri Olsa $(call test_O,$@) && \ 205095ae69bSJiri Olsa rm -f $@ && \ 206c9311674SJiri Olsa rm -rf $$TMP_O \ 207c9311674SJiri Olsa rm -rf $$TMP_DEST 208095ae69bSJiri Olsa 209095ae69bSJiri Olsaall: $(run) $(run_O) 210095ae69bSJiri Olsa @echo OK 211095ae69bSJiri Olsa 212095ae69bSJiri Olsaout: $(run_O) 213095ae69bSJiri Olsa @echo OK 214095ae69bSJiri Olsa 215095ae69bSJiri Olsa.PHONY: all $(run) $(run_O) clean 216