if(CONFIG_LIB_AVB)
nuttx_add_library(avb STATIC)
set(CFLAGS -DAVB_COMPILATION -DAVB_FOOTER_SEARCH_BLKSIZE=CONFIG_LIB_AVB_FOOTER_SEARCH_BLKSIZE)
set(INCDIR ${NUTTX_APPS_DIR}/external/avb/avb)
if(CONFIG_LIB_AVB_CRC32_CRYPTODEV OR CONFIG_LIB_AVB_SHA256_CRYPTODEV OR CONFIG_LIB_AVB_SHA512_CRYPTODEV)
list(APPEND INCDIR ${NUTTX_APPS_DIR}/external/avb/avb/libavb/cryptodev)
else()
list(APPEND INCDIR ${NUTTX_APPS_DIR}/external/avb/avb/libavb/sha)
endif()
set(CSRCS
avb/libavb/avb_chain_partition_descriptor.c
avb/libavb/avb_cmdline.c
avb/libavb/avb_crypto.c
avb/libavb/avb_descriptor.c
avb/libavb/avb_footer.c
avb/libavb/avb_hash_descriptor.c
avb/libavb/avb_hashtree_descriptor.c
avb/libavb/avb_kernel_cmdline_descriptor.c
avb/libavb/avb_property_descriptor.c
avb/libavb/avb_slot_verify.c
avb/libavb/avb_sysdeps_posix.c
avb/libavb/avb_util.c
avb/libavb/avb_vbmeta_image.c
avb/libavb/avb_version.c
avb/libavb_user/avb_verify.c
avb/libavb_user/avb_ops_user.c)
if(CONFIG_LIB_AVB_CRC32)
list(APPEND CSRCS avb/libavb/avb_crc32.c)
if(CONFIG_LIB_AVB_CRC32_CRYPTODEV)
list(APPEND CSRCS avb/libavb/cryptodev/crc32_cryptodev.c)
endif()
endif()
if(CONFIG_LIB_AVB_SHA256)
if(CONFIG_LIB_AVB_SHA256_CRYPTODEV)
list(APPEND CSRCS avb/libavb/cryptodev/sha256_cryptodev.c)
else()
list(APPEND CSRCS avb/libavb/sha/sha256_impl.c)
endif()
endif()
if(CONFIG_LIB_AVB_SHA512)
if(CONFIG_LIB_AVB_SHA512_CRYPTODEV)
list(APPEND CSRCS avb/libavb/cryptodev/sha512_cryptodev.c)
else()
list(APPEND CSRCS avb/libavb/sha/sha512_impl.c)
endif()
endif()
if(CONFIG_LIB_AVB_RSA_VERIFY_CRYPTODEV)
list(APPEND CSRCS avb/libavb/cryptodev/rsa_cryptodev.c)
else()
list(APPEND CSRCS avb/libavb/avb_rsa.c)
endif()
target_sources(avb PRIVATE ${CSRCS})
target_include_directories(avb PRIVATE ${INCDIR})
target_compile_options(avb PRIVATE ${CFLAGS})
endif()