openblas.mk 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. ################################################################################
  2. #
  3. # openblas
  4. #
  5. ################################################################################
  6. OPENBLAS_VERSION = 0.3.26
  7. OPENBLAS_SITE = https://github.com/OpenMathLib/OpenBLAS/releases/download/v$(OPENBLAS_VERSION)
  8. OPENBLAS_LICENSE = BSD-3-Clause
  9. OPENBLAS_LICENSE_FILES = LICENSE
  10. OPENBLAS_INSTALL_STAGING = YES
  11. OPENBLAS_CPE_ID_VALID = YES
  12. # Initialise OpenBLAS make options to $(TARGET_CONFIGURE_OPTS)
  13. OPENBLAS_MAKE_OPTS = $(TARGET_CONFIGURE_OPTS)
  14. # Enable cross-compiling
  15. OPENBLAS_MAKE_OPTS += CROSS=1
  16. # Set OpenBLAS target
  17. OPENBLAS_MAKE_OPTS += TARGET=$(BR2_PACKAGE_OPENBLAS_TARGET)
  18. # When Fortran is not available, only build the C version of BLAS
  19. ifeq ($(BR2_TOOLCHAIN_HAS_FORTRAN),)
  20. OPENBLAS_MAKE_OPTS += ONLY_CBLAS=1
  21. endif
  22. # Enable/Disable multi-threading (not for static-only since it uses dlfcn.h)
  23. ifeq ($(BR2_PACKAGE_OPENBLAS_USE_THREAD),y)
  24. OPENBLAS_MAKE_OPTS += USE_THREAD=1
  25. else
  26. OPENBLAS_MAKE_OPTS += USE_THREAD=0
  27. endif
  28. ifeq ($(BR2_PACKAGE_OPENBLAS_USE_LOCKING),y)
  29. OPENBLAS_MAKE_OPTS += USE_LOCKING=1
  30. else
  31. # not passing USE_LOCKING=0 as this could be confusing: its effect is implicit
  32. # in case of USE_THREAD=1.
  33. endif
  34. # We don't know if OpenMP is available or not, so disable
  35. OPENBLAS_MAKE_OPTS += USE_OPENMP=0
  36. # Static-only/Shared-only toggle
  37. # Note: static library is always generated so that applications can link
  38. # statically for size reduction, even if BR2_STATIC_LIBS is not set.
  39. ifeq ($(BR2_STATIC_LIBS),y)
  40. OPENBLAS_MAKE_OPTS += NO_SHARED=1
  41. endif
  42. ifeq ($(BR2_ARCH_IS_64),y)
  43. OPENBLAS_MAKE_OPTS += BINARY=64
  44. else
  45. OPENBLAS_MAKE_OPTS += BINARY=32
  46. endif
  47. # binutils version <= 2.23.2 has a bug
  48. # (https://sourceware.org/bugzilla/show_bug.cgi?id=14887) where
  49. # whitespaces in ARM register specifications such as [ r1, #12 ] or [
  50. # r2 ] cause the assembler to reject the code. Since there are
  51. # numerous instances of such cases in the code, we use sed rather than
  52. # a patch. We simply replace [ foobar ] by [foobar] to work around the
  53. # problem.
  54. define OPENBLAS_FIXUP_ARM_ASSEMBLY
  55. $(SED) 's%\[\s*%\[%;s%\s*\]%\]%' $(@D)/kernel/arm/*.S
  56. endef
  57. OPENBLAS_POST_PATCH_HOOKS += OPENBLAS_FIXUP_ARM_ASSEMBLY
  58. define OPENBLAS_BUILD_CMDS
  59. $(TARGET_MAKE_ENV) $(MAKE) $(OPENBLAS_MAKE_OPTS) \
  60. -C $(@D)
  61. endef
  62. define OPENBLAS_INSTALL_STAGING_CMDS
  63. $(TARGET_MAKE_ENV) $(MAKE) $(OPENBLAS_MAKE_OPTS) \
  64. -C $(@D) install PREFIX=$(STAGING_DIR)/usr
  65. endef
  66. define OPENBLAS_INSTALL_TARGET_CMDS
  67. $(TARGET_MAKE_ENV) $(MAKE) $(OPENBLAS_MAKE_OPTS) \
  68. -C $(@D) install PREFIX=$(TARGET_DIR)/usr
  69. endef
  70. ifeq ($(BR2_PACKAGE_OPENBLAS_INSTALL_TESTS),y)
  71. # Tests are always built, but are not installed, so we need to install
  72. # them manually. The set of available tests may fluctuate depending on
  73. # the architecture and other options, so only install whatever gets
  74. # built.
  75. define OPENBLAS_INSTALL_TESTS
  76. mkdir -p $(TARGET_DIR)/usr/libexec/openblas/tests
  77. find $(@D)/ctest \
  78. -type f -name "x[sdcz]cblat[123]" -perm -0100 \
  79. -exec $(INSTALL) -m 0755 {} \
  80. $(TARGET_DIR)/usr/libexec/openblas/tests \;
  81. find $(@D)/ctest \
  82. -type f -name "[sdcz]in[123]" \
  83. -exec $(INSTALL) -m 0644 {} \
  84. $(TARGET_DIR)/usr/libexec/openblas/tests \;
  85. endef
  86. OPENBLAS_POST_INSTALL_TARGET_HOOKS += OPENBLAS_INSTALL_TESTS
  87. endif
  88. $(eval $(generic-package))