blob: 67837c6cdbd8eb55e4f1380c0916e22b440c9a59 [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),)
Will Deacon762abdc2015-04-23 15:00:16 +010027 JOBS := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
David Ahernc65568c2015-02-18 18:59:31 -050028 ifeq ($(JOBS),0)
Ingo Molnarbd69cc22013-10-02 11:49:08 +020029 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),)
Ingo Molnar3fb66332013-10-09 17:00:23 +020037 FULL_O := $(shell readlink -f $(O) || echo $(O))
Ingo Molnarb1024202013-10-04 12:08:05 +020038endif
39
Ingo Molnarfcf92582013-10-10 08:05:25 +020040#
41# Only accept the 'DEBUG' variable from the command line:
42#
43ifeq ("$(origin DEBUG)", "command line")
44 ifeq ($(DEBUG),)
45 override DEBUG = 0
46 else
47 SET_DEBUG = "DEBUG=$(DEBUG)"
48 endif
49else
50 override DEBUG = 0
51endif
52
Ingo Molnar73a725f2013-10-02 11:58:30 +020053define print_msg
Ingo Molnar65fb0992013-10-09 11:49:27 +020054 @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
Ingo Molnar73a725f2013-10-02 11:58:30 +020055endef
56
57define make
Ingo Molnarfcf92582013-10-10 08:05:25 +020058 @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@
Ingo Molnar73a725f2013-10-02 11:58:30 +020059endef
Ingo Molnard24e4732009-04-20 13:32:07 +020060
Ingo Molnarde0f03f2013-10-02 09:43:23 +020061#
Ingo Molnarbd69cc22013-10-02 11:49:08 +020062# Needed if no target specified:
Jiri Olsa26286142013-11-26 13:54:12 +010063# (Except for tags and TAGS targets. The reason is that the
64# Makefile does not treat tags/TAGS as targets but as files
65# and thus won't rebuilt them once they are in place.)
Ingo Molnarde0f03f2013-10-02 09:43:23 +020066#
Jiri Olsa26286142013-11-26 13:54:12 +010067all tags TAGS:
Ingo Molnar73a725f2013-10-02 11:58:30 +020068 $(print_msg)
69 $(make)
Ingo Molnarde0f03f2013-10-02 09:43:23 +020070
Jiri Olsa3e2751d2016-02-04 12:30:36 +010071ifdef MAKECMDGOALS
72has_clean := 0
73ifneq ($(filter clean,$(MAKECMDGOALS)),)
74 has_clean := 1
75endif # clean
76
77ifeq ($(has_clean),1)
78 rest := $(filter-out clean,$(MAKECMDGOALS))
79 ifneq ($(rest),)
80$(rest): clean
81 endif # rest
82endif # has_clean
83endif # MAKECMDGOALS
84
Ingo Molnar73a725f2013-10-02 11:58:30 +020085#
86# The clean target is not really parallel, don't print the jobs info:
87#
88clean:
89 $(make)
90
91#
Arnaldo Carvalho de Meloa639a622016-01-29 14:49:31 -030092# The build-test target is not really parallel, don't print the jobs info,
93# it also uses only the tests/make targets that don't pollute the source
94# repository, i.e. that uses O= or builds the tarpkg outside the source
95# repo directories.
96#
97# For a full test, use:
98#
99# make -C tools/perf -f tests/make
Namhyung Kima7077232014-01-16 10:52:53 +0900100#
101build-test:
Arnaldo Carvalho de Meloa639a622016-01-29 14:49:31 -0300102 @$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile --no-print-directory tarpkg out
Namhyung Kima7077232014-01-16 10:52:53 +0900103
104#
Ingo Molnar73a725f2013-10-02 11:58:30 +0200105# All other targets get passed through:
106#
Jiri Olsa8e557352015-06-22 14:50:52 +0200107%: FORCE
Ingo Molnar73a725f2013-10-02 11:58:30 +0200108 $(print_msg)
109 $(make)
Jiri Olsa26286142013-11-26 13:54:12 +0100110
Jiri Olsa8e557352015-06-22 14:50:52 +0200111.PHONY: tags TAGS FORCE Makefile