linux-tool-perf.mk 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ################################################################################
  2. #
  3. # perf
  4. #
  5. ################################################################################
  6. LINUX_TOOLS += perf
  7. PERF_DEPENDENCIES = host-flex host-bison
  8. ifeq ($(KERNEL_ARCH),x86_64)
  9. PERF_ARCH=x86
  10. else
  11. PERF_ARCH=$(KERNEL_ARCH)
  12. endif
  13. PERF_MAKE_FLAGS = \
  14. $(LINUX_MAKE_FLAGS) \
  15. ARCH=$(PERF_ARCH) \
  16. NO_LIBAUDIT=1 \
  17. NO_NEWT=1 \
  18. NO_GTK2=1 \
  19. NO_LIBPERL=1 \
  20. NO_LIBPYTHON=1 \
  21. DESTDIR=$(TARGET_DIR) \
  22. prefix=/usr \
  23. WERROR=0 \
  24. ASCIIDOC=
  25. # We need to pass an argument to ld for setting the endianness when
  26. # building it for MIPS architecture, otherwise the default one will
  27. # always be used (which is big endian) and the compilation for little
  28. # endian will always fail showing an error like this one:
  29. # LD foo.o
  30. # mips-linux-gnu-ld: foo.o: compiled for a little endian system and
  31. # target is big endian
  32. ifeq ($(BR2_mips)$(BR2_mips64),y)
  33. PERF_MAKE_FLAGS += LD="$(TARGET_LD) -EB"
  34. else ifeq ($(BR2_mipsel)$(BR2_mips64el),y)
  35. PERF_MAKE_FLAGS += LD="$(TARGET_LD) -EL"
  36. endif
  37. # The call to backtrace() function fails for ARC, because for some
  38. # reason the unwinder from libgcc returns early. Thus the usage of
  39. # backtrace() should be disabled in perf explicitly: at build time
  40. # backtrace() appears to be available, but it fails at runtime: the
  41. # backtrace will contain only several functions from the top of stack,
  42. # instead of the complete backtrace.
  43. ifeq ($(BR2_arc),y)
  44. PERF_MAKE_FLAGS += NO_BACKTRACE=1
  45. endif
  46. ifeq ($(BR2_PACKAGE_SLANG),y)
  47. PERF_DEPENDENCIES += slang
  48. endif
  49. ifeq ($(BR2_PACKAGE_LIBUNWIND),y)
  50. PERF_DEPENDENCIES += libunwind
  51. endif
  52. ifeq ($(BR2_PACKAGE_NUMACTL),y)
  53. PERF_DEPENDENCIES += numactl
  54. endif
  55. ifeq ($(BR2_PACKAGE_ELFUTILS),y)
  56. PERF_DEPENDENCIES += elfutils
  57. else
  58. PERF_MAKE_FLAGS += NO_LIBELF=1 NO_DWARF=1
  59. endif
  60. # O must be redefined here to overwrite the one used by Buildroot for
  61. # out of tree build. We build perf in $(@D)/tools/perf/ and not just
  62. # $(@D) so that it isn't built in the root directory of the kernel
  63. # sources.
  64. define PERF_BUILD_CMDS
  65. $(Q)if test ! -f $(@D)/tools/perf/Makefile ; then \
  66. echo "Your kernel version is too old and does not have the perf tool." ; \
  67. echo "At least kernel 2.6.31 must be used." ; \
  68. exit 1 ; \
  69. fi
  70. $(Q)if test "$(BR2_PACKAGE_ELFUTILS)" = "" ; then \
  71. if ! grep -q NO_LIBELF $(@D)/tools/perf/Makefile* ; then \
  72. if ! test -r $(@D)/tools/perf/config/Makefile ; then \
  73. echo "The perf tool in your kernel cannot be built without libelf." ; \
  74. echo "Either upgrade your kernel to >= 3.7, or enable the elfutils package." ; \
  75. exit 1 ; \
  76. fi \
  77. fi \
  78. fi
  79. $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
  80. -C $(@D)/tools/perf O=$(@D)/tools/perf/
  81. endef
  82. # After installation, we remove the Perl and Python scripts from the
  83. # target.
  84. define PERF_INSTALL_TARGET_CMDS
  85. $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
  86. -C $(@D)/tools/perf O=$(@D)/tools/perf/ install
  87. $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/
  88. $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/
  89. endef