Improve support for custom libdir locations

- Remove hardwiring of $ZEEK_ROOT/lib throughout the three and
  defaults the name of Zeek's library directory to the default on the
  given platform (e.g. lib64), via GNUInstallDirs.

- Consistently use that lib directory, instead of two lib folders
  resulting when using a custom libdir.

- Remove the old lib directory in the installation prefix, if one exists

- Add --lib_dir to zeek-config (and sort its options a bit).

- Bump submodules for corresponding changes
This commit is contained in:
Christian Kreibich 2020-11-16 15:20:03 -08:00
parent 8d0f2f9ab7
commit ec76b2510a
8 changed files with 66 additions and 53 deletions

View file

@ -4,14 +4,7 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(Zeek C CXX) project(Zeek C CXX)
if ( NOT CMAKE_INSTALL_LIBDIR ) include(GNUInstallDirs)
# Currently, some sub-projects may use GNUInstallDirs.cmake to choose the
# library install dir, while others just default to "lib". For sake of
# consistency, this just overrides the former to always use "lib" in case
# it would have chosen something else, like "lib64", but a thing for the
# future may be to standardize all sub-projects to use GNUInstallDirs.
set(CMAKE_INSTALL_LIBDIR lib)
endif ()
include(cmake/CommonCMakeConfig.cmake) include(cmake/CommonCMakeConfig.cmake)
include(cmake/FindClangTidy.cmake) include(cmake/FindClangTidy.cmake)
@ -60,7 +53,8 @@ endif ()
get_filename_component(ZEEK_SCRIPT_INSTALL_PATH ${ZEEK_SCRIPT_INSTALL_PATH} get_filename_component(ZEEK_SCRIPT_INSTALL_PATH ${ZEEK_SCRIPT_INSTALL_PATH}
ABSOLUTE) ABSOLUTE)
set(BRO_PLUGIN_INSTALL_PATH ${ZEEK_ROOT_DIR}/lib/zeek/plugins CACHE STRING "Installation path for plugins" FORCE) set(BRO_PLUGIN_INSTALL_PATH ${CMAKE_INSTALL_FULL_LIBDIR}/zeek/plugins CACHE STRING "Installation path for plugins" FORCE)
set(PY_MOD_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/zeekctl CACHE STRING "Installation path for Python modules" FORCE)
configure_file(zeek-path-dev.in ${CMAKE_CURRENT_BINARY_DIR}/zeek-path-dev) configure_file(zeek-path-dev.in ${CMAKE_CURRENT_BINARY_DIR}/zeek-path-dev)
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink
@ -126,7 +120,7 @@ if ( NOT BINARY_PACKAGING_MODE )
# before Zeek 3.0. # before Zeek 3.0.
_make_install_dir_symlink("${CMAKE_INSTALL_PREFIX}/include/bro" "${CMAKE_INSTALL_PREFIX}/include/zeek") _make_install_dir_symlink("${CMAKE_INSTALL_PREFIX}/include/bro" "${CMAKE_INSTALL_PREFIX}/include/zeek")
_make_install_dir_symlink("${CMAKE_INSTALL_PREFIX}/share/bro" "${CMAKE_INSTALL_PREFIX}/share/zeek") _make_install_dir_symlink("${CMAKE_INSTALL_PREFIX}/share/bro" "${CMAKE_INSTALL_PREFIX}/share/zeek")
_make_install_dir_symlink("${CMAKE_INSTALL_PREFIX}/lib/bro" "${CMAKE_INSTALL_PREFIX}/lib/zeek") _make_install_dir_symlink("${CMAKE_INSTALL_PREFIX}/lib/bro" "${CMAKE_INSTALL_LIBDIR}/zeek")
endif () endif ()
if ( ZEEK_SANITIZERS ) if ( ZEEK_SANITIZERS )
@ -514,6 +508,23 @@ CheckOptionalBuildSources(auxil/zeekctl ZeekControl INSTALL_ZEEKCTL)
CheckOptionalBuildSources(auxil/zeek-aux Zeek-Aux INSTALL_AUX_TOOLS) CheckOptionalBuildSources(auxil/zeek-aux Zeek-Aux INSTALL_AUX_TOOLS)
CheckOptionalBuildSources(auxil/zeek-archiver ZeekArchiver INSTALL_ZEEK_ARCHIVER) CheckOptionalBuildSources(auxil/zeek-archiver ZeekArchiver INSTALL_ZEEK_ARCHIVER)
########################################################################
## Transitions and cleanups
if ( NOT BINARY_PACKAGING_MODE )
# Remove pre-existing libdir of the old hardwired name if it is not
# the name we're now installing under.
set(_old_libdir ${CMAKE_INSTALL_PREFIX}/lib)
install(CODE "
if ( EXISTS \"${_old_libdir}\" AND IS_DIRECTORY \"${_old_libdir}\"
AND NOT \"${_old_libdir}\" STREQUAL \"${CMAKE_INSTALL_FULL_LIBDIR}\" )
message(STATUS \"WARNING: removing old library directory ${_old_libdir}\")
execute_process(COMMAND \"${CMAKE_COMMAND}\" -E remove_directory \"${_old_libdir}\")
endif ()
")
endif ()
######################################################################## ########################################################################
## Packaging Setup ## Packaging Setup

@ -1 +1 @@
Subproject commit 28fbb63d06c9192923effc930a4b60226c35fb0e Subproject commit 830c757d3b0ddfd2902db9bd0cd28110ba30d4b6

@ -1 +1 @@
Subproject commit 512c911c27aeb319430093187f85c70610d80035 Subproject commit 8dd1b45071ad41d5f1c4e5e6d0b9e189ccb5cb1f

@ -1 +1 @@
Subproject commit fbb5a21719d4d00244bdd9f0d0a2f8543580a016 Subproject commit 6a5d774c998d873071c551ad11d0e330fb2231e3

@ -1 +1 @@
Subproject commit f99e3265c5e7d6c45361b7d8dc03e772f66b0d4b Subproject commit 80d0bec0379a5208d7fb36933b1483e1603f5ec8

2
cmake

@ -1 +1 @@
Subproject commit cf652b845908a15c02e11dca3162f3eecca0a9c5 Subproject commit 0acdf4093ebae0026327b43b850e68225d046cb7

2
configure vendored
View file

@ -148,7 +148,6 @@ prefix=/usr/local/zeek
CMakeCacheEntries="" CMakeCacheEntries=""
append_cache_entry CMAKE_INSTALL_PREFIX PATH $prefix append_cache_entry CMAKE_INSTALL_PREFIX PATH $prefix
append_cache_entry ZEEK_ROOT_DIR PATH $prefix append_cache_entry ZEEK_ROOT_DIR PATH $prefix
append_cache_entry PY_MOD_INSTALL_DIR PATH $prefix/lib/zeekctl
append_cache_entry ZEEK_SCRIPT_INSTALL_PATH STRING $prefix/share/zeek append_cache_entry ZEEK_SCRIPT_INSTALL_PATH STRING $prefix/share/zeek
append_cache_entry ZEEK_ETC_INSTALL_DIR PATH $prefix/etc append_cache_entry ZEEK_ETC_INSTALL_DIR PATH $prefix/etc
append_cache_entry ENABLE_DEBUG BOOL false append_cache_entry ENABLE_DEBUG BOOL false
@ -203,7 +202,6 @@ while [ $# -ne 0 ]; do
prefix=$optarg prefix=$optarg
append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
append_cache_entry ZEEK_ROOT_DIR PATH $optarg append_cache_entry ZEEK_ROOT_DIR PATH $optarg
append_cache_entry PY_MOD_INSTALL_DIR PATH $optarg/lib/zeekctl
;; ;;
--libdir=*) --libdir=*)
append_cache_entry CMAKE_INSTALL_LIBDIR PATH $optarg append_cache_entry CMAKE_INSTALL_LIBDIR PATH $optarg

View file

@ -5,6 +5,7 @@ build_type=@CMAKE_BUILD_TYPE_LOWER@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
script_dir=@ZEEK_SCRIPT_INSTALL_PATH@ script_dir=@ZEEK_SCRIPT_INSTALL_PATH@
site_dir=@ZEEK_SCRIPT_INSTALL_PATH@/site site_dir=@ZEEK_SCRIPT_INSTALL_PATH@/site
lib_dir=@CMAKE_INSTALL_FULL_LIBDIR@
plugin_dir=@BRO_PLUGIN_INSTALL_PATH@ plugin_dir=@BRO_PLUGIN_INSTALL_PATH@
config_dir=@ZEEK_ETC_INSTALL_DIR@ config_dir=@ZEEK_ETC_INSTALL_DIR@
python_dir=@PY_MOD_INSTALL_DIR@ python_dir=@PY_MOD_INSTALL_DIR@
@ -24,7 +25,7 @@ include_dir=${include_dir}:@ZEEK_CONFIG_LibKrb5_INCLUDE_DIR@
include_dir=${include_dir}:@ZEEK_CONFIG_GooglePerftools_INCLUDE_DIR@ include_dir=${include_dir}:@ZEEK_CONFIG_GooglePerftools_INCLUDE_DIR@
usage="\ usage="\
Usage: zeek-config [--version] [--build_type] [--prefix] [--script_dir] [--site_dir] [--plugin_dir] [--config_dir] [--python_dir] [--include_dir] [--cmake_dir] [--zeekpath] [--zeek_dist] [--binpac_root] [--caf_root] [--broker_root]" Usage: zeek-config [--version] [--build_type] [--prefix] [--lib_dir] [--script_dir] [--site_dir] [--plugin_dir] [--config_dir] [--python_dir] [--include_dir] [--cmake_dir] [--zeekpath] [--zeek_dist] [--binpac_root] [--caf_root] [--broker_root]"
if [ $# -eq 0 ] ; then if [ $# -eq 0 ] ; then
echo "${usage}" 1>&2 echo "${usage}" 1>&2
@ -38,14 +39,44 @@ while [ $# -ne 0 ]; do
esac esac
case $1 in case $1 in
--version) --binpac_root)
echo $version echo $binpac_root
;;
--bro_dist) # For compatibility with legacy Bro plugins.
echo $zeek_dist
;;
--broker_root)
echo $broker_root
;;
--bropath) # For compatibility with legacy Bro plugins.
echo $zeekpath
;;
--build_type)
echo $build_type
;;
--caf_root)
echo $caf_root
;;
--cmake_dir)
echo $cmake_dir
;;
--config_dir)
echo $config_dir
;;
--include_dir)
echo $include_dir
;;
--lib_dir)
echo $lib_dir
;;
--plugin_dir)
echo $plugin_dir
;; ;;
--prefix) --prefix)
echo $prefix echo $prefix
;; ;;
--build_type) --python_dir)
echo $build_type echo $python_dir
;; ;;
--script_dir) --script_dir)
echo $script_dir echo $script_dir
@ -53,41 +84,14 @@ while [ $# -ne 0 ]; do
--site_dir) --site_dir)
echo $site_dir echo $site_dir
;; ;;
--plugin_dir) --version)
echo $plugin_dir echo $version
;;
--config_dir)
echo $config_dir
;;
--python_dir)
echo $python_dir
;;
--cmake_dir)
echo $cmake_dir
;;
--include_dir)
echo $include_dir
;;
--bropath) # For compatibility with legacy Bro plugins.
echo $zeekpath
;;
--zeekpath)
echo $zeekpath
;;
--bro_dist) # For compatibility with legacy Bro plugins.
echo $zeek_dist
;; ;;
--zeek_dist) --zeek_dist)
echo $zeek_dist echo $zeek_dist
;; ;;
--binpac_root) --zeekpath)
echo $binpac_root echo $zeekpath
;;
--caf_root)
echo $caf_root
;;
--broker_root)
echo $broker_root
;; ;;
*) *)
echo "${usage}" 1>&2 echo "${usage}" 1>&2