cmake: Make libbcc_bpf.so the BCC runtime

This commit adds more functionality into libbcc_bpf.so such that
libbcc_bpf.so contains all of BCC's runtime components. "Runtime" in
this context means everything except the stuff that depends on
clang/LLVM.

libbcc_bpf.so was originally created in fa073456 ("make libbpf
standalone-ready") with (I'm guessing) the intent of creating
bcc-libbpf. That has been superceded by libbpf (separate repo) so I
don't think it should be used much anymore.

This updated libbcc_bpf.so will be used by ahead-of-time compiled
bpftrace scripts[0] to drop the dependency on LLVM/clang for the runtime
component.

[0]: https://dxuuu.xyz/aot-bpftrace.html
diff --git a/src/cc/CMakeLists.txt b/src/cc/CMakeLists.txt
index 1441f40..974fa49 100644
--- a/src/cc/CMakeLists.txt
+++ b/src/cc/CMakeLists.txt
@@ -101,11 +101,17 @@
 set(bcc-lua-static
   ${bcc_common_sources} ${bcc_table_sources} ${bcc_sym_sources} ${bcc_util_sources})
 
-add_library(bpf-static STATIC libbpf.c perf_reader.c ${libbpf_sources})
+set(bpf_sources libbpf.c perf_reader.c ${libbpf_sources} ${bcc_sym_sources} ${bcc_util_sources} ${bcc_usdt_sources})
+add_library(bpf-static STATIC ${bpf_sources})
 set_target_properties(bpf-static PROPERTIES OUTPUT_NAME bcc_bpf)
-add_library(bpf-shared SHARED libbpf.c perf_reader.c ${libbpf_sources})
+target_link_libraries(bpf-static elf z)
+add_library(bpf-shared SHARED ${bpf_sources})
 set_target_properties(bpf-shared PROPERTIES VERSION ${REVISION_LAST} SOVERSION 0)
 set_target_properties(bpf-shared PROPERTIES OUTPUT_NAME bcc_bpf)
+target_link_libraries(bpf-shared elf z)
+if(LIBDEBUGINFOD_FOUND)
+  target_link_libraries(bpf-shared ${LIBDEBUGINFOD_LIBRARIES})
+endif(LIBDEBUGINFOD_FOUND)
 if(CMAKE_USE_LIBBPF_PACKAGE AND LIBBPF_FOUND)
   target_link_libraries(bpf-shared ${LIBBPF_LIBRARIES})
 endif()