linux-tool-perf.mk.in 4.7 KB

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