Codebase list bifcl / d5aa66dc-b9ab-441d-878b-e1b42c8d7f61/main
New upstream release. Debian Janitor 2 years ago
26 changed file(s) with 309 addition(s) and 301 deletion(s). Raw diff Collapse all Expand all
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)
059
160 1.4.0 | 2020-07-23 10:10:53 -0700
261
00
1 cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
1 cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
22 project(BifCl C CXX)
33
44 include(cmake/CommonCMakeConfig.cmake)
1818 include(RequireCXX17)
1919
2020 include_directories(BEFORE
21 ${CMAKE_CURRENT_SOURCE_DIR}/include
22 ${CMAKE_CURRENT_BINARY_DIR}
21 ${BifCl_SOURCE_DIR}/include
22 ${BifCl_BINARY_DIR}
2323 )
2424
2525 set(BISON_FLAGS "--debug")
2626
2727 # BIF parser/scanner
2828 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
3232 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)
3434 add_flex_bison_dependency(BIFScanner BIFParser)
3535 set_property(SOURCE bif_lex.cc APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-sign-compare")
3636
5757 "\n====================| Bifcl Build Summary |====================="
5858 "\n"
5959 "\nBuild type: ${CMAKE_BUILD_TYPE}"
60 "\nBuild dir: ${CMAKE_BINARY_DIR}"
60 "\nBuild dir: ${PROJECT_BINARY_DIR}"
6161 "\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
6262 "\nDebug mode: ${ENABLE_DEBUG}"
6363 "\n"
0 1.4.0
0 1.6.0
7171 fprintf(fp, ");\n");
7272 }
7373
74 void BuiltinFuncArg::PrintCArg(FILE* fp, int n, bool smart)
74 void BuiltinFuncArg::PrintCArg(FILE* fp, int n)
7575 {
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);
8177 }
8278
83 void BuiltinFuncArg::PrintBroValConstructor(FILE* fp, bool smart)
79 void BuiltinFuncArg::PrintBroValConstructor(FILE* fp)
8480 {
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);
8982 }
234234 fprintf(fp_func_h, "#ifndef BRO_IN_NETVAR\n");
235235 fprintf(fp_func_h, "#ifndef %s\n", guard);
236236 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");
238238 fprintf(fp_func_h, "#endif\n");
239239 fprintf(fp_func_h, "#endif\n");
240240 fprintf(fp_func_h, "\n");
241241
242242 fprintf(fp_func_def, "\n");
243243 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");
245245 fprintf(fp_func_def, "\n");
246246
247247 static char name[1024];
266266 fprintf(fp_func_init, "\n");
267267 fprintf(fp_func_init, "#include <list>\n");
268268 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");
271271 fprintf(fp_func_init, "#include \"%s.h\"\n", input_filename);
272272 fprintf(fp_func_init, "\n");
273273 fprintf(fp_func_init, "namespace plugin { namespace %s {\n", plugin_canon);
275275 fprintf(fp_func_init, "void __bif_%s_init(zeek::plugin::Plugin* plugin)\n", name);
276276 fprintf(fp_func_init, "\t{\n");
277277
278 fprintf(fp_func_register, "#include \"plugin/Manager.h\"\n");
278 fprintf(fp_func_register, "#include \"zeek/plugin/Manager.h\"\n");
279279 fprintf(fp_func_register, "\n");
280280 fprintf(fp_func_register, "namespace plugin { namespace %s {\n", plugin_canon);
281281 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);
283283 fprintf(fp_func_register, "} }\n");
284284 }
285285 }
310310 #endif
311311 #endif
312312
313 #if defined(USING_ASAN)
313 // FreeBSD doesn't support LeakSanitizer
314 #if defined(USING_ASAN) && !defined(__FreeBSD__)
314315 #include <sanitizer/lsan_interface.h>
316 #define BIFCL_LSAN_DISABLE(x) __lsan_disable(x)
317 #else
318 #define BIFCL_LSAN_DISABLE(x)
315319 #endif
316320
317321 int main(int argc, char* argv[])
318322 {
319 #if defined(USING_ASAN)
320323 // We generally do not care at all if bifcl is leaking and the default
321324 // behavior of LSAN to treat leaks as errors only trips up Zeek's build.
322 __lsan_disable();
323 #endif
325 BIFCL_LSAN_DISABLE();
324326
325327 int opt;
326328
1515 extern int line_number;
1616 extern char* input_filename;
1717 extern char* plugin;
18 extern int alternative_mode;
1819
1920 #define print_line_directive(fp) fprintf(fp, "\n#line %d \"%s\"\n", line_number, input_filename)
2021
205206 return s;
206207 }
207208
208 static void print_event_c_prototype_args(FILE* fp, bool smart)
209 static void print_event_c_prototype_args(FILE* fp)
209210 {
210211 for ( auto i = 0u; i < args.size(); ++i )
211212 {
212213 if ( i > 0 )
213214 fprintf(fp, ", ");
214215
215 args[i]->PrintCArg(fp, i, smart);
216 args[i]->PrintCArg(fp, i);
216217 }
217218 }
218219
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);
235228 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);
251239 fprintf(fp, ")");
252240 fprintf(fp, "\n");
253241 }
254242
255 static void print_event_c_body(FILE* fp, bool smart)
243 static void print_event_c_body(FILE* fp)
256244 {
257245 fprintf(fp, "\t{\n");
258246 fprintf(fp, "\t// Note that it is intentional that here we do not\n");
265253
266254 BuiltinFuncArg* connection_arg = 0;
267255
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());
269257
270258 for ( int i = 0; i < (int) args.size(); ++i )
271259 {
272260 fprintf(fp, "\t ");
273 args[i]->PrintBroValConstructor(fp, smart);
261 args[i]->PrintBroValConstructor(fp);
274262 fprintf(fp, ",\n");
275263
276264 if ( args[i]->Type() == TYPE_CONNECTION )
287275 }
288276 }
289277
290 fprintf(fp, "\t },\n\t SOURCE_LOCAL, analyzer->GetID()");
278 fprintf(fp, "\t },\n\t zeek::util::detail::SOURCE_LOCAL, analyzer->GetID()");
291279
292280 if ( connection_arg )
293281 // Pass the connection to the EventMgr as the "cookie"
381369 fprintf(fp_netvar_h, "namespace zeek { %s extern zeek::IntrusivePtr<zeek::%sType> %s; %s}\n",
382370 decl.c_namespace_start.c_str(), type_name.c_str(),
383371 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
388372
389373 fprintf(fp_netvar_def, "namespace zeek { %s zeek::IntrusivePtr<zeek::%sType> %s; %s}\n",
390374 decl.c_namespace_start.c_str(), type_name.c_str(),
397381 "\tzeek::%s = zeek::id::find_type<zeek::%sType>(\"%s\");\n",
398382 decl.c_fullname.c_str(), type_name.c_str(),
399383 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());
403384
404385 record_bif_item(decl.bro_fullname.c_str(), "TYPE");
405386 }
426407 {
427408 if ( events.find(decl.bro_fullname) == events.end() )
428409 {
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);
435413 events.insert(decl.bro_fullname);
436414 }
437415 }
454432 // Now generate the netvar's.
455433 fprintf(fp_netvar_h, "namespace zeek { %s extern zeek::IntrusivePtr<zeek::EnumType> %s; %s}\n",
456434 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
461435 fprintf(fp_netvar_def, "namespace zeek { %s zeek::IntrusivePtr<zeek::EnumType> %s; %s}\n",
462436 decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str());
463437 fprintf(fp_netvar_def, "%s zeek::EnumType * %s; %s\n",
466440 fprintf(fp_netvar_init,
467441 "\tzeek::%s = zeek::id::find_type<zeek::EnumType>(\"%s\");\n",
468442 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());
472443
473444 record_bif_item(decl.bro_fullname.c_str(), "TYPE");
474445 }
519490 fprintf(fp_netvar_h, "namespace zeek { %s extern %s %s; %s }\n",
520491 decl.c_namespace_start.c_str(),
521492 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(),
526493 decl.c_namespace_end.c_str());
527494
528495 fprintf(fp_netvar_def, "namespace zeek { %s %s %s; %s }\n",
534501 builtin_types[typeidx].c_type, decl.bare_name.c_str(),
535502 decl.c_namespace_end.c_str());
536503
504 if ( alternative_mode && ! plugin )
505 fprintf(fp_netvar_init, "\tzeek::detail::bif_initializers.emplace_back([]()\n");
506
537507 fprintf(fp_netvar_init, "\t{\n");
538508 fprintf(fp_netvar_init, "\tconst auto& v = zeek::id::find_const%s(\"%s\");\n",
539509 builtin_types[typeidx].cast_smart, decl.bro_fullname.c_str());
540510 fprintf(fp_netvar_init, "\tzeek::%s = v%s;\n",
541511 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);
544512 fprintf(fp_netvar_init, "\t}\n");
513
514 if ( alternative_mode && ! plugin )
515 fprintf(fp_netvar_init, "\t);\n");
545516
546517 record_bif_item(decl.bro_fullname.c_str(), "CONSTANT");
547518 }
630601 // (e.g. ones at global scope that may be used to implement
631602 // the BIF itself).
632603 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",
634605 decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str());
635606
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
645607 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)",
647609 decl.c_fullname.c_str(), arg_list_name);
648610
649611 record_bif_item(decl.bro_fullname.c_str(), "FUNCTION");
654616 {
655617 // TODO: add namespace for events here
656618 fprintf(fp_netvar_h,
657 "%sextern EventHandlerPtr %s; %s\n",
619 "%sextern zeek::EventHandlerPtr %s; %s\n",
658620 decl.c_namespace_start.c_str(), decl.bare_name.c_str(), decl.c_namespace_end.c_str());
659621
660622 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());
663625
664626 fprintf(fp_netvar_init,
665 "\t%s = event_registry->Register(\"%s\");\n",
627 "\t%s = zeek::event_registry->Register(\"%s\");\n",
666628 decl.c_fullname.c_str(), decl.bro_fullname.c_str());
667629
668630 record_bif_item(decl.bro_fullname.c_str(), "EVENT");
1717
1818 if ( "${ARGV1}" STREQUAL "standard" )
1919 set(bifcl_args "")
20 set(target "bif-std-${CMAKE_CURRENT_BINARY_DIR}/${bifInputBasename}")
20 set(target "bif-std-${CMAKE_CURRENT_BINARY_DIR}/${bifInputBasename}")
2121 set(bifOutputs
2222 ${CMAKE_CURRENT_BINARY_DIR}/${bifInputBasename}.func_def
2323 ${CMAKE_CURRENT_BINARY_DIR}/${bifInputBasename}.func_h
3131 ${bifInputBasename}.netvar_init)
3232 set(BIF_OUTPUT_H ${bifInputBasename}.func_h
3333 ${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)
3535 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
3636
3737 # Do this here so that all of the necessary files for each individual BIF get added to clang-tidy
6767 set(BIF_OUTPUT_H ${bifInputBasename}.h)
6868
6969 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)
7171 else ()
7272 set(BIF_OUTPUT_BRO ${BRO_PLUGIN_BIF}/${bifInputBasename}.zeek)
7373 endif()
9393 # In order be able to run Zeek from the build directory, the
9494 # generated Zeek script needs to be inside a directory tree
9595 # 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)
9797
9898 set(bro_AUTO_BIFS ${bro_AUTO_BIFS} ${CMAKE_CURRENT_BINARY_DIR}/${bifInputBasename} CACHE INTERNAL "BIFs for automatic inclusion" FORCE) # Propagate to top-level.
9999 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
139139 COMMENT "[BIFCL] Processing ${bifInput}"
140140 )
141141
142 string(REGEX REPLACE "${CMAKE_BINARY_DIR}/src/" "" target "${target}")
142 string(REGEX REPLACE "${Zeek_BINARY_DIR}/src/" "" target "${target}")
143143 string(REGEX REPLACE "/" "-" target "${target}")
144144 add_custom_target(${target} DEPENDS ${BIF_OUTPUT_H} ${BIF_OUTPUT_CC})
145145 set_source_files_properties(${bifOutputs} PROPERTIES GENERATED 1)
3535 COMMAND ${BinPAC_EXE}
3636 ARGS -q -d ${CMAKE_CURRENT_BINARY_DIR}
3737 -I ${CMAKE_CURRENT_SOURCE_DIR}
38 -I ${CMAKE_SOURCE_DIR}/src
38 -I ${CMAKE_CURRENT_SOURCE_DIR}/src
39 -I ${PROJECT_SOURCE_DIR}/src
3940 ${BinPAC_addl_args}
4041 ${CMAKE_CURRENT_SOURCE_DIR}/${pacFile}
4142 DEPENDS ${binpacDep} ${pacFile}
5253
5354 set(target "pac-${CMAKE_CURRENT_BINARY_DIR}/${pacFile}")
5455
55 string(REGEX REPLACE "${CMAKE_BINARY_DIR}/src/" "" target "${target}")
56 string(REGEX REPLACE "${PROJECT_BINARY_DIR}/src/" "" target "${target}")
5657 string(REGEX REPLACE "/" "-" target "${target}")
5758 add_custom_target(${target} DEPENDS ${pacOutputs})
5859 set(BINPAC_BUILD_TARGET ${target})
2323 # Should result in ${libs} containing:
2424 # /usr/lib/libz.dylib
2525 # /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
2828 # /usr/local/lib/somestaticlib.a
2929 #
3030 # such that we can now do:
4040 find_program(INSTALL_NAME_TOOL install_name_tool)
4141
4242 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)
4444 set(SUPPORT_INSTALL_DIR support_libs)
4545
4646 file(MAKE_DIRECTORY ${SUPPORT_BIN_DIR})
5555 get_filename_component(_libname ${_lib} NAME)
5656 set(_adjustedLib ${SUPPORT_BIN_DIR}/${_libname})
5757 set(_tmpLib
58 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_libname})
58 ${Zeek_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_libname})
5959
6060 # make a tempory copy so we can adjust permissions
6161 configure_file(${_lib} ${_tmpLib} COPYONLY)
11
22 check_function_exists(getopt_long HAVE_GETOPT_LONG)
33 check_function_exists(mallinfo HAVE_MALLINFO)
4 check_function_exists(mallinfo2 HAVE_MALLINFO2)
45 check_function_exists(strcasestr HAVE_STRCASESTR)
56 check_function_exists(strerror HAVE_STRERROR)
67 check_function_exists(strsep HAVE_STRSEP)
262262
263263 # add default files/directories to ignore for source package
264264 # 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")
266266
267267 include(CPack)
268268 endmacro(ConfigurePackaging)
104104 DEPENDS
105105 "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output"
106106 COMMENT "[BISON][${Name}] Copying bison verbose table to ${filename}"
107 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
107 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
108108 SET(BISON_${Name}_VERBOSE_FILE ${filename})
109109 LIST(APPEND BISON_TARGET_extraoutputs
110110 "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output")
+0
-147
cmake/FindCAF.cmake less more
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)
3838
3939 if (RUN_CLANG_TIDY)
4040 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}
4343 )
4444 else()
4545 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}
4848 )
4949 endif()
5050 endif()
133133
134134 set(HAVE_KQUEUE true)
135135 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)
137137
138138 include_directories(BEFORE ${LIBKQUEUE_INCLUDE_DIRS})
139139 set(zeekdeps ${zeekdeps} ${LIBKQUEUE_LIBRARIES})
4040 # symlink).
4141 get_filename_component(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}" REALPATH)
4242 get_filename_component(PYTHON_EXECUTABLE_DIR "${PYTHON_EXECUTABLE}" DIRECTORY)
43 get_filename_component(PYTHON_EXECUTABLE_NAME "${PYTHON_EXECUTABLE}" NAME)
4344
4445 if ( EXISTS ${PYTHON_EXECUTABLE}-config )
4546 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 )
4754 set(PYTHON_CONFIG ${PYTHON_EXECUTABLE_DIR}/python-config CACHE PATH "" FORCE)
4855 endif ()
4956 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 )
5466 endif ()
5567
5668 # The OpenBSD python packages have python-config's that don't reliably
5769 # report linking flags that will work.
5870 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
6083 OUTPUT_VARIABLE PYTHON_LIBRARIES
6184 OUTPUT_STRIP_TRAILING_WHITESPACE
6285 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
6395 string(STRIP "${PYTHON_LIBRARIES}" PYTHON_LIBRARIES)
6496
6597 execute_process(COMMAND "${PYTHON_CONFIG}" --includes
77109 PYTHON_LIBRARIES
78110 )
79111 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 ()
83132 endif ()
133
84134 find_package_handle_standard_args(PythonDev DEFAULT_MSG
85135 PYTHON_INCLUDE_DIR
86136 PYTHON_LIBRARIES
3434 string(REGEX MATCH ${_regex} _match ${_srclines})
3535 if (_match)
3636 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 )
3838 set(${_shell}_interp ${PYTHON_EXECUTABLE})
3939 else ()
4040 find_program(${_shell}_interp ${_shell})
00 if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
1 set(bro_LINKER_FLAGS "${bro_LINKER_FLAGS} -rdynamic")
21
32 elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
4 set(bro_LINKER_FLAGS "${bro_LINKER_FLAGS} -rdynamic")
53
64 elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
75 set(HAVE_DARWIN true)
00 include(CheckCSourceCompiles)
11 include(CheckCXXSourceCompiles)
22 include(CheckCSourceRuns)
3 include(CheckIncludeFiles)
34
45 set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS})
56 # Use all includes, not just OpenSSL includes to see if there are
3233 if (OPENSSL_VERSION VERSION_LESS "0.9.7")
3334 message(FATAL_ERROR "OpenSSL >= v0.9.7 required")
3435 endif ()
36
37 check_include_files(openssl/kdf.h OPENSSL_HAVE_KDF_H)
3538
3639 check_cxx_source_compiles("
3740 #include <openssl/x509.h>
00 # Prohibit in-source builds.
1 if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
1 if ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
22 message(FATAL_ERROR "In-source builds are not allowed. Please use "
33 "./configure to choose a build directory and "
44 "initialize the build configuration.")
11 # can find internal/private libraries or libraries external to the build
22 # directory that were explicitly linked against
33 if (NOT BINARY_PACKAGING_MODE)
4 SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
5 SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
6
74 include(GNUInstallDirs)
85
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}")
158 endif ()
2727 ZEEK_EXE_PATH
2828 CMAKE_CXX_FLAGS
2929 CMAKE_C_FLAGS
30 PCAP_INCLUDE_DIR
31 ZLIB_INCLUDE_DIR
32 OPENSSL_INCLUDE_DIR
33 LibKrb5_INCLUDE_DIR
34 GooglePerftools_INCLUDE_DIR
3035 CAF_INCLUDE_DIRS)
3136
3237 if ( NOT BRO_PLUGIN_BRO_PLUGIN_INSTALL_PATH )
5055 set(CMAKE_MODULE_PATH ${BRO_PLUGIN_BRO_CMAKE} ${CMAKE_MODULE_PATH})
5156 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${bro_cache_CMAKE_C_FLAGS}")
5257 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 ()
5374
5475 # Zeek 3.2+ has auxil/ instead of aux/
5576 include_directories(BEFORE
106127 " to the installation path of Zeek headers")
107128 endif ()
108129
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
109154 set(BRO_PLUGIN_BRO_CONFIG_INCLUDE_DIR "${BRO_CONFIG_INCLUDE_DIR}"
110155 CACHE INTERNAL "" FORCE)
111156 set(BRO_PLUGIN_BRO_INSTALL_PREFIX "${BRO_CONFIG_PREFIX}"
118163 set(CMAKE_MODULE_PATH ${BRO_PLUGIN_BRO_CMAKE} ${CMAKE_MODULE_PATH})
119164
120165 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
122183 find_package(Broker REQUIRED)
123184
124185 string(REPLACE ":" ";" ZEEK_CONFIG_INCLUDE_DIRS "${BRO_CONFIG_INCLUDE_DIR}")
254315
255316 add_dependencies(${_plugin_lib} bro-plugin-${_plugin_name_canon})
256317
257 set(_dist_tarball_name ${_plugin_name_canon}.tar.gz)
318 set(_dist_tarball_name ${_plugin_name_canon}.tgz)
258319 set(_dist_output ${CMAKE_CURRENT_BINARY_DIR}/${_dist_tarball_name})
259320
260321 # Create binary install package.
2727
2828 add_dependencies(${_plugin_lib} generate_outputs)
2929
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
3056 set(bro_PLUGIN_LIBS ${bro_PLUGIN_LIBS} "$<TARGET_OBJECTS:${_plugin_lib}>" CACHE INTERNAL "plugin libraries")
3157 set(bro_PLUGIN_DEPS ${bro_PLUGIN_DEPS} "${_plugin_lib}" CACHE INTERNAL "plugin dependencies")
3258 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
06 bifcl (1.4.0-1) unstable; urgency=medium
17
28 * New upstream version 1.4.0
2626
2727 void PrintBro(FILE* fp);
2828 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);
3131
3232 protected:
3333 const char* name;
22 DEFINE_BIF_TYPE(TYPE_ANY, "any", "any", "zeek::Val*", "zeek::IntrusivePtr<zeek::Val>", "%s", "%s", "", "zeek::IntrusivePtr{zeek::AdoptRef{}, %s}", "std::move(%s)")
33 DEFINE_BIF_TYPE(TYPE_BOOL, "bool", "bool", "int", "int", "%s->AsBool()", "%s->AsBool()", "", "zeek::val_mgr->Bool(%s)", "zeek::val_mgr->Bool(%s)")
44 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()")
66 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)")
77 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)")
99 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)")
1010 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)")
1111 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)")