diff --git a/CMakeLists.txt b/CMakeLists.txt index 374af64a18..5a7fba482e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,9 +170,19 @@ include(RequireCXX11) # Tell the plugin code that we're building as part of the main tree. set(BRO_PLUGIN_INTERNAL_BUILD true CACHE INTERNAL "" FORCE) +set(DEFAULT_BROPATH .:${BRO_SCRIPT_INSTALL_PATH}:${BRO_SCRIPT_INSTALL_PATH}/policy:${BRO_SCRIPT_INSTALL_PATH}/site) + +if ( NOT BINARY_PACKAGING_MODE ) + set(BRO_DIST ${CMAKE_SOURCE_DIR}) +endif () + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bro-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/bro-config.h) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bro-config.in + ${CMAKE_CURRENT_BINARY_DIR}/bro-config @ONLY) +install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/bro-config DESTINATION bin) + include_directories(${CMAKE_CURRENT_BINARY_DIR}) ######################################################################## diff --git a/bro-config.in b/bro-config.in new file mode 100755 index 0000000000..0c426fd17b --- /dev/null +++ b/bro-config.in @@ -0,0 +1,63 @@ +#!/bin/sh + +version=@VERSION@ +prefix=@CMAKE_INSTALL_PREFIX@ +script_dir=@BRO_SCRIPT_INSTALL_PATH@ +site_dir=@BRO_SCRIPT_INSTALL_PATH@/site +plugin_dir=@BRO_PLUGIN_INSTALL_PATH@ +config_dir=@BRO_ETC_INSTALL_DIR@ +python_dir=@PY_MOD_INSTALL_DIR@ +bropath=@DEFAULT_BROPATH@ +bro_dist=@BRO_DIST@ + +usage="\ +Usage: bro-config [--version] [--prefix] [--script_dir] [--site_dir] [--plugin_dir] [--config_dir] [--python_dir] [--bropath] [--bro_dist]" + +if [ $# -eq 0 ] ; then + echo "${usage}" 1>&2 + exit 1 +fi + +while [ $# -ne 0 ]; do + case "$1" in + -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + case $1 in + --version) + echo $version + ;; + --prefix) + echo $prefix + ;; + --script_dir) + echo $script_dir + ;; + --site_dir) + echo $site_dir + ;; + --plugin_dir) + echo $plugin_dir + ;; + --config_dir) + echo $config_dir + ;; + --python_dir) + echo $python_dir + ;; + --bropath) + echo $bropath + ;; + --bro_dist) + echo $bro_dist + ;; + *) + echo "${usage}" 1>&2 + exit 1 + ;; + esac + shift +done + +exit 0 diff --git a/src/util-config.h.in b/src/util-config.h.in index 016ac105a6..c0817b7f5f 100644 --- a/src/util-config.h.in +++ b/src/util-config.h.in @@ -1,2 +1,3 @@ #define BRO_SCRIPT_INSTALL_PATH "@BRO_SCRIPT_INSTALL_PATH@" #define BRO_PLUGIN_INSTALL_PATH "@BRO_PLUGIN_INSTALL_PATH@" +#define DEFAULT_BROPATH "@DEFAULT_BROPATH@" diff --git a/src/util.cc b/src/util.cc index 11524349d5..acfcb19573 100644 --- a/src/util.cc +++ b/src/util.cc @@ -949,11 +949,9 @@ const std::string& bro_path() if ( bro_path_value.empty() ) { const char* path = getenv("BROPATH"); + if ( ! path ) - path = ".:" - BRO_SCRIPT_INSTALL_PATH ":" - BRO_SCRIPT_INSTALL_PATH "/policy" ":" - BRO_SCRIPT_INSTALL_PATH "/site"; + path = DEFAULT_BROPATH; bro_path_value = path; }