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 8eb807730SWang Nan @echo "Testing Makefile.perf"; $(MAKE) -sf tests/make MK=Makefile.perf SET_PARALLEL=1 SET_O=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 := . 1668824de1SWang NanPERF_O := $(PERF) 17eb807730SWang NanO_OPT := 1879191c89SWang NanFULL_O := $(shell readlink -f $(PERF_O) || echo $(PERF_O)) 19eb807730SWang Nan 20eb807730SWang Nanifneq ($(O),) 21eb807730SWang Nan FULL_O := $(shell readlink -f $(O) || echo $(O)) 2268824de1SWang Nan PERF_O := $(FULL_O) 23eb807730SWang Nan ifeq ($(SET_O),1) 24eb807730SWang Nan O_OPT := 'O=$(FULL_O)' 25eb807730SWang Nan endif 26c15e758cSWang Nan K_O_OPT := 'O=$(FULL_O)' 27eb807730SWang Nanendif 28095ae69bSJiri Olsa 297be43dfbSWang NanPARALLEL_OPT= 307be43dfbSWang Nanifeq ($(SET_PARALLEL),1) 317b1642f2SArnaldo Carvalho de Melo ifeq ($(JOBS),) 32818448e9STiezhu Yang cores := $(shell (getconf _NPROCESSORS_ONLN || grep -E -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null) 337be43dfbSWang Nan ifeq ($(cores),0) 347be43dfbSWang Nan cores := 1 357be43dfbSWang Nan endif 367b1642f2SArnaldo Carvalho de Melo else 377b1642f2SArnaldo Carvalho de Melo cores=$(JOBS) 387b1642f2SArnaldo Carvalho de Melo endif 397be43dfbSWang Nan PARALLEL_OPT="-j$(cores)" 407be43dfbSWang Nanendif 417be43dfbSWang Nan 42935e6bd3SWang Nan# As per kernel Makefile, avoid funny character set dependencies 43935e6bd3SWang Nanunexport LC_ALL 44935e6bd3SWang NanLC_COLLATE=C 45935e6bd3SWang NanLC_NUMERIC=C 46935e6bd3SWang Nanexport LC_COLLATE LC_NUMERIC 47935e6bd3SWang Nan 48935e6bd3SWang Nanifeq ($(srctree),) 49e19b7ceeSUwe Kleine-Königsrctree := $(patsubst %/,%,$(dir $(CURDIR))) 50935e6bd3SWang Nansrctree := $(patsubst %/,%,$(dir $(srctree))) 51935e6bd3SWang Nan#$(info Determined 'srctree' to be $(srctree)) 52935e6bd3SWang Nanendif 53935e6bd3SWang Nan 54935e6bd3SWang Naninclude $(srctree)/tools/scripts/Makefile.arch 55f7c64474SJiri Olsa 56f7c64474SJiri Olsa# FIXME looks like x86 is the only arch running tests ;-) 57f7c64474SJiri Olsa# we need some IS_(32/64) flag to make this generic 5876aea773SH.J. Luifeq ($(ARCH)$(IS_64_BIT), x861) 59f7c64474SJiri Olsalib = lib64 60f7c64474SJiri Olsaelse 61f7c64474SJiri Olsalib = lib 62f7c64474SJiri Olsaendif 63f7c64474SJiri Olsa 640659e669SJiri Olsahas = $(shell which $1 2>/dev/null) 657a9b223cSIan Rogerspython_perf_so := $(shell $(MAKE) python_perf_target|grep "Target is:"|awk '{print $$3}') 660659e669SJiri Olsa 67095ae69bSJiri Olsa# standard single make variable specified 68095ae69bSJiri Olsamake_clean_all := clean all 697a9b223cSIan Rogersmake_python_perf_so := $(python_perf_so) 70095ae69bSJiri Olsamake_debug := DEBUG=1 71dd317df0SIan Rogersmake_nondistro := BUILD_NONDISTRO=1 72d436373aSAdrian Huntermake_extra_tests := EXTRA_TESTS=1 73*06c39e74SIan Rogersmake_bpf_skel := BUILD_BPF_SKEL=1 74*06c39e74SIan Rogersmake_gen_vmlinux_h := BUILD_BPF_SKEL=1 GEN_VMLINUX_H=1 75095ae69bSJiri Olsamake_no_libperl := NO_LIBPERL=1 76095ae69bSJiri Olsamake_no_libpython := NO_LIBPYTHON=1 77095ae69bSJiri Olsamake_no_scripts := NO_LIBPYTHON=1 NO_LIBPERL=1 78095ae69bSJiri Olsamake_no_slang := NO_SLANG=1 79095ae69bSJiri Olsamake_no_gtk2 := NO_GTK2=1 80f1925bd5SIan Rogersmake_no_ui := NO_SLANG=1 NO_GTK2=1 81095ae69bSJiri Olsamake_no_demangle := NO_DEMANGLE=1 82095ae69bSJiri Olsamake_no_libelf := NO_LIBELF=1 83095ae69bSJiri Olsamake_no_libunwind := NO_LIBUNWIND=1 849e8c06eaSJiri Olsamake_no_libdw_dwarf_unwind := NO_LIBDW_DWARF_UNWIND=1 85095ae69bSJiri Olsamake_no_backtrace := NO_BACKTRACE=1 86095ae69bSJiri Olsamake_no_libnuma := NO_LIBNUMA=1 87095ae69bSJiri Olsamake_no_libaudit := NO_LIBAUDIT=1 88095ae69bSJiri Olsamake_no_libbionic := NO_LIBBIONIC=1 89e31f0d01SAdrian Huntermake_no_auxtrace := NO_AUXTRACE=1 90ed63f34cSWang Nanmake_no_libbpf := NO_LIBBPF=1 918df12cbcSArnaldo Carvalho de Melomake_libbpf_dynamic := LIBBPF_DYNAMIC=1 92beb64203SJiri Olsamake_no_libbpf_DEBUG := NO_LIBBPF=1 DEBUG=1 938ee46460SStephane Eranianmake_no_libcrypto := NO_LIBCRYPTO=1 94f5ce4573SWang Nanmake_with_babeltrace:= LIBBABELTRACE=1 951ce296a4SArnaldo Carvalho de Melomake_with_coresight := CORESIGHT=1 96e26e63beSMasami Hiramatsumake_no_sdt := NO_SDT=1 975bc7aac3SArnaldo Carvalho de Melomake_no_syscall_tbl := NO_SYSCALL_TABLE=1 98d7c4f89aSIan Rogersmake_no_libpfm4 := NO_LIBPFM4=1 9920719c82SArnaldo Carvalho de Melomake_with_gtk2 := GTK2=1 100686c5118SArnaldo Carvalho de Melomake_refcnt_check := EXTRA_CFLAGS="-DREFCNT_CHECKING=1" 101095ae69bSJiri Olsamake_tags := tags 102095ae69bSJiri Olsamake_cscope := cscope 103095ae69bSJiri Olsamake_help := help 104095ae69bSJiri Olsamake_doc := doc 105095ae69bSJiri Olsamake_perf_o := perf.o 106095ae69bSJiri Olsamake_util_map_o := util/map.o 1072a94f6c4SJiri Olsamake_util_pmu_bison_o := util/pmu-bison.o 108c0ec1108SJiri Olsamake_install := install 109c0ec1108SJiri Olsamake_install_bin := install-bin 110dbad4189SJiri Olsamake_install_doc := install-doc 111dbad4189SJiri Olsamake_install_man := install-man 112dbad4189SJiri Olsamake_install_html := install-html 113dbad4189SJiri Olsamake_install_info := install-info 114dbad4189SJiri Olsamake_install_pdf := install-pdf 115eb30d2c5SJiri Olsamake_install_prefix := install prefix=/tmp/krava 116aa53c09eSJiri Olsamake_install_prefix_slash := install prefix=/tmp/krava/ 1178d98ca5cSIan Rogersmake_static := LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1 NO_LIBTRACEEVENT=1 NO_LIBELF=1 118095ae69bSJiri Olsa 119095ae69bSJiri Olsa# all the NO_* variable combined 120f1925bd5SIan Rogersmake_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_GTK2=1 121095ae69bSJiri Olsamake_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 122095ae69bSJiri Olsamake_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 123ed63f34cSWang Nanmake_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 1245b6f5aefSArnaldo Carvalho de Melomake_minimal += NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1 NO_LIBZSTD=1 1255bc7aac3SArnaldo Carvalho de Melomake_minimal += NO_LIBCAP=1 NO_SYSCALL_TABLE=1 126095ae69bSJiri Olsa 127095ae69bSJiri Olsa# $(run) contains all available tests 128095ae69bSJiri Olsarun := make_pure 129502819c5SJiri Olsa# Targets 'clean all' can be run together only through top level 130502819c5SJiri Olsa# Makefile because we detect clean target in Makefile.perf and 131502819c5SJiri Olsa# disable features detection 132502819c5SJiri Olsaifeq ($(MK),Makefile) 133095ae69bSJiri Olsarun += make_clean_all 1345978531bSArnaldo Carvalho de MeloMAKE_F := $(MAKE) 1355978531bSArnaldo Carvalho de Meloelse 1365978531bSArnaldo Carvalho de MeloMAKE_F := $(MAKE) -f $(MK) 137502819c5SJiri Olsaendif 138095ae69bSJiri Olsarun += make_python_perf_so 139095ae69bSJiri Olsarun += make_debug 140dd317df0SIan Rogersrun += make_nondistro 141*06c39e74SIan Rogersrun += make_build_bpf_skel 142*06c39e74SIan Rogersrun += make_gen_vmlinux_h 143095ae69bSJiri Olsarun += make_no_libperl 144095ae69bSJiri Olsarun += make_no_libpython 145095ae69bSJiri Olsarun += make_no_scripts 146095ae69bSJiri Olsarun += make_no_slang 147095ae69bSJiri Olsarun += make_no_gtk2 148095ae69bSJiri Olsarun += make_no_ui 149095ae69bSJiri Olsarun += make_no_demangle 150095ae69bSJiri Olsarun += make_no_libelf 151095ae69bSJiri Olsarun += make_no_libunwind 1529e8c06eaSJiri Olsarun += make_no_libdw_dwarf_unwind 153095ae69bSJiri Olsarun += make_no_backtrace 154095ae69bSJiri Olsarun += make_no_libnuma 155095ae69bSJiri Olsarun += make_no_libaudit 156095ae69bSJiri Olsarun += make_no_libbionic 157e31f0d01SAdrian Hunterrun += make_no_auxtrace 158ed63f34cSWang Nanrun += make_no_libbpf 159beb64203SJiri Olsarun += make_no_libbpf_DEBUG 16069fbadbeSArnaldo Carvalho de Melorun += make_no_libcrypto 16160da3a12SArnaldo Carvalho de Melorun += make_no_sdt 1625bc7aac3SArnaldo Carvalho de Melorun += make_no_syscall_tbl 163f5ce4573SWang Nanrun += make_with_babeltrace 1641ce296a4SArnaldo Carvalho de Melorun += make_with_coresight 165d58ac0bfSWang Nanrun += make_with_clangllvm 166d7c4f89aSIan Rogersrun += make_no_libpfm4 167686c5118SArnaldo Carvalho de Melorun += make_refcnt_check 168095ae69bSJiri Olsarun += make_help 169095ae69bSJiri Olsarun += make_doc 170095ae69bSJiri Olsarun += make_perf_o 171095ae69bSJiri Olsarun += make_util_map_o 1722a94f6c4SJiri Olsarun += make_util_pmu_bison_o 173c0ec1108SJiri Olsarun += make_install 174c0ec1108SJiri Olsarun += make_install_bin 175eb30d2c5SJiri Olsarun += make_install_prefix 176aa53c09eSJiri Olsarun += make_install_prefix_slash 177dbad4189SJiri Olsa# FIXME 'install-*' commented out till they're fixed 178dbad4189SJiri Olsa# run += make_install_doc 179dbad4189SJiri Olsa# run += make_install_man 180dbad4189SJiri Olsa# run += make_install_html 181dbad4189SJiri Olsa# run += make_install_info 182dbad4189SJiri Olsa# run += make_install_pdf 183095ae69bSJiri Olsarun += make_minimal 184095ae69bSJiri Olsa 185d1992261SJames Clarkold_libbpf := $(shell echo '\#include <bpf/libbpf.h>' | $(CC) -E -dM -x c -| egrep -q "define[[:space:]]+LIBBPF_MAJOR_VERSION[[:space:]]+0{1}") 18656d52294SIan Rogers 18756d52294SIan Rogersifneq ($(old_libbpf),) 18856d52294SIan Rogersrun += make_libbpf_dynamic 18956d52294SIan Rogersendif 19056d52294SIan Rogers 1910659e669SJiri Olsaifneq ($(call has,ctags),) 1920659e669SJiri Olsarun += make_tags 1930659e669SJiri Olsaendif 1940659e669SJiri Olsaifneq ($(call has,cscope),) 1950659e669SJiri Olsarun += make_cscope 1960659e669SJiri Olsaendif 1970659e669SJiri Olsa 198095ae69bSJiri Olsa# $(run_O) contains same portion of $(run) tests with '_O' attached 199095ae69bSJiri Olsa# to distinguish O=... tests 200095ae69bSJiri Olsarun_O := $(addsuffix _O,$(run)) 201095ae69bSJiri Olsa 202095ae69bSJiri Olsa# disable some tests for O=... 203095ae69bSJiri Olsarun_O := $(filter-out make_python_perf_so_O,$(run_O)) 204095ae69bSJiri Olsa 205095ae69bSJiri Olsa# define test for each compile as 'test_NAME' variable 206095ae69bSJiri Olsa# with the test itself as a value 207095ae69bSJiri Olsatest_make_tags = test -f tags 208095ae69bSJiri Olsatest_make_cscope = test -f cscope.out 209095ae69bSJiri Olsa 210095ae69bSJiri Olsatest_make_tags_O := $(test_make_tags) 211095ae69bSJiri Olsatest_make_cscope_O := $(test_make_cscope) 212095ae69bSJiri Olsa 213095ae69bSJiri Olsatest_ok := true 214095ae69bSJiri Olsatest_make_help := $(test_ok) 215095ae69bSJiri Olsatest_make_doc := $(test_ok) 216095ae69bSJiri Olsatest_make_help_O := $(test_ok) 217095ae69bSJiri Olsatest_make_doc_O := $(test_ok) 218095ae69bSJiri Olsa 2197a9b223cSIan Rogerstest_make_python_perf_so := test -f $(PERF_O)/$(python_perf_so) 220095ae69bSJiri Olsa 22168824de1SWang Nantest_make_perf_o := test -f $(PERF_O)/perf.o 22268824de1SWang Nantest_make_util_map_o := test -f $(PERF_O)/util/map.o 22368824de1SWang Nantest_make_util_pmu_bison_o := test -f $(PERF_O)/util/pmu-bison.o 224095ae69bSJiri Olsa 225ee4ad93eSJiri Olsadefine test_dest_files 226ee4ad93eSJiri Olsa for file in $(1); do \ 227ee4ad93eSJiri Olsa if [ ! -x $$TMP_DEST/$$file ]; then \ 228ee4ad93eSJiri Olsa echo " failed to find: $$file"; \ 229ee4ad93eSJiri Olsa fi \ 230ee4ad93eSJiri Olsa done 231ee4ad93eSJiri Olsaendef 232ee4ad93eSJiri Olsa 233ee4ad93eSJiri Olsainstalled_files_bin := bin/perf 234ee4ad93eSJiri Olsainstalled_files_bin += etc/bash_completion.d/perf 235ee4ad93eSJiri Olsainstalled_files_bin += libexec/perf-core/perf-archive 236ee4ad93eSJiri Olsa 237ee4ad93eSJiri Olsainstalled_files_all := $(installed_files_bin) 238ee4ad93eSJiri Olsa 239ee4ad93eSJiri Olsatest_make_install := $(call test_dest_files,$(installed_files_all)) 240ee4ad93eSJiri Olsatest_make_install_O := $(call test_dest_files,$(installed_files_all)) 241ee4ad93eSJiri Olsatest_make_install_bin := $(call test_dest_files,$(installed_files_bin)) 242ee4ad93eSJiri Olsatest_make_install_bin_O := $(call test_dest_files,$(installed_files_bin)) 243c0ec1108SJiri Olsa 244aa53c09eSJiri Olsa# We prefix all installed files for make_install_prefix(_slash) 245eb30d2c5SJiri Olsa# with '/tmp/krava' to match installed/prefix-ed files. 246eb30d2c5SJiri Olsainstalled_files_all_prefix := $(addprefix /tmp/krava/,$(installed_files_all)) 247eb30d2c5SJiri Olsatest_make_install_prefix := $(call test_dest_files,$(installed_files_all_prefix)) 248eb30d2c5SJiri Olsatest_make_install_prefix_O := $(call test_dest_files,$(installed_files_all_prefix)) 249eb30d2c5SJiri Olsa 250aa53c09eSJiri Olsatest_make_install_prefix_slash := $(test_make_install_prefix) 251aa53c09eSJiri Olsatest_make_install_prefix_slash_O := $(test_make_install_prefix_O) 252aa53c09eSJiri Olsa 253dbad4189SJiri Olsa# FIXME nothing gets installed 254dbad4189SJiri Olsatest_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1 255dbad4189SJiri Olsatest_make_install_man_O := $(test_make_install_man) 256dbad4189SJiri Olsa 257dbad4189SJiri Olsa# FIXME nothing gets installed 258dbad4189SJiri Olsatest_make_install_doc := $(test_ok) 259dbad4189SJiri Olsatest_make_install_doc_O := $(test_ok) 260dbad4189SJiri Olsa 261dbad4189SJiri Olsa# FIXME nothing gets installed 262dbad4189SJiri Olsatest_make_install_html := $(test_ok) 263dbad4189SJiri Olsatest_make_install_html_O := $(test_ok) 264dbad4189SJiri Olsa 265dbad4189SJiri Olsa# FIXME nothing gets installed 266dbad4189SJiri Olsatest_make_install_info := $(test_ok) 267dbad4189SJiri Olsatest_make_install_info_O := $(test_ok) 268dbad4189SJiri Olsa 269dbad4189SJiri Olsa# FIXME nothing gets installed 270dbad4189SJiri Olsatest_make_install_pdf := $(test_ok) 271dbad4189SJiri Olsatest_make_install_pdf_O := $(test_ok) 272dbad4189SJiri Olsa 2738df12cbcSArnaldo Carvalho de Melotest_make_libbpf_dynamic := ldd $(PERF_O)/perf | grep -q libbpf 2748df12cbcSArnaldo Carvalho de Melotest_make_libbpf_dynamic_O := ldd $$TMP_O/perf | grep -q libbpf 2758df12cbcSArnaldo Carvalho de Melo 27604b01a1dSJiri Olsatest_make_python_perf_so_O := test -f $$TMP_O/python/perf.so 27704b01a1dSJiri Olsatest_make_perf_o_O := test -f $$TMP_O/perf.o 27804b01a1dSJiri Olsatest_make_util_map_o_O := test -f $$TMP_O/util/map.o 2792a94f6c4SJiri Olsatest_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o 280095ae69bSJiri Olsa 28168824de1SWang Nantest_default = test -x $(PERF_O)/perf 282095ae69bSJiri Olsatest = $(if $(test_$1),$(test_$1),$(test_default)) 283095ae69bSJiri Olsa 2848ba7cdeaSJiri Olsatest_default_O = test -x $$TMP_O/perf 285095ae69bSJiri Olsatest_O = $(if $(test_$1),$(test_$1),$(test_default_O)) 286095ae69bSJiri Olsa 287095ae69bSJiri Olsaall: 288095ae69bSJiri Olsa 28998916392SArnaldo Carvalho de Meloifdef SHUF 29098916392SArnaldo Carvalho de Melorun := $(shell shuf -e $(run)) 29198916392SArnaldo Carvalho de Melorun_O := $(shell shuf -e $(run_O)) 29298916392SArnaldo Carvalho de Meloendif 29398916392SArnaldo Carvalho de Melo 294814568dbSArnaldo Carvalho de Melomax_width := $(shell echo $(run_O) | sed 's/ /\n/g' | wc -L) 295814568dbSArnaldo Carvalho de Melo 296095ae69bSJiri Olsaifdef DEBUG 297095ae69bSJiri Olsad := $(info run $(run)) 298095ae69bSJiri Olsad := $(info run_O $(run_O)) 299095ae69bSJiri Olsaendif 300095ae69bSJiri Olsa 301095ae69bSJiri OlsaMAKEFLAGS := --no-print-directory 302095ae69bSJiri Olsa 303207da473SJiri Olsaclean := @(cd $(PERF); $(MAKE_F) -s $(O_OPT) clean >/dev/null && $(MAKE) -s $(O_OPT) -C ../build clean >/dev/null) 304095ae69bSJiri Olsa 305095ae69bSJiri Olsa$(run): 306095ae69bSJiri Olsa $(call clean) 307c9311674SJiri Olsa @TMP_DEST=$$(mktemp -d); \ 3083c7a152bSArnaldo Carvalho de Melo cmd="cd $(PERF) && $(MAKE_F) $($@) $(PARALLEL_OPT) $(O_OPT) DESTDIR=$$TMP_DEST"; \ 309814568dbSArnaldo Carvalho de Melo printf "%*.*s: %s\n" $(max_width) $(max_width) "$@" "$$cmd" && echo $$cmd > $@ && \ 310095ae69bSJiri Olsa ( eval $$cmd ) >> $@ 2>&1; \ 311ee4ad93eSJiri Olsa echo " test: $(call test,$@)" >> $@ 2>&1; \ 312095ae69bSJiri Olsa $(call test,$@) && \ 313a5c5009fSArnaldo Carvalho de Melo rm -rf $@ $$TMP_DEST || (cat $@ ; false) 314095ae69bSJiri Olsa 315bb7db869SArnaldo Carvalho de Melomake_with_gtk2: 316bb7db869SArnaldo Carvalho de Melo $(call clean) 317bb7db869SArnaldo Carvalho de Melo @TMP_DEST=$$(mktemp -d); \ 318bb7db869SArnaldo Carvalho de Melo cmd="cd $(PERF) && $(MAKE_F) $($@) $(PARALLEL_OPT) $(O_OPT) DESTDIR=$$TMP_DEST"; \ 319bb7db869SArnaldo Carvalho de Melo printf "%*.*s: %s\n" $(max_width) $(max_width) "$@" "$$cmd" && echo $$cmd > $@ && \ 320bb7db869SArnaldo Carvalho de Melo ( eval $$cmd ) >> $@ 2>&1; \ 321bb7db869SArnaldo Carvalho de Melo echo " test: $(call test,$@)" >> $@ 2>&1; \ 322bb7db869SArnaldo Carvalho de Melo $(call test,$@) && \ 323bb7db869SArnaldo Carvalho de Melo rm -rf $@ $$TMP_DEST || (cat $@ ; false) 324bb7db869SArnaldo Carvalho de Melo 325bb7db869SArnaldo Carvalho de Melomake_static: 326bb7db869SArnaldo Carvalho de Melo $(call clean) 327bb7db869SArnaldo Carvalho de Melo @TMP_DEST=$$(mktemp -d); \ 328bb7db869SArnaldo Carvalho de Melo cmd="cd $(PERF) && $(MAKE_F) $($@) $(PARALLEL_OPT) $(O_OPT) DESTDIR=$$TMP_DEST"; \ 329bb7db869SArnaldo Carvalho de Melo printf "%*.*s: %s\n" $(max_width) $(max_width) "$@" "$$cmd" && echo $$cmd > $@ && \ 330bb7db869SArnaldo Carvalho de Melo ( eval $$cmd ) >> $@ 2>&1; \ 331bb7db869SArnaldo Carvalho de Melo echo " test: $(call test,$@)" >> $@ 2>&1; \ 332bb7db869SArnaldo Carvalho de Melo $(call test,$@) && \ 333bb7db869SArnaldo Carvalho de Melo rm -rf $@ $$TMP_DEST || (cat $@ ; false) 334bb7db869SArnaldo Carvalho de Melo 335095ae69bSJiri Olsa$(run_O): 336095ae69bSJiri Olsa $(call clean) 3378ba7cdeaSJiri Olsa @TMP_O=$$(mktemp -d); \ 338c9311674SJiri Olsa TMP_DEST=$$(mktemp -d); \ 3393c7a152bSArnaldo Carvalho de Melo cmd="cd $(PERF) && $(MAKE_F) $($(patsubst %_O,%,$@)) $(PARALLEL_OPT) O=$$TMP_O DESTDIR=$$TMP_DEST"; \ 340814568dbSArnaldo Carvalho de Melo printf "%*.*s: %s\n" $(max_width) $(max_width) "$@" "$$cmd" && echo $$cmd > $@ && \ 341095ae69bSJiri Olsa ( eval $$cmd ) >> $@ 2>&1 && \ 342ee4ad93eSJiri Olsa echo " test: $(call test_O,$@)" >> $@ 2>&1; \ 343095ae69bSJiri Olsa $(call test_O,$@) && \ 344a5c5009fSArnaldo Carvalho de Melo rm -rf $@ $$TMP_O $$TMP_DEST || (cat $@ ; false) 345095ae69bSJiri Olsa 34648878053SArnaldo Carvalho de Melotarpkg: 34748878053SArnaldo Carvalho de Melo @cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \ 34848878053SArnaldo Carvalho de Melo echo "- $@: $$cmd" && echo $$cmd > $@ && \ 349004bd89dSJosh Poimboeuf ( eval $$cmd ) >> $@ 2>&1 && \ 350004bd89dSJosh Poimboeuf rm -f $@ 35148878053SArnaldo Carvalho de Melo 35268824de1SWang NanKERNEL_O := ../.. 35368824de1SWang Nanifneq ($(O),) 35468824de1SWang Nan KERNEL_O := $(O) 35568824de1SWang Nanendif 35668824de1SWang Nan 357c41c6647SJiri Olsamake_kernelsrc: 358c15e758cSWang Nan @echo "- make -C <kernelsrc> $(PARALLEL_OPT) $(K_O_OPT) tools/perf" 359c41c6647SJiri Olsa $(call clean); \ 360c15e758cSWang Nan (make -C ../.. $(PARALLEL_OPT) $(K_O_OPT) tools/perf) > $@ 2>&1 && \ 36168824de1SWang Nan test -x $(KERNEL_O)/tools/perf/perf && rm -f $@ || (cat $@ ; false) 362c41c6647SJiri Olsa 363c41c6647SJiri Olsamake_kernelsrc_tools: 364c15e758cSWang Nan @echo "- make -C <kernelsrc>/tools $(PARALLEL_OPT) $(K_O_OPT) perf" 365c41c6647SJiri Olsa $(call clean); \ 366c15e758cSWang Nan (make -C ../../tools $(PARALLEL_OPT) $(K_O_OPT) perf) > $@ 2>&1 && \ 36768824de1SWang Nan test -x $(KERNEL_O)/tools/perf/perf && rm -f $@ || (cat $@ ; false) 368c41c6647SJiri Olsa 3699eab951fSJiri Olsamake_libperf: 3709eab951fSJiri Olsa @echo "- make -C lib"; 3719eab951fSJiri Olsa make -C lib clean >$@ 2>&1; make -C lib >>$@ 2>&1 && rm $@ 3729eab951fSJiri Olsa 37379191c89SWang NanFEATURES_DUMP_FILE := $(FULL_O)/BUILD_TEST_FEATURE_DUMP 37479191c89SWang NanFEATURES_DUMP_FILE_STATIC := $(FULL_O)/BUILD_TEST_FEATURE_DUMP_STATIC 37579191c89SWang Nan 376c41c6647SJiri Olsaall: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools 377095ae69bSJiri Olsa @echo OK 37879191c89SWang Nan @rm -f $(FEATURES_DUMP_FILE) $(FEATURES_DUMP_FILE_STATIC) 379095ae69bSJiri Olsa 380095ae69bSJiri Olsaout: $(run_O) 381095ae69bSJiri Olsa @echo OK 38279191c89SWang Nan @rm -f $(FEATURES_DUMP_FILE) $(FEATURES_DUMP_FILE_STATIC) 38379191c89SWang Nan 38479191c89SWang Nanifeq ($(REUSE_FEATURES_DUMP),1) 38579191c89SWang Nan$(FEATURES_DUMP_FILE): 38679191c89SWang Nan $(call clean) 38779191c89SWang Nan @cmd="cd $(PERF) && make FEATURE_DUMP_COPY=$@ $(O_OPT) feature-dump"; \ 38879191c89SWang Nan echo "- $@: $$cmd" && echo $$cmd && \ 38979191c89SWang Nan ( eval $$cmd ) > /dev/null 2>&1 39079191c89SWang Nan 39179191c89SWang Nan$(FEATURES_DUMP_FILE_STATIC): 39279191c89SWang Nan $(call clean) 39379191c89SWang Nan @cmd="cd $(PERF) && make FEATURE_DUMP_COPY=$@ $(O_OPT) LDFLAGS='-static' feature-dump"; \ 39479191c89SWang Nan echo "- $@: $$cmd" && echo $$cmd && \ 39579191c89SWang Nan ( eval $$cmd ) > /dev/null 2>&1 39679191c89SWang Nan 39779191c89SWang Nan# Add feature dump dependency for run/run_O targets 39879191c89SWang Nan$(foreach t,$(run) $(run_O),$(eval \ 39979191c89SWang Nan $(t): $(if $(findstring make_static,$(t)),\ 40079191c89SWang Nan $(FEATURES_DUMP_FILE_STATIC),\ 40179191c89SWang Nan $(FEATURES_DUMP_FILE)))) 40279191c89SWang Nan 40379191c89SWang Nan# Append 'FEATURES_DUMP=' option to all test cases. For example: 40479191c89SWang Nan# make_no_libbpf: NO_LIBBPF=1 --> NO_LIBBPF=1 FEATURES_DUMP=/a/b/BUILD_TEST_FEATURE_DUMP 40579191c89SWang Nan# make_static: LDFLAGS=-static --> LDFLAGS=-static FEATURES_DUMP=/a/b/BUILD_TEST_FEATURE_DUMP_STATIC 40679191c89SWang Nan$(foreach t,$(run),$(if $(findstring make_static,$(t)),\ 40779191c89SWang Nan $(eval $(t) := $($(t)) FEATURES_DUMP=$(FEATURES_DUMP_FILE_STATIC)),\ 40879191c89SWang Nan $(eval $(t) := $($(t)) FEATURES_DUMP=$(FEATURES_DUMP_FILE)))) 40979191c89SWang Nanendif 410095ae69bSJiri Olsa 4119eab951fSJiri Olsa.PHONY: all $(run) $(run_O) tarpkg clean make_kernelsrc make_kernelsrc_tools make_libperf 412502819c5SJiri Olsaendif # ifndef MK 413