Merge branch 'x86/boot' into x86/urgent
[sfrench/cifs-2.6.git] / tools / perf / Makefile
1 #
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 #
8
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
15 #
16 # We don't want to pass along options like -j:
17 #
18 unexport MAKEFLAGS
19
20 #
21 # 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.
23 #
24 # (To override it, run 'make JOBS=1' and similar.)
25 #
26 ifeq ($(JOBS),)
27   JOBS := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
28   ifeq ($(JOBS),0)
29     JOBS := 1
30   endif
31 endif
32
33 #
34 # Only pass canonical directory names as the output directory:
35 #
36 ifneq ($(O),)
37   FULL_O := $(shell readlink -f $(O) || echo $(O))
38 endif
39
40 #
41 # Only accept the 'DEBUG' variable from the command line:
42 #
43 ifeq ("$(origin DEBUG)", "command line")
44   ifeq ($(DEBUG),)
45     override DEBUG = 0
46   else
47     SET_DEBUG = "DEBUG=$(DEBUG)"
48   endif
49 else
50   override DEBUG = 0
51 endif
52
53 define print_msg
54   @printf '  BUILD:   Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
55 endef
56
57 define make
58   @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@
59 endef
60
61 #
62 # Needed if no target specified:
63 # (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.)
66 #
67 all tags TAGS:
68         $(print_msg)
69         $(make)
70
71 #
72 # The clean target is not really parallel, don't print the jobs info:
73 #
74 clean:
75         $(make)
76
77 #
78 # The build-test target is not really parallel, don't print the jobs info:
79 #
80 build-test:
81         @$(MAKE) -f tests/make --no-print-directory
82
83 #
84 # All other targets get passed through:
85 #
86 %:
87         $(print_msg)
88         $(make)
89
90 .PHONY: tags TAGS