1935e6bd3SWang Naninclude ../scripts/Makefile.include 2935e6bd3SWang Nan 3502819c5SJiri Olsaifndef MK 4502819c5SJiri Olsaifeq ($(MAKECMDGOALS),) 5502819c5SJiri Olsa# no target specified, trigger the whole suite 6502819c5SJiri Olsaall: 7502819c5SJiri Olsa @echo "Testing Makefile"; $(MAKE) -sf tests/make MK=Makefile 8*7be43dfbSWang Nan @echo "Testing Makefile.perf"; $(MAKE) -sf tests/make MK=Makefile.perf SET_PARALLEL=1 9502819c5SJiri Olsaelse 10502819c5SJiri Olsa# run only specific test over 'Makefile' 11502819c5SJiri Olsa%: 12502819c5SJiri Olsa @echo "Testing Makefile"; $(MAKE) -sf tests/make MK=Makefile $@ 13502819c5SJiri Olsaendif 14502819c5SJiri Olsaelse 15095ae69bSJiri OlsaPERF := . 16095ae69bSJiri Olsa 17*7be43dfbSWang NanPARALLEL_OPT= 18*7be43dfbSWang Nanifeq ($(SET_PARALLEL),1) 19*7be43dfbSWang Nan cores := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null) 20*7be43dfbSWang Nan ifeq ($(cores),0) 21*7be43dfbSWang Nan cores := 1 22*7be43dfbSWang Nan endif 23*7be43dfbSWang Nan PARALLEL_OPT="-j$(cores)" 24*7be43dfbSWang Nanendif 25*7be43dfbSWang Nan 26935e6bd3SWang Nan# As per kernel Makefile, avoid funny character set dependencies 27935e6bd3SWang Nanunexport LC_ALL 28935e6bd3SWang NanLC_COLLATE=C 29935e6bd3SWang NanLC_NUMERIC=C 30935e6bd3SWang Nanexport LC_COLLATE LC_NUMERIC 31935e6bd3SWang Nan 32935e6bd3SWang Nanifeq ($(srctree),) 33935e6bd3SWang Nansrctree := $(patsubst %/,%,$(dir $(shell pwd))) 34935e6bd3SWang Nansrctree := $(patsubst %/,%,$(dir $(srctree))) 35935e6bd3SWang Nan#$(info Determined 'srctree' to be $(srctree)) 36935e6bd3SWang Nanendif 37935e6bd3SWang Nan 38935e6bd3SWang Naninclude $(srctree)/tools/scripts/Makefile.arch 39f7c64474SJiri Olsa 40f7c64474SJiri Olsa# FIXME looks like x86 is the only arch running tests ;-) 41f7c64474SJiri Olsa# we need some IS_(32/64) flag to make this generic 4276aea773SH.J. Luifeq ($(ARCH)$(IS_64_BIT), x861) 43f7c64474SJiri Olsalib = lib64 44f7c64474SJiri Olsaelse 45f7c64474SJiri Olsalib = lib 46f7c64474SJiri Olsaendif 47f7c64474SJiri Olsa 480659e669SJiri Olsahas = $(shell which $1 2>/dev/null) 490659e669SJiri Olsa 50095ae69bSJiri Olsa# standard single make variable specified 51095ae69bSJiri Olsamake_clean_all := clean all 52095ae69bSJiri Olsamake_python_perf_so := python/perf.so 53095ae69bSJiri Olsamake_debug := DEBUG=1 54095ae69bSJiri Olsamake_no_libperl := NO_LIBPERL=1 55095ae69bSJiri Olsamake_no_libpython := NO_LIBPYTHON=1 56095ae69bSJiri Olsamake_no_scripts := NO_LIBPYTHON=1 NO_LIBPERL=1 57095ae69bSJiri Olsamake_no_newt := NO_NEWT=1 58095ae69bSJiri Olsamake_no_slang := NO_SLANG=1 59095ae69bSJiri Olsamake_no_gtk2 := NO_GTK2=1 60095ae69bSJiri Olsamake_no_ui := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1 61095ae69bSJiri Olsamake_no_demangle := NO_DEMANGLE=1 62095ae69bSJiri Olsamake_no_libelf := NO_LIBELF=1 63095ae69bSJiri Olsamake_no_libunwind := NO_LIBUNWIND=1 649e8c06eaSJiri Olsamake_no_libdw_dwarf_unwind := NO_LIBDW_DWARF_UNWIND=1 65095ae69bSJiri Olsamake_no_backtrace := NO_BACKTRACE=1 66095ae69bSJiri Olsamake_no_libnuma := NO_LIBNUMA=1 67095ae69bSJiri Olsamake_no_libaudit := NO_LIBAUDIT=1 68095ae69bSJiri Olsamake_no_libbionic := NO_LIBBIONIC=1 69e31f0d01SAdrian Huntermake_no_auxtrace := NO_AUXTRACE=1 70ed63f34cSWang Nanmake_no_libbpf := NO_LIBBPF=1 71095ae69bSJiri Olsamake_tags := tags 72095ae69bSJiri Olsamake_cscope := cscope 73095ae69bSJiri Olsamake_help := help 74095ae69bSJiri Olsamake_doc := doc 75095ae69bSJiri Olsamake_perf_o := perf.o 76095ae69bSJiri Olsamake_util_map_o := util/map.o 772a94f6c4SJiri Olsamake_util_pmu_bison_o := util/pmu-bison.o 78c0ec1108SJiri Olsamake_install := install 79c0ec1108SJiri Olsamake_install_bin := install-bin 80dbad4189SJiri Olsamake_install_doc := install-doc 81dbad4189SJiri Olsamake_install_man := install-man 82dbad4189SJiri Olsamake_install_html := install-html 83dbad4189SJiri Olsamake_install_info := install-info 84dbad4189SJiri Olsamake_install_pdf := install-pdf 85eb30d2c5SJiri Olsamake_install_prefix := install prefix=/tmp/krava 86aa53c09eSJiri Olsamake_install_prefix_slash := install prefix=/tmp/krava/ 87611ec127SJiri Olsamake_static := LDFLAGS=-static 88095ae69bSJiri Olsa 89095ae69bSJiri Olsa# all the NO_* variable combined 90095ae69bSJiri Olsamake_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 91095ae69bSJiri Olsamake_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 92095ae69bSJiri Olsamake_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 93ed63f34cSWang Nanmake_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 94095ae69bSJiri Olsa 95095ae69bSJiri Olsa# $(run) contains all available tests 96095ae69bSJiri Olsarun := make_pure 97502819c5SJiri Olsa# Targets 'clean all' can be run together only through top level 98502819c5SJiri Olsa# Makefile because we detect clean target in Makefile.perf and 99502819c5SJiri Olsa# disable features detection 100502819c5SJiri Olsaifeq ($(MK),Makefile) 101095ae69bSJiri Olsarun += make_clean_all 102502819c5SJiri Olsaendif 103095ae69bSJiri Olsarun += make_python_perf_so 104095ae69bSJiri Olsarun += make_debug 105095ae69bSJiri Olsarun += make_no_libperl 106095ae69bSJiri Olsarun += make_no_libpython 107095ae69bSJiri Olsarun += make_no_scripts 108095ae69bSJiri Olsarun += make_no_newt 109095ae69bSJiri Olsarun += make_no_slang 110095ae69bSJiri Olsarun += make_no_gtk2 111095ae69bSJiri Olsarun += make_no_ui 112095ae69bSJiri Olsarun += make_no_demangle 113095ae69bSJiri Olsarun += make_no_libelf 114095ae69bSJiri Olsarun += make_no_libunwind 1159e8c06eaSJiri Olsarun += make_no_libdw_dwarf_unwind 116095ae69bSJiri Olsarun += make_no_backtrace 117095ae69bSJiri Olsarun += make_no_libnuma 118095ae69bSJiri Olsarun += make_no_libaudit 119095ae69bSJiri Olsarun += make_no_libbionic 120e31f0d01SAdrian Hunterrun += make_no_auxtrace 121ed63f34cSWang Nanrun += make_no_libbpf 122095ae69bSJiri Olsarun += make_help 123095ae69bSJiri Olsarun += make_doc 124095ae69bSJiri Olsarun += make_perf_o 125095ae69bSJiri Olsarun += make_util_map_o 1262a94f6c4SJiri Olsarun += make_util_pmu_bison_o 127c0ec1108SJiri Olsarun += make_install 128c0ec1108SJiri Olsarun += make_install_bin 129eb30d2c5SJiri Olsarun += make_install_prefix 130aa53c09eSJiri Olsarun += make_install_prefix_slash 131dbad4189SJiri Olsa# FIXME 'install-*' commented out till they're fixed 132dbad4189SJiri Olsa# run += make_install_doc 133dbad4189SJiri Olsa# run += make_install_man 134dbad4189SJiri Olsa# run += make_install_html 135dbad4189SJiri Olsa# run += make_install_info 136dbad4189SJiri Olsa# run += make_install_pdf 137095ae69bSJiri Olsarun += make_minimal 138611ec127SJiri Olsarun += make_static 139095ae69bSJiri Olsa 1400659e669SJiri Olsaifneq ($(call has,ctags),) 1410659e669SJiri Olsarun += make_tags 1420659e669SJiri Olsaendif 1430659e669SJiri Olsaifneq ($(call has,cscope),) 1440659e669SJiri Olsarun += make_cscope 1450659e669SJiri Olsaendif 1460659e669SJiri Olsa 147095ae69bSJiri Olsa# $(run_O) contains same portion of $(run) tests with '_O' attached 148095ae69bSJiri Olsa# to distinguish O=... tests 149095ae69bSJiri Olsarun_O := $(addsuffix _O,$(run)) 150095ae69bSJiri Olsa 151095ae69bSJiri Olsa# disable some tests for O=... 152095ae69bSJiri Olsarun_O := $(filter-out make_python_perf_so_O,$(run_O)) 153095ae69bSJiri Olsa 154095ae69bSJiri Olsa# define test for each compile as 'test_NAME' variable 155095ae69bSJiri Olsa# with the test itself as a value 156095ae69bSJiri Olsatest_make_tags = test -f tags 157095ae69bSJiri Olsatest_make_cscope = test -f cscope.out 158095ae69bSJiri Olsa 159095ae69bSJiri Olsatest_make_tags_O := $(test_make_tags) 160095ae69bSJiri Olsatest_make_cscope_O := $(test_make_cscope) 161095ae69bSJiri Olsa 162095ae69bSJiri Olsatest_ok := true 163095ae69bSJiri Olsatest_make_help := $(test_ok) 164095ae69bSJiri Olsatest_make_doc := $(test_ok) 165095ae69bSJiri Olsatest_make_help_O := $(test_ok) 166095ae69bSJiri Olsatest_make_doc_O := $(test_ok) 167095ae69bSJiri Olsa 168095ae69bSJiri Olsatest_make_python_perf_so := test -f $(PERF)/python/perf.so 169095ae69bSJiri Olsa 170095ae69bSJiri Olsatest_make_perf_o := test -f $(PERF)/perf.o 171095ae69bSJiri Olsatest_make_util_map_o := test -f $(PERF)/util/map.o 1722a94f6c4SJiri Olsatest_make_util_pmu_bison_o := test -f $(PERF)/util/pmu-bison.o 173095ae69bSJiri Olsa 174ee4ad93eSJiri Olsadefine test_dest_files 175ee4ad93eSJiri Olsa for file in $(1); do \ 176ee4ad93eSJiri Olsa if [ ! -x $$TMP_DEST/$$file ]; then \ 177ee4ad93eSJiri Olsa echo " failed to find: $$file"; \ 178ee4ad93eSJiri Olsa fi \ 179ee4ad93eSJiri Olsa done 180ee4ad93eSJiri Olsaendef 181ee4ad93eSJiri Olsa 182ee4ad93eSJiri Olsainstalled_files_bin := bin/perf 183ee4ad93eSJiri Olsainstalled_files_bin += etc/bash_completion.d/perf 184ee4ad93eSJiri Olsainstalled_files_bin += libexec/perf-core/perf-archive 185ee4ad93eSJiri Olsa 186f7c64474SJiri Olsainstalled_files_plugins := $(lib)/traceevent/plugins/plugin_cfg80211.so 187f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_scsi.so 188f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_xen.so 189f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_function.so 190f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_sched_switch.so 191f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_mac80211.so 192f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_kvm.so 193f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_kmem.so 194f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_hrtimer.so 195f7c64474SJiri Olsainstalled_files_plugins += $(lib)/traceevent/plugins/plugin_jbd2.so 196ee4ad93eSJiri Olsa 197ee4ad93eSJiri Olsainstalled_files_all := $(installed_files_bin) 198ee4ad93eSJiri Olsainstalled_files_all += $(installed_files_plugins) 199ee4ad93eSJiri Olsa 200ee4ad93eSJiri Olsatest_make_install := $(call test_dest_files,$(installed_files_all)) 201ee4ad93eSJiri Olsatest_make_install_O := $(call test_dest_files,$(installed_files_all)) 202ee4ad93eSJiri Olsatest_make_install_bin := $(call test_dest_files,$(installed_files_bin)) 203ee4ad93eSJiri Olsatest_make_install_bin_O := $(call test_dest_files,$(installed_files_bin)) 204c0ec1108SJiri Olsa 205aa53c09eSJiri Olsa# We prefix all installed files for make_install_prefix(_slash) 206eb30d2c5SJiri Olsa# with '/tmp/krava' to match installed/prefix-ed files. 207eb30d2c5SJiri Olsainstalled_files_all_prefix := $(addprefix /tmp/krava/,$(installed_files_all)) 208eb30d2c5SJiri Olsatest_make_install_prefix := $(call test_dest_files,$(installed_files_all_prefix)) 209eb30d2c5SJiri Olsatest_make_install_prefix_O := $(call test_dest_files,$(installed_files_all_prefix)) 210eb30d2c5SJiri Olsa 211aa53c09eSJiri Olsatest_make_install_prefix_slash := $(test_make_install_prefix) 212aa53c09eSJiri Olsatest_make_install_prefix_slash_O := $(test_make_install_prefix_O) 213aa53c09eSJiri Olsa 214dbad4189SJiri Olsa# FIXME nothing gets installed 215dbad4189SJiri Olsatest_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1 216dbad4189SJiri Olsatest_make_install_man_O := $(test_make_install_man) 217dbad4189SJiri Olsa 218dbad4189SJiri Olsa# FIXME nothing gets installed 219dbad4189SJiri Olsatest_make_install_doc := $(test_ok) 220dbad4189SJiri Olsatest_make_install_doc_O := $(test_ok) 221dbad4189SJiri Olsa 222dbad4189SJiri Olsa# FIXME nothing gets installed 223dbad4189SJiri Olsatest_make_install_html := $(test_ok) 224dbad4189SJiri Olsatest_make_install_html_O := $(test_ok) 225dbad4189SJiri Olsa 226dbad4189SJiri Olsa# FIXME nothing gets installed 227dbad4189SJiri Olsatest_make_install_info := $(test_ok) 228dbad4189SJiri Olsatest_make_install_info_O := $(test_ok) 229dbad4189SJiri Olsa 230dbad4189SJiri Olsa# FIXME nothing gets installed 231dbad4189SJiri Olsatest_make_install_pdf := $(test_ok) 232dbad4189SJiri Olsatest_make_install_pdf_O := $(test_ok) 233dbad4189SJiri Olsa 23404b01a1dSJiri Olsatest_make_python_perf_so_O := test -f $$TMP_O/python/perf.so 23504b01a1dSJiri Olsatest_make_perf_o_O := test -f $$TMP_O/perf.o 23604b01a1dSJiri Olsatest_make_util_map_o_O := test -f $$TMP_O/util/map.o 2372a94f6c4SJiri Olsatest_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o 238095ae69bSJiri Olsa 239095ae69bSJiri Olsatest_default = test -x $(PERF)/perf 240095ae69bSJiri Olsatest = $(if $(test_$1),$(test_$1),$(test_default)) 241095ae69bSJiri Olsa 2428ba7cdeaSJiri Olsatest_default_O = test -x $$TMP_O/perf 243095ae69bSJiri Olsatest_O = $(if $(test_$1),$(test_$1),$(test_default_O)) 244095ae69bSJiri Olsa 245095ae69bSJiri Olsaall: 246095ae69bSJiri Olsa 24798916392SArnaldo Carvalho de Meloifdef SHUF 24898916392SArnaldo Carvalho de Melorun := $(shell shuf -e $(run)) 24998916392SArnaldo Carvalho de Melorun_O := $(shell shuf -e $(run_O)) 25098916392SArnaldo Carvalho de Meloendif 25198916392SArnaldo Carvalho de Melo 252095ae69bSJiri Olsaifdef DEBUG 253095ae69bSJiri Olsad := $(info run $(run)) 254095ae69bSJiri Olsad := $(info run_O $(run_O)) 255095ae69bSJiri Olsaendif 256095ae69bSJiri Olsa 257095ae69bSJiri OlsaMAKEFLAGS := --no-print-directory 258095ae69bSJiri Olsa 259095ae69bSJiri Olsaclean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null) 260095ae69bSJiri Olsa 261095ae69bSJiri Olsa$(run): 262095ae69bSJiri Olsa $(call clean) 263c9311674SJiri Olsa @TMP_DEST=$$(mktemp -d); \ 264*7be43dfbSWang Nan cmd="cd $(PERF) && make -f $(MK) $(PARALLEL_OPT) DESTDIR=$$TMP_DEST $($@)"; \ 265095ae69bSJiri Olsa echo "- $@: $$cmd" && echo $$cmd > $@ && \ 266095ae69bSJiri Olsa ( eval $$cmd ) >> $@ 2>&1; \ 267ee4ad93eSJiri Olsa echo " test: $(call test,$@)" >> $@ 2>&1; \ 268095ae69bSJiri Olsa $(call test,$@) && \ 269a5c5009fSArnaldo Carvalho de Melo rm -rf $@ $$TMP_DEST || (cat $@ ; false) 270095ae69bSJiri Olsa 271095ae69bSJiri Olsa$(run_O): 272095ae69bSJiri Olsa $(call clean) 2738ba7cdeaSJiri Olsa @TMP_O=$$(mktemp -d); \ 274c9311674SJiri Olsa TMP_DEST=$$(mktemp -d); \ 275*7be43dfbSWang Nan cmd="cd $(PERF) && make -f $(MK) $(PARALLEL_OPT) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \ 276095ae69bSJiri Olsa echo "- $@: $$cmd" && echo $$cmd > $@ && \ 277095ae69bSJiri Olsa ( eval $$cmd ) >> $@ 2>&1 && \ 278ee4ad93eSJiri Olsa echo " test: $(call test_O,$@)" >> $@ 2>&1; \ 279095ae69bSJiri Olsa $(call test_O,$@) && \ 280a5c5009fSArnaldo Carvalho de Melo rm -rf $@ $$TMP_O $$TMP_DEST || (cat $@ ; false) 281095ae69bSJiri Olsa 28248878053SArnaldo Carvalho de Melotarpkg: 28348878053SArnaldo Carvalho de Melo @cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \ 28448878053SArnaldo Carvalho de Melo echo "- $@: $$cmd" && echo $$cmd > $@ && \ 285004bd89dSJosh Poimboeuf ( eval $$cmd ) >> $@ 2>&1 && \ 286004bd89dSJosh Poimboeuf rm -f $@ 28748878053SArnaldo Carvalho de Melo 288c41c6647SJiri Olsamake_kernelsrc: 289*7be43dfbSWang Nan @echo "- make -C <kernelsrc> $(PARALLEL_OPT) tools/perf" 290c41c6647SJiri Olsa $(call clean); \ 291*7be43dfbSWang Nan (make -C ../.. $(PARALLEL_OPT) tools/perf) > $@ 2>&1 && \ 292c41c6647SJiri Olsa test -x perf && rm -f $@ || (cat $@ ; false) 293c41c6647SJiri Olsa 294c41c6647SJiri Olsamake_kernelsrc_tools: 295*7be43dfbSWang Nan @echo "- make -C <kernelsrc>/tools $(PARALLEL_OPT) perf" 296c41c6647SJiri Olsa $(call clean); \ 297*7be43dfbSWang Nan (make -C ../../tools $(PARALLEL_OPT) perf) > $@ 2>&1 && \ 298c41c6647SJiri Olsa test -x perf && rm -f $@ || (cat $@ ; false) 299c41c6647SJiri Olsa 300c41c6647SJiri Olsaall: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools 301095ae69bSJiri Olsa @echo OK 302095ae69bSJiri Olsa 303095ae69bSJiri Olsaout: $(run_O) 304095ae69bSJiri Olsa @echo OK 305095ae69bSJiri Olsa 3063167eea2SWang Nan.PHONY: all $(run) $(run_O) tarpkg clean make_kernelsrc make_kernelsrc_tools 307502819c5SJiri Olsaendif # ifndef MK 308