linux-tool-perf.mk.in 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. ################################################################################
  2. #
  3. # perf
  4. #
  5. ################################################################################
  6. LINUX_TOOLS += perf
  7. PERF_DEPENDENCIES = host-flex host-bison
  8. ifeq ($(NORMALIZED_ARCH),x86_64)
  9. PERF_ARCH=x86
  10. else
  11. PERF_ARCH=$(NORMALIZED_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_GTK2=1 \
  21. NO_LIBPERL=1 \
  22. NO_LIBPYTHON=1 \
  23. NO_LIBBIONIC=1
  24. # We need to pass an argument to ld for setting the emulation when
  25. # building for MIPS architecture, otherwise the default one will always
  26. # be used and the compilation for most variants will fail.
  27. ifeq ($(BR2_mips),y)
  28. PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32btsmip"
  29. else ifeq ($(BR2_mipsel),y)
  30. PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmip"
  31. else ifeq ($(BR2_mips64),y)
  32. ifeq ($(BR2_MIPS_NABI32),y)
  33. PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32btsmipn32"
  34. else
  35. PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64btsmip"
  36. endif
  37. else ifeq ($(BR2_mips64el),y)
  38. ifeq ($(BR2_MIPS_NABI32),y)
  39. PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf32ltsmipn32"
  40. else
  41. PERF_MAKE_FLAGS += LD="$(TARGET_LD) -m elf64ltsmip"
  42. endif
  43. endif
  44. # The call to backtrace() function fails for ARC, because for some
  45. # reason the unwinder from libgcc returns early. Thus the usage of
  46. # backtrace() should be disabled in perf explicitly: at build time
  47. # backtrace() appears to be available, but it fails at runtime: the
  48. # backtrace will contain only several functions from the top of stack,
  49. # instead of the complete backtrace.
  50. ifeq ($(BR2_arc),y)
  51. PERF_MAKE_FLAGS += NO_BACKTRACE=1
  52. endif
  53. ifeq ($(BR2_PACKAGE_LINUX_TOOLS_PERF_TUI),y)
  54. PERF_DEPENDENCIES += slang
  55. else
  56. PERF_MAKE_FLAGS += NO_NEWT=1 NO_SLANG=1
  57. endif
  58. ifeq ($(BR2_PACKAGE_AUDIT),y)
  59. PERF_DEPENDENCIES += audit
  60. else
  61. PERF_MAKE_FLAGS += NO_LIBAUDIT=1
  62. endif
  63. ifeq ($(BR2_PACKAGE_ZSTD),y)
  64. PERF_DEPENDENCIES += zstd
  65. endif
  66. ifeq ($(BR2_PACKAGE_LIBUNWIND),y)
  67. PERF_DEPENDENCIES += libunwind
  68. else
  69. PERF_MAKE_FLAGS += NO_LIBUNWIND=1
  70. endif
  71. ifeq ($(BR2_PACKAGE_NUMACTL),y)
  72. PERF_DEPENDENCIES += numactl
  73. else
  74. PERF_MAKE_FLAGS += NO_LIBNUMA=1
  75. endif
  76. ifeq ($(BR2_PACKAGE_ELFUTILS),y)
  77. PERF_DEPENDENCIES += elfutils
  78. else
  79. PERF_MAKE_FLAGS += NO_LIBELF=1 NO_DWARF=1
  80. endif
  81. ifeq ($(BR2_PACKAGE_BINUTILS),y)
  82. PERF_DEPENDENCIES += binutils
  83. else
  84. PERF_MAKE_FLAGS += NO_DEMANGLE=1
  85. endif
  86. ifeq ($(BR2_PACKAGE_OPENSSL),y)
  87. PERF_DEPENDENCIES += openssl
  88. else
  89. PERF_MAKE_FLAGS += NO_LIBCRYPTO=1
  90. endif
  91. ifeq ($(BR2_PACKAGE_ZLIB),y)
  92. PERF_DEPENDENCIES += zlib
  93. else
  94. PERF_MAKE_FLAGS += NO_ZLIB=1
  95. endif
  96. # lzma is provided by xz
  97. ifeq ($(BR2_PACKAGE_XZ),y)
  98. PERF_DEPENDENCIES += xz
  99. else
  100. PERF_MAKE_FLAGS += NO_LZMA=1
  101. endif
  102. # We really do not want to build the perf documentation, because it
  103. # has stringent requirement on the documentation generation tools,
  104. # like xmlto and asciidoc), which may be lagging behind on some
  105. # distributions.
  106. # We name it 'GNUmakefile' so that GNU make will use it instead of
  107. # the existing 'Makefile'.
  108. define PERF_DISABLE_DOCUMENTATION
  109. if [ -f $(LINUX_DIR)/tools/perf/Documentation/Makefile ]; then \
  110. printf "%%:\n\t@:\n" >$(LINUX_DIR)/tools/perf/Documentation/GNUmakefile; \
  111. fi
  112. endef
  113. LINUX_POST_PATCH_HOOKS += PERF_DISABLE_DOCUMENTATION
  114. # O must be redefined here to overwrite the one used by Buildroot for
  115. # out of tree build. We build perf in $(LINUX_DIR)/tools/perf/ and not just
  116. # $(LINUX_DIR) so that it isn't built in the root directory of the kernel
  117. # sources.
  118. define PERF_BUILD_CMDS
  119. $(Q)if test ! -f $(LINUX_DIR)/tools/perf/Makefile ; then \
  120. echo "Your kernel version is too old and does not have the perf tool." ; \
  121. echo "At least kernel 2.6.31 must be used." ; \
  122. exit 1 ; \
  123. fi
  124. $(Q)if test "$(BR2_PACKAGE_ELFUTILS)" = "" ; then \
  125. if ! grep -q NO_LIBELF $(LINUX_DIR)/tools/perf/Makefile* ; then \
  126. if ! test -r $(LINUX_DIR)/tools/perf/config/Makefile ; then \
  127. echo "The perf tool in your kernel cannot be built without libelf." ; \
  128. echo "Either upgrade your kernel to >= 3.7, or enable the elfutils package." ; \
  129. exit 1 ; \
  130. fi \
  131. fi \
  132. fi
  133. $(Q)if test "$(BR2_PACKAGE_LINUX_TOOLS_PERF_TUI)" = "y" ; then \
  134. if ! grep -q NO_SLANG $(LINUX_DIR)/tools/perf/Makefile* ; then \
  135. echo "The perf tool in your kernel cannot be build with the TUI." ; \
  136. echo "Either upgrade your kernel to >= 3.10, or disable the TUI." ; \
  137. exit 1 ; \
  138. fi \
  139. fi
  140. $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
  141. -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/
  142. endef
  143. # After installation, we remove the Perl and Python scripts from the
  144. # target.
  145. define PERF_INSTALL_TARGET_CMDS
  146. $(TARGET_MAKE_ENV) $(MAKE1) $(PERF_MAKE_FLAGS) \
  147. -C $(LINUX_DIR)/tools/perf O=$(LINUX_DIR)/tools/perf/ install
  148. $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/scripts/
  149. $(RM) -rf $(TARGET_DIR)/usr/libexec/perf-core/tests/
  150. endef
  151. define PERF_LINUX_CONFIG_FIXUPS
  152. $(call KCONFIG_ENABLE_OPT,CONFIG_PERF_EVENTS)
  153. endef