Blame view

tools/perf/Makefile 2.54 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  # SPDX-License-Identifier: GPL-2.0
684f434cc   Ingo Molnar   tools/perf/build:...
2
3
4
5
6
7
8
  #
  # This is a simple wrapper Makefile that calls the main Makefile.perf
  # with a -j option to do parallel builds
  #
  # If you want to invoke the perf build in some non-standard way then
  # you can use the 'make -f Makefile.perf' method to invoke it.
  #
b016a0dd0   Ingo Molnar   tools/perf/build:...
9
10
11
12
13
14
  
  #
  # Clear out the built-in rules GNU make defines by default (such as .o targets),
  # so that we pass through all targets to Makefile.perf:
  #
  .SUFFIXES:
4e34d9588   Namhyung Kim   perf tools: Conve...
15
  #
684f434cc   Ingo Molnar   tools/perf/build:...
16
17
18
19
20
  # We don't want to pass along options like -j:
  #
  unexport MAKEFLAGS
  
  #
bd69cc286   Ingo Molnar   tools/perf/build:...
21
22
  # Do a parallel build with multiple jobs, based on the number of CPUs online
  # in this system: 'make -j8' on a 8-CPU system, etc.
79d824e31   Peter Hurley   perf tools: Make ...
23
  #
bd69cc286   Ingo Molnar   tools/perf/build:...
24
  # (To override it, run 'make JOBS=1' and similar.)
4e22db464   Jiri Olsa   perf tools: Add N...
25
  #
bd69cc286   Ingo Molnar   tools/perf/build:...
26
  ifeq ($(JOBS),)
762abdc0c   Will Deacon   perf tools: Use g...
27
    JOBS := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
c65568c54   David Ahern   perf tools: Compa...
28
    ifeq ($(JOBS),0)
bd69cc286   Ingo Molnar   tools/perf/build:...
29
      JOBS := 1
8e1b3f686   Jiri Olsa   perf tools: Repla...
30
    endif
2bcd355b7   Jiri Olsa   perf tools: Add i...
31
  endif
f4e7ac0a2   Kirill A. Shutemov   perf tools: add t...
32

b102420b5   Ingo Molnar   tools/perf/build:...
33
34
35
36
  #
  # Only pass canonical directory names as the output directory:
  #
  ifneq ($(O),)
be40920fb   Masami Hiramatsu   tools: Let O= mak...
37
    FULL_O := $(shell cd $(PWD); readlink -f $(O) || echo $(O))
b102420b5   Ingo Molnar   tools/perf/build:...
38
  endif
fcf925850   Ingo Molnar   tools/perf/build:...
39
40
41
42
43
44
45
46
47
48
49
50
  #
  # Only accept the 'DEBUG' variable from the command line:
  #
  ifeq ("$(origin DEBUG)", "command line")
    ifeq ($(DEBUG),)
      override DEBUG = 0
    else
      SET_DEBUG = "DEBUG=$(DEBUG)"
    endif
  else
    override DEBUG = 0
  endif
73a725f00   Ingo Molnar   tools/perf/build:...
51
  define print_msg
65fb09922   Ingo Molnar   tools: Harmonize ...
52
53
    @printf '  BUILD:   Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build
  '
73a725f00   Ingo Molnar   tools/perf/build:...
54
55
56
  endef
  
  define make
fcf925850   Ingo Molnar   tools/perf/build:...
57
    @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@
73a725f00   Ingo Molnar   tools/perf/build:...
58
  endef
d24e473e5   Ingo Molnar   perf_counter: cop...
59

de0f03fb8   Ingo Molnar   tools/perf/build:...
60
  #
bd69cc286   Ingo Molnar   tools/perf/build:...
61
  # Needed if no target specified:
26286141a   Jiri Olsa   perf tools: Fix t...
62
63
64
  # (Except for tags and TAGS targets. The reason is that the
  # Makefile does not treat tags/TAGS as targets but as files
  # and thus won't rebuilt them once they are in place.)
de0f03fb8   Ingo Molnar   tools/perf/build:...
65
  #
26286141a   Jiri Olsa   perf tools: Fix t...
66
  all tags TAGS:
73a725f00   Ingo Molnar   tools/perf/build:...
67
68
  	$(print_msg)
  	$(make)
3e2751d91   Jiri Olsa   perf tools: Fix p...
69
70
71
72
73
74
75
76
77
78
79
80
81
  ifdef MAKECMDGOALS
  has_clean := 0
  ifneq ($(filter clean,$(MAKECMDGOALS)),)
    has_clean := 1
  endif # clean
  
  ifeq ($(has_clean),1)
    rest := $(filter-out clean,$(MAKECMDGOALS))
    ifneq ($(rest),)
  $(rest): clean
    endif # rest
  endif # has_clean
  endif # MAKECMDGOALS
73a725f00   Ingo Molnar   tools/perf/build:...
82
  #
da15fc2fa   Rasmus Villemoes   perf tools: Disab...
83
  # Explicitly disable parallelism for the clean target.
73a725f00   Ingo Molnar   tools/perf/build:...
84
85
  #
  clean:
da15fc2fa   Rasmus Villemoes   perf tools: Disab...
86
  	$(make) -j1
c72e3f04b   Ingo Molnar   tools/perf/build:...
87

73a725f00   Ingo Molnar   tools/perf/build:...
88
  #
a639a6239   Arnaldo Carvalho de Melo   perf tools: Speed...
89
90
91
92
93
94
95
96
  # The build-test target is not really parallel, don't print the jobs info,
  # it also uses only the tests/make targets that don't pollute the source
  # repository, i.e. that uses O= or builds the tarpkg outside the source
  # repo directories.
  #
  # For a full test, use:
  #
  # make -C tools/perf -f tests/make
a7077234d   Namhyung Kim   perf tools: Add '...
97
98
  #
  build-test:
be9e49911   Arnaldo Carvalho de Melo   perf build tests:...
99
  	@$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg out
a7077234d   Namhyung Kim   perf tools: Add '...
100
101
  
  #
73a725f00   Ingo Molnar   tools/perf/build:...
102
103
  # All other targets get passed through:
  #
8e5573515   Jiri Olsa   perf build: Fix s...
104
  %: FORCE
73a725f00   Ingo Molnar   tools/perf/build:...
105
106
  	$(print_msg)
  	$(make)
26286141a   Jiri Olsa   perf tools: Fix t...
107

8e5573515   Jiri Olsa   perf build: Fix s...
108
  .PHONY: tags TAGS FORCE Makefile