NetdataEBPFLegacy.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Handling for eBPF legacy programs
  2. #
  3. # Copyright (c) 2024 Netdata Inc.
  4. # SPDX-License-Identifier: GPL-3.0-or-later
  5. include(ExternalProject)
  6. include(NetdataUtil)
  7. set(ebpf-legacy_SOURCE_DIR "${CMAKE_BINARY_DIR}/ebpf-legacy")
  8. set(ebpf-legacy_BUILD_DIR "${CMAKE_BINARY_DIR}/ebpf-legacy-build")
  9. # Fetch the legacy eBPF code.
  10. function(netdata_fetch_legacy_ebpf_code)
  11. netdata_identify_libc(_libc)
  12. if(DEFINED BUILD_SHARED_LIBS)
  13. if(NOT BUILD_SHARED_LIBS)
  14. set(need_static TRUE)
  15. endif()
  16. endif()
  17. if(need_static)
  18. set(_hash ca0c6186b5c9c4640f8ba13ea375b66882203e8ca831a2e6e5e4e039b37f277a)
  19. set(_libc "static")
  20. elseif(_libc STREQUAL "glibc")
  21. set(_hash d3027685e15fdb6406fd36faf45287d79534d40601d388aca5ab87e90959846d)
  22. elseif(_libc STREQUAL "musl")
  23. set(_hash e2268ca1fa012e87d4d3d588e01b3a2389ad8a4b1c878508f6226ce1dad34acf)
  24. else()
  25. message(FATAL_ERROR "Could not determine libc implementation, unable to install eBPF legacy code.")
  26. endif()
  27. ExternalProject_Add(
  28. ebpf-code-legacy
  29. URL https://github.com/netdata/kernel-collector/releases/download/v1.5.0/netdata-kernel-collector-${_libc}-v1.5.0.tar.xz
  30. URL_HASH SHA256=${_hash}
  31. SOURCE_DIR "${ebpf-legacy_SOURCE_DIR}"
  32. CONFIGURE_COMMAND ""
  33. BUILD_COMMAND sh -c "mkdir -p ${ebpf-legacy_BUILD_DIR}/ebpf.d && mv ${ebpf-legacy_SOURCE_DIR}/*netdata_ebpf_*.o ${ebpf-legacy_BUILD_DIR}/ebpf.d"
  34. INSTALL_COMMAND ""
  35. )
  36. endfunction()
  37. function(netdata_install_legacy_ebpf_code)
  38. install(DIRECTORY ${ebpf-legacy_BUILD_DIR}/ebpf.d
  39. DESTINATION usr/libexec/netdata/plugins.d
  40. COMPONENT ebpf-code-legacy)
  41. endfunction()