1*4882a593Smuzhiyuninclude ../scripts/Makefile.include 2*4882a593Smuzhiyun 3*4882a593Smuzhiyunifndef MK 4*4882a593Smuzhiyunifeq ($(MAKECMDGOALS),) 5*4882a593Smuzhiyun# no target specified, trigger the whole suite 6*4882a593Smuzhiyunall: 7*4882a593Smuzhiyun @echo "Testing Makefile"; $(MAKE) -sf tests/make MK=Makefile 8*4882a593Smuzhiyun @echo "Testing Makefile.perf"; $(MAKE) -sf tests/make MK=Makefile.perf SET_PARALLEL=1 SET_O=1 9*4882a593Smuzhiyunelse 10*4882a593Smuzhiyun# run only specific test over 'Makefile' 11*4882a593Smuzhiyun%: 12*4882a593Smuzhiyun @echo "Testing Makefile"; $(MAKE) -sf tests/make MK=Makefile $@ 13*4882a593Smuzhiyunendif 14*4882a593Smuzhiyunelse 15*4882a593SmuzhiyunPERF := . 16*4882a593SmuzhiyunPERF_O := $(PERF) 17*4882a593SmuzhiyunO_OPT := 18*4882a593SmuzhiyunFULL_O := $(shell readlink -f $(PERF_O) || echo $(PERF_O)) 19*4882a593Smuzhiyun 20*4882a593Smuzhiyunifneq ($(O),) 21*4882a593Smuzhiyun FULL_O := $(shell readlink -f $(O) || echo $(O)) 22*4882a593Smuzhiyun PERF_O := $(FULL_O) 23*4882a593Smuzhiyun ifeq ($(SET_O),1) 24*4882a593Smuzhiyun O_OPT := 'O=$(FULL_O)' 25*4882a593Smuzhiyun endif 26*4882a593Smuzhiyun K_O_OPT := 'O=$(FULL_O)' 27*4882a593Smuzhiyunendif 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunPARALLEL_OPT= 30*4882a593Smuzhiyunifeq ($(SET_PARALLEL),1) 31*4882a593Smuzhiyun ifeq ($(JOBS),) 32*4882a593Smuzhiyun cores := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null) 33*4882a593Smuzhiyun ifeq ($(cores),0) 34*4882a593Smuzhiyun cores := 1 35*4882a593Smuzhiyun endif 36*4882a593Smuzhiyun else 37*4882a593Smuzhiyun cores=$(JOBS) 38*4882a593Smuzhiyun endif 39*4882a593Smuzhiyun PARALLEL_OPT="-j$(cores)" 40*4882a593Smuzhiyunendif 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun# As per kernel Makefile, avoid funny character set dependencies 43*4882a593Smuzhiyununexport LC_ALL 44*4882a593SmuzhiyunLC_COLLATE=C 45*4882a593SmuzhiyunLC_NUMERIC=C 46*4882a593Smuzhiyunexport LC_COLLATE LC_NUMERIC 47*4882a593Smuzhiyun 48*4882a593Smuzhiyunifeq ($(srctree),) 49*4882a593Smuzhiyunsrctree := $(patsubst %/,%,$(dir $(CURDIR))) 50*4882a593Smuzhiyunsrctree := $(patsubst %/,%,$(dir $(srctree))) 51*4882a593Smuzhiyun#$(info Determined 'srctree' to be $(srctree)) 52*4882a593Smuzhiyunendif 53*4882a593Smuzhiyun 54*4882a593Smuzhiyuninclude $(srctree)/tools/scripts/Makefile.arch 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun# FIXME looks like x86 is the only arch running tests ;-) 57*4882a593Smuzhiyun# we need some IS_(32/64) flag to make this generic 58*4882a593Smuzhiyunifeq ($(ARCH)$(IS_64_BIT), x861) 59*4882a593Smuzhiyunlib = lib64 60*4882a593Smuzhiyunelse 61*4882a593Smuzhiyunlib = lib 62*4882a593Smuzhiyunendif 63*4882a593Smuzhiyun 64*4882a593Smuzhiyunhas = $(shell which $1 2>/dev/null) 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun# standard single make variable specified 67*4882a593Smuzhiyunmake_clean_all := clean all 68*4882a593Smuzhiyunmake_python_perf_so := python/perf.so 69*4882a593Smuzhiyunmake_debug := DEBUG=1 70*4882a593Smuzhiyunmake_no_libperl := NO_LIBPERL=1 71*4882a593Smuzhiyunmake_no_libpython := NO_LIBPYTHON=1 72*4882a593Smuzhiyunmake_no_scripts := NO_LIBPYTHON=1 NO_LIBPERL=1 73*4882a593Smuzhiyunmake_no_newt := NO_NEWT=1 74*4882a593Smuzhiyunmake_no_slang := NO_SLANG=1 75*4882a593Smuzhiyunmake_no_gtk2 := NO_GTK2=1 76*4882a593Smuzhiyunmake_no_ui := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1 77*4882a593Smuzhiyunmake_no_demangle := NO_DEMANGLE=1 78*4882a593Smuzhiyunmake_no_libelf := NO_LIBELF=1 79*4882a593Smuzhiyunmake_no_libunwind := NO_LIBUNWIND=1 80*4882a593Smuzhiyunmake_no_libdw_dwarf_unwind := NO_LIBDW_DWARF_UNWIND=1 81*4882a593Smuzhiyunmake_no_backtrace := NO_BACKTRACE=1 82*4882a593Smuzhiyunmake_no_libnuma := NO_LIBNUMA=1 83*4882a593Smuzhiyunmake_no_libaudit := NO_LIBAUDIT=1 84*4882a593Smuzhiyunmake_no_libbionic := NO_LIBBIONIC=1 85*4882a593Smuzhiyunmake_no_auxtrace := NO_AUXTRACE=1 86*4882a593Smuzhiyunmake_no_libbpf := NO_LIBBPF=1 87*4882a593Smuzhiyunmake_no_libbpf_DEBUG := NO_LIBBPF=1 DEBUG=1 88*4882a593Smuzhiyunmake_no_libcrypto := NO_LIBCRYPTO=1 89*4882a593Smuzhiyunmake_with_babeltrace:= LIBBABELTRACE=1 90*4882a593Smuzhiyunmake_no_sdt := NO_SDT=1 91*4882a593Smuzhiyunmake_no_syscall_tbl := NO_SYSCALL_TABLE=1 92*4882a593Smuzhiyunmake_with_clangllvm := LIBCLANGLLVM=1 93*4882a593Smuzhiyunmake_with_libpfm4 := LIBPFM4=1 94*4882a593Smuzhiyunmake_with_gtk2 := GTK2=1 95*4882a593Smuzhiyunmake_tags := tags 96*4882a593Smuzhiyunmake_cscope := cscope 97*4882a593Smuzhiyunmake_help := help 98*4882a593Smuzhiyunmake_doc := doc 99*4882a593Smuzhiyunmake_perf_o := perf.o 100*4882a593Smuzhiyunmake_util_map_o := util/map.o 101*4882a593Smuzhiyunmake_util_pmu_bison_o := util/pmu-bison.o 102*4882a593Smuzhiyunmake_install := install 103*4882a593Smuzhiyunmake_install_bin := install-bin 104*4882a593Smuzhiyunmake_install_doc := install-doc 105*4882a593Smuzhiyunmake_install_man := install-man 106*4882a593Smuzhiyunmake_install_html := install-html 107*4882a593Smuzhiyunmake_install_info := install-info 108*4882a593Smuzhiyunmake_install_pdf := install-pdf 109*4882a593Smuzhiyunmake_install_prefix := install prefix=/tmp/krava 110*4882a593Smuzhiyunmake_install_prefix_slash := install prefix=/tmp/krava/ 111*4882a593Smuzhiyunmake_static := LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun# all the NO_* variable combined 114*4882a593Smuzhiyunmake_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 115*4882a593Smuzhiyunmake_minimal += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 116*4882a593Smuzhiyunmake_minimal += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 117*4882a593Smuzhiyunmake_minimal += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 118*4882a593Smuzhiyunmake_minimal += NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1 NO_LIBZSTD=1 119*4882a593Smuzhiyunmake_minimal += NO_LIBCAP=1 NO_SYSCALL_TABLE=1 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun# $(run) contains all available tests 122*4882a593Smuzhiyunrun := make_pure 123*4882a593Smuzhiyun# Targets 'clean all' can be run together only through top level 124*4882a593Smuzhiyun# Makefile because we detect clean target in Makefile.perf and 125*4882a593Smuzhiyun# disable features detection 126*4882a593Smuzhiyunifeq ($(MK),Makefile) 127*4882a593Smuzhiyunrun += make_clean_all 128*4882a593SmuzhiyunMAKE_F := $(MAKE) 129*4882a593Smuzhiyunelse 130*4882a593SmuzhiyunMAKE_F := $(MAKE) -f $(MK) 131*4882a593Smuzhiyunendif 132*4882a593Smuzhiyunrun += make_python_perf_so 133*4882a593Smuzhiyunrun += make_debug 134*4882a593Smuzhiyunrun += make_no_libperl 135*4882a593Smuzhiyunrun += make_no_libpython 136*4882a593Smuzhiyunrun += make_no_scripts 137*4882a593Smuzhiyunrun += make_no_newt 138*4882a593Smuzhiyunrun += make_no_slang 139*4882a593Smuzhiyunrun += make_no_gtk2 140*4882a593Smuzhiyunrun += make_no_ui 141*4882a593Smuzhiyunrun += make_no_demangle 142*4882a593Smuzhiyunrun += make_no_libelf 143*4882a593Smuzhiyunrun += make_no_libunwind 144*4882a593Smuzhiyunrun += make_no_libdw_dwarf_unwind 145*4882a593Smuzhiyunrun += make_no_backtrace 146*4882a593Smuzhiyunrun += make_no_libnuma 147*4882a593Smuzhiyunrun += make_no_libaudit 148*4882a593Smuzhiyunrun += make_no_libbionic 149*4882a593Smuzhiyunrun += make_no_auxtrace 150*4882a593Smuzhiyunrun += make_no_libbpf 151*4882a593Smuzhiyunrun += make_no_libbpf_DEBUG 152*4882a593Smuzhiyunrun += make_no_libcrypto 153*4882a593Smuzhiyunrun += make_no_sdt 154*4882a593Smuzhiyunrun += make_no_syscall_tbl 155*4882a593Smuzhiyunrun += make_with_babeltrace 156*4882a593Smuzhiyunrun += make_with_clangllvm 157*4882a593Smuzhiyunrun += make_with_libpfm4 158*4882a593Smuzhiyunrun += make_with_gtk2 159*4882a593Smuzhiyunrun += make_help 160*4882a593Smuzhiyunrun += make_doc 161*4882a593Smuzhiyunrun += make_perf_o 162*4882a593Smuzhiyunrun += make_util_map_o 163*4882a593Smuzhiyunrun += make_util_pmu_bison_o 164*4882a593Smuzhiyunrun += make_install 165*4882a593Smuzhiyunrun += make_install_bin 166*4882a593Smuzhiyunrun += make_install_prefix 167*4882a593Smuzhiyunrun += make_install_prefix_slash 168*4882a593Smuzhiyun# FIXME 'install-*' commented out till they're fixed 169*4882a593Smuzhiyun# run += make_install_doc 170*4882a593Smuzhiyun# run += make_install_man 171*4882a593Smuzhiyun# run += make_install_html 172*4882a593Smuzhiyun# run += make_install_info 173*4882a593Smuzhiyun# run += make_install_pdf 174*4882a593Smuzhiyunrun += make_minimal 175*4882a593Smuzhiyunrun += make_static 176*4882a593Smuzhiyun 177*4882a593Smuzhiyunifneq ($(call has,ctags),) 178*4882a593Smuzhiyunrun += make_tags 179*4882a593Smuzhiyunendif 180*4882a593Smuzhiyunifneq ($(call has,cscope),) 181*4882a593Smuzhiyunrun += make_cscope 182*4882a593Smuzhiyunendif 183*4882a593Smuzhiyun 184*4882a593Smuzhiyun# $(run_O) contains same portion of $(run) tests with '_O' attached 185*4882a593Smuzhiyun# to distinguish O=... tests 186*4882a593Smuzhiyunrun_O := $(addsuffix _O,$(run)) 187*4882a593Smuzhiyun 188*4882a593Smuzhiyun# disable some tests for O=... 189*4882a593Smuzhiyunrun_O := $(filter-out make_python_perf_so_O,$(run_O)) 190*4882a593Smuzhiyun 191*4882a593Smuzhiyun# define test for each compile as 'test_NAME' variable 192*4882a593Smuzhiyun# with the test itself as a value 193*4882a593Smuzhiyuntest_make_tags = test -f tags 194*4882a593Smuzhiyuntest_make_cscope = test -f cscope.out 195*4882a593Smuzhiyun 196*4882a593Smuzhiyuntest_make_tags_O := $(test_make_tags) 197*4882a593Smuzhiyuntest_make_cscope_O := $(test_make_cscope) 198*4882a593Smuzhiyun 199*4882a593Smuzhiyuntest_ok := true 200*4882a593Smuzhiyuntest_make_help := $(test_ok) 201*4882a593Smuzhiyuntest_make_doc := $(test_ok) 202*4882a593Smuzhiyuntest_make_help_O := $(test_ok) 203*4882a593Smuzhiyuntest_make_doc_O := $(test_ok) 204*4882a593Smuzhiyun 205*4882a593Smuzhiyuntest_make_python_perf_so := test -f $(PERF_O)/python/perf.so 206*4882a593Smuzhiyun 207*4882a593Smuzhiyuntest_make_perf_o := test -f $(PERF_O)/perf.o 208*4882a593Smuzhiyuntest_make_util_map_o := test -f $(PERF_O)/util/map.o 209*4882a593Smuzhiyuntest_make_util_pmu_bison_o := test -f $(PERF_O)/util/pmu-bison.o 210*4882a593Smuzhiyun 211*4882a593Smuzhiyundefine test_dest_files 212*4882a593Smuzhiyun for file in $(1); do \ 213*4882a593Smuzhiyun if [ ! -x $$TMP_DEST/$$file ]; then \ 214*4882a593Smuzhiyun echo " failed to find: $$file"; \ 215*4882a593Smuzhiyun fi \ 216*4882a593Smuzhiyun done 217*4882a593Smuzhiyunendef 218*4882a593Smuzhiyun 219*4882a593Smuzhiyuninstalled_files_bin := bin/perf 220*4882a593Smuzhiyuninstalled_files_bin += etc/bash_completion.d/perf 221*4882a593Smuzhiyuninstalled_files_bin += libexec/perf-core/perf-archive 222*4882a593Smuzhiyun 223*4882a593Smuzhiyuninstalled_files_plugins := $(lib)/traceevent/plugins/plugin_cfg80211.so 224*4882a593Smuzhiyuninstalled_files_plugins += $(lib)/traceevent/plugins/plugin_scsi.so 225*4882a593Smuzhiyuninstalled_files_plugins += $(lib)/traceevent/plugins/plugin_xen.so 226*4882a593Smuzhiyuninstalled_files_plugins += $(lib)/traceevent/plugins/plugin_function.so 227*4882a593Smuzhiyuninstalled_files_plugins += $(lib)/traceevent/plugins/plugin_sched_switch.so 228*4882a593Smuzhiyuninstalled_files_plugins += $(lib)/traceevent/plugins/plugin_mac80211.so 229*4882a593Smuzhiyuninstalled_files_plugins += $(lib)/traceevent/plugins/plugin_kvm.so 230*4882a593Smuzhiyuninstalled_files_plugins += $(lib)/traceevent/plugins/plugin_kmem.so 231*4882a593Smuzhiyuninstalled_files_plugins += $(lib)/traceevent/plugins/plugin_hrtimer.so 232*4882a593Smuzhiyuninstalled_files_plugins += $(lib)/traceevent/plugins/plugin_jbd2.so 233*4882a593Smuzhiyun 234*4882a593Smuzhiyuninstalled_files_all := $(installed_files_bin) 235*4882a593Smuzhiyuninstalled_files_all += $(installed_files_plugins) 236*4882a593Smuzhiyun 237*4882a593Smuzhiyuntest_make_install := $(call test_dest_files,$(installed_files_all)) 238*4882a593Smuzhiyuntest_make_install_O := $(call test_dest_files,$(installed_files_all)) 239*4882a593Smuzhiyuntest_make_install_bin := $(call test_dest_files,$(installed_files_bin)) 240*4882a593Smuzhiyuntest_make_install_bin_O := $(call test_dest_files,$(installed_files_bin)) 241*4882a593Smuzhiyun 242*4882a593Smuzhiyun# We prefix all installed files for make_install_prefix(_slash) 243*4882a593Smuzhiyun# with '/tmp/krava' to match installed/prefix-ed files. 244*4882a593Smuzhiyuninstalled_files_all_prefix := $(addprefix /tmp/krava/,$(installed_files_all)) 245*4882a593Smuzhiyuntest_make_install_prefix := $(call test_dest_files,$(installed_files_all_prefix)) 246*4882a593Smuzhiyuntest_make_install_prefix_O := $(call test_dest_files,$(installed_files_all_prefix)) 247*4882a593Smuzhiyun 248*4882a593Smuzhiyuntest_make_install_prefix_slash := $(test_make_install_prefix) 249*4882a593Smuzhiyuntest_make_install_prefix_slash_O := $(test_make_install_prefix_O) 250*4882a593Smuzhiyun 251*4882a593Smuzhiyun# FIXME nothing gets installed 252*4882a593Smuzhiyuntest_make_install_man := test -f $$TMP_DEST/share/man/man1/perf.1 253*4882a593Smuzhiyuntest_make_install_man_O := $(test_make_install_man) 254*4882a593Smuzhiyun 255*4882a593Smuzhiyun# FIXME nothing gets installed 256*4882a593Smuzhiyuntest_make_install_doc := $(test_ok) 257*4882a593Smuzhiyuntest_make_install_doc_O := $(test_ok) 258*4882a593Smuzhiyun 259*4882a593Smuzhiyun# FIXME nothing gets installed 260*4882a593Smuzhiyuntest_make_install_html := $(test_ok) 261*4882a593Smuzhiyuntest_make_install_html_O := $(test_ok) 262*4882a593Smuzhiyun 263*4882a593Smuzhiyun# FIXME nothing gets installed 264*4882a593Smuzhiyuntest_make_install_info := $(test_ok) 265*4882a593Smuzhiyuntest_make_install_info_O := $(test_ok) 266*4882a593Smuzhiyun 267*4882a593Smuzhiyun# FIXME nothing gets installed 268*4882a593Smuzhiyuntest_make_install_pdf := $(test_ok) 269*4882a593Smuzhiyuntest_make_install_pdf_O := $(test_ok) 270*4882a593Smuzhiyun 271*4882a593Smuzhiyuntest_make_python_perf_so_O := test -f $$TMP_O/python/perf.so 272*4882a593Smuzhiyuntest_make_perf_o_O := test -f $$TMP_O/perf.o 273*4882a593Smuzhiyuntest_make_util_map_o_O := test -f $$TMP_O/util/map.o 274*4882a593Smuzhiyuntest_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o 275*4882a593Smuzhiyun 276*4882a593Smuzhiyuntest_default = test -x $(PERF_O)/perf 277*4882a593Smuzhiyuntest = $(if $(test_$1),$(test_$1),$(test_default)) 278*4882a593Smuzhiyun 279*4882a593Smuzhiyuntest_default_O = test -x $$TMP_O/perf 280*4882a593Smuzhiyuntest_O = $(if $(test_$1),$(test_$1),$(test_default_O)) 281*4882a593Smuzhiyun 282*4882a593Smuzhiyunall: 283*4882a593Smuzhiyun 284*4882a593Smuzhiyunifdef SHUF 285*4882a593Smuzhiyunrun := $(shell shuf -e $(run)) 286*4882a593Smuzhiyunrun_O := $(shell shuf -e $(run_O)) 287*4882a593Smuzhiyunendif 288*4882a593Smuzhiyun 289*4882a593Smuzhiyunmax_width := $(shell echo $(run_O) | sed 's/ /\n/g' | wc -L) 290*4882a593Smuzhiyun 291*4882a593Smuzhiyunifdef DEBUG 292*4882a593Smuzhiyund := $(info run $(run)) 293*4882a593Smuzhiyund := $(info run_O $(run_O)) 294*4882a593Smuzhiyunendif 295*4882a593Smuzhiyun 296*4882a593SmuzhiyunMAKEFLAGS := --no-print-directory 297*4882a593Smuzhiyun 298*4882a593Smuzhiyunclean := @(cd $(PERF); $(MAKE_F) -s $(O_OPT) clean >/dev/null && $(MAKE) -s $(O_OPT) -C ../build clean >/dev/null) 299*4882a593Smuzhiyun 300*4882a593Smuzhiyun$(run): 301*4882a593Smuzhiyun $(call clean) 302*4882a593Smuzhiyun @TMP_DEST=$$(mktemp -d); \ 303*4882a593Smuzhiyun cmd="cd $(PERF) && $(MAKE_F) $($@) $(PARALLEL_OPT) $(O_OPT) DESTDIR=$$TMP_DEST"; \ 304*4882a593Smuzhiyun printf "%*.*s: %s\n" $(max_width) $(max_width) "$@" "$$cmd" && echo $$cmd > $@ && \ 305*4882a593Smuzhiyun ( eval $$cmd ) >> $@ 2>&1; \ 306*4882a593Smuzhiyun echo " test: $(call test,$@)" >> $@ 2>&1; \ 307*4882a593Smuzhiyun $(call test,$@) && \ 308*4882a593Smuzhiyun rm -rf $@ $$TMP_DEST || (cat $@ ; false) 309*4882a593Smuzhiyun 310*4882a593Smuzhiyun$(run_O): 311*4882a593Smuzhiyun $(call clean) 312*4882a593Smuzhiyun @TMP_O=$$(mktemp -d); \ 313*4882a593Smuzhiyun TMP_DEST=$$(mktemp -d); \ 314*4882a593Smuzhiyun cmd="cd $(PERF) && $(MAKE_F) $($(patsubst %_O,%,$@)) $(PARALLEL_OPT) O=$$TMP_O DESTDIR=$$TMP_DEST"; \ 315*4882a593Smuzhiyun printf "%*.*s: %s\n" $(max_width) $(max_width) "$@" "$$cmd" && echo $$cmd > $@ && \ 316*4882a593Smuzhiyun ( eval $$cmd ) >> $@ 2>&1 && \ 317*4882a593Smuzhiyun echo " test: $(call test_O,$@)" >> $@ 2>&1; \ 318*4882a593Smuzhiyun $(call test_O,$@) && \ 319*4882a593Smuzhiyun rm -rf $@ $$TMP_O $$TMP_DEST || (cat $@ ; false) 320*4882a593Smuzhiyun 321*4882a593Smuzhiyuntarpkg: 322*4882a593Smuzhiyun @cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \ 323*4882a593Smuzhiyun echo "- $@: $$cmd" && echo $$cmd > $@ && \ 324*4882a593Smuzhiyun ( eval $$cmd ) >> $@ 2>&1 && \ 325*4882a593Smuzhiyun rm -f $@ 326*4882a593Smuzhiyun 327*4882a593SmuzhiyunKERNEL_O := ../.. 328*4882a593Smuzhiyunifneq ($(O),) 329*4882a593Smuzhiyun KERNEL_O := $(O) 330*4882a593Smuzhiyunendif 331*4882a593Smuzhiyun 332*4882a593Smuzhiyunmake_kernelsrc: 333*4882a593Smuzhiyun @echo "- make -C <kernelsrc> $(PARALLEL_OPT) $(K_O_OPT) tools/perf" 334*4882a593Smuzhiyun $(call clean); \ 335*4882a593Smuzhiyun (make -C ../.. $(PARALLEL_OPT) $(K_O_OPT) tools/perf) > $@ 2>&1 && \ 336*4882a593Smuzhiyun test -x $(KERNEL_O)/tools/perf/perf && rm -f $@ || (cat $@ ; false) 337*4882a593Smuzhiyun 338*4882a593Smuzhiyunmake_kernelsrc_tools: 339*4882a593Smuzhiyun @echo "- make -C <kernelsrc>/tools $(PARALLEL_OPT) $(K_O_OPT) perf" 340*4882a593Smuzhiyun $(call clean); \ 341*4882a593Smuzhiyun (make -C ../../tools $(PARALLEL_OPT) $(K_O_OPT) perf) > $@ 2>&1 && \ 342*4882a593Smuzhiyun test -x $(KERNEL_O)/tools/perf/perf && rm -f $@ || (cat $@ ; false) 343*4882a593Smuzhiyun 344*4882a593Smuzhiyunmake_libperf: 345*4882a593Smuzhiyun @echo "- make -C lib"; 346*4882a593Smuzhiyun make -C lib clean >$@ 2>&1; make -C lib >>$@ 2>&1 && rm $@ 347*4882a593Smuzhiyun 348*4882a593SmuzhiyunFEATURES_DUMP_FILE := $(FULL_O)/BUILD_TEST_FEATURE_DUMP 349*4882a593SmuzhiyunFEATURES_DUMP_FILE_STATIC := $(FULL_O)/BUILD_TEST_FEATURE_DUMP_STATIC 350*4882a593Smuzhiyun 351*4882a593Smuzhiyunall: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools 352*4882a593Smuzhiyun @echo OK 353*4882a593Smuzhiyun @rm -f $(FEATURES_DUMP_FILE) $(FEATURES_DUMP_FILE_STATIC) 354*4882a593Smuzhiyun 355*4882a593Smuzhiyunout: $(run_O) 356*4882a593Smuzhiyun @echo OK 357*4882a593Smuzhiyun @rm -f $(FEATURES_DUMP_FILE) $(FEATURES_DUMP_FILE_STATIC) 358*4882a593Smuzhiyun 359*4882a593Smuzhiyunifeq ($(REUSE_FEATURES_DUMP),1) 360*4882a593Smuzhiyun$(FEATURES_DUMP_FILE): 361*4882a593Smuzhiyun $(call clean) 362*4882a593Smuzhiyun @cmd="cd $(PERF) && make FEATURE_DUMP_COPY=$@ $(O_OPT) feature-dump"; \ 363*4882a593Smuzhiyun echo "- $@: $$cmd" && echo $$cmd && \ 364*4882a593Smuzhiyun ( eval $$cmd ) > /dev/null 2>&1 365*4882a593Smuzhiyun 366*4882a593Smuzhiyun$(FEATURES_DUMP_FILE_STATIC): 367*4882a593Smuzhiyun $(call clean) 368*4882a593Smuzhiyun @cmd="cd $(PERF) && make FEATURE_DUMP_COPY=$@ $(O_OPT) LDFLAGS='-static' feature-dump"; \ 369*4882a593Smuzhiyun echo "- $@: $$cmd" && echo $$cmd && \ 370*4882a593Smuzhiyun ( eval $$cmd ) > /dev/null 2>&1 371*4882a593Smuzhiyun 372*4882a593Smuzhiyun# Add feature dump dependency for run/run_O targets 373*4882a593Smuzhiyun$(foreach t,$(run) $(run_O),$(eval \ 374*4882a593Smuzhiyun $(t): $(if $(findstring make_static,$(t)),\ 375*4882a593Smuzhiyun $(FEATURES_DUMP_FILE_STATIC),\ 376*4882a593Smuzhiyun $(FEATURES_DUMP_FILE)))) 377*4882a593Smuzhiyun 378*4882a593Smuzhiyun# Append 'FEATURES_DUMP=' option to all test cases. For example: 379*4882a593Smuzhiyun# make_no_libbpf: NO_LIBBPF=1 --> NO_LIBBPF=1 FEATURES_DUMP=/a/b/BUILD_TEST_FEATURE_DUMP 380*4882a593Smuzhiyun# make_static: LDFLAGS=-static --> LDFLAGS=-static FEATURES_DUMP=/a/b/BUILD_TEST_FEATURE_DUMP_STATIC 381*4882a593Smuzhiyun$(foreach t,$(run),$(if $(findstring make_static,$(t)),\ 382*4882a593Smuzhiyun $(eval $(t) := $($(t)) FEATURES_DUMP=$(FEATURES_DUMP_FILE_STATIC)),\ 383*4882a593Smuzhiyun $(eval $(t) := $($(t)) FEATURES_DUMP=$(FEATURES_DUMP_FILE)))) 384*4882a593Smuzhiyunendif 385*4882a593Smuzhiyun 386*4882a593Smuzhiyun.PHONY: all $(run) $(run_O) tarpkg clean make_kernelsrc make_kernelsrc_tools make_libperf 387*4882a593Smuzhiyunendif # ifndef MK 388