1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c5c4c396..4bc3e499 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -103,9 +103,10 @@ find_package(FLEX REQUIRED)
bison_target(bison_parser src/parser.yy ${CMAKE_BINARY_DIR}/parser.tab.cc VERBOSE)
flex_target(flex_lexer src/lexer.l ${CMAKE_BINARY_DIR}/lex.yy.cc)
add_flex_bison_dependency(flex_lexer bison_parser)
-add_library(parser ${BISON_bison_parser_OUTPUTS} ${FLEX_flex_lexer_OUTPUTS})
-target_compile_options(parser PRIVATE "-w")
-target_include_directories(parser PUBLIC src src/ast ${CMAKE_BINARY_DIR})
+add_library(bpftraceparser ${BISON_bison_parser_OUTPUTS} ${FLEX_flex_lexer_OUTPUTS})
+target_compile_options(bpftraceparser PRIVATE "-w")
+target_include_directories(bpftraceparser PUBLIC src src/ast ${CMAKE_BINARY_DIR})
+install(TARGETS bpftraceparser LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
include(CheckSymbolExists)
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt
index a95c60a1..f5c4d676 100644
--- a/resources/CMakeLists.txt
+++ b/resources/CMakeLists.txt
@@ -1,6 +1,7 @@
-add_library(resources headers.cpp)
+add_library(bpftraceresources headers.cpp)
-target_include_directories(resources PUBLIC ../src)
+target_include_directories(bpftraceresources PUBLIC ../src)
+install(TARGETS bpftraceresources LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
function(embed_headers output)
file(WRITE ${output} "#include \"headers.h\"\n\nnamespace bpftrace {\n")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 66a7fd66..738d9327 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -41,7 +41,7 @@ add_library(runtime
${BFD_DISASM_SRC}
)
# Ensure flex+bison outputs are built first
-add_dependencies(runtime parser)
+add_dependencies(runtime bpftraceparser)
add_library(libbpftrace
build_info.cpp
@@ -58,6 +58,7 @@ add_executable(${BPFTRACE}
)
install(TARGETS ${BPFTRACE} DESTINATION ${CMAKE_INSTALL_BINDIR})
+install(TARGETS libbpftrace LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_link_libraries(${BPFTRACE} libbpftrace)
if (BUILD_FUZZ)
@@ -110,6 +111,7 @@ target_include_directories(runtime PRIVATE ${CMAKE_BINARY_DIR})
target_include_directories(runtime PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_include_directories(runtime PRIVATE ${CMAKE_SOURCE_DIR}/src/ast)
target_compile_definitions(runtime PRIVATE ${BPFTRACE_FLAGS})
+install(TARGETS runtime LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_compile_definitions(libbpftrace PRIVATE ${BPFTRACE_FLAGS})
# Linking
@@ -122,7 +124,8 @@ if(STATIC_LINKING)
endif(STATIC_LINKING)
-target_link_libraries(libbpftrace parser resources runtime aot ast arch cxxdemangler_llvm)
+target_link_libraries(libbpftrace bpftraceparser bpftraceresources
+ runtime aot bpftraceast bpftracearch cxxdemangler_llvm)
if (LIBBPF_BTF_DUMP_FOUND)
target_include_directories(runtime PUBLIC ${LIBBPF_INCLUDE_DIRS})
diff --git a/src/aot/CMakeLists.txt b/src/aot/CMakeLists.txt
index 291d53f2..22944ddc 100644
--- a/src/aot/CMakeLists.txt
+++ b/src/aot/CMakeLists.txt
@@ -2,6 +2,7 @@ add_library(aot aot.cpp)
target_include_directories(aot PUBLIC ${CMAKE_SOURCE_DIR}/src)
target_include_directories(aot PUBLIC ${CMAKE_BINARY_DIR})
target_compile_definitions(aot PRIVATE ${BPFTRACE_FLAGS})
+install(TARGETS aot LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
# Only build aotrt if supported bcc is used
# (https://github.com/iovisor/bcc/commit/719191867a25ce07dc96f7faf9b8ccedadc7ec44)
@@ -10,7 +11,7 @@ if(NOT LIBBCC_BPF_CONTAINS_RUNTIME)
endif()
add_executable(bpftrace-aotrt aot_main.cpp)
-target_link_libraries(bpftrace-aotrt aot runtime arch ast_defs cxxdemangler_stdlib)
+target_link_libraries(bpftrace-aotrt aot runtime bpftracearch ast_defs cxxdemangler_stdlib)
install(TARGETS bpftrace-aotrt DESTINATION ${CMAKE_INSTALL_BINDIR})
# Linking
diff --git a/src/arch/CMakeLists.txt b/src/arch/CMakeLists.txt
index 127c3528..4e05d40a 100644
--- a/src/arch/CMakeLists.txt
+++ b/src/arch/CMakeLists.txt
@@ -1,17 +1,19 @@
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
- add_library(arch aarch64.cpp)
+ add_library(bpftracearch aarch64.cpp)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64" OR
CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le")
- add_library(arch ppc64.cpp)
+ add_library(bpftracearch ppc64.cpp)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "s390" OR
CMAKE_SYSTEM_PROCESSOR STREQUAL "s390x")
- add_library(arch s390.cpp)
+ add_library(bpftracearch s390.cpp)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
- add_library(arch x86_64.cpp)
+ add_library(bpftracearch x86_64.cpp)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "mips64")
- add_library(arch mips64.cpp)
+ add_library(bpftracearch mips64.cpp)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
- add_library(arch riscv64.cpp)
+ add_library(bpftracearch riscv64.cpp)
else()
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
+
+install(TARGETS bpftracearch LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/src/ast/CMakeLists.txt b/src/ast/CMakeLists.txt
index 014295cd..c35f6ac6 100644
--- a/src/ast/CMakeLists.txt
+++ b/src/ast/CMakeLists.txt
@@ -1,6 +1,6 @@
add_library(ast_defs ast.cpp)
-add_library(ast
+add_library(bpftraceast
async_event_types.cpp
attachpoint_parser.cpp
int_parser.cpp
@@ -20,11 +20,13 @@ add_library(ast
target_include_directories(ast_defs PUBLIC ${CMAKE_SOURCE_DIR}/src)
target_include_directories(ast_defs PUBLIC ${CMAKE_SOURCE_DIR}/src/ast)
target_include_directories(ast_defs PUBLIC ${CMAKE_BINARY_DIR})
-target_link_libraries(ast ast_defs arch bpforc parser)
+target_link_libraries(bpftraceast ast_defs bpftracearch bpforc bpftraceparser)
+install(TARGETS ast_defs LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(TARGETS bpftraceast LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-add_dependencies(ast_defs parser)
+add_dependencies(ast_defs bpftraceparser)
-target_compile_definitions(ast PRIVATE ${BPFTRACE_FLAGS})
+target_compile_definitions(bpftraceast PRIVATE ${BPFTRACE_FLAGS})
if (STATIC_LINKING)
set(clang_libs
@@ -55,11 +57,11 @@ if (STATIC_LINKING)
if(EMBED_USE_LLVM)
- target_link_libraries(ast "-Wl,--start-group" ${CLANG_EMBEDDED_CMAKE_TARGETS} ${LLVM_EMBEDDED_CMAKE_TARGETS} "-Wl,--end-group")
+ target_link_libraries(bpftraceast "-Wl,--start-group" ${CLANG_EMBEDDED_CMAKE_TARGETS} ${LLVM_EMBEDDED_CMAKE_TARGETS} "-Wl,--end-group")
else()
llvm_map_components_to_libnames(llvm_libs ${llvm_lib_names})
- target_link_libraries(ast ${clang_libs})
- target_link_libraries(ast ${llvm_libs})
+ target_link_libraries(bpftraceast ${clang_libs})
+ target_link_libraries(bpftraceast ${llvm_libs})
endif()
if(STATIC_LIBC)
@@ -69,13 +71,13 @@ if (STATIC_LINKING)
else()
find_library(found_LLVM LLVM HINTS ${LLVM_LIBRARY_DIRS})
if(found_LLVM)
- target_link_libraries(ast LLVM)
+ target_link_libraries(bpftraceast LLVM)
else()
llvm_map_components_to_libnames(_llvm_libs bpfcodegen ipo irreader mcjit orcjit ${LLVM_TARGETS_TO_BUILD})
llvm_expand_dependencies(llvm_libs ${_llvm_libs})
- target_link_libraries(ast ${llvm_libs})
+ target_link_libraries(bpftraceast ${llvm_libs})
endif()
- target_link_libraries(ast libclang)
+ target_link_libraries(bpftraceast libclang)
endif()
add_subdirectory(bpforc)
diff --git a/src/ast/bpforc/CMakeLists.txt b/src/ast/bpforc/CMakeLists.txt
index 3f6dbefa..8ccfbb2b 100644
--- a/src/ast/bpforc/CMakeLists.txt
+++ b/src/ast/bpforc/CMakeLists.txt
@@ -1 +1,2 @@
add_library(bpforc bpforc.cpp)
+install(TARGETS bpforc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/src/cxxdemangler/CMakeLists.txt b/src/cxxdemangler/CMakeLists.txt
index 04cfcdd9..5677aa4b 100644
--- a/src/cxxdemangler/CMakeLists.txt
+++ b/src/cxxdemangler/CMakeLists.txt
@@ -1,2 +1,4 @@
add_library(cxxdemangler_stdlib cxxdemangler_stdlib.cpp)
add_library(cxxdemangler_llvm cxxdemangler_llvm.cpp)
+install(TARGETS cxxdemangler_stdlib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(TARGETS cxxdemangler_llvm LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|