blob: 5aa3d040bbf3fa17c9bbffce14b8a3a6a2da70be [file] [log] [blame]
Ingo Molnar684f4342013-10-04 11:11:32 +02001#
2# This is a simple wrapper Makefile that calls the main Makefile.perf
3# with a -j option to do parallel builds
4#
5# If you want to invoke the perf build in some non-standard way then
6# you can use the 'make -f Makefile.perf' method to invoke it.
7#
Ingo Molnarb016a0d2013-10-03 14:32:10 +02008
9#
10# Clear out the built-in rules GNU make defines by default (such as .o targets),
11# so that we pass through all targets to Makefile.perf:
12#
13.SUFFIXES:
14
Ingo Molnard24e4732009-04-20 13:32:07 +020015#
Ingo Molnar684f4342013-10-04 11:11:32 +020016# We don't want to pass along options like -j:
17#
18unexport MAKEFLAGS
19
20#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020021# Do a parallel build with multiple jobs, based on the number of CPUs online
22# in this system: 'make -j8' on a 8-CPU system, etc.
Namhyung Kim67cbbd72012-02-23 16:08:14 +090023#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020024# (To override it, run 'make JOBS=1' and similar.)
Namhyung Kim67cbbd72012-02-23 16:08:14 +090025#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020026ifeq ($(JOBS),)
27 JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
28 ifeq ($(JOBS),)
29 JOBS := 1
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020030 endif
Jiri Olsa2bcd3552012-08-07 15:20:43 +020031endif
Kirill A. Shutemovf4e7ac02010-08-21 03:38:20 +030032
Ingo Molnarb1024202013-10-04 12:08:05 +020033#
34# Only pass canonical directory names as the output directory:
35#
36ifneq ($(O),)
37 FULL_O := $(shell readlink -f $(O))
38endif
39
Ingo Molnar73a725f2013-10-02 11:58:30 +020040define print_msg
Ingo Molnar65fb0992013-10-09 11:49:27 +020041 @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
Ingo Molnar73a725f2013-10-02 11:58:30 +020042endef
43
44define make
Ingo Molnarb1024202013-10-04 12:08:05 +020045 @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $@
Ingo Molnar73a725f2013-10-02 11:58:30 +020046endef
Ingo Molnard24e4732009-04-20 13:32:07 +020047
Ingo Molnarde0f03f2013-10-02 09:43:23 +020048#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020049# Needed if no target specified:
Ingo Molnarde0f03f2013-10-02 09:43:23 +020050#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020051all:
Ingo Molnar73a725f2013-10-02 11:58:30 +020052 $(print_msg)
53 $(make)
Ingo Molnarde0f03f2013-10-02 09:43:23 +020054
Ingo Molnar73a725f2013-10-02 11:58:30 +020055#
56# The clean target is not really parallel, don't print the jobs info:
57#
58clean:
59 $(make)
60
61#
62# All other targets get passed through:
63#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020064%:
Ingo Molnar73a725f2013-10-02 11:58:30 +020065 $(print_msg)
66 $(make)