1502819c5SJiri Olsaifndef MK 2502819c5SJiri Olsaifeq ($(MAKECMDGOALS),) 3502819c5SJiri Olsa# no target specified, trigger the whole suite 4502819c5SJiri Olsaall: 5502819c5SJiri Olsa @echo "Testing Makefile"; $(MAKE) -sf tests/make MK=Makefile 6502819c5SJiri Olsa @echo "Testing Makefile.perf"; $(MAKE) -sf tests/make MK=Makefile.perf 7502819c5SJiri Olsaelse 8502819c5SJiri Olsa# run only specific test over 'Makefile' 9502819c5SJiri Olsa%: 10502819c5SJiri Olsa @echo "Testing Makefile"; $(MAKE) -sf tests/make MK=Makefile $@ 11502819c5SJiri Olsaendif 12502819c5SJiri Olsaelse 13095ae69bSJiri OlsaPERF := . 14095ae69bSJiri Olsa 15f7c64474SJiri Olsainclude config/Makefile.arch 16f7c64474SJiri Olsa 17f7c64474SJiri Olsa# FIXME looks like x86 is the only arch running tests ;-) 18f7c64474SJiri Olsa# we need some IS_(32/64) flag to make this generic 1976aea773SH.J. Luifeq ($(ARCH)$(IS_64_BIT), x861) 20f7c64474SJiri Olsalib = lib64 21f7c64474SJiri Olsaelse 22f7c64474SJiri Olsalib = lib 23f7c64474SJiri Olsaendif 24f7c64474SJiri Olsa 250659e669SJiri Olsahas = $(shell which $1 2>/dev/null) 260659e669SJiri Olsa 27095ae69bSJiri Olsa# standard single make variable specified 28095ae69bSJiri Olsamake_clean_all := clean all 29095ae69bSJiri Olsamake_python_perf_so := python/perf.so 30095ae69bSJiri Olsamake_debug := DEBUG=1 31095ae69bSJiri Olsamake_no_libperl := NO_LIBPERL=1 32095ae69bSJiri Olsamake_no_libpython := NO_LIBPYTHON=1 33095ae69bSJiri Olsamake_no_scripts := NO_LIBPYTHON=1 NO_LIBPERL=1 34095ae69bSJiri Olsamake_no_newt := NO_NEWT=1 35095ae69bSJiri Olsamake_no_slang := NO_SLANG=1 36095ae69bSJiri Olsamake_no_gtk2 := NO_GTK2=1 37095ae69bSJiri Olsamake_no_ui := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1 38095ae69bSJiri Olsamake_no_demangle := NO_DEMANGLE=1 39095ae69bSJiri Olsamake_no_libelf := NO_LIBELF=1 40095ae69bSJiri Olsamake_no_libunwind := NO_LIBUNWIND=1 419e8c06eaSJiri Olsamake_no_libdw_dwarf_unwind := NO_LIBDW_DWARF_UNWIND=1 42095ae69bSJiri Olsamake_no_backtrace := NO_BACKTRACE=1 43095ae69bSJiri Olsamake_no_libnuma := NO_LIBNUMA=1 44095ae69bSJiri Olsamake_no_libaudit := NO_LIBAUDIT=1 45095ae69bSJiri Olsamake_no_libbionic := NO_LIBBIONIC=1 46e31f0d01SAdrian Huntermake_no_auxtrace := NO_AUXTRACE=1 47*ed63f34cSWang Nanmake_no_libbpf := NO_LIBBPF=1 48095ae69bSJiri Olsamake_tags := tags 49095ae69bSJiri Olsamake_cscope := cscope 50095ae69bSJiri Olsamake_help := help 51095ae69bSJiri Olsamake_doc := doc 52095ae69bSJiri Olsamake_perf_o := perf.o 53095ae69bSJiri Olsamake_util_map_o := util/map.o 542a94f6c4SJiri Olsamake_util_pmu_bison_o := util/pmu-bison.o 55c0ec1108SJiri Olsamake_install := install 56c0ec1108SJiri Olsamake_install_bin := install-bin 57dbad4189SJiri Olsamake_install_doc := install-doc 58dbad4189SJiri Olsamake_install_man := install-man 59dbad4189SJiri Olsamake_install_html := install-html 60dbad4189SJiri Olsamake_install_info := install-info 61dbad4189SJiri Olsamake_install_pdf := install-pdf 62eb30d2c5SJiri Olsamake_install_prefix := install prefix=/tmp/krava 63aa53c09eSJiri Olsamake_install_prefix_slash := install prefix=/tmp/krava/ 64611ec127SJiri Olsamake_static := LDFLAGS=-static 65095ae69bSJiri Olsa 66095ae69bSJiri Olsa# all the NO_* variable combined 67095ae69bSJiri Olsamake_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 68095ae69bSJiri Olsamake_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 69095ae69bSJiri Olsamake_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 70*ed63f34cSWang Nanmake_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 71095ae69bSJiri Olsa 72095ae69bSJiri Olsa# $(run) contains all available tests 73095ae69bSJiri Olsarun := make_pure 74502819c5SJiri Olsa# Targets 'clean all' can be run together only through top level 75502819c5SJiri Olsa# Makefile because we detect clean target in Makefile.perf and 76502819c5SJiri Olsa# disable features detection 77502819c5SJiri Olsaifeq ($(MK),Makefile) 78095ae69bSJiri Olsarun += make_clean_all 79502819c5SJiri Olsaendif 80095ae69bSJiri Olsarun += make_python_perf_so 81095ae69bSJiri Olsarun += make_debug 82095ae69bSJiri Olsarun += make_no_libperl 83095ae69bSJiri Olsarun += make_no_libpython 84095ae69bSJiri Olsarun += make_no_scripts 85095ae69bSJiri Olsarun += make_no_newt 86095ae69bSJiri Olsarun += make_no_slang 87095ae69bSJiri Olsarun += make_no_gtk2 88095ae69bSJiri Olsarun += make_no_ui 89095ae69bSJiri Olsarun += make_no_demangle 90095ae69bSJiri Olsarun += make_no_libelf 91095ae69bSJiri Olsarun += make_no_libunwind 929e8c06eaSJiri Olsarun += make_no_libdw_dwarf_unwind 93095ae69bSJiri Olsarun += make_no_backtrace 94095ae69bSJiri Olsarun += make_no_libnuma 95095ae69bSJiri Olsarun += make_no_libaudit 96095ae69bSJiri Olsarun += make_no_libbionic 97e31f0d01SAdrian Hunterrun += make_no_auxtrace 98*ed63f34cSWang Nanrun += make_no_libbpf 99095ae69bSJiri Olsarun += make_help 100095ae69bSJiri Olsarun += make_doc 101095ae69bSJiri Olsarun += make_perf_o 102095ae69bSJiri Olsarun += make_util_map_o 1032a94f6c4SJiri Olsarun += make_util_pmu_bison_o 104c0ec1108SJiri Olsarun += make_install 105c0ec1108SJiri Olsarun += make_install_bin 106eb30d2c5SJiri Olsarun += make_install_prefix 107aa53c09eSJiri Olsarun += make_install_prefix_slash 108dbad4189SJiri Olsa# FIXME 'install-*' commented out till they're fixed 109dbad4189SJiri Olsa# run += make_install_doc 110dbad4189SJiri Olsa# run += make_install_man 111dbad4189SJiri Olsa# run += make_install_html 112dbad4189SJiri Olsa# run += make_install_info 113dbad4189SJiri Olsa# run += make_install_pdf 114095ae69bSJiri Olsarun += make_minimal 115611ec127SJiri Olsarun += make_static 116095ae69bSJiri Olsa 1170659e669SJiri Olsaifneq ($(call has,ctags),) 1180659e669SJiri Olsarun += make_tags 1190659e669SJiri Olsaendif 1200659e669SJiri Olsaifneq ($(call has,cscope),) 1210659e669SJiri Olsarun += make_cscope 1220659e669SJiri Olsaendif 1230659e669SJiri Olsa 124095ae69bSJiri Olsa# $(run_O) contains same portion of $(run) tests with '_O' attached 125095ae69bSJiri Olsa# to distinguish O=... tests 126095ae69bSJiri Olsarun_O := $(addsuffix _O,$(run)) 127095ae69bSJiri Olsa 128095ae69bSJiri Olsa# disable some tests for O=... 129095ae69bSJiri Olsarun_O := $(filter-out make_python_perf_so_O,$(run_O)) 130095ae69bSJiri Olsa 131095ae69bSJiri Olsa# define test for each compile as 'test_NAME' variable 132095ae69bSJiri Olsa# with the test itself as a value 133095ae69bSJiri Olsatest_make_tags = test -f tags 134095ae69bSJiri Olsatest_make_cscope = test -f cscope.out 135095ae69bSJiri Olsa 136095ae69bSJiri Olsatest_make_tags_O := $(test_make_tags) 137095ae69bSJiri Olsatest_make_cscope_O := $(test_make_cscope) 138095ae69bSJiri Olsa 139095ae69bSJiri Olsatest_ok := true 140095ae69bSJiri Olsatest_make_help := $(test_ok) 141095ae69bSJiri Olsatest_make_doc := $(test_ok) 142095ae69bSJiri Olsatest_make_help_O := $(test_ok) 143095ae69bSJiri Olsatest_make_doc_O := $(test_ok) 144095ae69bSJiri Olsa 145095ae69bSJiri Olsatest_make_python_perf_so := test -f $(PERF)/python/perf.so 146095ae69bSJiri Olsa 147095ae69bSJiri Olsatest_make_perf_o := test -f $(PERF)/perf.o 148095ae69bSJiri Olsatest_make_util_map_o := test -f $(PERF)/util/map.o 1492a94f6c4SJiri Olsatest_make_util_pmu_bison_o := test -f $(PERF)/util/pmu-bison.o 150095ae69bSJiri Olsa 151ee4ad93eSJiri Olsadefine test_dest_files 152ee4ad93eSJiri Olsa for file in $(1); do \ 153ee4ad93eSJiri Olsa if [ ! -x $$TMP_DEST/$$file ]; then \ 154ee4ad93eSJiri Olsa echo " failed to find: $$file"; \ 155ee4ad93eSJiri Olsa fi \ 156ee4ad93eSJiri Olsa done 157ee4ad93eSJiri Olsaendef 158ee4ad93eSJiri Olsa 159ee4ad93eSJiri Olsainstalled_files_bin := bin/perf 160ee4ad93eSJiri Olsainstalled_files_bin += etc/bash_completion.d/perf 161ee4ad93eSJiri Olsainstalled_files_bin += libexec/perf-core/perf-archive 162ee4ad93eSJiri Olsa 163f7c64474SJiri Olsainstalled_files_plugins := $(lib)/traceevent/plugins/plugin_cfg80211.so 164f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_scsi.so 165f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_xen.so 166f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_function.so 167f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_sched_switch.so 168f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_mac80211.so 169f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_kvm.so 170f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_kmem.so 171f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_hrtimer.so 172f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_jbd2.so 173ee4ad93eSJiri Olsa 174ee4ad93eSJiri Olsainstalled_files_all := $(installed_files_bin) 175ee4ad93eSJiri Olsainstalled_files_all += $(installed_files_plugins) 176ee4ad93eSJiri Olsa 177ee4ad93eSJiri Olsatest_make_install := $(call test_dest_files,$(installed_files_all)) 178ee4ad93eSJiri Olsatest_make_install_O := $(call test_dest_files,$(installed_files_all)) 179ee4ad93eSJiri Olsatest_make_install_bin := $(call test_dest_files,$(installed_files_bin)) 180ee4ad93eSJiri Olsatest_make_install_bin_O := $(call test_dest_files,$(installed_files_bin)) 181c0ec1108SJiri Olsa 182aa53c09eSJiri Olsa# We prefix all installed files for make_install_prefix(_slash) 183eb30d2c5SJiri Olsa# with '/tmp/krava' to match installed/prefix-ed files. 184eb30d2c5SJiri Olsainstalled_files_all_prefix := $(addprefix /tmp/krava/,$(installed_files_all)) 185eb30d2c5SJiri Olsatest_make_install_prefix := $(call test_dest_files,$(installed_files_all_prefix)) 186eb30d2c5SJiri Olsatest_make_install_prefix_O := $(call test_dest_files,$(installed_files_all_prefix)) 187eb30d2c5SJiri Olsa 188aa53c09eSJiri Olsatest_make_install_prefix_slash := $(test_make_install_prefix) 189aa53c09eSJiri Olsatest_make_install_prefix_slash_O := $(test_make_install_prefix_O) 190aa53c09eSJiri Olsa 191dbad4189SJiri Olsa# FIXME nothing gets installed 192dbad4189SJiri Olsatest_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1 193dbad4189SJiri Olsatest_make_install_man_O := $(test_make_install_man) 194dbad4189SJiri Olsa 195dbad4189SJiri Olsa# FIXME nothing gets installed 196dbad4189SJiri Olsatest_make_install_doc := $(test_ok) 197dbad4189SJiri Olsatest_make_install_doc_O := $(test_ok) 198dbad4189SJiri Olsa 199dbad4189SJiri Olsa# FIXME nothing gets installed 200dbad4189SJiri Olsatest_make_install_html := $(test_ok) 201dbad4189SJiri Olsatest_make_install_html_O := $(test_ok) 202dbad4189SJiri Olsa 203dbad4189SJiri Olsa# FIXME nothing gets installed 204dbad4189SJiri Olsatest_make_install_info := $(test_ok) 205dbad4189SJiri Olsatest_make_install_info_O := $(test_ok) 206dbad4189SJiri Olsa 207dbad4189SJiri Olsa# FIXME nothing gets installed 208dbad4189SJiri Olsatest_make_install_pdf := $(test_ok) 209dbad4189SJiri Olsatest_make_install_pdf_O := $(test_ok) 210dbad4189SJiri Olsa 21104b01a1dSJiri Olsatest_make_python_perf_so_O := test -f $$TMP_O/python/perf.so 21204b01a1dSJiri Olsatest_make_perf_o_O := test -f $$TMP_O/perf.o 21304b01a1dSJiri Olsatest_make_util_map_o_O := test -f $$TMP_O/util/map.o 2142a94f6c4SJiri Olsatest_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o 215095ae69bSJiri Olsa 216095ae69bSJiri Olsatest_default = test -x $(PERF)/perf 217095ae69bSJiri Olsatest = $(if $(test_$1),$(test_$1),$(test_default)) 218095ae69bSJiri Olsa 2198ba7cdeaSJiri Olsatest_default_O = test -x $$TMP_O/perf 220095ae69bSJiri Olsatest_O = $(if $(test_$1),$(test_$1),$(test_default_O)) 221095ae69bSJiri Olsa 222095ae69bSJiri Olsaall: 223095ae69bSJiri Olsa 224095ae69bSJiri Olsaifdef DEBUG 225095ae69bSJiri Olsad := $(info run $(run)) 226095ae69bSJiri Olsad := $(info run_O $(run_O)) 227095ae69bSJiri Olsaendif 228095ae69bSJiri Olsa 229095ae69bSJiri OlsaMAKEFLAGS := --no-print-directory 230095ae69bSJiri Olsa 231095ae69bSJiri Olsaclean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null) 232095ae69bSJiri Olsa 233095ae69bSJiri Olsa$(run): 234095ae69bSJiri Olsa $(call clean) 235c9311674SJiri Olsa @TMP_DEST=$$(mktemp -d); \ 236c9311674SJiri Olsa cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \ 237095ae69bSJiri Olsa echo "- $@: $$cmd" && echo $$cmd > $@ && \ 238095ae69bSJiri Olsa ( eval $$cmd ) >> $@ 2>&1; \ 239ee4ad93eSJiri Olsa echo " test: $(call test,$@)" >> $@ 2>&1; \ 240095ae69bSJiri Olsa $(call test,$@) && \ 241a5c5009fSArnaldo Carvalho de Melo rm -rf $@ $$TMP_DEST || (cat $@ ; false) 242095ae69bSJiri Olsa 243095ae69bSJiri Olsa$(run_O): 244095ae69bSJiri Olsa $(call clean) 2458ba7cdeaSJiri Olsa @TMP_O=$$(mktemp -d); \ 246c9311674SJiri Olsa TMP_DEST=$$(mktemp -d); \ 247c9311674SJiri Olsa cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \ 248095ae69bSJiri Olsa echo "- $@: $$cmd" && echo $$cmd > $@ && \ 249095ae69bSJiri Olsa ( eval $$cmd ) >> $@ 2>&1 && \ 250ee4ad93eSJiri Olsa echo " test: $(call test_O,$@)" >> $@ 2>&1; \ 251095ae69bSJiri Olsa $(call test_O,$@) && \ 252a5c5009fSArnaldo Carvalho de Melo rm -rf $@ $$TMP_O $$TMP_DEST || (cat $@ ; false) 253095ae69bSJiri Olsa 25448878053SArnaldo Carvalho de Melotarpkg: 25548878053SArnaldo Carvalho de Melo @cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \ 25648878053SArnaldo Carvalho de Melo echo "- $@: $$cmd" && echo $$cmd > $@ && \ 25748878053SArnaldo Carvalho de Melo ( eval $$cmd ) >> $@ 2>&1 25848878053SArnaldo Carvalho de Melo 259c41c6647SJiri Olsamake_kernelsrc: 260c41c6647SJiri Olsa @echo "- make -C <kernelsrc> tools/perf" 261c41c6647SJiri Olsa $(call clean); \ 262c41c6647SJiri Olsa (make -C ../.. tools/perf) > $@ 2>&1 && \ 263c41c6647SJiri Olsa test -x perf && rm -f $@ || (cat $@ ; false) 264c41c6647SJiri Olsa 265c41c6647SJiri Olsamake_kernelsrc_tools: 266c41c6647SJiri Olsa @echo "- make -C <kernelsrc>/tools perf" 267c41c6647SJiri Olsa $(call clean); \ 268c41c6647SJiri Olsa (make -C ../../tools perf) > $@ 2>&1 && \ 269c41c6647SJiri Olsa test -x perf && rm -f $@ || (cat $@ ; false) 270c41c6647SJiri Olsa 271c41c6647SJiri Olsaall: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools 272095ae69bSJiri Olsa @echo OK 273095ae69bSJiri Olsa 274095ae69bSJiri Olsaout: $(run_O) 275095ae69bSJiri Olsa @echo OK 276095ae69bSJiri Olsa 27748878053SArnaldo Carvalho de Melo.PHONY: all $(run) $(run_O) tarpkg clean 278502819c5SJiri Olsaendif # ifndef MK 279