mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00

Notable changes: - libmagic is no longer used at all. All MIME type detection is done through new Bro signatures, and there's no longer a means to get verbose file type descriptions (e.g. "PNG image data, 1435 x 170"). The majority of the default file magic signatures are derived from the default magic database of libmagic ~5.17. - File magic signatures consist of two new constructs in the signature rule parsing grammar: "file-magic" gives a regular expression to match against, and "file-mime" gives the MIME type string of content that matches the magic and an optional strength value for the match. - Modified signature/rule syntax for identifiers: they can no longer start with a '-', which made for ambiguous syntax when doing negative strength values in "file-mime". Also brought syntax for Bro script identifiers in line with reality (they can't start with numbers or include '-' at all). - A new Built-In Function, "file_magic", can be used to get all file magic matches and their corresponding strength against a given chunk of data - The second parameter of the "identify_data" Built-In Function can no longer be used to get verbose file type descriptions, though it can still be used to get the strongest matching file magic signature. - The "file_transferred" event's "descr" parameter no longer contains verbose file type descriptions. - The BROMAGIC environment variable no longer changes any behavior in Bro as magic databases are no longer used/installed. - Reverted back to minimum requirement of CMake 2.6.3 from 2.8.0 (it's back to being the same requirement as the Bro v2.2 release). The bump was to accomodate building libmagic as an external project, which is no longer needed. Addresses BIT-1143.
242 lines
7.5 KiB
CMake
242 lines
7.5 KiB
CMake
project(Bro C CXX)
|
|
cmake_minimum_required(VERSION 2.6.3 FATAL_ERROR)
|
|
include(cmake/CommonCMakeConfig.cmake)
|
|
|
|
########################################################################
|
|
## Project/Build Configuration
|
|
|
|
set(BRO_ROOT_DIR ${CMAKE_INSTALL_PREFIX})
|
|
if (NOT BRO_SCRIPT_INSTALL_PATH)
|
|
# set the default Bro script installation path (user did not specify one)
|
|
set(BRO_SCRIPT_INSTALL_PATH ${BRO_ROOT_DIR}/share/bro)
|
|
endif ()
|
|
|
|
# sanitize the Bro script install directory into an absolute path
|
|
# (CMake is confused by ~ as a representation of home directory)
|
|
get_filename_component(BRO_SCRIPT_INSTALL_PATH ${BRO_SCRIPT_INSTALL_PATH}
|
|
ABSOLUTE)
|
|
|
|
configure_file(bro-path-dev.in ${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev)
|
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev.sh
|
|
"export BROPATH=`${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev`\n"
|
|
"export PATH=\"${CMAKE_CURRENT_BINARY_DIR}/src\":$PATH\n")
|
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev.csh
|
|
"setenv BROPATH `${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev`\n"
|
|
"setenv PATH \"${CMAKE_CURRENT_BINARY_DIR}/src\":$PATH\n")
|
|
|
|
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VERSION LIMIT_COUNT 1)
|
|
string(REPLACE "." " " version_numbers ${VERSION})
|
|
separate_arguments(version_numbers)
|
|
list(GET version_numbers 0 VERSION_MAJOR)
|
|
list(GET version_numbers 1 VERSION_MINOR)
|
|
set(VERSION_MAJ_MIN "${VERSION_MAJOR}.${VERSION_MINOR}")
|
|
|
|
########################################################################
|
|
## Dependency Configuration
|
|
|
|
include(FindRequiredPackage)
|
|
|
|
# Check cache value first to avoid displaying "Found sed" messages everytime
|
|
if (NOT SED_EXE)
|
|
find_program(SED_EXE sed)
|
|
if (NOT SED_EXE)
|
|
message(FATAL_ERROR "Could not find required dependency: sed")
|
|
else ()
|
|
message(STATUS "Found sed: ${SED_EXE}")
|
|
endif ()
|
|
endif ()
|
|
|
|
FindRequiredPackage(Perl)
|
|
FindRequiredPackage(FLEX)
|
|
FindRequiredPackage(BISON)
|
|
FindRequiredPackage(PCAP)
|
|
FindRequiredPackage(OpenSSL)
|
|
FindRequiredPackage(BIND)
|
|
FindRequiredPackage(ZLIB)
|
|
|
|
if (NOT BinPAC_ROOT_DIR AND
|
|
EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/aux/binpac/CMakeLists.txt)
|
|
add_subdirectory(aux/binpac)
|
|
endif ()
|
|
FindRequiredPackage(BinPAC)
|
|
|
|
if (MISSING_PREREQS)
|
|
foreach (prereq ${MISSING_PREREQ_DESCS})
|
|
message(SEND_ERROR ${prereq})
|
|
endforeach ()
|
|
message(FATAL_ERROR "Configuration aborted due to missing prerequisites")
|
|
endif ()
|
|
|
|
include_directories(BEFORE
|
|
${PCAP_INCLUDE_DIR}
|
|
${OpenSSL_INCLUDE_DIR}
|
|
${BIND_INCLUDE_DIR}
|
|
${BinPAC_INCLUDE_DIR}
|
|
${ZLIB_INCLUDE_DIR}
|
|
)
|
|
|
|
# Optional Dependencies
|
|
|
|
set(USE_GEOIP false)
|
|
find_package(LibGeoIP)
|
|
if (LIBGEOIP_FOUND)
|
|
set(USE_GEOIP true)
|
|
include_directories(BEFORE ${LibGeoIP_INCLUDE_DIR})
|
|
list(APPEND OPTLIBS ${LibGeoIP_LIBRARY})
|
|
endif ()
|
|
|
|
set(HAVE_PERFTOOLS false)
|
|
set(USE_PERFTOOLS_DEBUG false)
|
|
set(USE_PERFTOOLS_TCMALLOC false)
|
|
|
|
if (NOT DISABLE_PERFTOOLS)
|
|
find_package(GooglePerftools)
|
|
endif ()
|
|
|
|
if (GOOGLEPERFTOOLS_FOUND)
|
|
set(HAVE_PERFTOOLS true)
|
|
# Non-Linux systems may not be well-supported by gperftools, so
|
|
# require explicit request from user to enable it in that case.
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ENABLE_PERFTOOLS)
|
|
set(USE_PERFTOOLS_TCMALLOC true)
|
|
|
|
if (ENABLE_PERFTOOLS_DEBUG)
|
|
# Enable heap debugging with perftools.
|
|
set(USE_PERFTOOLS_DEBUG true)
|
|
include_directories(BEFORE ${GooglePerftools_INCLUDE_DIR})
|
|
list(APPEND OPTLIBS ${GooglePerftools_LIBRARIES_DEBUG})
|
|
else ()
|
|
# Link in tcmalloc for better performance.
|
|
list(APPEND OPTLIBS ${GooglePerftools_LIBRARIES})
|
|
endif ()
|
|
endif ()
|
|
endif ()
|
|
|
|
set(USE_DATASERIES false)
|
|
find_package(Lintel)
|
|
find_package(DataSeries)
|
|
find_package(LibXML2)
|
|
|
|
if (NOT DISABLE_DATASERIES AND
|
|
LINTEL_FOUND AND DATASERIES_FOUND AND LIBXML2_FOUND)
|
|
set(USE_DATASERIES true)
|
|
include_directories(BEFORE ${Lintel_INCLUDE_DIR})
|
|
include_directories(BEFORE ${DataSeries_INCLUDE_DIR})
|
|
include_directories(BEFORE ${LibXML2_INCLUDE_DIR})
|
|
list(APPEND OPTLIBS ${Lintel_LIBRARIES})
|
|
list(APPEND OPTLIBS ${DataSeries_LIBRARIES})
|
|
list(APPEND OPTLIBS ${LibXML2_LIBRARIES})
|
|
endif()
|
|
|
|
set(USE_ELASTICSEARCH false)
|
|
set(USE_CURL false)
|
|
find_package(LibCURL)
|
|
|
|
if (NOT DISABLE_ELASTICSEARCH AND LIBCURL_FOUND)
|
|
set(USE_ELASTICSEARCH true)
|
|
set(USE_CURL true)
|
|
include_directories(BEFORE ${LibCURL_INCLUDE_DIR})
|
|
list(APPEND OPTLIBS ${LibCURL_LIBRARIES})
|
|
endif()
|
|
|
|
if (ENABLE_PERFTOOLS_DEBUG OR ENABLE_PERFTOOLS)
|
|
# Just a no op to prevent CMake from complaining about manually-specified
|
|
# ENABLE_PERFTOOLS_DEBUG or ENABLE_PERFTOOLS not being used if google
|
|
# perftools weren't found
|
|
endif ()
|
|
|
|
set(brodeps
|
|
${BinPAC_LIBRARY}
|
|
${PCAP_LIBRARY}
|
|
${OpenSSL_LIBRARIES}
|
|
${BIND_LIBRARY}
|
|
${ZLIB_LIBRARY}
|
|
${OPTLIBS}
|
|
)
|
|
|
|
########################################################################
|
|
## System Introspection
|
|
|
|
include(TestBigEndian)
|
|
test_big_endian(WORDS_BIGENDIAN)
|
|
|
|
include(OSSpecific)
|
|
include(CheckTypes)
|
|
include(CheckHeaders)
|
|
include(CheckFunctions)
|
|
include(MiscTests)
|
|
include(PCAPTests)
|
|
include(OpenSSLTests)
|
|
include(CheckNameserCompat)
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
########################################################################
|
|
## Recurse on sub-directories
|
|
|
|
add_subdirectory(src)
|
|
add_subdirectory(scripts)
|
|
add_subdirectory(doc)
|
|
|
|
include(CheckOptionalBuildSources)
|
|
|
|
CheckOptionalBuildSources(aux/broctl Broctl INSTALL_BROCTL)
|
|
CheckOptionalBuildSources(aux/bro-aux Bro-Aux INSTALL_AUX_TOOLS)
|
|
CheckOptionalBuildSources(aux/broccoli Broccoli INSTALL_BROCCOLI)
|
|
|
|
########################################################################
|
|
## Packaging Setup
|
|
|
|
if (INSTALL_BROCTL)
|
|
# CPack RPM Generator may not automatically detect this
|
|
set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.6.0")
|
|
endif ()
|
|
|
|
# If this CMake project is a sub-project of another, we will not
|
|
# configure the generic packaging because CPack will fail in the case
|
|
# that the parent project has already configured packaging
|
|
if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
|
|
include(ConfigurePackaging)
|
|
ConfigurePackaging(${VERSION})
|
|
endif ()
|
|
|
|
########################################################################
|
|
## Build Summary
|
|
|
|
if (CMAKE_BUILD_TYPE)
|
|
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
|
|
endif ()
|
|
|
|
message(
|
|
"\n====================| Bro Build Summary |====================="
|
|
"\n"
|
|
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
|
|
"\nBro Script Path: ${BRO_SCRIPT_INSTALL_PATH}"
|
|
"\nDebug mode: ${ENABLE_DEBUG}"
|
|
"\n"
|
|
"\nCC: ${CMAKE_C_COMPILER}"
|
|
"\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}"
|
|
"\nCXX: ${CMAKE_CXX_COMPILER}"
|
|
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}"
|
|
"\nCPP: ${CMAKE_CXX_COMPILER}"
|
|
"\n"
|
|
"\nBroccoli: ${INSTALL_BROCCOLI}"
|
|
"\nBroctl: ${INSTALL_BROCTL}"
|
|
"\nAux. Tools: ${INSTALL_AUX_TOOLS}"
|
|
"\n"
|
|
"\nGeoIP: ${USE_GEOIP}"
|
|
"\ngperftools found: ${HAVE_PERFTOOLS}"
|
|
"\n tcmalloc: ${USE_PERFTOOLS_TCMALLOC}"
|
|
"\n debugging: ${USE_PERFTOOLS_DEBUG}"
|
|
"\ncURL: ${USE_CURL}"
|
|
"\n"
|
|
"\nDataSeries: ${USE_DATASERIES}"
|
|
"\nElasticSearch: ${USE_ELASTICSEARCH}"
|
|
"\n"
|
|
"\n================================================================\n"
|
|
)
|
|
|
|
include(UserChangedWarning)
|