libcamera.mk 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. ################################################################################
  2. #
  3. # libcamera
  4. #
  5. ################################################################################
  6. LIBCAMERA_VERSION = 9b28cffeba4698ce65c288146fa79cf748f0b609
  7. LIBCAMERA_SITE = https://github.com/starfive-tech/libcamera
  8. LIBCAMERA_SITE_METHOD = git
  9. LIBCAMERA_DEPENDENCIES = \
  10. host-openssl \
  11. host-pkgconf \
  12. host-python3-pyyaml \
  13. host-python-jinja2 \
  14. host-python-ply \
  15. host-patchelf \
  16. libyaml \
  17. gnutls
  18. LIBCAMERA_CONF_OPTS = \
  19. -Dandroid=disabled \
  20. -Ddocumentation=disabled \
  21. -Dtest=false \
  22. -Dwerror=false
  23. LIBCAMERA_INSTALL_STAGING = YES
  24. LIBCAMERA_LICENSE = \
  25. LGPL-2.1+ (library), \
  26. GPL-2.0+ (utils), \
  27. MIT (qcam/assets/feathericons), \
  28. BSD-2-Clause (raspberrypi), \
  29. GPL-2.0 with Linux-syscall-note or BSD-3-Clause (linux kernel headers), \
  30. CC0-1.0 (meson build system), \
  31. CC-BY-SA-4.0 (doc)
  32. LIBCAMERA_LICENSE_FILES = \
  33. LICENSES/LGPL-2.1-or-later.txt \
  34. LICENSES/GPL-2.0-or-later.txt \
  35. LICENSES/MIT.txt \
  36. LICENSES/BSD-2-Clause.txt \
  37. LICENSES/GPL-2.0-only.txt \
  38. LICENSES/Linux-syscall-note.txt \
  39. LICENSES/BSD-3-Clause.txt \
  40. LICENSES/CC0-1.0.txt \
  41. LICENSES/CC-BY-SA-4.0.txt
  42. ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_7),y)
  43. LIBCAMERA_CXXFLAGS = -faligned-new
  44. endif
  45. ifeq ($(BR2_PACKAGE_LIBCAMERA_V4L2),y)
  46. LIBCAMERA_CONF_OPTS += -Dv4l2=true
  47. else
  48. LIBCAMERA_CONF_OPTS += -Dv4l2=false
  49. endif
  50. LIBCAMERA_PIPELINES-$(BR2_PACKAGE_LIBCAMERA_PIPELINE_IPU3) += ipu3
  51. ifeq ($(BR2_PACKAGE_LIBCAMERA_PIPELINE_RASPBERRYPI),y)
  52. LIBCAMERA_PIPELINES-y += raspberrypi
  53. LIBCAMERA_DEPENDENCIES += boost
  54. endif
  55. LIBCAMERA_PIPELINES-$(BR2_PACKAGE_LIBCAMERA_PIPELINE_RKISP1) += rkisp1
  56. LIBCAMERA_PIPELINES-$(BR2_PACKAGE_LIBCAMERA_PIPELINE_SIMPLE) += simple
  57. LIBCAMERA_PIPELINES-$(BR2_PACKAGE_LIBCAMERA_PIPELINE_UVCVIDEO) += uvcvideo
  58. LIBCAMERA_PIPELINES-$(BR2_PACKAGE_LIBCAMERA_PIPELINE_VIMC) += vimc
  59. LIBCAMERA_PIPELINES-$(BR2_PACKAGE_LIBCAMERA_PIPELINE_STARFIVE) += starfive
  60. LIBCAMERA_CONF_OPTS += -Dpipelines=$(subst $(space),$(comma),$(LIBCAMERA_PIPELINES-y))
  61. ifeq ($(BR2_PACKAGE_LIBCAMERA_COMPLIANCE),y)
  62. LIBCAMERA_DEPENDENCIES += gtest libevent
  63. LIBCAMERA_CONF_OPTS += -Dlc-compliance=enabled
  64. else
  65. LIBCAMERA_CONF_OPTS += -Dlc-compliance=disabled
  66. endif
  67. # gstreamer-video-1.0, gstreamer-allocators-1.0
  68. ifeq ($(BR2_PACKAGE_GSTREAMER1)$(BR2_PACKAGE_GST1_PLUGINS_BASE),yy)
  69. LIBCAMERA_CONF_OPTS += -Dgstreamer=enabled
  70. LIBCAMERA_DEPENDENCIES += gstreamer1 gst1-plugins-base
  71. endif
  72. ifeq ($(BR2_PACKAGE_QT5BASE_WIDGETS),y)
  73. LIBCAMERA_CONF_OPTS += -Dqcam=enabled
  74. LIBCAMERA_DEPENDENCIES += qt5base
  75. ifeq ($(BR2_PACKAGE_QT5TOOLS_LINGUIST_TOOLS),y)
  76. LIBCAMERA_DEPENDENCIES += qt5tools
  77. endif
  78. else
  79. LIBCAMERA_CONF_OPTS += -Dqcam=disabled
  80. endif
  81. ifeq ($(BR2_PACKAGE_LIBEVENT),y)
  82. LIBCAMERA_CONF_OPTS += -Dcam=enabled
  83. LIBCAMERA_DEPENDENCIES += libevent
  84. else
  85. LIBCAMERA_CONF_OPTS += -Dcam=disabled
  86. endif
  87. ifeq ($(BR2_PACKAGE_TIFF),y)
  88. LIBCAMERA_DEPENDENCIES += tiff
  89. endif
  90. ifeq ($(BR2_PACKAGE_HAS_UDEV),y)
  91. LIBCAMERA_DEPENDENCIES += udev
  92. endif
  93. ifeq ($(BR2_PACKAGE_LTTNG_LIBUST),y)
  94. LIBCAMERA_CONF_OPTS += -Dtracing=enabled
  95. LIBCAMERA_DEPENDENCIES += lttng-libust
  96. else
  97. LIBCAMERA_CONF_OPTS += -Dtracing=disabled
  98. endif
  99. ifeq ($(BR2_PACKAGE_LIBEXECINFO),y)
  100. LIBCAMERA_DEPENDENCIES += libexecinfo
  101. LIBCAMERA_LDFLAGS = $(TARGET_LDFLAGS) -lexecinfo
  102. endif
  103. ifeq ($(BR2_PACKAGE_LIBCAMERA_PIPELINE_STARFIVE),y)
  104. LIBCAMERA_DEPENDENCIES += yaml-cpp
  105. endif
  106. # Open-Source IPA shlibs need to be signed in order to be runnable within the
  107. # same process, otherwise they are deemed Closed-Source and run in another
  108. # process and communicate over IPC.
  109. # Buildroot sanitizes RPATH in a post build process. meson gets rid of rpath
  110. # while installing so we don't need to do it manually here.
  111. # Buildroot may strip symbols, so we need to do the same before signing
  112. # otherwise the signature won't match the shlib on the rootfs. Since meson
  113. # install target is signing the shlibs, we need to strip them before.
  114. LIBCAMERA_STRIP_FIND_CMD = \
  115. find $(@D)/build/src/ipa \
  116. $(if $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES)), \
  117. -not \( $(call findfileclauses,$(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) ) \
  118. -type f -name 'ipa_*.so' -print0
  119. define LIBCAMERA_BUILD_STRIP_IPA_SO
  120. $(LIBCAMERA_STRIP_FIND_CMD) | xargs --no-run-if-empty -0 $(STRIPCMD)
  121. endef
  122. # LIBCAMERA_POST_BUILD_HOOKS += LIBCAMERA_BUILD_STRIP_IPA_SO
  123. ## replace with the starfive full feature ipa library which is closed source when post build
  124. define LIBCAMERA_BUILD_REPLACE_STARFIVE_IPA
  125. @echo "LIBCAMERA_POST_BUILD_HOOKS !!!!"
  126. $(if $(wildcard $(@D)/starfive_post_script/replace_algorithm_lib.sh),
  127. $(@D)/starfive_post_script/replace_algorithm_lib.sh)
  128. endef
  129. LIBCAMERA_POST_BUILD_HOOKS += LIBCAMERA_BUILD_REPLACE_STARFIVE_IPA
  130. ## replace with the starfive full feature ipa library which is closed source when post install to stage
  131. define LIBCAMERA_INSTALL_STAGING_REPLACE_STARFIVE_IPA
  132. @echo "LIBCAMERA_POST_INSTALL_STAGING_HOOKS !!!!"
  133. $(if $(wildcard $(@D)/starfive_post_script/replace_algorithm_lib.sh),
  134. $(@D)/starfive_post_script/replace_algorithm_lib.sh $(STAGING_DIR)/usr/lib/)
  135. endef
  136. LIBCAMERA_POST_INSTALL_STAGING_HOOKS += LIBCAMERA_INSTALL_STAGING_REPLACE_STARFIVE_IPA
  137. ## replace with the starfive full feature ipa library which is closed source when post install to target
  138. ## consider the support/scripts/fix-rpath will always change the rpath in library when make rootfs, so try to run it before sign
  139. define LIBCAMERA_TARGET_INSTALL_REPLACE_STARFIVE_IPA
  140. @echo "LIBCAMERA_POST_INSTALL_TARGET_HOOKS !!!!"
  141. $(if $(wildcard $(@D)/starfive_post_script/replace_algorithm_lib.sh),
  142. $(@D)/starfive_post_script/replace_algorithm_lib.sh $(TARGET_DIR)/usr/lib/; \
  143. $(@D)/starfive_post_script/replace_algorithm_lib.sh)
  144. PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) $(TOPDIR)/support/scripts/fix-rpath target
  145. $(@D)/src/ipa/ipa-sign-install.sh $(@D)/build/src/ipa-priv-key.pem $(TARGET_DIR)/usr/lib/libcamera/ipa_starfive.so
  146. @echo "$(@D)/src/ipa/ipa-sign-install.sh $(@D)/build/src/ipa-priv-key.pem $(TARGET_DIR)/usr/lib/libcamera/ipa_starfive.so"
  147. endef
  148. LIBCAMERA_POST_INSTALL_TARGET_HOOKS += LIBCAMERA_TARGET_INSTALL_REPLACE_STARFIVE_IPA
  149. $(eval $(meson-package))