xref: /openbmc/linux/tools/perf/Makefile (revision 3fb66335)
1684f434cSIngo Molnar#
2684f434cSIngo Molnar# This is a simple wrapper Makefile that calls the main Makefile.perf
3684f434cSIngo Molnar# with a -j option to do parallel builds
4684f434cSIngo Molnar#
5684f434cSIngo Molnar# If you want to invoke the perf build in some non-standard way then
6684f434cSIngo Molnar# you can use the 'make -f Makefile.perf' method to invoke it.
7684f434cSIngo Molnar#
8b016a0ddSIngo Molnar
9b016a0ddSIngo Molnar#
10b016a0ddSIngo Molnar# Clear out the built-in rules GNU make defines by default (such as .o targets),
11b016a0ddSIngo Molnar# so that we pass through all targets to Makefile.perf:
12b016a0ddSIngo Molnar#
13b016a0ddSIngo Molnar.SUFFIXES:
14b016a0ddSIngo Molnar
15bd69cc28SIngo Molnar#
16684f434cSIngo Molnar# We don't want to pass along options like -j:
17684f434cSIngo Molnar#
18684f434cSIngo Molnarunexport MAKEFLAGS
19684f434cSIngo Molnar
20684f434cSIngo Molnar#
21bd69cc28SIngo Molnar# Do a parallel build with multiple jobs, based on the number of CPUs online
22bd69cc28SIngo Molnar# in this system: 'make -j8' on a 8-CPU system, etc.
23bd69cc28SIngo Molnar#
24bd69cc28SIngo Molnar# (To override it, run 'make JOBS=1' and similar.)
25bd69cc28SIngo Molnar#
26bd69cc28SIngo Molnarifeq ($(JOBS),)
27bd69cc28SIngo Molnar  JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
28bd69cc28SIngo Molnar  ifeq ($(JOBS),)
29bd69cc28SIngo Molnar    JOBS := 1
30bd69cc28SIngo Molnar  endif
31bd69cc28SIngo Molnarendif
32c29ede61SArnaldo Carvalho de Melo
33b102420bSIngo Molnar#
34b102420bSIngo Molnar# Only pass canonical directory names as the output directory:
35b102420bSIngo Molnar#
36b102420bSIngo Molnarifneq ($(O),)
373fb66335SIngo Molnar  FULL_O := $(shell readlink -f $(O) || echo $(O))
38b102420bSIngo Molnarendif
39b102420bSIngo Molnar
4073a725f0SIngo Molnardefine print_msg
4173a725f0SIngo Molnar  @printf '  BUILD:   Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
4273a725f0SIngo Molnarendef
4373a725f0SIngo Molnar
4473a725f0SIngo Molnardefine make
45b102420bSIngo Molnar  @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $@
4673a725f0SIngo Molnarendef
47bd69cc28SIngo Molnar
48bd69cc28SIngo Molnar#
49bd69cc28SIngo Molnar# Needed if no target specified:
50bd69cc28SIngo Molnar#
51a3d1ee10SMichael Wittenall:
5273a725f0SIngo Molnar	$(print_msg)
5373a725f0SIngo Molnar	$(make)
5486470930SIngo Molnar
5573a725f0SIngo Molnar#
5673a725f0SIngo Molnar# The clean target is not really parallel, don't print the jobs info:
5773a725f0SIngo Molnar#
5873a725f0SIngo Molnarclean:
5973a725f0SIngo Molnar	$(make)
6073a725f0SIngo Molnar
6173a725f0SIngo Molnar#
6273a725f0SIngo Molnar# All other targets get passed through:
6373a725f0SIngo Molnar#
64bd69cc28SIngo Molnar%:
6573a725f0SIngo Molnar	$(print_msg)
6673a725f0SIngo Molnar	$(make)
67