hyperscan: build chimera in static build

This commit is contained in:
Maksym Balatsko 2023-09-30 14:41:14 -07:00 committed by Yt
parent 76a8ec168c
commit 053e4b089c

View file

@ -1,14 +1,16 @@
{ lib, stdenv, fetchFromGitHub, cmake, ragel, python3
, util-linux, fetchpatch
{ lib
, stdenv
, fetchFromGitHub
, cmake
, ragel
, python3
, util-linux
, pkg-config
, boost
, pcre
, withStatic ? false # build only shared libs by default, build static+shared if true
}:
# NOTICE: pkg-config, pcap and pcre intentionally omitted from build inputs
# pcap used only in examples, pkg-config used only to check for pcre
# which is fixed 8.41 version requirement (nixpkgs have 8.42+, and
# I not see any reason (for now) to backport 8.41.
stdenv.mkDerivation (finalAttrs: {
pname = "hyperscan";
version = "5.4.2";
@ -24,7 +26,7 @@ stdenv.mkDerivation (finalAttrs: {
buildInputs = [ boost ];
nativeBuildInputs = [
cmake ragel python3 util-linux
cmake ragel python3 util-linux pkg-config
];
cmakeFlags = [
@ -34,6 +36,14 @@ stdenv.mkDerivation (finalAttrs: {
++ lib.optional (withStatic) "-DBUILD_STATIC_AND_SHARED=ON"
++ lib.optional (!withStatic) "-DBUILD_SHARED_LIBS=ON";
# hyperscan CMake is completely broken for chimera builds when pcre is compiled
# the only option to make it build - building from source
# In case pcre is built from source, chimera build is turned on by default
preConfigure = lib.optional withStatic ''
mkdir -p pcre
tar xvf ${pcre.src} --strip-components 1 -C pcre
'';
postPatch = ''
sed -i '/examples/d' CMakeLists.txt
substituteInPlace libhs.pc.in \
@ -46,6 +56,7 @@ stdenv.mkDerivation (finalAttrs: {
runHook preCheck
bin/unit-hyperscan
${lib.optionalString withStatic ''bin/unit-chimera''}
runHook postCheck
'';