1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 2684f434cSIngo Molnar# 3684f434cSIngo Molnar# This is a simple wrapper Makefile that calls the main Makefile.perf 4684f434cSIngo Molnar# with a -j option to do parallel builds 5684f434cSIngo Molnar# 6684f434cSIngo Molnar# If you want to invoke the perf build in some non-standard way then 7684f434cSIngo Molnar# you can use the 'make -f Makefile.perf' method to invoke it. 8684f434cSIngo Molnar# 9b016a0ddSIngo Molnar 10b016a0ddSIngo Molnar# 11b016a0ddSIngo Molnar# Clear out the built-in rules GNU make defines by default (such as .o targets), 12b016a0ddSIngo Molnar# so that we pass through all targets to Makefile.perf: 13b016a0ddSIngo Molnar# 14b016a0ddSIngo Molnar.SUFFIXES: 15b016a0ddSIngo Molnar 16bd69cc28SIngo Molnar# 17684f434cSIngo Molnar# We don't want to pass along options like -j: 18684f434cSIngo Molnar# 19684f434cSIngo Molnarunexport MAKEFLAGS 20684f434cSIngo Molnar 21684f434cSIngo Molnar# 22bd69cc28SIngo Molnar# Do a parallel build with multiple jobs, based on the number of CPUs online 23bd69cc28SIngo Molnar# in this system: 'make -j8' on a 8-CPU system, etc. 24bd69cc28SIngo Molnar# 25bd69cc28SIngo Molnar# (To override it, run 'make JOBS=1' and similar.) 26bd69cc28SIngo Molnar# 27bd69cc28SIngo Molnarifeq ($(JOBS),) 28762abdc0SWill Deacon JOBS := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null) 29c65568c5SDavid Ahern ifeq ($(JOBS),0) 30bd69cc28SIngo Molnar JOBS := 1 31bd69cc28SIngo Molnar endif 32bd69cc28SIngo Molnarendif 33c29ede61SArnaldo Carvalho de Melo 34b102420bSIngo Molnar# 35b102420bSIngo Molnar# Only pass canonical directory names as the output directory: 36b102420bSIngo Molnar# 37b102420bSIngo Molnarifneq ($(O),) 38be40920fSMasami Hiramatsu FULL_O := $(shell cd $(PWD); readlink -f $(O) || echo $(O)) 39b102420bSIngo Molnarendif 40b102420bSIngo Molnar 41fcf92585SIngo Molnar# 42fcf92585SIngo Molnar# Only accept the 'DEBUG' variable from the command line: 43fcf92585SIngo Molnar# 44fcf92585SIngo Molnarifeq ("$(origin DEBUG)", "command line") 45fcf92585SIngo Molnar ifeq ($(DEBUG),) 46fcf92585SIngo Molnar override DEBUG = 0 47fcf92585SIngo Molnar else 48fcf92585SIngo Molnar SET_DEBUG = "DEBUG=$(DEBUG)" 49fcf92585SIngo Molnar endif 50fcf92585SIngo Molnarelse 51fcf92585SIngo Molnar override DEBUG = 0 52fcf92585SIngo Molnarendif 53fcf92585SIngo Molnar 5473a725f0SIngo Molnardefine print_msg 5573a725f0SIngo Molnar @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n' 5673a725f0SIngo Molnarendef 5773a725f0SIngo Molnar 5873a725f0SIngo Molnardefine make 59fcf92585SIngo Molnar @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@ 6073a725f0SIngo Molnarendef 61bd69cc28SIngo Molnar 62bd69cc28SIngo Molnar# 63bd69cc28SIngo Molnar# Needed if no target specified: 6426286141SJiri Olsa# (Except for tags and TAGS targets. The reason is that the 6526286141SJiri Olsa# Makefile does not treat tags/TAGS as targets but as files 6626286141SJiri Olsa# and thus won't rebuilt them once they are in place.) 67bd69cc28SIngo Molnar# 6826286141SJiri Olsaall tags TAGS: 6973a725f0SIngo Molnar $(print_msg) 7073a725f0SIngo Molnar $(make) 7186470930SIngo Molnar 723e2751d9SJiri Olsaifdef MAKECMDGOALS 733e2751d9SJiri Olsahas_clean := 0 743e2751d9SJiri Olsaifneq ($(filter clean,$(MAKECMDGOALS)),) 753e2751d9SJiri Olsa has_clean := 1 763e2751d9SJiri Olsaendif # clean 773e2751d9SJiri Olsa 783e2751d9SJiri Olsaifeq ($(has_clean),1) 793e2751d9SJiri Olsa rest := $(filter-out clean,$(MAKECMDGOALS)) 803e2751d9SJiri Olsa ifneq ($(rest),) 813e2751d9SJiri Olsa$(rest): clean 823e2751d9SJiri Olsa endif # rest 833e2751d9SJiri Olsaendif # has_clean 843e2751d9SJiri Olsaendif # MAKECMDGOALS 853e2751d9SJiri Olsa 8673a725f0SIngo Molnar# 87da15fc2fSRasmus Villemoes# Explicitly disable parallelism for the clean target. 8873a725f0SIngo Molnar# 8973a725f0SIngo Molnarclean: 90da15fc2fSRasmus Villemoes $(make) -j1 9173a725f0SIngo Molnar 9273a725f0SIngo Molnar# 93a639a623SArnaldo Carvalho de Melo# The build-test target is not really parallel, don't print the jobs info, 94a639a623SArnaldo Carvalho de Melo# it also uses only the tests/make targets that don't pollute the source 95a639a623SArnaldo Carvalho de Melo# repository, i.e. that uses O= or builds the tarpkg outside the source 96a639a623SArnaldo Carvalho de Melo# repo directories. 97a639a623SArnaldo Carvalho de Melo# 98a639a623SArnaldo Carvalho de Melo# For a full test, use: 99a639a623SArnaldo Carvalho de Melo# 100a639a623SArnaldo Carvalho de Melo# make -C tools/perf -f tests/make 101a7077234SNamhyung Kim# 102a7077234SNamhyung Kimbuild-test: 103be9e4991SArnaldo Carvalho de Melo @$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg out 104a7077234SNamhyung Kim 105a7077234SNamhyung Kim# 10673a725f0SIngo Molnar# All other targets get passed through: 10773a725f0SIngo Molnar# 1088e557351SJiri Olsa%: FORCE 10973a725f0SIngo Molnar $(print_msg) 11073a725f0SIngo Molnar $(make) 11126286141SJiri Olsa 1128e557351SJiri Olsa.PHONY: tags TAGS FORCE Makefile 113