Alexandre Belloni | 8dfd59d | 2013-06-05 23:53:30 +0000 | [diff] [blame] | 1 | ################################################################################ |
Thomas Petazzoni | d82f5cb | 2013-01-06 05:22:45 +0000 | [diff] [blame] | 2 | # |
| 3 | # perf |
| 4 | # |
Alexandre Belloni | 8dfd59d | 2013-06-05 23:53:30 +0000 | [diff] [blame] | 5 | ################################################################################ |
Thomas Petazzoni | d82f5cb | 2013-01-06 05:22:45 +0000 | [diff] [blame] | 6 | |
Romain Naour | 1326e76 | 2015-07-14 19:35:14 +0200 | [diff] [blame] | 7 | LINUX_TOOLS += perf |
Thomas Petazzoni | d82f5cb | 2013-01-06 05:22:45 +0000 | [diff] [blame] | 8 | |
Romain Naour | 1326e76 | 2015-07-14 19:35:14 +0200 | [diff] [blame] | 9 | PERF_DEPENDENCIES = host-flex host-bison |
Thomas Petazzoni | d82f5cb | 2013-01-06 05:22:45 +0000 | [diff] [blame] | 10 | |
Steven Noonan | 1b78782 | 2015-07-14 19:35:11 +0200 | [diff] [blame] | 11 | ifeq ($(KERNEL_ARCH),x86_64) |
| 12 | PERF_ARCH=x86 |
| 13 | else |
| 14 | PERF_ARCH=$(KERNEL_ARCH) |
| 15 | endif |
| 16 | |
Thomas Petazzoni | d82f5cb | 2013-01-06 05:22:45 +0000 | [diff] [blame] | 17 | PERF_MAKE_FLAGS = \ |
| 18 | $(LINUX_MAKE_FLAGS) \ |
Yann E. MORIN | d4a2020 | 2016-03-11 19:19:55 +0100 | [diff] [blame] | 19 | JOBS=$(PARALLEL_JOBS) \ |
Steven Noonan | 1b78782 | 2015-07-14 19:35:11 +0200 | [diff] [blame] | 20 | ARCH=$(PERF_ARCH) \ |
Yann E. MORIN | 2b1d5df | 2016-03-11 19:19:56 +0100 | [diff] [blame] | 21 | DESTDIR=$(TARGET_DIR) \ |
| 22 | prefix=/usr \ |
| 23 | WERROR=0 \ |
Thomas Petazzoni | d82f5cb | 2013-01-06 05:22:45 +0000 | [diff] [blame] | 24 | NO_LIBAUDIT=1 \ |
| 25 | NO_NEWT=1 \ |
| 26 | NO_GTK2=1 \ |
| 27 | NO_LIBPERL=1 \ |
| 28 | NO_LIBPYTHON=1 \ |
Yann E. MORIN | 2b1d5df | 2016-03-11 19:19:56 +0100 | [diff] [blame] | 29 | NO_LIBBIONIC=1 |
Thomas Petazzoni | d82f5cb | 2013-01-06 05:22:45 +0000 | [diff] [blame] | 30 | |
Vicente Olivert Riera | f574a8e | 2017-02-17 10:59:05 +0000 | [diff] [blame] | 31 | # 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. |
| 34 | ifeq ($(BR2_mips),y) |
| 35 | PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32btsmip" |
| 36 | else ifeq ($(BR2_mipsel),y) |
| 37 | PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmip" |
| 38 | else ifeq ($(BR2_mips64),y) |
| 39 | ifeq ($(BR2_MIPS_NABI32),y) |
| 40 | PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32btsmipn32" |
| 41 | else |
| 42 | PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64btsmip" |
| 43 | endif |
| 44 | else ifeq ($(BR2_mips64el),y) |
| 45 | ifeq ($(BR2_MIPS_NABI32),y) |
| 46 | PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmipn32" |
| 47 | else |
| 48 | PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64ltsmip" |
| 49 | endif |
Vicente Olivert Riera | 7f3a52f | 2016-02-22 10:22:45 +0000 | [diff] [blame] | 50 | endif |
| 51 | |
Mischa Jonker | fc093d6 | 2014-01-28 14:10:58 +0100 | [diff] [blame] | 52 | # 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. |
| 58 | ifeq ($(BR2_arc),y) |
Jerzy Grzegorek | bd8c733 | 2015-03-31 09:21:57 +0200 | [diff] [blame] | 59 | PERF_MAKE_FLAGS += NO_BACKTRACE=1 |
Mischa Jonker | fc093d6 | 2014-01-28 14:10:58 +0100 | [diff] [blame] | 60 | endif |
| 61 | |
Steven Noonan | 15f2cc5 | 2015-07-14 19:35:08 +0200 | [diff] [blame] | 62 | ifeq ($(BR2_PACKAGE_SLANG),y) |
| 63 | PERF_DEPENDENCIES += slang |
Yann E. MORIN | 2b1d5df | 2016-03-11 19:19:56 +0100 | [diff] [blame] | 64 | else |
| 65 | PERF_MAKE_FLAGS += NO_SLANG=1 |
Steven Noonan | 15f2cc5 | 2015-07-14 19:35:08 +0200 | [diff] [blame] | 66 | endif |
| 67 | |
Steven Noonan | 71e5ff6 | 2015-07-14 19:35:10 +0200 | [diff] [blame] | 68 | ifeq ($(BR2_PACKAGE_LIBUNWIND),y) |
| 69 | PERF_DEPENDENCIES += libunwind |
Yann E. MORIN | 2b1d5df | 2016-03-11 19:19:56 +0100 | [diff] [blame] | 70 | else |
| 71 | PERF_MAKE_FLAGS += NO_LIBUNWIND=1 |
Steven Noonan | 71e5ff6 | 2015-07-14 19:35:10 +0200 | [diff] [blame] | 72 | endif |
| 73 | |
Steven Noonan | 1bc3685 | 2015-07-14 19:35:09 +0200 | [diff] [blame] | 74 | ifeq ($(BR2_PACKAGE_NUMACTL),y) |
| 75 | PERF_DEPENDENCIES += numactl |
Yann E. MORIN | 2b1d5df | 2016-03-11 19:19:56 +0100 | [diff] [blame] | 76 | else |
| 77 | PERF_MAKE_FLAGS += NO_LIBNUMA=1 |
Steven Noonan | 1bc3685 | 2015-07-14 19:35:09 +0200 | [diff] [blame] | 78 | endif |
| 79 | |
Thomas Petazzoni | 69030ca | 2013-01-06 05:22:46 +0000 | [diff] [blame] | 80 | ifeq ($(BR2_PACKAGE_ELFUTILS),y) |
Jerzy Grzegorek | bd8c733 | 2015-03-31 09:21:57 +0200 | [diff] [blame] | 81 | PERF_DEPENDENCIES += elfutils |
Thomas Petazzoni | 69030ca | 2013-01-06 05:22:46 +0000 | [diff] [blame] | 82 | else |
Jerzy Grzegorek | bd8c733 | 2015-03-31 09:21:57 +0200 | [diff] [blame] | 83 | PERF_MAKE_FLAGS += NO_LIBELF=1 NO_DWARF=1 |
Thomas Petazzoni | 69030ca | 2013-01-06 05:22:46 +0000 | [diff] [blame] | 84 | endif |
| 85 | |
Yann E. MORIN | 9666835 | 2016-03-11 19:19:57 +0100 | [diff] [blame] | 86 | ifeq ($(BR2_PACKAGE_ZLIB),y) |
| 87 | PERF_DEPENDENCIES += zlib |
| 88 | else |
| 89 | PERF_MAKE_FLAGS += NO_ZLIB=1 |
| 90 | endif |
| 91 | |
| 92 | # lzma is provided by xz |
| 93 | ifeq ($(BR2_PACKAGE_XZ),y) |
| 94 | PERF_DEPENDENCIES += xz |
| 95 | else |
| 96 | PERF_MAKE_FLAGS += NO_LZMA=1 |
| 97 | endif |
| 98 | |
Yann E. MORIN | c306e04 | 2016-03-11 19:19:54 +0100 | [diff] [blame] | 99 | # 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'. |
| 105 | define PERF_DISABLE_DOCUMENTATION |
Yann E. MORIN | 20b1446 | 2016-09-06 16:29:14 +0200 | [diff] [blame] | 106 | if [ -f $(LINUX_DIR)/tools/perf/Documentation/Makefile ]; then \ |
| 107 | printf "%%:\n\t@:\n" >$(LINUX_DIR)/tools/perf/Documentation/GNUmakefile; \ |
Yann E. MORIN | c306e04 | 2016-03-11 19:19:54 +0100 | [diff] [blame] | 108 | fi |
| 109 | endef |
| 110 | LINUX_POST_PATCH_HOOKS += PERF_DISABLE_DOCUMENTATION |
| 111 | |
Romain Naour | 1326e76 | 2015-07-14 19:35:14 +0200 | [diff] [blame] | 112 | # O must be redefined here to overwrite the one used by Buildroot for |
Yann E. MORIN | 20b1446 | 2016-09-06 16:29:14 +0200 | [diff] [blame] | 113 | # 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 Naour | 1326e76 | 2015-07-14 19:35:14 +0200 | [diff] [blame] | 115 | # sources. |
Thomas Petazzoni | d82f5cb | 2013-01-06 05:22:45 +0000 | [diff] [blame] | 116 | define PERF_BUILD_CMDS |
Yann E. MORIN | 20b1446 | 2016-09-06 16:29:14 +0200 | [diff] [blame] | 117 | $(Q)if test ! -f $(LINUX_DIR)/tools/perf/Makefile ; then \ |
Thomas Petazzoni | 1727e89 | 2013-01-06 05:22:47 +0000 | [diff] [blame] | 118 | 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. MORIN | 20b1446 | 2016-09-06 16:29:14 +0200 | [diff] [blame] | 123 | if ! grep -q NO_LIBELF $(LINUX_DIR)/tools/perf/Makefile* ; then \ |
| 124 | if ! test -r $(LINUX_DIR)/tools/perf/config/Makefile ; then \ |
Peter Meerwald | 220490c | 2014-04-05 14:51:02 +0200 | [diff] [blame] | 125 | 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 Petazzoni | 1727e89 | 2013-01-06 05:22:47 +0000 | [diff] [blame] | 129 | fi \ |
| 130 | fi |
Romain Naour | 1326e76 | 2015-07-14 19:35:14 +0200 | [diff] [blame] | 131 | $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \ |
Yann E. MORIN | 20b1446 | 2016-09-06 16:29:14 +0200 | [diff] [blame] | 132 | -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ |
Thomas Petazzoni | d82f5cb | 2013-01-06 05:22:45 +0000 | [diff] [blame] | 133 | endef |
| 134 | |
| 135 | # After installation, we remove the Perl and Python scripts from the |
| 136 | # target. |
| 137 | define PERF_INSTALL_TARGET_CMDS |
Romain Naour | 1326e76 | 2015-07-14 19:35:14 +0200 | [diff] [blame] | 138 | $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \ |
Yann E. MORIN | 20b1446 | 2016-09-06 16:29:14 +0200 | [diff] [blame] | 139 | -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ install |
Thomas Petazzoni | d82f5cb | 2013-01-06 05:22:45 +0000 | [diff] [blame] | 140 | $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/ |
Thomas De Schampheleire | 77e7cdb | 2016-01-15 09:47:35 +0100 | [diff] [blame] | 141 | $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/ |
Thomas Petazzoni | d82f5cb | 2013-01-06 05:22:45 +0000 | [diff] [blame] | 142 | endef |