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 30*c0ec1108SJiri Olsamake_install := install 31*c0ec1108SJiri Olsamake_install_bin := install-bin 32095ae69bSJiri Olsa 33095ae69bSJiri Olsa# all the NO_* variable combined 34095ae69bSJiri Olsamake_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 35095ae69bSJiri Olsamake_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 36095ae69bSJiri Olsamake_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 37095ae69bSJiri Olsa 38095ae69bSJiri Olsa# $(run) contains all available tests 39095ae69bSJiri Olsarun := make_pure 40095ae69bSJiri Olsarun += make_clean_all 41095ae69bSJiri Olsarun += make_python_perf_so 42095ae69bSJiri Olsarun += make_debug 43095ae69bSJiri Olsarun += make_no_libperl 44095ae69bSJiri Olsarun += make_no_libpython 45095ae69bSJiri Olsarun += make_no_scripts 46095ae69bSJiri Olsarun += make_no_newt 47095ae69bSJiri Olsarun += make_no_slang 48095ae69bSJiri Olsarun += make_no_gtk2 49095ae69bSJiri Olsarun += make_no_ui 50095ae69bSJiri Olsarun += make_no_demangle 51095ae69bSJiri Olsarun += make_no_libelf 52095ae69bSJiri Olsarun += make_no_libunwind 53095ae69bSJiri Olsarun += make_no_backtrace 54095ae69bSJiri Olsarun += make_no_libnuma 55095ae69bSJiri Olsarun += make_no_libaudit 56095ae69bSJiri Olsarun += make_no_libbionic 57095ae69bSJiri Olsarun += make_help 58095ae69bSJiri Olsarun += make_doc 59095ae69bSJiri Olsarun += make_perf_o 60095ae69bSJiri Olsarun += make_util_map_o 61*c0ec1108SJiri Olsarun += make_install 62*c0ec1108SJiri Olsarun += make_install_bin 63095ae69bSJiri Olsarun += make_minimal 64095ae69bSJiri Olsa 650659e669SJiri Olsaifneq ($(call has,ctags),) 660659e669SJiri Olsarun += make_tags 670659e669SJiri Olsaendif 680659e669SJiri Olsaifneq ($(call has,cscope),) 690659e669SJiri Olsarun += make_cscope 700659e669SJiri Olsaendif 710659e669SJiri Olsa 72095ae69bSJiri Olsa# $(run_O) contains same portion of $(run) tests with '_O' attached 73095ae69bSJiri Olsa# to distinguish O=... tests 74095ae69bSJiri Olsarun_O := $(addsuffix _O,$(run)) 75095ae69bSJiri Olsa 76095ae69bSJiri Olsa# disable some tests for O=... 77095ae69bSJiri Olsarun_O := $(filter-out make_python_perf_so_O,$(run_O)) 78095ae69bSJiri Olsa 79095ae69bSJiri Olsa# define test for each compile as 'test_NAME' variable 80095ae69bSJiri Olsa# with the test itself as a value 81095ae69bSJiri Olsatest_make_tags = test -f tags 82095ae69bSJiri Olsatest_make_cscope = test -f cscope.out 83095ae69bSJiri Olsa 84095ae69bSJiri Olsatest_make_tags_O := $(test_make_tags) 85095ae69bSJiri Olsatest_make_cscope_O := $(test_make_cscope) 86095ae69bSJiri Olsa 87095ae69bSJiri Olsatest_ok := true 88095ae69bSJiri Olsatest_make_help := $(test_ok) 89095ae69bSJiri Olsatest_make_doc := $(test_ok) 90095ae69bSJiri Olsatest_make_help_O := $(test_ok) 91095ae69bSJiri Olsatest_make_doc_O := $(test_ok) 92095ae69bSJiri Olsa 93095ae69bSJiri Olsatest_make_python_perf_so := test -f $(PERF)/python/perf.so 94095ae69bSJiri Olsa 95095ae69bSJiri Olsatest_make_perf_o := test -f $(PERF)/perf.o 96095ae69bSJiri Olsatest_make_util_map_o := test -f $(PERF)/util/map.o 97095ae69bSJiri Olsa 98*c0ec1108SJiri Olsatest_make_install := test -x $$TMP_DEST/bin/perf 99*c0ec1108SJiri Olsatest_make_install_O := $(test_make_install) 100*c0ec1108SJiri Olsatest_make_install_bin := $(test_make_install) 101*c0ec1108SJiri Olsatest_make_install_bin_O := $(test_make_install) 102*c0ec1108SJiri Olsa 103095ae69bSJiri Olsa# Kbuild tests only 104095ae69bSJiri Olsa#test_make_python_perf_so_O := test -f $$TMP/tools/perf/python/perf.so 105095ae69bSJiri Olsa#test_make_perf_o_O := test -f $$TMP/tools/perf/perf.o 106095ae69bSJiri Olsa#test_make_util_map_o_O := test -f $$TMP/tools/perf/util/map.o 107095ae69bSJiri Olsa 108095ae69bSJiri Olsatest_make_perf_o_O := true 109095ae69bSJiri Olsatest_make_util_map_o_O := true 110095ae69bSJiri Olsa 111095ae69bSJiri Olsatest_default = test -x $(PERF)/perf 112095ae69bSJiri Olsatest = $(if $(test_$1),$(test_$1),$(test_default)) 113095ae69bSJiri Olsa 1148ba7cdeaSJiri Olsatest_default_O = test -x $$TMP_O/perf 115095ae69bSJiri Olsatest_O = $(if $(test_$1),$(test_$1),$(test_default_O)) 116095ae69bSJiri Olsa 117095ae69bSJiri Olsaall: 118095ae69bSJiri Olsa 119095ae69bSJiri Olsaifdef DEBUG 120095ae69bSJiri Olsad := $(info run $(run)) 121095ae69bSJiri Olsad := $(info run_O $(run_O)) 122095ae69bSJiri Olsaendif 123095ae69bSJiri Olsa 124095ae69bSJiri OlsaMAKEFLAGS := --no-print-directory 125095ae69bSJiri Olsa 126095ae69bSJiri Olsaclean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null) 127095ae69bSJiri Olsa 128095ae69bSJiri Olsa$(run): 129095ae69bSJiri Olsa $(call clean) 130c9311674SJiri Olsa @TMP_DEST=$$(mktemp -d); \ 131c9311674SJiri Olsa cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \ 132095ae69bSJiri Olsa echo "- $@: $$cmd" && echo $$cmd > $@ && \ 133095ae69bSJiri Olsa ( eval $$cmd ) >> $@ 2>&1; \ 134095ae69bSJiri Olsa echo " test: $(call test,$@)"; \ 135095ae69bSJiri Olsa $(call test,$@) && \ 136c9311674SJiri Olsa rm -f $@ \ 137c9311674SJiri Olsa rm -rf $$TMP_DEST 138095ae69bSJiri Olsa 139095ae69bSJiri Olsa$(run_O): 140095ae69bSJiri Olsa $(call clean) 1418ba7cdeaSJiri Olsa @TMP_O=$$(mktemp -d); \ 142c9311674SJiri Olsa TMP_DEST=$$(mktemp -d); \ 143c9311674SJiri Olsa cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \ 144095ae69bSJiri Olsa echo "- $@: $$cmd" && echo $$cmd > $@ && \ 145095ae69bSJiri Olsa ( eval $$cmd ) >> $@ 2>&1 && \ 146095ae69bSJiri Olsa echo " test: $(call test_O,$@)"; \ 147095ae69bSJiri Olsa $(call test_O,$@) && \ 148095ae69bSJiri Olsa rm -f $@ && \ 149c9311674SJiri Olsa rm -rf $$TMP_O \ 150c9311674SJiri Olsa rm -rf $$TMP_DEST 151095ae69bSJiri Olsa 152095ae69bSJiri Olsaall: $(run) $(run_O) 153095ae69bSJiri Olsa @echo OK 154095ae69bSJiri Olsa 155095ae69bSJiri Olsaout: $(run_O) 156095ae69bSJiri Olsa @echo OK 157095ae69bSJiri Olsa 158095ae69bSJiri Olsa.PHONY: all $(run) $(run_O) clean 159