valgrind.mk 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. ################################################################################
  2. #
  3. # valgrind
  4. #
  5. ################################################################################
  6. VALGRIND_VERSION = 3.22.0
  7. VALGRIND_SITE = https://sourceware.org/pub/valgrind
  8. VALGRIND_SOURCE = valgrind-$(VALGRIND_VERSION).tar.bz2
  9. VALGRIND_LICENSE = GPL-2.0, GFDL-1.2
  10. VALGRIND_LICENSE_FILES = COPYING COPYING.DOCS
  11. VALGRIND_CPE_ID_VENDOR = valgrind
  12. VALGRIND_CONF_OPTS = \
  13. --disable-ubsan \
  14. --without-mpicc
  15. VALGRIND_INSTALL_STAGING = YES
  16. # Valgrind must be compiled with no stack protection, so forcefully
  17. # pass -fno-stack-protector to override what Buildroot may have in
  18. # TARGET_CFLAGS if BR2_SSP_* support is enabled.
  19. VALGRIND_CFLAGS = \
  20. $(TARGET_CFLAGS) \
  21. -fno-stack-protector
  22. # When Valgrind detects a 32-bit MIPS architecture, it forcibly adds
  23. # -march=mips32 to CFLAGS; when it detects a 64-bit MIPS architecture,
  24. # it forcibly adds -march=mips64. This causes Valgrind to be built
  25. # always for the first ISA revision level (R1), even when the user has
  26. # configured Buildroot for the second ISA revision level (R2).
  27. #
  28. # Override the CFLAGS variable (which Valgrind appends to its CFLAGS)
  29. # and pass the right -march option, so they take precedence over
  30. # Valgrind's wrongfully detected value.
  31. ifeq ($(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el),y)
  32. VALGRIND_CFLAGS += -march="$(GCC_TARGET_ARCH)"
  33. endif
  34. VALGRIND_CONF_ENV = CFLAGS="$(VALGRIND_CFLAGS)"
  35. # fix uclibc configure c99 support detection
  36. VALGRIND_CONF_ENV += ac_cv_prog_cc_c99='-std=gnu99'
  37. # On ARM, Valgrind only supports ARMv7, and uses the arch part of the
  38. # host tuple to determine whether it's being built for ARMv7 or
  39. # not. Therefore, we adjust the host tuple to specify we're on
  40. # ARMv7. The valgrind package is guaranteed, through Config.in, to
  41. # only be selected on ARMv7-A platforms.
  42. ifeq ($(BR2_ARM_CPU_ARMV7A),y)
  43. VALGRIND_CONF_OPTS += \
  44. --host=$(patsubst arm-%,armv7-%,$(GNU_TARGET_NAME))
  45. endif
  46. ifeq ($(BR2_ENABLE_LTO),y)
  47. VALGRIND_CONF_OPTS += --enable-lto
  48. else
  49. VALGRIND_CONF_OPTS += --disable-lto
  50. endif
  51. define VALGRIND_INSTALL_UCLIBC_SUPP
  52. $(INSTALL) -D -m 0644 package/valgrind/uclibc.supp $(TARGET_DIR)/usr/lib/valgrind/uclibc.supp
  53. endef
  54. VALGRIND_POST_INSTALL_TARGET_HOOKS += VALGRIND_INSTALL_UCLIBC_SUPP
  55. ifeq ($(BR2_PACKAGE_VALGRIND_MEMCHECK),)
  56. define VALGRIND_REMOVE_MEMCHECK
  57. rm -f $(TARGET_DIR)/usr/libexec/valgrind/*memcheck*
  58. endef
  59. VALGRIND_POST_INSTALL_TARGET_HOOKS += VALGRIND_REMOVE_MEMCHECK
  60. endif
  61. ifeq ($(BR2_PACKAGE_VALGRIND_CACHEGRIND),)
  62. define VALGRIND_REMOVE_CACHEGRIND
  63. rm -f $(TARGET_DIR)/usr/libexec/valgrind/*cachegrind*
  64. for i in cg_annotate cg_diff cg_merge; do \
  65. rm -f $(TARGET_DIR)/usr/bin/$$i ; \
  66. done
  67. endef
  68. VALGRIND_POST_INSTALL_TARGET_HOOKS += VALGRIND_REMOVE_CACHEGRIND
  69. endif
  70. ifeq ($(BR2_PACKAGE_VALGRIND_CALLGRIND),)
  71. define VALGRIND_REMOVE_CALLGRIND
  72. rm -f $(TARGET_DIR)/usr/libexec/valgrind/*callgrind*
  73. for i in callgrind_annotate callgrind_control ; do \
  74. rm -f $(TARGET_DIR)/usr/bin/$$i ; \
  75. done
  76. endef
  77. VALGRIND_POST_INSTALL_TARGET_HOOKS += VALGRIND_REMOVE_CALLGRIND
  78. endif
  79. ifeq ($(BR2_PACKAGE_VALGRIND_HELGRIND),)
  80. define VALGRIND_REMOVE_HELGRIND
  81. rm -f $(TARGET_DIR)/usr/libexec/valgrind/*helgrind*
  82. endef
  83. VALGRIND_POST_INSTALL_TARGET_HOOKS += VALGRIND_REMOVE_HELGRIND
  84. endif
  85. ifeq ($(BR2_PACKAGE_VALGRIND_DRD),)
  86. define VALGRIND_REMOVE_DRD
  87. rm -f $(TARGET_DIR)/usr/libexec/valgrind/*drd*
  88. endef
  89. VALGRIND_POST_INSTALL_TARGET_HOOKS += VALGRIND_REMOVE_DRD
  90. endif
  91. ifeq ($(BR2_PACKAGE_VALGRIND_MASSIF),)
  92. define VALGRIND_REMOVE_MASSIF
  93. rm -f $(TARGET_DIR)/usr/libexec/valgrind/*massif*
  94. rm -f $(TARGET_DIR)/usr/bin/ms_print
  95. endef
  96. VALGRIND_POST_INSTALL_TARGET_HOOKS += VALGRIND_REMOVE_MASSIF
  97. endif
  98. ifeq ($(BR2_PACKAGE_VALGRIND_DHAT),)
  99. define VALGRIND_REMOVE_DHAT
  100. rm -f $(TARGET_DIR)/usr/libexec/valgrind/*dhat*
  101. endef
  102. VALGRIND_POST_INSTALL_TARGET_HOOKS += VALGRIND_REMOVE_DHAT
  103. endif
  104. ifeq ($(BR2_PACKAGE_VALGRIND_SGCHECK),)
  105. define VALGRIND_REMOVE_SGCHECK
  106. rm -f $(TARGET_DIR)/usr/libexec/valgrind/*sgcheck*
  107. endef
  108. VALGRIND_POST_INSTALL_TARGET_HOOKS += VALGRIND_REMOVE_SGCHECK
  109. endif
  110. ifeq ($(BR2_PACKAGE_VALGRIND_BBV),)
  111. define VALGRIND_REMOVE_BBV
  112. rm -f $(TARGET_DIR)/usr/libexec/valgrind/*bbv*
  113. endef
  114. VALGRIND_POST_INSTALL_TARGET_HOOKS += VALGRIND_REMOVE_BBV
  115. endif
  116. ifeq ($(BR2_PACKAGE_VALGRIND_LACKEY),)
  117. define VALGRIND_REMOVE_LACKEY
  118. rm -f $(TARGET_DIR)/usr/libexec/valgrind/*lackey*
  119. endef
  120. VALGRIND_POST_INSTALL_TARGET_HOOKS += VALGRIND_REMOVE_LACKEY
  121. endif
  122. ifeq ($(BR2_PACKAGE_VALGRIND_NULGRIND),)
  123. define VALGRIND_REMOVE_NULGRIND
  124. rm -f $(TARGET_DIR)/usr/libexec/valgrind/*none*
  125. endef
  126. VALGRIND_POST_INSTALL_TARGET_HOOKS += VALGRIND_REMOVE_NULGRIND
  127. endif
  128. $(eval $(autotools-package))