Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Ingo Molnar | 684f434 | 2013-10-04 11:11:32 +0200 | [diff] [blame] | 2 | # |
| 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 Molnar | b016a0d | 2013-10-03 14:32:10 +0200 | [diff] [blame] | 9 | |
| 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 Molnar | d24e473 | 2009-04-20 13:32:07 +0200 | [diff] [blame] | 16 | # |
Ingo Molnar | 684f434 | 2013-10-04 11:11:32 +0200 | [diff] [blame] | 17 | # We don't want to pass along options like -j: |
| 18 | # |
| 19 | unexport MAKEFLAGS |
| 20 | |
| 21 | # |
Ingo Molnar | bd69cc2 | 2013-10-02 11:49:08 +0200 | [diff] [blame] | 22 | # 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 Kim | 67cbbd7 | 2012-02-23 16:08:14 +0900 | [diff] [blame] | 24 | # |
Ingo Molnar | bd69cc2 | 2013-10-02 11:49:08 +0200 | [diff] [blame] | 25 | # (To override it, run 'make JOBS=1' and similar.) |
Namhyung Kim | 67cbbd7 | 2012-02-23 16:08:14 +0900 | [diff] [blame] | 26 | # |
Ingo Molnar | bd69cc2 | 2013-10-02 11:49:08 +0200 | [diff] [blame] | 27 | ifeq ($(JOBS),) |
Will Deacon | 762abdc | 2015-04-23 15:00:16 +0100 | [diff] [blame] | 28 | JOBS := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null) |
David Ahern | c65568c | 2015-02-18 18:59:31 -0500 | [diff] [blame] | 29 | ifeq ($(JOBS),0) |
Ingo Molnar | bd69cc2 | 2013-10-02 11:49:08 +0200 | [diff] [blame] | 30 | JOBS := 1 |
Jiri Olsa | 8e1b3f6 | 2013-04-15 04:06:58 +0200 | [diff] [blame] | 31 | endif |
Jiri Olsa | 2bcd355 | 2012-08-07 15:20:43 +0200 | [diff] [blame] | 32 | endif |
Kirill A. Shutemov | f4e7ac0 | 2010-08-21 03:38:20 +0300 | [diff] [blame] | 33 | |
Ingo Molnar | b102420 | 2013-10-04 12:08:05 +0200 | [diff] [blame] | 34 | # |
| 35 | # Only pass canonical directory names as the output directory: |
| 36 | # |
| 37 | ifneq ($(O),) |
Ingo Molnar | 3fb6633 | 2013-10-09 17:00:23 +0200 | [diff] [blame] | 38 | FULL_O := $(shell readlink -f $(O) || echo $(O)) |
Ingo Molnar | b102420 | 2013-10-04 12:08:05 +0200 | [diff] [blame] | 39 | endif |
| 40 | |
Ingo Molnar | fcf9258 | 2013-10-10 08:05:25 +0200 | [diff] [blame] | 41 | # |
| 42 | # Only accept the 'DEBUG' variable from the command line: |
| 43 | # |
| 44 | ifeq ("$(origin DEBUG)", "command line") |
| 45 | ifeq ($(DEBUG),) |
| 46 | override DEBUG = 0 |
| 47 | else |
| 48 | SET_DEBUG = "DEBUG=$(DEBUG)" |
| 49 | endif |
| 50 | else |
| 51 | override DEBUG = 0 |
| 52 | endif |
| 53 | |
Ingo Molnar | 73a725f | 2013-10-02 11:58:30 +0200 | [diff] [blame] | 54 | define print_msg |
Ingo Molnar | 65fb099 | 2013-10-09 11:49:27 +0200 | [diff] [blame] | 55 | @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n' |
Ingo Molnar | 73a725f | 2013-10-02 11:58:30 +0200 | [diff] [blame] | 56 | endef |
| 57 | |
| 58 | define make |
Ingo Molnar | fcf9258 | 2013-10-10 08:05:25 +0200 | [diff] [blame] | 59 | @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@ |
Ingo Molnar | 73a725f | 2013-10-02 11:58:30 +0200 | [diff] [blame] | 60 | endef |
Ingo Molnar | d24e473 | 2009-04-20 13:32:07 +0200 | [diff] [blame] | 61 | |
Ingo Molnar | de0f03f | 2013-10-02 09:43:23 +0200 | [diff] [blame] | 62 | # |
Ingo Molnar | bd69cc2 | 2013-10-02 11:49:08 +0200 | [diff] [blame] | 63 | # Needed if no target specified: |
Jiri Olsa | 2628614 | 2013-11-26 13:54:12 +0100 | [diff] [blame] | 64 | # (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 Molnar | de0f03f | 2013-10-02 09:43:23 +0200 | [diff] [blame] | 67 | # |
Jiri Olsa | 2628614 | 2013-11-26 13:54:12 +0100 | [diff] [blame] | 68 | all tags TAGS: |
Ingo Molnar | 73a725f | 2013-10-02 11:58:30 +0200 | [diff] [blame] | 69 | $(print_msg) |
| 70 | $(make) |
Ingo Molnar | de0f03f | 2013-10-02 09:43:23 +0200 | [diff] [blame] | 71 | |
Jiri Olsa | 3e2751d | 2016-02-04 12:30:36 +0100 | [diff] [blame] | 72 | ifdef MAKECMDGOALS |
| 73 | has_clean := 0 |
| 74 | ifneq ($(filter clean,$(MAKECMDGOALS)),) |
| 75 | has_clean := 1 |
| 76 | endif # clean |
| 77 | |
| 78 | ifeq ($(has_clean),1) |
| 79 | rest := $(filter-out clean,$(MAKECMDGOALS)) |
| 80 | ifneq ($(rest),) |
| 81 | $(rest): clean |
| 82 | endif # rest |
| 83 | endif # has_clean |
| 84 | endif # MAKECMDGOALS |
| 85 | |
Ingo Molnar | 73a725f | 2013-10-02 11:58:30 +0200 | [diff] [blame] | 86 | # |
Rasmus Villemoes | da15fc2 | 2018-07-05 15:15:27 +0200 | [diff] [blame] | 87 | # Explicitly disable parallelism for the clean target. |
Ingo Molnar | 73a725f | 2013-10-02 11:58:30 +0200 | [diff] [blame] | 88 | # |
| 89 | clean: |
Rasmus Villemoes | da15fc2 | 2018-07-05 15:15:27 +0200 | [diff] [blame] | 90 | $(make) -j1 |
Ingo Molnar | 73a725f | 2013-10-02 11:58:30 +0200 | [diff] [blame] | 91 | |
| 92 | # |
Arnaldo Carvalho de Melo | a639a62 | 2016-01-29 14:49:31 -0300 | [diff] [blame] | 93 | # 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 Kim | a707723 | 2014-01-16 10:52:53 +0900 | [diff] [blame] | 101 | # |
| 102 | build-test: |
Arnaldo Carvalho de Melo | be9e499 | 2016-02-03 17:28:45 -0300 | [diff] [blame] | 103 | @$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg out |
Namhyung Kim | a707723 | 2014-01-16 10:52:53 +0900 | [diff] [blame] | 104 | |
| 105 | # |
Ingo Molnar | 73a725f | 2013-10-02 11:58:30 +0200 | [diff] [blame] | 106 | # All other targets get passed through: |
| 107 | # |
Jiri Olsa | 8e55735 | 2015-06-22 14:50:52 +0200 | [diff] [blame] | 108 | %: FORCE |
Ingo Molnar | 73a725f | 2013-10-02 11:58:30 +0200 | [diff] [blame] | 109 | $(print_msg) |
| 110 | $(make) |
Jiri Olsa | 2628614 | 2013-11-26 13:54:12 +0100 | [diff] [blame] | 111 | |
Jiri Olsa | 8e55735 | 2015-06-22 14:50:52 +0200 | [diff] [blame] | 112 | .PHONY: tags TAGS FORCE Makefile |