tools/perf/build: Standardize the various messages output by parallel make
[linux-drm-fsl-dcu.git] / tools / perf / Makefile
1 #
2 # Do a parallel build with multiple jobs, based on the number of CPUs online
3 # in this system: 'make -j8' on a 8-CPU system, etc.
4 #
5 # (To override it, run 'make JOBS=1' and similar.)
6 #
7 ifeq ($(JOBS),)
8   JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
9   ifeq ($(JOBS),)
10     JOBS := 1
11   endif
12 endif
13
14 export JOBS
15
16 define print_msg
17   @printf '    BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
18 endef
19
20 define make
21   @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) $@
22 endef
23
24 #
25 # Needed if no target specified:
26 #
27 all:
28         $(print_msg)
29         $(make)
30
31 #
32 # The clean target is not really parallel, don't print the jobs info:
33 #
34 clean:
35         $(make)
36
37 #
38 # All other targets get passed through:
39 #
40 %:
41         $(print_msg)
42         $(make)