blob: 69492ba8da9740a2a7ae3fba34d5aaa9fce86553 [file] [log] [blame]
Alexandre Belloni8dfd59d2013-06-05 23:53:30 +00001################################################################################
Thomas Petazzonid82f5cb2013-01-06 05:22:45 +00002#
3# perf
4#
Alexandre Belloni8dfd59d2013-06-05 23:53:30 +00005################################################################################
Thomas Petazzonid82f5cb2013-01-06 05:22:45 +00006
Romain Naour1326e762015-07-14 19:35:14 +02007LINUX_TOOLS += perf
Thomas Petazzonid82f5cb2013-01-06 05:22:45 +00008
Romain Naour1326e762015-07-14 19:35:14 +02009PERF_DEPENDENCIES = host-flex host-bison
Thomas Petazzonid82f5cb2013-01-06 05:22:45 +000010
Steven Noonan1b787822015-07-14 19:35:11 +020011ifeq ($(KERNEL_ARCH),x86_64)
12PERF_ARCH=x86
13else
14PERF_ARCH=$(KERNEL_ARCH)
15endif
16
Thomas Petazzonid82f5cb2013-01-06 05:22:45 +000017PERF_MAKE_FLAGS = \
18 $(LINUX_MAKE_FLAGS) \
Yann E. MORINd4a20202016-03-11 19:19:55 +010019 JOBS=$(PARALLEL_JOBS) \
Steven Noonan1b787822015-07-14 19:35:11 +020020 ARCH=$(PERF_ARCH) \
Yann E. MORIN2b1d5df2016-03-11 19:19:56 +010021 DESTDIR=$(TARGET_DIR) \
22 prefix=/usr \
23 WERROR=0 \
Thomas Petazzonid82f5cb2013-01-06 05:22:45 +000024 NO_LIBAUDIT=1 \
25 NO_NEWT=1 \
26 NO_GTK2=1 \
27 NO_LIBPERL=1 \
28 NO_LIBPYTHON=1 \
Yann E. MORIN2b1d5df2016-03-11 19:19:56 +010029 NO_LIBBIONIC=1
Thomas Petazzonid82f5cb2013-01-06 05:22:45 +000030
Vicente Olivert Rieraf574a8e2017-02-17 10:59:05 +000031# We need to pass an argument to ld for setting the emulation when
32# building for MIPS architecture, otherwise the default one will always
33# be used and the compilation for most variants will fail.
34ifeq ($(BR2_mips),y)
35PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32btsmip"
36else ifeq ($(BR2_mipsel),y)
37PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmip"
38else ifeq ($(BR2_mips64),y)
39ifeq ($(BR2_MIPS_NABI32),y)
40PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32btsmipn32"
41else
42PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64btsmip"
43endif
44else ifeq ($(BR2_mips64el),y)
45ifeq ($(BR2_MIPS_NABI32),y)
46PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmipn32"
47else
48PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64ltsmip"
49endif
Vicente Olivert Riera7f3a52f2016-02-22 10:22:45 +000050endif
51
Mischa Jonkerfc093d62014-01-28 14:10:58 +010052# The call to backtrace() function fails for ARC, because for some
53# reason the unwinder from libgcc returns early. Thus the usage of
54# backtrace() should be disabled in perf explicitly: at build time
55# backtrace() appears to be available, but it fails at runtime: the
56# backtrace will contain only several functions from the top of stack,
57# instead of the complete backtrace.
58ifeq ($(BR2_arc),y)
Jerzy Grzegorekbd8c7332015-03-31 09:21:57 +020059PERF_MAKE_FLAGS += NO_BACKTRACE=1
Mischa Jonkerfc093d62014-01-28 14:10:58 +010060endif
61
Steven Noonan15f2cc52015-07-14 19:35:08 +020062ifeq ($(BR2_PACKAGE_SLANG),y)
63PERF_DEPENDENCIES += slang
Yann E. MORIN2b1d5df2016-03-11 19:19:56 +010064else
65PERF_MAKE_FLAGS += NO_SLANG=1
Steven Noonan15f2cc52015-07-14 19:35:08 +020066endif
67
Steven Noonan71e5ff62015-07-14 19:35:10 +020068ifeq ($(BR2_PACKAGE_LIBUNWIND),y)
69PERF_DEPENDENCIES += libunwind
Yann E. MORIN2b1d5df2016-03-11 19:19:56 +010070else
71PERF_MAKE_FLAGS += NO_LIBUNWIND=1
Steven Noonan71e5ff62015-07-14 19:35:10 +020072endif
73
Steven Noonan1bc36852015-07-14 19:35:09 +020074ifeq ($(BR2_PACKAGE_NUMACTL),y)
75PERF_DEPENDENCIES += numactl
Yann E. MORIN2b1d5df2016-03-11 19:19:56 +010076else
77PERF_MAKE_FLAGS += NO_LIBNUMA=1
Steven Noonan1bc36852015-07-14 19:35:09 +020078endif
79
Thomas Petazzoni69030ca2013-01-06 05:22:46 +000080ifeq ($(BR2_PACKAGE_ELFUTILS),y)
Jerzy Grzegorekbd8c7332015-03-31 09:21:57 +020081PERF_DEPENDENCIES += elfutils
Thomas Petazzoni69030ca2013-01-06 05:22:46 +000082else
Jerzy Grzegorekbd8c7332015-03-31 09:21:57 +020083PERF_MAKE_FLAGS += NO_LIBELF=1 NO_DWARF=1
Thomas Petazzoni69030ca2013-01-06 05:22:46 +000084endif
85
Yann E. MORIN96668352016-03-11 19:19:57 +010086ifeq ($(BR2_PACKAGE_ZLIB),y)
87PERF_DEPENDENCIES += zlib
88else
89PERF_MAKE_FLAGS += NO_ZLIB=1
90endif
91
92# lzma is provided by xz
93ifeq ($(BR2_PACKAGE_XZ),y)
94PERF_DEPENDENCIES += xz
95else
96PERF_MAKE_FLAGS += NO_LZMA=1
97endif
98
Yann E. MORINc306e042016-03-11 19:19:54 +010099# We really do not want to build the perf documentation, because it
100# has stringent requirement on the documentation generation tools,
101# like xmlto and asciidoc), which may be lagging behind on some
102# distributions.
103# We name it 'GNUmakefile' so that GNU make will use it instead of
104# the existing 'Makefile'.
105define PERF_DISABLE_DOCUMENTATION
Yann E. MORIN20b14462016-09-06 16:29:14 +0200106 if [ -f $(LINUX_DIR)/tools/perf/Documentation/Makefile ]; then \
107 printf "%%:\n\t@:\n" >$(LINUX_DIR)/tools/perf/Documentation/GNUmakefile; \
Yann E. MORINc306e042016-03-11 19:19:54 +0100108 fi
109endef
110LINUX_POST_PATCH_HOOKS += PERF_DISABLE_DOCUMENTATION
111
Romain Naour1326e762015-07-14 19:35:14 +0200112# O must be redefined here to overwrite the one used by Buildroot for
Yann E. MORIN20b14462016-09-06 16:29:14 +0200113# out of tree build. We build perf in $(LINUX_DIR)/tools/perf/ and not just
114# $(LINUX_DIR) so that it isn't built in the root directory of the kernel
Romain Naour1326e762015-07-14 19:35:14 +0200115# sources.
Thomas Petazzonid82f5cb2013-01-06 05:22:45 +0000116define PERF_BUILD_CMDS
Yann E. MORIN20b14462016-09-06 16:29:14 +0200117 $(Q)if test ! -f $(LINUX_DIR)/tools/perf/Makefile ; then \
Thomas Petazzoni1727e892013-01-06 05:22:47 +0000118 echo "Your kernel version is too old and does not have the perf tool." ; \
119 echo "At least kernel 2.6.31 must be used." ; \
120 exit 1 ; \
121 fi
122 $(Q)if test "$(BR2_PACKAGE_ELFUTILS)" = "" ; then \
Yann E. MORIN20b14462016-09-06 16:29:14 +0200123 if ! grep -q NO_LIBELF $(LINUX_DIR)/tools/perf/Makefile* ; then \
124 if ! test -r $(LINUX_DIR)/tools/perf/config/Makefile ; then \
Peter Meerwald220490c2014-04-05 14:51:02 +0200125 echo "The perf tool in your kernel cannot be built without libelf." ; \
126 echo "Either upgrade your kernel to >= 3.7, or enable the elfutils package." ; \
127 exit 1 ; \
128 fi \
Thomas Petazzoni1727e892013-01-06 05:22:47 +0000129 fi \
130 fi
Romain Naour1326e762015-07-14 19:35:14 +0200131 $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
Yann E. MORIN20b14462016-09-06 16:29:14 +0200132 -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/
Thomas Petazzonid82f5cb2013-01-06 05:22:45 +0000133endef
134
135# After installation, we remove the Perl and Python scripts from the
136# target.
137define PERF_INSTALL_TARGET_CMDS
Romain Naour1326e762015-07-14 19:35:14 +0200138 $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
Yann E. MORIN20b14462016-09-06 16:29:14 +0200139 -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ install
Thomas Petazzonid82f5cb2013-01-06 05:22:45 +0000140 $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/
Thomas De Schampheleire77e7cdb2016-01-15 09:47:35 +0100141 $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/
Thomas Petazzonid82f5cb2013-01-06 05:22:45 +0000142endef