blob: 3b925ad0d5f5899abbfd0bc3d0a2ba80014e0ef1 [file] [log] [blame]
Ingo Molnard24e4732009-04-20 13:32:07 +02001#
Ingo Molnarbd69cc22013-10-02 11:49:08 +02002# 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.
Namhyung Kim67cbbd72012-02-23 16:08:14 +09004#
Ingo Molnarbd69cc22013-10-02 11:49:08 +02005# (To override it, run 'make JOBS=1' and similar.)
Namhyung Kim67cbbd72012-02-23 16:08:14 +09006#
Ingo Molnarbd69cc22013-10-02 11:49:08 +02007ifeq ($(JOBS),)
8 JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
9 ifeq ($(JOBS),)
10 JOBS := 1
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020011 endif
Jiri Olsa2bcd3552012-08-07 15:20:43 +020012endif
Kirill A. Shutemovf4e7ac02010-08-21 03:38:20 +030013
Ingo Molnarbd69cc22013-10-02 11:49:08 +020014export JOBS
Peter Hurley79d824e2013-01-27 20:51:22 -050015
Ingo Molnar73a725f2013-10-02 11:58:30 +020016define print_msg
17 @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
18endef
19
20define make
21 @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) $@
22endef
Ingo Molnard24e4732009-04-20 13:32:07 +020023
Ingo Molnarde0f03f2013-10-02 09:43:23 +020024#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020025# Needed if no target specified:
Ingo Molnarde0f03f2013-10-02 09:43:23 +020026#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020027all:
Ingo Molnar73a725f2013-10-02 11:58:30 +020028 $(print_msg)
29 $(make)
Ingo Molnarde0f03f2013-10-02 09:43:23 +020030
Ingo Molnar73a725f2013-10-02 11:58:30 +020031#
32# The clean target is not really parallel, don't print the jobs info:
33#
34clean:
35 $(make)
36
37#
38# All other targets get passed through:
39#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020040%:
Ingo Molnar73a725f2013-10-02 11:58:30 +020041 $(print_msg)
42 $(make)