xref: /openbmc/linux/tools/perf/Makefile (revision be9e4991)
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),)
27762abdc0SWill Deacon  JOBS := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
28c65568c5SDavid Ahern  ifeq ($(JOBS),0)
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
40fcf92585SIngo Molnar#
41fcf92585SIngo Molnar# Only accept the 'DEBUG' variable from the command line:
42fcf92585SIngo Molnar#
43fcf92585SIngo Molnarifeq ("$(origin DEBUG)", "command line")
44fcf92585SIngo Molnar  ifeq ($(DEBUG),)
45fcf92585SIngo Molnar    override DEBUG = 0
46fcf92585SIngo Molnar  else
47fcf92585SIngo Molnar    SET_DEBUG = "DEBUG=$(DEBUG)"
48fcf92585SIngo Molnar  endif
49fcf92585SIngo Molnarelse
50fcf92585SIngo Molnar  override DEBUG = 0
51fcf92585SIngo Molnarendif
52fcf92585SIngo Molnar
5373a725f0SIngo Molnardefine print_msg
5473a725f0SIngo Molnar  @printf '  BUILD:   Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
5573a725f0SIngo Molnarendef
5673a725f0SIngo Molnar
5773a725f0SIngo Molnardefine make
58fcf92585SIngo Molnar  @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@
5973a725f0SIngo Molnarendef
60bd69cc28SIngo Molnar
61bd69cc28SIngo Molnar#
62bd69cc28SIngo Molnar# Needed if no target specified:
6326286141SJiri Olsa# (Except for tags and TAGS targets. The reason is that the
6426286141SJiri Olsa# Makefile does not treat tags/TAGS as targets but as files
6526286141SJiri Olsa# and thus won't rebuilt them once they are in place.)
66bd69cc28SIngo Molnar#
6726286141SJiri Olsaall tags TAGS:
6873a725f0SIngo Molnar	$(print_msg)
6973a725f0SIngo Molnar	$(make)
7086470930SIngo Molnar
713e2751d9SJiri Olsaifdef MAKECMDGOALS
723e2751d9SJiri Olsahas_clean := 0
733e2751d9SJiri Olsaifneq ($(filter clean,$(MAKECMDGOALS)),)
743e2751d9SJiri Olsa  has_clean := 1
753e2751d9SJiri Olsaendif # clean
763e2751d9SJiri Olsa
773e2751d9SJiri Olsaifeq ($(has_clean),1)
783e2751d9SJiri Olsa  rest := $(filter-out clean,$(MAKECMDGOALS))
793e2751d9SJiri Olsa  ifneq ($(rest),)
803e2751d9SJiri Olsa$(rest): clean
813e2751d9SJiri Olsa  endif # rest
823e2751d9SJiri Olsaendif # has_clean
833e2751d9SJiri Olsaendif # MAKECMDGOALS
843e2751d9SJiri Olsa
8573a725f0SIngo Molnar#
8673a725f0SIngo Molnar# The clean target is not really parallel, don't print the jobs info:
8773a725f0SIngo Molnar#
8873a725f0SIngo Molnarclean:
8973a725f0SIngo Molnar	$(make)
9073a725f0SIngo Molnar
9173a725f0SIngo Molnar#
92a639a623SArnaldo Carvalho de Melo# The build-test target is not really parallel, don't print the jobs info,
93a639a623SArnaldo Carvalho de Melo# it also uses only the tests/make targets that don't pollute the source
94a639a623SArnaldo Carvalho de Melo# repository, i.e. that uses O= or builds the tarpkg outside the source
95a639a623SArnaldo Carvalho de Melo# repo directories.
96a639a623SArnaldo Carvalho de Melo#
97a639a623SArnaldo Carvalho de Melo# For a full test, use:
98a639a623SArnaldo Carvalho de Melo#
99a639a623SArnaldo Carvalho de Melo# make -C tools/perf -f tests/make
100a7077234SNamhyung Kim#
101a7077234SNamhyung Kimbuild-test:
102*be9e4991SArnaldo Carvalho de Melo	@$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile SET_PARALLEL=1 --no-print-directory tarpkg out
103a7077234SNamhyung Kim
104a7077234SNamhyung Kim#
10573a725f0SIngo Molnar# All other targets get passed through:
10673a725f0SIngo Molnar#
1078e557351SJiri Olsa%: FORCE
10873a725f0SIngo Molnar	$(print_msg)
10973a725f0SIngo Molnar	$(make)
11026286141SJiri Olsa
1118e557351SJiri Olsa.PHONY: tags TAGS FORCE Makefile
112