New upstream release.
Debian Janitor
2 years ago
0 | 1.6.0 | 2021-07-06 08:55:36 -0700 | |
1 | ||
2 | * Update cmake submodule pointer (Tim Wojtulewicz, Corelight) | |
3 | ||
4 | 1.5.0-14 | 2021-07-06 08:52:10 -0700 | |
5 | ||
6 | * Updates for building Zeek as a subproject (Seth Hall, Corelight) | |
7 | ||
8 | 1.5.0-12 | 2021-04-29 10:44:10 -0700 | |
9 | ||
10 | * Rename Session::ConnVal() to Session::GetVal() (Tim Wojtulewicz, Corelight) | |
11 | ||
12 | 1.5.0-10 | 2021-03-17 13:44:12 -0700 | |
13 | ||
14 | * Prevent use of LeakSanitizer on FreeBSD (Jon Siwek, Corelight) | |
15 | ||
16 | 1.5.0-8 | 2021-01-29 21:05:13 -0800 | |
17 | ||
18 | * GH-1377: Add missing zeek/ to generated header includes (Jon Siwek, Corelight) | |
19 | ||
20 | 1.5.0-6 | 2021-01-29 16:37:13 -0800 | |
21 | ||
22 | * Remove v4.1 deprecation warnings (Tim Wojtulewicz, Corelight) | |
23 | ||
24 | 1.5.0-4 | 2021-01-21 10:03:42 -0700 | |
25 | ||
26 | * support for new FileVal class (Vern Paxson, Corelight) | |
27 | ||
28 | 1.5.0 | 2020-12-04 11:14:48 -0800 | |
29 | ||
30 | * Release 1.5.0. | |
31 | ||
32 | 1.4.0-19 | 2020-12-02 11:04:01 -0800 | |
33 | ||
34 | * Update minimum required CMake to 3.5 (Jon Siwek, Corelight) | |
35 | ||
36 | * Postpone initialization of constants for subdir BIFs (Jon Siwek, Corelight) | |
37 | ||
38 | 1.4.0-11 | 2020-08-26 11:20:13 -0700 | |
39 | ||
40 | * Rename bro-bif.h to zeek-bif.h (Tim Wojtulewicz, Corelight) | |
41 | ||
42 | 1.4.0-9 | 2020-08-21 08:30:47 -0700 | |
43 | ||
44 | * Move __RegisterBif from zeek::detail::plugin to zeek::plugin::detail (Tim Wojtulewicz, Corelight) | |
45 | ||
46 | * SOURCE_LOCAL is part of the zeek::util::detail namespace now (Tim Wojtulewicz, Corelight) | |
47 | ||
48 | 1.4.0-6 | 2020-08-01 09:14:45 -0700 | |
49 | ||
50 | * Move Connection to zeek namespace (Tim Wojtulewicz, Corelight) | |
51 | ||
52 | * Move BifReturnVal to zeek::detail namespace (Tim Wojtulewicz, Corelight) | |
53 | ||
54 | * Move event code to zeek namespace, rename mgr to event_mgr (Tim Wojtulewicz, Corelight) | |
55 | ||
56 | * Move BroFile to zeek namespace, rename to File (Tim Wojtulewicz, Corelight) | |
57 | ||
58 | * Move base analyzer classes to zeek namespace (Tim Wojtulewicz, Corelight) | |
0 | 59 | |
1 | 60 | 1.4.0 | 2020-07-23 10:10:53 -0700 |
2 | 61 |
0 | 0 | |
1 | cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) | |
1 | cmake_minimum_required(VERSION 3.5 FATAL_ERROR) | |
2 | 2 | project(BifCl C CXX) |
3 | 3 | |
4 | 4 | include(cmake/CommonCMakeConfig.cmake) |
18 | 18 | include(RequireCXX17) |
19 | 19 | |
20 | 20 | include_directories(BEFORE |
21 | ${CMAKE_CURRENT_SOURCE_DIR}/include | |
22 | ${CMAKE_CURRENT_BINARY_DIR} | |
21 | ${BifCl_SOURCE_DIR}/include | |
22 | ${BifCl_BINARY_DIR} | |
23 | 23 | ) |
24 | 24 | |
25 | 25 | set(BISON_FLAGS "--debug") |
26 | 26 | |
27 | 27 | # BIF parser/scanner |
28 | 28 | bison_target(BIFParser builtin-func.y |
29 | ${CMAKE_CURRENT_BINARY_DIR}/bif_parse.cc | |
30 | HEADER ${CMAKE_CURRENT_BINARY_DIR}/bif_parse.h | |
31 | #VERBOSE ${CMAKE_CURRENT_BINARY_DIR}/bif_parse.output | |
29 | ${BifCl_BINARY_DIR}/bif_parse.cc | |
30 | HEADER ${BifCl_BINARY_DIR}/bif_parse.h | |
31 | #VERBOSE ${BifCl_BINARY_DIR}/bif_parse.output | |
32 | 32 | COMPILE_FLAGS "${BISON_FLAGS}") |
33 | flex_target(BIFScanner builtin-func.l ${CMAKE_CURRENT_BINARY_DIR}/bif_lex.cc) | |
33 | flex_target(BIFScanner builtin-func.l ${BifCl_BINARY_DIR}/bif_lex.cc) | |
34 | 34 | add_flex_bison_dependency(BIFScanner BIFParser) |
35 | 35 | set_property(SOURCE bif_lex.cc APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-sign-compare") |
36 | 36 | |
57 | 57 | "\n====================| Bifcl Build Summary |=====================" |
58 | 58 | "\n" |
59 | 59 | "\nBuild type: ${CMAKE_BUILD_TYPE}" |
60 | "\nBuild dir: ${CMAKE_BINARY_DIR}" | |
60 | "\nBuild dir: ${PROJECT_BINARY_DIR}" | |
61 | 61 | "\nInstall prefix: ${CMAKE_INSTALL_PREFIX}" |
62 | 62 | "\nDebug mode: ${ENABLE_DEBUG}" |
63 | 63 | "\n" |
71 | 71 | fprintf(fp, ");\n"); |
72 | 72 | } |
73 | 73 | |
74 | void BuiltinFuncArg::PrintCArg(FILE* fp, int n, bool smart) | |
74 | void BuiltinFuncArg::PrintCArg(FILE* fp, int n) | |
75 | 75 | { |
76 | const char* ctype = smart ? builtin_func_arg_type[type].c_type_smart | |
77 | : builtin_func_arg_type[type].c_type; | |
78 | char buf[1024]; | |
79 | ||
80 | fprintf(fp, "%s %s", ctype, name); | |
76 | fprintf(fp, "%s %s", builtin_func_arg_type[type].c_type_smart, name); | |
81 | 77 | } |
82 | 78 | |
83 | void BuiltinFuncArg::PrintBroValConstructor(FILE* fp, bool smart) | |
79 | void BuiltinFuncArg::PrintBroValConstructor(FILE* fp) | |
84 | 80 | { |
85 | if ( smart ) | |
86 | fprintf(fp, builtin_func_arg_type[type].ctor_smart, name); | |
87 | else | |
88 | fprintf(fp, builtin_func_arg_type[type].constructor, name); | |
81 | fprintf(fp, builtin_func_arg_type[type].ctor_smart, name); | |
89 | 82 | } |
234 | 234 | fprintf(fp_func_h, "#ifndef BRO_IN_NETVAR\n"); |
235 | 235 | fprintf(fp_func_h, "#ifndef %s\n", guard); |
236 | 236 | fprintf(fp_func_h, "#define %s\n", guard); |
237 | fprintf(fp_func_h, "#include \"bro-bif.h\"\n"); | |
237 | fprintf(fp_func_h, "#include \"zeek/zeek-bif.h\"\n"); | |
238 | 238 | fprintf(fp_func_h, "#endif\n"); |
239 | 239 | fprintf(fp_func_h, "#endif\n"); |
240 | 240 | fprintf(fp_func_h, "\n"); |
241 | 241 | |
242 | 242 | fprintf(fp_func_def, "\n"); |
243 | 243 | fprintf(fp_func_def, "#include \"%s.h\"\n", input_filename); |
244 | fprintf(fp_func_def, "#include \"Func.h\"\n"); | |
244 | fprintf(fp_func_def, "#include \"zeek/Func.h\"\n"); | |
245 | 245 | fprintf(fp_func_def, "\n"); |
246 | 246 | |
247 | 247 | static char name[1024]; |
266 | 266 | fprintf(fp_func_init, "\n"); |
267 | 267 | fprintf(fp_func_init, "#include <list>\n"); |
268 | 268 | fprintf(fp_func_init, "#include <string>\n"); |
269 | fprintf(fp_func_init, "#include \"plugin/Plugin.h\"\n"); | |
270 | fprintf(fp_func_init, "#include \"Func.h\"\n"); | |
269 | fprintf(fp_func_init, "#include \"zeek/plugin/Plugin.h\"\n"); | |
270 | fprintf(fp_func_init, "#include \"zeek/Func.h\"\n"); | |
271 | 271 | fprintf(fp_func_init, "#include \"%s.h\"\n", input_filename); |
272 | 272 | fprintf(fp_func_init, "\n"); |
273 | 273 | fprintf(fp_func_init, "namespace plugin { namespace %s {\n", plugin_canon); |
275 | 275 | fprintf(fp_func_init, "void __bif_%s_init(zeek::plugin::Plugin* plugin)\n", name); |
276 | 276 | fprintf(fp_func_init, "\t{\n"); |
277 | 277 | |
278 | fprintf(fp_func_register, "#include \"plugin/Manager.h\"\n"); | |
278 | fprintf(fp_func_register, "#include \"zeek/plugin/Manager.h\"\n"); | |
279 | 279 | fprintf(fp_func_register, "\n"); |
280 | 280 | fprintf(fp_func_register, "namespace plugin { namespace %s {\n", plugin_canon); |
281 | 281 | fprintf(fp_func_register, "void __bif_%s_init(zeek::plugin::Plugin* plugin);\n", name); |
282 | fprintf(fp_func_register, "zeek::detail::plugin::__RegisterBif __register_bifs_%s_%s(\"%s\", __bif_%s_init);\n", plugin_canon, name, plugin, name); | |
282 | fprintf(fp_func_register, "zeek::plugin::detail::__RegisterBif __register_bifs_%s_%s(\"%s\", __bif_%s_init);\n", plugin_canon, name, plugin, name); | |
283 | 283 | fprintf(fp_func_register, "} }\n"); |
284 | 284 | } |
285 | 285 | } |
310 | 310 | #endif |
311 | 311 | #endif |
312 | 312 | |
313 | #if defined(USING_ASAN) | |
313 | // FreeBSD doesn't support LeakSanitizer | |
314 | #if defined(USING_ASAN) && !defined(__FreeBSD__) | |
314 | 315 | #include <sanitizer/lsan_interface.h> |
316 | #define BIFCL_LSAN_DISABLE(x) __lsan_disable(x) | |
317 | #else | |
318 | #define BIFCL_LSAN_DISABLE(x) | |
315 | 319 | #endif |
316 | 320 | |
317 | 321 | int main(int argc, char* argv[]) |
318 | 322 | { |
319 | #if defined(USING_ASAN) | |
320 | 323 | // We generally do not care at all if bifcl is leaking and the default |
321 | 324 | // behavior of LSAN to treat leaks as errors only trips up Zeek's build. |
322 | __lsan_disable(); | |
323 | #endif | |
325 | BIFCL_LSAN_DISABLE(); | |
324 | 326 | |
325 | 327 | int opt; |
326 | 328 |
15 | 15 | extern int line_number; |
16 | 16 | extern char* input_filename; |
17 | 17 | extern char* plugin; |
18 | extern int alternative_mode; | |
18 | 19 | |
19 | 20 | #define print_line_directive(fp) fprintf(fp, "\n#line %d \"%s\"\n", line_number, input_filename) |
20 | 21 | |
205 | 206 | return s; |
206 | 207 | } |
207 | 208 | |
208 | static void print_event_c_prototype_args(FILE* fp, bool smart) | |
209 | static void print_event_c_prototype_args(FILE* fp) | |
209 | 210 | { |
210 | 211 | for ( auto i = 0u; i < args.size(); ++i ) |
211 | 212 | { |
212 | 213 | if ( i > 0 ) |
213 | 214 | fprintf(fp, ", "); |
214 | 215 | |
215 | args[i]->PrintCArg(fp, i, smart); | |
216 | args[i]->PrintCArg(fp, i); | |
216 | 217 | } |
217 | 218 | } |
218 | 219 | |
219 | static void print_event_c_prototype_header(FILE* fp, bool smart) | |
220 | { | |
221 | if ( smart ) | |
222 | fprintf(fp, "namespace zeek { %s void %s(analyzer::Analyzer* analyzer%s", | |
223 | decl.generate_c_namespace_start.c_str(), | |
224 | decl.enqueue_c_barename.c_str(), | |
225 | args.size() ? ", " : "" ); | |
226 | else | |
227 | fprintf(fp, "%s [[deprecated(\"Remove in 4.1. Use %s.\")]] void %s(analyzer::Analyzer* analyzer%s", | |
228 | decl.generate_c_namespace_start.c_str(), | |
229 | decl.enqueue_c_fullname.c_str(), | |
230 | decl.generate_bare_name.c_str(), | |
231 | args.size() ? ", " : "" ); | |
232 | ||
233 | ||
234 | print_event_c_prototype_args(fp, smart); | |
220 | static void print_event_c_prototype_header(FILE* fp) | |
221 | { | |
222 | fprintf(fp, "namespace zeek { %s void %s(zeek::analyzer::Analyzer* analyzer%s", | |
223 | decl.generate_c_namespace_start.c_str(), | |
224 | decl.enqueue_c_barename.c_str(), | |
225 | args.size() ? ", " : "" ); | |
226 | ||
227 | print_event_c_prototype_args(fp); | |
235 | 228 | fprintf(fp, ")"); |
236 | fprintf(fp, "; %s%s\n", decl.generate_c_namespace_end.c_str(), smart ? " }" : ""); | |
237 | } | |
238 | ||
239 | static void print_event_c_prototype_impl(FILE* fp, bool smart) | |
240 | { | |
241 | if ( smart ) | |
242 | fprintf(fp, "void %s(analyzer::Analyzer* analyzer%s", | |
243 | decl.enqueue_c_fullname.c_str(), | |
244 | args.size() ? ", " : "" ); | |
245 | else | |
246 | fprintf(fp, "void %s(analyzer::Analyzer* analyzer%s", | |
247 | decl.generate_c_fullname.c_str(), | |
248 | args.size() ? ", " : "" ); | |
249 | ||
250 | print_event_c_prototype_args(fp, smart); | |
229 | fprintf(fp, "; %s }\n", decl.generate_c_namespace_end.c_str()); | |
230 | } | |
231 | ||
232 | static void print_event_c_prototype_impl(FILE* fp) | |
233 | { | |
234 | fprintf(fp, "void %s(zeek::analyzer::Analyzer* analyzer%s", | |
235 | decl.enqueue_c_fullname.c_str(), | |
236 | args.size() ? ", " : "" ); | |
237 | ||
238 | print_event_c_prototype_args(fp); | |
251 | 239 | fprintf(fp, ")"); |
252 | 240 | fprintf(fp, "\n"); |
253 | 241 | } |
254 | 242 | |
255 | static void print_event_c_body(FILE* fp, bool smart) | |
243 | static void print_event_c_body(FILE* fp) | |
256 | 244 | { |
257 | 245 | fprintf(fp, "\t{\n"); |
258 | 246 | fprintf(fp, "\t// Note that it is intentional that here we do not\n"); |
265 | 253 | |
266 | 254 | BuiltinFuncArg* connection_arg = 0; |
267 | 255 | |
268 | fprintf(fp, "\tmgr.Enqueue(%s, zeek::Args{\n", decl.c_fullname.c_str()); | |
256 | fprintf(fp, "\tzeek::event_mgr.Enqueue(%s, zeek::Args{\n", decl.c_fullname.c_str()); | |
269 | 257 | |
270 | 258 | for ( int i = 0; i < (int) args.size(); ++i ) |
271 | 259 | { |
272 | 260 | fprintf(fp, "\t "); |
273 | args[i]->PrintBroValConstructor(fp, smart); | |
261 | args[i]->PrintBroValConstructor(fp); | |
274 | 262 | fprintf(fp, ",\n"); |
275 | 263 | |
276 | 264 | if ( args[i]->Type() == TYPE_CONNECTION ) |
287 | 275 | } |
288 | 276 | } |
289 | 277 | |
290 | fprintf(fp, "\t },\n\t SOURCE_LOCAL, analyzer->GetID()"); | |
278 | fprintf(fp, "\t },\n\t zeek::util::detail::SOURCE_LOCAL, analyzer->GetID()"); | |
291 | 279 | |
292 | 280 | if ( connection_arg ) |
293 | 281 | // Pass the connection to the EventMgr as the "cookie" |
381 | 369 | fprintf(fp_netvar_h, "namespace zeek { %s extern zeek::IntrusivePtr<zeek::%sType> %s; %s}\n", |
382 | 370 | decl.c_namespace_start.c_str(), type_name.c_str(), |
383 | 371 | decl.bare_name.c_str(), decl.c_namespace_end.c_str()); |
384 | fprintf(fp_netvar_h, "%s [[deprecated(\"Remove in v4.1. Use zeek::%s.\")]] extern zeek::%sType * %s; %s\n", | |
385 | decl.c_namespace_start.c_str(), decl.c_fullname.c_str(), type_name.c_str(), | |
386 | decl.bare_name.c_str(), decl.c_namespace_end.c_str()); | |
387 | ||
388 | 372 | |
389 | 373 | fprintf(fp_netvar_def, "namespace zeek { %s zeek::IntrusivePtr<zeek::%sType> %s; %s}\n", |
390 | 374 | decl.c_namespace_start.c_str(), type_name.c_str(), |
397 | 381 | "\tzeek::%s = zeek::id::find_type<zeek::%sType>(\"%s\");\n", |
398 | 382 | decl.c_fullname.c_str(), type_name.c_str(), |
399 | 383 | decl.bro_fullname.c_str()); |
400 | fprintf(fp_netvar_init, | |
401 | "\t%s = zeek::%s.get();\n", | |
402 | decl.c_fullname.c_str(), decl.c_fullname.c_str()); | |
403 | 384 | |
404 | 385 | record_bif_item(decl.bro_fullname.c_str(), "TYPE"); |
405 | 386 | } |
426 | 407 | { |
427 | 408 | if ( events.find(decl.bro_fullname) == events.end() ) |
428 | 409 | { |
429 | print_event_c_prototype_header(fp_func_h, false); | |
430 | print_event_c_prototype_impl(fp_func_def, false); | |
431 | print_event_c_body(fp_func_def, false); | |
432 | print_event_c_prototype_header(fp_func_h, true); | |
433 | print_event_c_prototype_impl(fp_func_def, true); | |
434 | print_event_c_body(fp_func_def, true); | |
410 | print_event_c_prototype_header(fp_func_h); | |
411 | print_event_c_prototype_impl(fp_func_def); | |
412 | print_event_c_body(fp_func_def); | |
435 | 413 | events.insert(decl.bro_fullname); |
436 | 414 | } |
437 | 415 | } |
454 | 432 | // Now generate the netvar's. |
455 | 433 | fprintf(fp_netvar_h, "namespace zeek { %s extern zeek::IntrusivePtr<zeek::EnumType> %s; %s}\n", |
456 | 434 | decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str()); |
457 | fprintf(fp_netvar_h, "%s [[deprecated(\"Remove in v4.1. Use zeek::%s.\")]] extern zeek::EnumType * %s; %s\n", | |
458 | decl.c_namespace_start.c_str(), decl.c_fullname.c_str(), | |
459 | decl.bare_name.c_str(), decl.c_namespace_end.c_str()); | |
460 | ||
461 | 435 | fprintf(fp_netvar_def, "namespace zeek { %s zeek::IntrusivePtr<zeek::EnumType> %s; %s}\n", |
462 | 436 | decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str()); |
463 | 437 | fprintf(fp_netvar_def, "%s zeek::EnumType * %s; %s\n", |
466 | 440 | fprintf(fp_netvar_init, |
467 | 441 | "\tzeek::%s = zeek::id::find_type<zeek::EnumType>(\"%s\");\n", |
468 | 442 | decl.c_fullname.c_str(), decl.bro_fullname.c_str()); |
469 | fprintf(fp_netvar_init, | |
470 | "\t%s = zeek::%s.get();\n", | |
471 | decl.c_fullname.c_str(), decl.c_fullname.c_str()); | |
472 | 443 | |
473 | 444 | record_bif_item(decl.bro_fullname.c_str(), "TYPE"); |
474 | 445 | } |
519 | 490 | fprintf(fp_netvar_h, "namespace zeek { %s extern %s %s; %s }\n", |
520 | 491 | decl.c_namespace_start.c_str(), |
521 | 492 | builtin_types[typeidx].c_type_smart, decl.bare_name.c_str(), |
522 | decl.c_namespace_end.c_str()); | |
523 | fprintf(fp_netvar_h, "%s [[deprecated(\"Remove in v4.1. Use zeek::%s.\")]] extern %s %s; %s\n", | |
524 | decl.c_namespace_start.c_str(), decl.c_fullname.c_str(), | |
525 | builtin_types[typeidx].c_type, decl.bare_name.c_str(), | |
526 | 493 | decl.c_namespace_end.c_str()); |
527 | 494 | |
528 | 495 | fprintf(fp_netvar_def, "namespace zeek { %s %s %s; %s }\n", |
534 | 501 | builtin_types[typeidx].c_type, decl.bare_name.c_str(), |
535 | 502 | decl.c_namespace_end.c_str()); |
536 | 503 | |
504 | if ( alternative_mode && ! plugin ) | |
505 | fprintf(fp_netvar_init, "\tzeek::detail::bif_initializers.emplace_back([]()\n"); | |
506 | ||
537 | 507 | fprintf(fp_netvar_init, "\t{\n"); |
538 | 508 | fprintf(fp_netvar_init, "\tconst auto& v = zeek::id::find_const%s(\"%s\");\n", |
539 | 509 | builtin_types[typeidx].cast_smart, decl.bro_fullname.c_str()); |
540 | 510 | fprintf(fp_netvar_init, "\tzeek::%s = v%s;\n", |
541 | 511 | decl.c_fullname.c_str(), accessor_smart); |
542 | fprintf(fp_netvar_init, "\t%s = v.get()%s;\n", | |
543 | decl.c_fullname.c_str(), accessor); | |
544 | 512 | fprintf(fp_netvar_init, "\t}\n"); |
513 | ||
514 | if ( alternative_mode && ! plugin ) | |
515 | fprintf(fp_netvar_init, "\t);\n"); | |
545 | 516 | |
546 | 517 | record_bif_item(decl.bro_fullname.c_str(), "CONSTANT"); |
547 | 518 | } |
630 | 601 | // (e.g. ones at global scope that may be used to implement |
631 | 602 | // the BIF itself). |
632 | 603 | fprintf(fp_func_h, |
633 | "namespace zeek { %sextern BifReturnVal %s_bif(zeek::detail::Frame* frame, const zeek::Args*);%s }\n", | |
604 | "namespace zeek { %sextern zeek::detail::BifReturnVal %s_bif(zeek::detail::Frame* frame, const zeek::Args*);%s }\n", | |
634 | 605 | decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str()); |
635 | 606 | |
636 | // This is the deprecated, legacy, version of the BIF that | |
637 | // forwards to the "canonical" version. It also does have | |
638 | // a "bro_" prefix in the name itself, but no "_bif" suffix. | |
639 | fprintf(fp_func_h, | |
640 | "%s [[deprecated(\"Remove in v4.1. Use zeek::%s_bif.\")]] inline BifReturnVal bro_%s(zeek::detail::Frame* frame, const zeek::Args* args)", | |
641 | decl.c_namespace_start.c_str(), decl.c_fullname.c_str(), decl.bare_name.c_str()); | |
642 | fprintf(fp_func_h, " { return zeek::%s_bif(frame, args); } %s\n", | |
643 | decl.c_fullname.c_str(), decl.c_namespace_end.c_str()); | |
644 | ||
645 | 607 | fprintf(fp_func_def, |
646 | "BifReturnVal zeek::%s_bif(zeek::detail::Frame* frame, const zeek::Args* %s)", | |
608 | "zeek::detail::BifReturnVal zeek::%s_bif(zeek::detail::Frame* frame, const zeek::Args* %s)", | |
647 | 609 | decl.c_fullname.c_str(), arg_list_name); |
648 | 610 | |
649 | 611 | record_bif_item(decl.bro_fullname.c_str(), "FUNCTION"); |
654 | 616 | { |
655 | 617 | // TODO: add namespace for events here |
656 | 618 | fprintf(fp_netvar_h, |
657 | "%sextern EventHandlerPtr %s; %s\n", | |
619 | "%sextern zeek::EventHandlerPtr %s; %s\n", | |
658 | 620 | decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str()); |
659 | 621 | |
660 | 622 | fprintf(fp_netvar_def, |
661 | "%sEventHandlerPtr %s; %s\n", | |
662 | decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str()); | |
623 | "%szeek::EventHandlerPtr %s; %s\n", | |
624 | decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str()); | |
663 | 625 | |
664 | 626 | fprintf(fp_netvar_init, |
665 | "\t%s = event_registry->Register(\"%s\");\n", | |
627 | "\t%s = zeek::event_registry->Register(\"%s\");\n", | |
666 | 628 | decl.c_fullname.c_str(), decl.bro_fullname.c_str()); |
667 | 629 | |
668 | 630 | record_bif_item(decl.bro_fullname.c_str(), "EVENT"); |
17 | 17 | |
18 | 18 | if ( "${ARGV1}" STREQUAL "standard" ) |
19 | 19 | set(bifcl_args "") |
20 | set(target "bif-std-${CMAKE_CURRENT_BINARY_DIR}/${bifInputBasename}") | |
20 | set(target "bif-std-${CMAKE_CURRENT_BINARY_DIR}/${bifInputBasename}") | |
21 | 21 | set(bifOutputs |
22 | 22 | ${CMAKE_CURRENT_BINARY_DIR}/${bifInputBasename}.func_def |
23 | 23 | ${CMAKE_CURRENT_BINARY_DIR}/${bifInputBasename}.func_h |
31 | 31 | ${bifInputBasename}.netvar_init) |
32 | 32 | set(BIF_OUTPUT_H ${bifInputBasename}.func_h |
33 | 33 | ${bifInputBasename}.netvar_h) |
34 | set(BIF_OUTPUT_BRO ${CMAKE_BINARY_DIR}/scripts/base/bif/${bifInputBasename}.zeek) | |
34 | set(BIF_OUTPUT_BRO ${Zeek_BINARY_DIR}/scripts/base/bif/${bifInputBasename}.zeek) | |
35 | 35 | set(bro_BASE_BIF_SCRIPTS ${bro_BASE_BIF_SCRIPTS} ${BIF_OUTPUT_BRO} CACHE INTERNAL "Zeek script stubs for BIFs in base distribution of Zeek" FORCE) # Propogate to top-level |
36 | 36 | |
37 | 37 | # Do this here so that all of the necessary files for each individual BIF get added to clang-tidy |
67 | 67 | set(BIF_OUTPUT_H ${bifInputBasename}.h) |
68 | 68 | |
69 | 69 | if ( NOT ZEEK_PLUGIN_BUILD_DYNAMIC ) |
70 | set(BIF_OUTPUT_BRO ${CMAKE_BINARY_DIR}/scripts/base/bif/plugins/${plugin_name_canon}.${bifInputBasename}.zeek) | |
70 | set(BIF_OUTPUT_BRO ${Zeek_BINARY_DIR}/scripts/base/bif/plugins/${plugin_name_canon}.${bifInputBasename}.zeek) | |
71 | 71 | else () |
72 | 72 | set(BIF_OUTPUT_BRO ${BRO_PLUGIN_BIF}/${bifInputBasename}.zeek) |
73 | 73 | endif() |
93 | 93 | # In order be able to run Zeek from the build directory, the |
94 | 94 | # generated Zeek script needs to be inside a directory tree |
95 | 95 | # named the same way it will be referenced from an @load. |
96 | set(BIF_OUTPUT_BRO ${CMAKE_BINARY_DIR}/scripts/base/bif/${bifInputBasename}.zeek) | |
96 | set(BIF_OUTPUT_BRO ${Zeek_BINARY_DIR}/scripts/base/bif/${bifInputBasename}.zeek) | |
97 | 97 | |
98 | 98 | set(bro_AUTO_BIFS ${bro_AUTO_BIFS} ${CMAKE_CURRENT_BINARY_DIR}/${bifInputBasename} CACHE INTERNAL "BIFs for automatic inclusion" FORCE) # Propagate to top-level. |
99 | 99 | set(bro_BASE_BIF_SCRIPTS ${bro_BASE_BIF_SCRIPTS} ${BIF_OUTPUT_BRO} CACHE INTERNAL "Zeek script stubs for BIFs in base distribution of Zeek" FORCE) # Propogate to top-level |
139 | 139 | COMMENT "[BIFCL] Processing ${bifInput}" |
140 | 140 | ) |
141 | 141 | |
142 | string(REGEX REPLACE "${CMAKE_BINARY_DIR}/src/" "" target "${target}") | |
142 | string(REGEX REPLACE "${Zeek_BINARY_DIR}/src/" "" target "${target}") | |
143 | 143 | string(REGEX REPLACE "/" "-" target "${target}") |
144 | 144 | add_custom_target(${target} DEPENDS ${BIF_OUTPUT_H} ${BIF_OUTPUT_CC}) |
145 | 145 | set_source_files_properties(${bifOutputs} PROPERTIES GENERATED 1) |
35 | 35 | COMMAND ${BinPAC_EXE} |
36 | 36 | ARGS -q -d ${CMAKE_CURRENT_BINARY_DIR} |
37 | 37 | -I ${CMAKE_CURRENT_SOURCE_DIR} |
38 | -I ${CMAKE_SOURCE_DIR}/src | |
38 | -I ${CMAKE_CURRENT_SOURCE_DIR}/src | |
39 | -I ${PROJECT_SOURCE_DIR}/src | |
39 | 40 | ${BinPAC_addl_args} |
40 | 41 | ${CMAKE_CURRENT_SOURCE_DIR}/${pacFile} |
41 | 42 | DEPENDS ${binpacDep} ${pacFile} |
52 | 53 | |
53 | 54 | set(target "pac-${CMAKE_CURRENT_BINARY_DIR}/${pacFile}") |
54 | 55 | |
55 | string(REGEX REPLACE "${CMAKE_BINARY_DIR}/src/" "" target "${target}") | |
56 | string(REGEX REPLACE "${PROJECT_BINARY_DIR}/src/" "" target "${target}") | |
56 | 57 | string(REGEX REPLACE "/" "-" target "${target}") |
57 | 58 | add_custom_target(${target} DEPENDS ${pacOutputs}) |
58 | 59 | set(BINPAC_BUILD_TARGET ${target}) |
23 | 23 | # Should result in ${libs} containing: |
24 | 24 | # /usr/lib/libz.dylib |
25 | 25 | # /usr/lib/libssl.dylib |
26 | # ${CMAKE_BINARY_DIR}/darwin_support_libs/libmagic.dylib | |
27 | # ${CMAKE_BINARY_DIR}/darwin_support_libs/libGeoIP.dylib | |
26 | # ${Zeek_BINARY_DIR}/darwin_support_libs/libmagic.dylib | |
27 | # ${Zeek_BINARY_DIR}/darwin_support_libs/libGeoIP.dylib | |
28 | 28 | # /usr/local/lib/somestaticlib.a |
29 | 29 | # |
30 | 30 | # such that we can now do: |
40 | 40 | find_program(INSTALL_NAME_TOOL install_name_tool) |
41 | 41 | |
42 | 42 | set(MAC_INSTALL_NAME_DEPS) |
43 | set(SUPPORT_BIN_DIR ${CMAKE_BINARY_DIR}/darwin_support_libs) | |
43 | set(SUPPORT_BIN_DIR ${Zeek_BINARY_DIR}/darwin_support_libs) | |
44 | 44 | set(SUPPORT_INSTALL_DIR support_libs) |
45 | 45 | |
46 | 46 | file(MAKE_DIRECTORY ${SUPPORT_BIN_DIR}) |
55 | 55 | get_filename_component(_libname ${_lib} NAME) |
56 | 56 | set(_adjustedLib ${SUPPORT_BIN_DIR}/${_libname}) |
57 | 57 | set(_tmpLib |
58 | ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_libname}) | |
58 | ${Zeek_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_libname}) | |
59 | 59 | |
60 | 60 | # make a tempory copy so we can adjust permissions |
61 | 61 | configure_file(${_lib} ${_tmpLib} COPYONLY) |
1 | 1 | |
2 | 2 | check_function_exists(getopt_long HAVE_GETOPT_LONG) |
3 | 3 | check_function_exists(mallinfo HAVE_MALLINFO) |
4 | check_function_exists(mallinfo2 HAVE_MALLINFO2) | |
4 | 5 | check_function_exists(strcasestr HAVE_STRCASESTR) |
5 | 6 | check_function_exists(strerror HAVE_STRERROR) |
6 | 7 | check_function_exists(strsep HAVE_STRSEP) |
262 | 262 | |
263 | 263 | # add default files/directories to ignore for source package |
264 | 264 | # user may specify others via configure script |
265 | list(APPEND CPACK_SOURCE_IGNORE_FILES ${CMAKE_BINARY_DIR} ".git") | |
265 | list(APPEND CPACK_SOURCE_IGNORE_FILES ${PROJECT_BINARY_DIR} ".git") | |
266 | 266 | |
267 | 267 | include(CPack) |
268 | 268 | endmacro(ConfigurePackaging) |
104 | 104 | DEPENDS |
105 | 105 | "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output" |
106 | 106 | COMMENT "[BISON][${Name}] Copying bison verbose table to ${filename}" |
107 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | |
107 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) | |
108 | 108 | SET(BISON_${Name}_VERBOSE_FILE ${filename}) |
109 | 109 | LIST(APPEND BISON_TARGET_extraoutputs |
110 | 110 | "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output") |
0 | # Try to find CAF headers and libraries. | |
1 | # | |
2 | # Use this module as follows: | |
3 | # | |
4 | # find_package(CAF [COMPONENTS <core|io|opencl|...>*] [REQUIRED]) | |
5 | # | |
6 | # Variables used by this module (they can change the default behaviour and need | |
7 | # to be set before calling find_package): | |
8 | # | |
9 | # CAF_ROOT_DIR Set this variable either to an installation prefix or to wa | |
10 | # CAF build directory where to look for the CAF libraries. | |
11 | # | |
12 | # Variables defined by this module: | |
13 | # | |
14 | # CAF_FOUND System has CAF headers and library | |
15 | # CAF_VERSION Found CAF release number | |
16 | # CAF_LIBRARIES List of library files for all components | |
17 | # CAF_INCLUDE_DIRS List of include paths for all components | |
18 | ||
19 | if(CAF_FIND_COMPONENTS STREQUAL "") | |
20 | message(FATAL_ERROR "FindCAF requires at least one COMPONENT.") | |
21 | endif() | |
22 | ||
23 | # iterate over user-defined components | |
24 | foreach (comp ${CAF_FIND_COMPONENTS}) | |
25 | # we use uppercase letters only for variable names | |
26 | string(TOUPPER "${comp}" UPPERCOMP) | |
27 | if ("${comp}" STREQUAL "core") | |
28 | set(HDRNAME "caf/all.hpp") | |
29 | elseif ("${comp}" STREQUAL "test") | |
30 | set(HDRNAME "caf/test/unit_test.hpp") | |
31 | else () | |
32 | set(HDRNAME "caf/${comp}/all.hpp") | |
33 | endif () | |
34 | if (CAF_ROOT_DIR) | |
35 | set(header_hints | |
36 | "${CAF_ROOT_DIR}/include" | |
37 | "${CAF_ROOT_DIR}" | |
38 | "${CAF_ROOT_DIR}/libcaf_${comp}" | |
39 | "${CAF_ROOT_DIR}/../libcaf_${comp}" | |
40 | "${CAF_ROOT_DIR}/../../libcaf_${comp}") | |
41 | endif () | |
42 | find_path(CAF_INCLUDE_DIR_${UPPERCOMP} | |
43 | NAMES | |
44 | ${HDRNAME} | |
45 | HINTS | |
46 | ${header_hints} | |
47 | /usr/include | |
48 | /usr/local/include | |
49 | /opt/local/include | |
50 | /sw/include | |
51 | ${CMAKE_INSTALL_PREFIX}/include | |
52 | ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) | |
53 | mark_as_advanced(CAF_INCLUDE_DIR_${UPPERCOMP}) | |
54 | if (NOT "${CAF_INCLUDE_DIR_${UPPERCOMP}}" | |
55 | STREQUAL "CAF_INCLUDE_DIR_${UPPERCOMP}-NOTFOUND") | |
56 | # mark as found (set back to false when missing library or build header) | |
57 | set(CAF_${comp}_FOUND true) | |
58 | # check for CMake-generated build header for the core component | |
59 | if ("${comp}" STREQUAL "core") | |
60 | find_path(caf_build_header_path | |
61 | NAMES | |
62 | caf/detail/build_config.hpp | |
63 | HINTS | |
64 | ${header_hints} | |
65 | /usr/include | |
66 | /usr/local/include | |
67 | /opt/local/include | |
68 | /sw/include | |
69 | ${CMAKE_INSTALL_PREFIX}/include | |
70 | ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) | |
71 | if ("${caf_build_header_path}" STREQUAL "caf_build_header_path-NOTFOUND") | |
72 | message(WARNING "Found all.hpp for CAF core, but not build_config.hpp") | |
73 | set(CAF_${comp}_FOUND false) | |
74 | else() | |
75 | list(APPEND CAF_INCLUDE_DIRS "${caf_build_header_path}") | |
76 | endif() | |
77 | endif() | |
78 | list(APPEND CAF_INCLUDE_DIRS "${CAF_INCLUDE_DIR_${UPPERCOMP}}") | |
79 | # look for (.dll|.so|.dylib) file, again giving hints for non-installed CAFs | |
80 | # skip probe_event as it is header only | |
81 | if (NOT ${comp} STREQUAL "probe_event" AND NOT ${comp} STREQUAL "test") | |
82 | if (CAF_ROOT_DIR) | |
83 | set(library_hints | |
84 | "${CAF_ROOT_DIR}/lib" | |
85 | "${CAF_ROOT_DIR}/libcaf_${comp}") | |
86 | endif () | |
87 | find_library(CAF_LIBRARY_${UPPERCOMP} | |
88 | NAMES | |
89 | "caf_${comp}" | |
90 | "caf_${comp}_static" | |
91 | HINTS | |
92 | ${library_hints} | |
93 | /usr/lib | |
94 | /usr/local/lib | |
95 | /opt/local/lib | |
96 | /sw/lib | |
97 | ${CMAKE_INSTALL_PREFIX}/lib | |
98 | ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} | |
99 | ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_BUILD_TYPE}) | |
100 | mark_as_advanced(CAF_LIBRARY_${UPPERCOMP}) | |
101 | if ("${CAF_LIBRARY_${UPPERCOMP}}" | |
102 | STREQUAL "CAF_LIBRARY_${UPPERCOMP}-NOTFOUND") | |
103 | set(CAF_${comp}_FOUND false) | |
104 | else () | |
105 | set(CAF_LIBRARIES ${CAF_LIBRARIES} ${CAF_LIBRARY_${UPPERCOMP}}) | |
106 | endif () | |
107 | endif () | |
108 | endif () | |
109 | endforeach () | |
110 | ||
111 | if (DEFINED CAF_INCLUDE_DIRS) | |
112 | list(REMOVE_DUPLICATES CAF_INCLUDE_DIRS) | |
113 | endif() | |
114 | ||
115 | ||
116 | if (NOT CAF_INCLUDE_DIR_CORE STREQUAL "CAF_INCLUDE_DIR_CORE-NOTFOUND") | |
117 | # read content of config.hpp | |
118 | file(READ "${CAF_INCLUDE_DIR_CORE}/caf/config.hpp" CONFIG_HPP) | |
119 | # get line containing the version | |
120 | string(REGEX MATCH "#define CAF_VERSION [0-9]+" VERSION_LINE "${CONFIG_HPP}") | |
121 | # extract version number from line | |
122 | string(REGEX MATCH "[0-9]+" VERSION_INT "${VERSION_LINE}") | |
123 | # calculate major, minor, and patch version | |
124 | math(EXPR CAF_VERSION_MAJOR "${VERSION_INT} / 10000") | |
125 | math(EXPR CAF_VERSION_MINOR "( ${VERSION_INT} / 100) % 100") | |
126 | math(EXPR CAF_VERSION_PATCH "${VERSION_INT} % 100") | |
127 | # create full version string | |
128 | set(CAF_VERSION "${CAF_VERSION_MAJOR}.${CAF_VERSION_MINOR}.${CAF_VERSION_PATCH}") | |
129 | if (NOT CAF_VERSION) | |
130 | unset(CAF_VERSION) | |
131 | message(WARNING "Unable to determine CAF version") | |
132 | endif () | |
133 | endif () | |
134 | ||
135 | # let CMake check whether all requested components have been found | |
136 | include(FindPackageHandleStandardArgs) | |
137 | find_package_handle_standard_args(CAF | |
138 | FOUND_VAR CAF_FOUND | |
139 | REQUIRED_VARS CAF_VERSION CAF_LIBRARIES CAF_INCLUDE_DIRS | |
140 | HANDLE_COMPONENTS) | |
141 | ||
142 | # final step to tell CMake we're done | |
143 | mark_as_advanced(CAF_ROOT_DIR | |
144 | CAF_VERSION | |
145 | CAF_LIBRARIES | |
146 | CAF_INCLUDE_DIRS) |
38 | 38 | |
39 | 39 | if (RUN_CLANG_TIDY) |
40 | 40 | add_custom_target(clang-tidy |
41 | COMMAND ${RUN_CLANG_TIDY} -p ${CMAKE_BINARY_DIR} -clang-tidy-binary ${CLANG_TIDY} -j 4 -export-fixes ${CMAKE_BINARY_DIR}/clang-tidy.yaml ${final_tidy_srcs} | |
42 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | |
41 | COMMAND ${RUN_CLANG_TIDY} -p ${PROJECT_BINARY_DIR} -clang-tidy-binary ${CLANG_TIDY} -j 4 -export-fixes ${PROJECT_BINARY_DIR}/clang-tidy.yaml ${final_tidy_srcs} | |
42 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |
43 | 43 | ) |
44 | 44 | else() |
45 | 45 | add_custom_target(clang-tidy |
46 | COMMAND ${CLANG_TIDY} -p ${CMAKE_BINARY_DIR} ${final_tidy_srcs} | |
47 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | |
46 | COMMAND ${CLANG_TIDY} -p ${PROJECT_BINARY_DIR} ${final_tidy_srcs} | |
47 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | |
48 | 48 | ) |
49 | 49 | endif() |
50 | 50 | endif() |
133 | 133 | |
134 | 134 | set(HAVE_KQUEUE true) |
135 | 135 | set(LIBKQUEUE_LIBRARIES libkqueue_a CACHE STRING "libkqueue libs" FORCE) |
136 | set(LIBKQUEUE_INCLUDE_DIRS "${kqueue_src}/include" CACHE STRING "libkqueue includes" FORCE) | |
136 | set(LIBKQUEUE_INCLUDE_DIRS "${kqueue_src}/include;${kqueue_build}/include" CACHE INTERNAL "libkqueue includes" FORCE) | |
137 | 137 | |
138 | 138 | include_directories(BEFORE ${LIBKQUEUE_INCLUDE_DIRS}) |
139 | 139 | set(zeekdeps ${zeekdeps} ${LIBKQUEUE_LIBRARIES}) |
40 | 40 | # symlink). |
41 | 41 | get_filename_component(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}" REALPATH) |
42 | 42 | get_filename_component(PYTHON_EXECUTABLE_DIR "${PYTHON_EXECUTABLE}" DIRECTORY) |
43 | get_filename_component(PYTHON_EXECUTABLE_NAME "${PYTHON_EXECUTABLE}" NAME) | |
43 | 44 | |
44 | 45 | if ( EXISTS ${PYTHON_EXECUTABLE}-config ) |
45 | 46 | set(PYTHON_CONFIG ${PYTHON_EXECUTABLE}-config CACHE PATH "" FORCE) |
46 | elseif ( EXISTS ${PYTHON_EXECUTABLE_DIR}/python-config ) | |
47 | # Avoid assumption that python-config is associated with python3 if | |
48 | # python3 co-exists in a directory that also contains python2 stuff | |
49 | elseif ( EXISTS ${PYTHON_EXECUTABLE_DIR}/python-config AND | |
50 | NOT EXISTS ${PYTHON_EXECUTABLE_DIR}/python2 AND | |
51 | NOT EXISTS ${PYTHON_EXECUTABLE_DIR}/python2.7 AND | |
52 | NOT EXISTS ${PYTHON_EXECUTABLE_DIR}/python2-config AND | |
53 | NOT EXISTS ${PYTHON_EXECUTABLE_DIR}/python2.7-config ) | |
47 | 54 | set(PYTHON_CONFIG ${PYTHON_EXECUTABLE_DIR}/python-config CACHE PATH "" FORCE) |
48 | 55 | endif () |
49 | 56 | else () |
50 | find_program(PYTHON_CONFIG | |
51 | NAMES python-config python3.7-config python3.6-config python3.5-config | |
52 | python3.4-config python-config2.7 python-config2.6 python-config2.6 | |
53 | python-config2.4 python-config2.3) | |
57 | find_program(PYTHON_CONFIG NAMES | |
58 | python3-config | |
59 | python3.9-config | |
60 | python3.8-config | |
61 | python3.7-config | |
62 | python3.6-config | |
63 | python3.5-config | |
64 | python-config | |
65 | ) | |
54 | 66 | endif () |
55 | 67 | |
56 | 68 | # The OpenBSD python packages have python-config's that don't reliably |
57 | 69 | # report linking flags that will work. |
58 | 70 | if (PYTHON_CONFIG AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") |
59 | execute_process(COMMAND "${PYTHON_CONFIG}" --ldflags | |
71 | # Try `--ldflags --embed` first and fallback to `--ldflags` if it fails. | |
72 | # Python 3.8+ introduced the `--embed` flag in relation to this: | |
73 | # https://docs.python.org/3.8/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build | |
74 | # Note that even if this FindPythonDev script could technically apply to | |
75 | # either embedded or extension use cases, the `--embed` flag only adds | |
76 | # a `-lpython` and it's generally safe to link libpython in both cases. | |
77 | # The only downside to doing that against an extension when it's not | |
78 | # strictly necessary is losing the ability to mix-and-match debug/release | |
79 | # modes between Python and extensions and that's not a feature to typically | |
80 | # care about. | |
81 | execute_process(COMMAND "${PYTHON_CONFIG}" --ldflags --embed | |
82 | RESULT_VARIABLE _python_config_result | |
60 | 83 | OUTPUT_VARIABLE PYTHON_LIBRARIES |
61 | 84 | OUTPUT_STRIP_TRAILING_WHITESPACE |
62 | 85 | ERROR_QUIET) |
86 | ||
87 | if ( NOT ${_python_config_result} EQUAL 0 ) | |
88 | execute_process(COMMAND "${PYTHON_CONFIG}" --ldflags | |
89 | RESULT_VARIABLE _python_config_result | |
90 | OUTPUT_VARIABLE PYTHON_LIBRARIES | |
91 | OUTPUT_STRIP_TRAILING_WHITESPACE | |
92 | ERROR_QUIET) | |
93 | endif () | |
94 | ||
63 | 95 | string(STRIP "${PYTHON_LIBRARIES}" PYTHON_LIBRARIES) |
64 | 96 | |
65 | 97 | execute_process(COMMAND "${PYTHON_CONFIG}" --includes |
77 | 109 | PYTHON_LIBRARIES |
78 | 110 | ) |
79 | 111 | else () |
80 | find_package(PythonLibs) | |
81 | if (PYTHON_INCLUDE_PATH AND NOT PYTHON_INCLUDE_DIR) | |
82 | set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}") | |
112 | if ( ${CMAKE_VERSION} VERSION_LESS "3.12.0" ) | |
113 | find_package(PythonLibs) | |
114 | ||
115 | if ( PYTHON_INCLUDE_PATH AND NOT PYTHON_INCLUDE_DIR ) | |
116 | set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}") | |
117 | endif () | |
118 | else () | |
119 | # Expect this branch to be used mostly in macOS where the system | |
120 | # default Python 3 installation is not easily/consistently detected | |
121 | # by CMake. CMake 3.12+ is required, but it's expected that macOS | |
122 | # users are getting a recent version from homebrew/etc anyway. | |
123 | find_package(Python3 COMPONENTS Development) | |
124 | ||
125 | if ( Python3_INCLUDE_DIRS AND NOT PYTHON_INCLUDE_DIR ) | |
126 | set(PYTHON_INCLUDE_DIR "${Python3_INCLUDE_DIRS}") | |
127 | endif () | |
128 | ||
129 | if ( Python3_LIBRARIES AND NOT PYTHON_LIBRARIES ) | |
130 | set(PYTHON_LIBRARIES "${Python3_LIBRARIES}") | |
131 | endif () | |
83 | 132 | endif () |
133 | ||
84 | 134 | find_package_handle_standard_args(PythonDev DEFAULT_MSG |
85 | 135 | PYTHON_INCLUDE_DIR |
86 | 136 | PYTHON_LIBRARIES |
34 | 34 | string(REGEX MATCH ${_regex} _match ${_srclines}) |
35 | 35 | if (_match) |
36 | 36 | set(_shell ${CMAKE_MATCH_1}) |
37 | if (${_shell} STREQUAL "python" AND PYTHON_EXECUTABLE) | |
37 | if ( (${_shell} STREQUAL "python" OR ${_shell} STREQUAL "python3") AND PYTHON_EXECUTABLE ) | |
38 | 38 | set(${_shell}_interp ${PYTHON_EXECUTABLE}) |
39 | 39 | else () |
40 | 40 | find_program(${_shell}_interp ${_shell}) |
0 | 0 | if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") |
1 | set(bro_LINKER_FLAGS "${bro_LINKER_FLAGS} -rdynamic") | |
2 | 1 | |
3 | 2 | elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") |
4 | set(bro_LINKER_FLAGS "${bro_LINKER_FLAGS} -rdynamic") | |
5 | 3 | |
6 | 4 | elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
7 | 5 | set(HAVE_DARWIN true) |
0 | 0 | include(CheckCSourceCompiles) |
1 | 1 | include(CheckCXXSourceCompiles) |
2 | 2 | include(CheckCSourceRuns) |
3 | include(CheckIncludeFiles) | |
3 | 4 | |
4 | 5 | set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS}) |
5 | 6 | # Use all includes, not just OpenSSL includes to see if there are |
32 | 33 | if (OPENSSL_VERSION VERSION_LESS "0.9.7") |
33 | 34 | message(FATAL_ERROR "OpenSSL >= v0.9.7 required") |
34 | 35 | endif () |
36 | ||
37 | check_include_files(openssl/kdf.h OPENSSL_HAVE_KDF_H) | |
35 | 38 | |
36 | 39 | check_cxx_source_compiles(" |
37 | 40 | #include <openssl/x509.h> |
0 | 0 | # Prohibit in-source builds. |
1 | if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") | |
1 | if ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") | |
2 | 2 | message(FATAL_ERROR "In-source builds are not allowed. Please use " |
3 | 3 | "./configure to choose a build directory and " |
4 | 4 | "initialize the build configuration.") |
1 | 1 | # can find internal/private libraries or libraries external to the build |
2 | 2 | # directory that were explicitly linked against |
3 | 3 | if (NOT BINARY_PACKAGING_MODE) |
4 | SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | |
5 | SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") | |
6 | ||
7 | 4 | include(GNUInstallDirs) |
8 | 5 | |
9 | if ( NOT CMAKE_INSTALL_LIBDIR STREQUAL "lib" ) | |
10 | # Ideally, we'd consistently use just one lib dir (e.g. lib/ or lib64/), | |
11 | # which requires every sub-project and external/embedded dependency | |
12 | # agrees and/or offers ability to install at that canonical location. | |
13 | set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") | |
14 | endif () | |
6 | SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | |
7 | set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") | |
15 | 8 | endif () |
27 | 27 | ZEEK_EXE_PATH |
28 | 28 | CMAKE_CXX_FLAGS |
29 | 29 | CMAKE_C_FLAGS |
30 | PCAP_INCLUDE_DIR | |
31 | ZLIB_INCLUDE_DIR | |
32 | OPENSSL_INCLUDE_DIR | |
33 | LibKrb5_INCLUDE_DIR | |
34 | GooglePerftools_INCLUDE_DIR | |
30 | 35 | CAF_INCLUDE_DIRS) |
31 | 36 | |
32 | 37 | if ( NOT BRO_PLUGIN_BRO_PLUGIN_INSTALL_PATH ) |
50 | 55 | set(CMAKE_MODULE_PATH ${BRO_PLUGIN_BRO_CMAKE} ${CMAKE_MODULE_PATH}) |
51 | 56 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${bro_cache_CMAKE_C_FLAGS}") |
52 | 57 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${bro_cache_CMAKE_CXX_FLAGS}") |
58 | ||
59 | if ( bro_cache_PCAP_INCLUDE_DIR ) | |
60 | include_directories(BEFORE ${bro_cache_PCAP_INCLUDE_DIR}) | |
61 | endif () | |
62 | if ( bro_cache_ZLIB_INCLUDE_DIR ) | |
63 | include_directories(BEFORE ${bro_cache_ZLIB_INCLUDE_DIR}) | |
64 | endif () | |
65 | if ( bro_cache_OPENSSL_INCLUDE_DIR ) | |
66 | include_directories(BEFORE ${bro_cache_OPENSSL_INCLUDE_DIR}) | |
67 | endif () | |
68 | if ( bro_cache_LibKrb5_INCLUDE_DIR ) | |
69 | include_directories(BEFORE ${bro_cache_LibKrb5_INCLUDE_DIR}) | |
70 | endif () | |
71 | if ( bro_cache_GooglePerftools_INCLUDE_DIR ) | |
72 | include_directories(BEFORE ${bro_cache_GooglePerftools_INCLUDE_DIR}) | |
73 | endif () | |
53 | 74 | |
54 | 75 | # Zeek 3.2+ has auxil/ instead of aux/ |
55 | 76 | include_directories(BEFORE |
106 | 127 | " to the installation path of Zeek headers") |
107 | 128 | endif () |
108 | 129 | |
130 | # Add potential custom library paths to our search path. This | |
131 | # works transparently across future find_library() calls. | |
132 | # | |
133 | # The zeek-config call is currently an outlier ... we need it | |
134 | # because existing plugin configure scripts need to keep | |
135 | # working with possible alternative libdirs, but do not | |
136 | # determine the libdir themselves. zeek-config is the only way | |
137 | # to determine it post-installation in those cases. | |
138 | # | |
139 | # XXX In the future the FindZeek module should make | |
140 | # zeek-config calls to establish the various settings | |
141 | # consistently within cmake. This would simplify configure | |
142 | # scripts and make cmake use with Zeek more standard. | |
143 | if ( NOT BRO_CONFIG_LIB_DIR ) | |
144 | execute_process( | |
145 | COMMAND ${BRO_CONFIG_PREFIX}/bin/zeek-config --lib_dir | |
146 | OUTPUT_VARIABLE BRO_CONFIG_LIB_DIR | |
147 | OUTPUT_STRIP_TRAILING_WHITESPACE) | |
148 | endif () | |
149 | ||
150 | if ( BRO_CONFIG_LIB_DIR ) | |
151 | set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${BRO_CONFIG_LIB_DIR}) | |
152 | endif () | |
153 | ||
109 | 154 | set(BRO_PLUGIN_BRO_CONFIG_INCLUDE_DIR "${BRO_CONFIG_INCLUDE_DIR}" |
110 | 155 | CACHE INTERNAL "" FORCE) |
111 | 156 | set(BRO_PLUGIN_BRO_INSTALL_PREFIX "${BRO_CONFIG_PREFIX}" |
118 | 163 | set(CMAKE_MODULE_PATH ${BRO_PLUGIN_BRO_CMAKE} ${CMAKE_MODULE_PATH}) |
119 | 164 | |
120 | 165 | find_package(BinPAC REQUIRED) |
121 | find_package(CAF COMPONENTS core io openssl REQUIRED) | |
166 | ||
167 | set(_saved_cmake_prefix_path "${CMAKE_PREFIX_PATH}") | |
168 | list(INSERT CMAKE_PREFIX_PATH 0 "${CAF_ROOT_DIR}") | |
169 | find_package(CAF REQUIRED COMPONENTS core io openssl CONFIG) | |
170 | set(CMAKE_PREFIX_PATH "${_saved_cmake_prefix_path}") | |
171 | ||
172 | set(CAF_LIBRARIES CAF::core CAF::io CAF::openssl CACHE INTERNAL "") | |
173 | set(caf_dirs "") | |
174 | foreach (caf_lib IN LISTS CAF_LIBRARIES ITEMS CAF::test) | |
175 | get_target_property(dirs ${caf_lib} INTERFACE_INCLUDE_DIRECTORIES) | |
176 | if ( dirs ) | |
177 | list(APPEND caf_dirs ${dirs}) | |
178 | endif () | |
179 | endforeach () | |
180 | list(REMOVE_DUPLICATES caf_dirs) | |
181 | set(CAF_INCLUDE_DIRS "${caf_dirs}" CACHE INTERNAL "") | |
182 | ||
122 | 183 | find_package(Broker REQUIRED) |
123 | 184 | |
124 | 185 | string(REPLACE ":" ";" ZEEK_CONFIG_INCLUDE_DIRS "${BRO_CONFIG_INCLUDE_DIR}") |
254 | 315 | |
255 | 316 | add_dependencies(${_plugin_lib} bro-plugin-${_plugin_name_canon}) |
256 | 317 | |
257 | set(_dist_tarball_name ${_plugin_name_canon}.tar.gz) | |
318 | set(_dist_tarball_name ${_plugin_name_canon}.tgz) | |
258 | 319 | set(_dist_output ${CMAKE_CURRENT_BINARY_DIR}/${_dist_tarball_name}) |
259 | 320 | |
260 | 321 | # Create binary install package. |
27 | 27 | |
28 | 28 | add_dependencies(${_plugin_lib} generate_outputs) |
29 | 29 | |
30 | set(preload_script ${_plugin_name_canon}/__preload__.zeek) | |
31 | if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/__preload__.zeek) | |
32 | file(APPEND ${Zeek_BINARY_DIR}/scripts/builtin-plugins/__preload__.zeek "\n@load ${preload_script}") | |
33 | endif() | |
34 | set(load_script ${_plugin_name_canon}/__load__.zeek) | |
35 | if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/__load__.zeek) | |
36 | file(APPEND ${Zeek_BINARY_DIR}/scripts/builtin-plugins/__load__.zeek "\n@load ${load_script}") | |
37 | endif() | |
38 | ||
39 | get_filename_component(plugin_name ${CMAKE_CURRENT_SOURCE_DIR} NAME) | |
40 | if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/scripts" ) | |
41 | install(DIRECTORY ./scripts/ | |
42 | DESTINATION "${ZEEK_SCRIPT_INSTALL_PATH}/builtin-plugins/${_plugin_name_canon}" | |
43 | FILES_MATCHING | |
44 | PATTERN "*.zeek" | |
45 | PATTERN "*.sig" | |
46 | PATTERN "*.fp") | |
47 | ||
48 | # Make a plugin directory and symlink the scripts directory into it | |
49 | # so that the development ZEEKPATH will work too. | |
50 | file(MAKE_DIRECTORY ${Zeek_BINARY_DIR}/scripts/builtin-plugins) | |
51 | execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink | |
52 | "${CMAKE_CURRENT_SOURCE_DIR}/scripts" | |
53 | "${Zeek_BINARY_DIR}/scripts/builtin-plugins/${_plugin_name_canon}") | |
54 | endif () | |
55 | ||
30 | 56 | set(bro_PLUGIN_LIBS ${bro_PLUGIN_LIBS} "$<TARGET_OBJECTS:${_plugin_lib}>" CACHE INTERNAL "plugin libraries") |
31 | 57 | set(bro_PLUGIN_DEPS ${bro_PLUGIN_DEPS} "${_plugin_lib}" CACHE INTERNAL "plugin dependencies") |
32 | 58 | endfunction() |
0 | bifcl (1.6.0-1) UNRELEASED; urgency=low | |
1 | ||
2 | * New upstream release. | |
3 | ||
4 | -- Debian Janitor <janitor@jelmer.uk> Thu, 19 Aug 2021 12:29:24 -0000 | |
5 | ||
0 | 6 | bifcl (1.4.0-1) unstable; urgency=medium |
1 | 7 | |
2 | 8 | * New upstream version 1.4.0 |
26 | 26 | |
27 | 27 | void PrintBro(FILE* fp); |
28 | 28 | void PrintCDef(FILE* fp, int n); |
29 | void PrintCArg(FILE* fp, int n, bool smart); | |
30 | void PrintBroValConstructor(FILE* fp, bool smart); | |
29 | void PrintCArg(FILE* fp, int n); | |
30 | void PrintBroValConstructor(FILE* fp); | |
31 | 31 | |
32 | 32 | protected: |
33 | 33 | const char* name; |
2 | 2 | DEFINE_BIF_TYPE(TYPE_ANY, "any", "any", "zeek::Val*", "zeek::IntrusivePtr<zeek::Val>", "%s", "%s", "", "zeek::IntrusivePtr{zeek::AdoptRef{}, %s}", "std::move(%s)") |
3 | 3 | DEFINE_BIF_TYPE(TYPE_BOOL, "bool", "bool", "int", "int", "%s->AsBool()", "%s->AsBool()", "", "zeek::val_mgr->Bool(%s)", "zeek::val_mgr->Bool(%s)") |
4 | 4 | DEFINE_BIF_TYPE(TYPE_CONN_ID, "conn_id", "conn_id", "zeek::Val*", "zeek::IntrusivePtr<zeek::Val>", "%s", "%s", "", "zeek::IntrusivePtr{zeek::AdoptRef{}, %s}", "std::move(%s)") |
5 | DEFINE_BIF_TYPE(TYPE_CONNECTION, "connection", "connection", "Connection*", "Connection*", "%s->AsRecordVal()->GetOrigin()", "%s->AsRecordVal()->GetOrigin()", "", "%s->ConnVal()", "%s->ConnVal()") | |
5 | DEFINE_BIF_TYPE(TYPE_CONNECTION, "connection", "connection", "zeek::Connection*", "zeek::Connection*", "%s->AsRecordVal()->GetOrigin()", "%s->AsRecordVal()->GetOrigin()", "", "%s->GetVal()", "%s->GetVal()") | |
6 | 6 | DEFINE_BIF_TYPE(TYPE_COUNT, "count", "count", "bro_uint_t", "bro_uint_t", "%s->AsCount()", "%s->AsCount()", "", "zeek::val_mgr->Count(%s)", "zeek::val_mgr->Count(%s)") |
7 | 7 | DEFINE_BIF_TYPE(TYPE_DOUBLE, "double", "double", "double", "double", "%s->AsDouble()", "%s->AsDouble()", "", "zeek::make_intrusive<zeek::DoubleVal>(%s)", "zeek::make_intrusive<zeek::DoubleVal>(%s)") |
8 | DEFINE_BIF_TYPE(TYPE_FILE, "file", "file", "BroFile*", "zeek::IntrusivePtr<zeek::Val>", "%s->AsFile()", "%s", "", "zeek::make_intrusive<zeek::Val>(zeek::IntrusivePtr{zeek::AdoptRef{}, %s})", "std::move(%s)") | |
8 | DEFINE_BIF_TYPE(TYPE_FILE, "file", "file", "zeek::File*", "zeek::IntrusivePtr<zeek::FileVal>", "%s->AsFile()", "%s", "", "zeek::make_intrusive<zeek::FileVal>(zeek::IntrusivePtr{zeek::AdoptRef{}, %s})", "std::move(%s)") | |
9 | 9 | DEFINE_BIF_TYPE(TYPE_INT, "int", "int", "bro_int_t", "bro_int_t", "%s->AsInt()", "%s->AsInt()", "", "zeek::val_mgr->Int(%s)", "zeek::val_mgr->Int(%s)") |
10 | 10 | DEFINE_BIF_TYPE(TYPE_INTERVAL, "interval", "interval", "double", "double", "%s->AsInterval()", "%s->AsInterval()", "", "zeek::make_intrusive<zeek::IntervalVal>(%s, Seconds)", "zeek::make_intrusive<zeek::IntervalVal>(%s, Seconds)") |
11 | 11 | DEFINE_BIF_TYPE(TYPE_PATTERN, "pattern", "pattern", "RE_Matcher*", "zeek::IntrusivePtr<zeek::PatternVal>", "%s->AsPattern()", "%s", "<zeek::PatternVal>", "zeek::make_intrusive<zeek::PatternVal>(%s)", "std::move(%s)") |