blob: 7902a5681fc89f6eda64234de379fc8122567529 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Ingo Molnar684f4342013-10-04 11:11:32 +02002#
3# This is a simple wrapper Makefile that calls the main Makefile.perf
4# with a -j option to do parallel builds
5#
6# If you want to invoke the perf build in some non-standard way then
7# you can use the 'make -f Makefile.perf' method to invoke it.
8#
Ingo Molnarb016a0d2013-10-03 14:32:10 +02009
10#
11# Clear out the built-in rules GNU make defines by default (such as .o targets),
12# so that we pass through all targets to Makefile.perf:
13#
14.SUFFIXES:
15
Ingo Molnard24e4732009-04-20 13:32:07 +020016#
Ingo Molnar684f4342013-10-04 11:11:32 +020017# We don't want to pass along options like -j:
18#
19unexport MAKEFLAGS
20
21#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020022# Do a parallel build with multiple jobs, based on the number of CPUs online
23# in this system: 'make -j8' on a 8-CPU system, etc.
Namhyung Kim67cbbd72012-02-23 16:08:14 +090024#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020025# (To override it, run 'make JOBS=1' and similar.)
Namhyung Kim67cbbd72012-02-23 16:08:14 +090026#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020027ifeq ($(JOBS),)
Will Deacon762abdc2015-04-23 15:00:16 +010028 JOBS := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
David Ahernc65568c2015-02-18 18:59:31 -050029 ifeq ($(JOBS),0)
Ingo Molnarbd69cc22013-10-02 11:49:08 +020030 JOBS := 1
Jiri Olsa8e1b3f62013-04-15 04:06:58 +020031 endif
Jiri Olsa2bcd3552012-08-07 15:20:43 +020032endif
Kirill A. Shutemovf4e7ac02010-08-21 03:38:20 +030033
Ingo Molnarb1024202013-10-04 12:08:05 +020034#
35# Only pass canonical directory names as the output directory:
36#
37ifneq ($(O),)
Ingo Molnar3fb66332013-10-09 17:00:23 +020038 FULL_O := $(shell readlink -f $(O) || echo $(O))
Ingo Molnarb1024202013-10-04 12:08:05 +020039endif
40
Ingo Molnarfcf92582013-10-10 08:05:25 +020041#
42# Only accept the 'DEBUG' variable from the command line:
43#
44ifeq ("$(origin DEBUG)", "command line")
45 ifeq ($(DEBUG),)
46 override DEBUG = 0
47 else
48 SET_DEBUG = "DEBUG=$(DEBUG)"
49 endif
50else
51 override DEBUG = 0
52endif
53
Ingo Molnar73a725f2013-10-02 11:58:30 +020054define print_msg
Ingo Molnar65fb0992013-10-09 11:49:27 +020055 @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
Ingo Molnar73a725f2013-10-02 11:58:30 +020056endef
57
58define make
Ingo Molnarfcf92582013-10-10 08:05:25 +020059 @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@
Ingo Molnar73a725f2013-10-02 11:58:30 +020060endef
Ingo Molnard24e4732009-04-20 13:32:07 +020061
Ingo Molnarde0f03f2013-10-02 09:43:23 +020062#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020063# Needed if no target specified:
Jiri Olsa26286142013-11-26 13:54:12 +010064# (Except for tags and TAGS targets. The reason is that the
65# Makefile does not treat tags/TAGS as targets but as files
66# and thus won't rebuilt them once they are in place.)
Ingo Molnarde0f03f2013-10-02 09:43:23 +020067#
Jiri Olsa26286142013-11-26 13:54:12 +010068all tags TAGS:
Ingo Molnar73a725f2013-10-02 11:58:30 +020069 $(print_msg)
70 $(make)
Ingo Molnarde0f03f2013-10-02 09:43:23 +020071
Jiri Olsa3e2751d2016-02-04 12:30:36 +010072ifdef MAKECMDGOALS
73has_clean := 0
74ifneq ($(filter clean,$(MAKECMDGOALS)),)
75 has_clean := 1
76endif # clean
77
78ifeq ($(has_clean),1)
79 rest := $(filter-out clean,$(MAKECMDGOALS))
80 ifneq ($(rest),)
81$(rest): clean
82 endif # rest
83endif # has_clean
84endif # MAKECMDGOALS
85
Ingo Molnar73a725f2013-10-02 11:58:30 +020086#
Rasmus Villemoesda15fc22018-07-05 15:15:27 +020087# Explicitly disable parallelism for the clean target.
Ingo Molnar73a725f2013-10-02 11:58:30 +020088#
89clean:
Rasmus Villemoesda15fc22018-07-05 15:15:27 +020090 $(make) -j1
Ingo Molnar73a725f2013-10-02 11:58:30 +020091
92#
Arnaldo Carvalho de Meloa639a622016-01-29 14:49:31 -030093# The build-test target is not really parallel, don't print the jobs info,
94# it also uses only the tests/make targets that don't pollute the source
95# repository, i.e. that uses O= or builds the tarpkg outside the source
96# repo directories.
97#
98# For a full test, use:
99#
100# make -C tools/perf -f tests/make
Namhyung Kima7077232014-01-16 10:52:53 +0900101#
102build-test:
Arnaldo Carvalho de Melobe9e4992016-02-03 17:28:45 -0300103 @$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg out
Namhyung Kima7077232014-01-16 10:52:53 +0900104
105#
Ingo Molnar73a725f2013-10-02 11:58:30 +0200106# All other targets get passed through:
107#
Jiri Olsa8e557352015-06-22 14:50:52 +0200108%: FORCE
Ingo Molnar73a725f2013-10-02 11:58:30 +0200109 $(print_msg)
110 $(make)
Jiri Olsa26286142013-11-26 13:54:12 +0100111
Jiri Olsa8e557352015-06-22 14:50:52 +0200112.PHONY: tags TAGS FORCE Makefile