linux-tool-perf.mk.in 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. JOBS=$(PARALLEL_JOBS) \
  16. ARCH=$(PERF_ARCH) \
  17. DESTDIR=$(TARGET_DIR) \
  18. prefix=/usr \
  19. WERROR=0 \
  20. NO_LIBAUDIT=1 \
  21. NO_NEWT=1 \
  22. NO_GTK2=1 \
  23. NO_LIBPERL=1 \
  24. NO_LIBPYTHON=1 \
  25. NO_LIBBIONIC=1
  26. # We need to pass an argument to ld for setting the endianness when
  27. # building it for MIPS architecture, otherwise the default one will
  28. # always be used (which is big endian) and the compilation for little
  29. # endian will always fail showing an error like this one:
  30. # LD foo.o
  31. # mips-linux-gnu-ld: foo.o: compiled for a little endian system and
  32. # target is big endian
  33. ifeq ($(BR2_mips)$(BR2_mips64),y)
  34. PERF_MAKE_FLAGS += LD="$(TARGET_LD) -EB"
  35. else ifeq ($(BR2_mipsel)$(BR2_mips64el),y)
  36. PERF_MAKE_FLAGS += LD="$(TARGET_LD) -EL"
  37. endif
  38. # The call to backtrace() function fails for ARC, because for some
  39. # reason the unwinder from libgcc returns early. Thus the usage of
  40. # backtrace() should be disabled in perf explicitly: at build time
  41. # backtrace() appears to be available, but it fails at runtime: the
  42. # backtrace will contain only several functions from the top of stack,
  43. # instead of the complete backtrace.
  44. ifeq ($(BR2_arc),y)
  45. PERF_MAKE_FLAGS += NO_BACKTRACE=1
  46. endif
  47. ifeq ($(BR2_PACKAGE_SLANG),y)
  48. PERF_DEPENDENCIES += slang
  49. else
  50. PERF_MAKE_FLAGS += NO_SLANG=1
  51. endif
  52. ifeq ($(BR2_PACKAGE_LIBUNWIND),y)
  53. PERF_DEPENDENCIES += libunwind
  54. else
  55. PERF_MAKE_FLAGS += NO_LIBUNWIND=1
  56. endif
  57. ifeq ($(BR2_PACKAGE_NUMACTL),y)
  58. PERF_DEPENDENCIES += numactl
  59. else
  60. PERF_MAKE_FLAGS += NO_LIBNUMA=1
  61. endif
  62. ifeq ($(BR2_PACKAGE_ELFUTILS),y)
  63. PERF_DEPENDENCIES += elfutils
  64. else
  65. PERF_MAKE_FLAGS += NO_LIBELF=1 NO_DWARF=1
  66. endif
  67. ifeq ($(BR2_PACKAGE_ZLIB),y)
  68. PERF_DEPENDENCIES += zlib
  69. else
  70. PERF_MAKE_FLAGS += NO_ZLIB=1
  71. endif
  72. # lzma is provided by xz
  73. ifeq ($(BR2_PACKAGE_XZ),y)
  74. PERF_DEPENDENCIES += xz
  75. else
  76. PERF_MAKE_FLAGS += NO_LZMA=1
  77. endif
  78. # We really do not want to build the perf documentation, because it
  79. # has stringent requirement on the documentation generation tools,
  80. # like xmlto and asciidoc), which may be lagging behind on some
  81. # distributions.
  82. # We name it 'GNUmakefile' so that GNU make will use it instead of
  83. # the existing 'Makefile'.
  84. define PERF_DISABLE_DOCUMENTATION
  85. if [ -f $(LINUX_DIR)/tools/perf/Documentation/Makefile ]; then \
  86. printf "%%:\n\t@:\n" >$(LINUX_DIR)/tools/perf/Documentation/GNUmakefile; \
  87. fi
  88. endef
  89. LINUX_POST_PATCH_HOOKS += PERF_DISABLE_DOCUMENTATION
  90. # O must be redefined here to overwrite the one used by Buildroot for
  91. # out of tree build. We build perf in $(LINUX_DIR)/tools/perf/ and not just
  92. # $(LINUX_DIR) so that it isn't built in the root directory of the kernel
  93. # sources.
  94. define PERF_BUILD_CMDS
  95. $(Q)if test ! -f $(LINUX_DIR)/tools/perf/Makefile ; then \
  96. echo "Your kernel version is too old and does not have the perf tool." ; \
  97. echo "At least kernel 2.6.31 must be used." ; \
  98. exit 1 ; \
  99. fi
  100. $(Q)if test "$(BR2_PACKAGE_ELFUTILS)" = "" ; then \
  101. if ! grep -q NO_LIBELF $(LINUX_DIR)/tools/perf/Makefile* ; then \
  102. if ! test -r $(LINUX_DIR)/tools/perf/config/Makefile ; then \
  103. echo "The perf tool in your kernel cannot be built without libelf." ; \
  104. echo "Either upgrade your kernel to >= 3.7, or enable the elfutils package." ; \
  105. exit 1 ; \
  106. fi \
  107. fi \
  108. fi
  109. $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
  110. -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/
  111. endef
  112. # After installation, we remove the Perl and Python scripts from the
  113. # target.
  114. define PERF_INSTALL_TARGET_CMDS
  115. $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
  116. -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ install
  117. $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/
  118. $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/
  119. endef