2022-02-06 15:55:45 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2021-01-26 23:09:35 +00:00
|
|
|
, enableStatic ? stdenv.hostPlatform.isStatic
|
|
|
|
, enableShared ? !enableStatic
|
2022-02-06 15:55:45 +00:00
|
|
|
# Multi-threading with OpenMP is disabled by default
|
|
|
|
# more info on https://www.cryptopp.com/wiki/OpenMP
|
|
|
|
, withOpenMP ? false
|
|
|
|
, llvmPackages
|
2021-01-26 23:09:35 +00:00
|
|
|
}:
|
2008-07-29 14:26:03 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "crypto++";
|
2022-11-27 10:47:14 +00:00
|
|
|
version = "8.7.0";
|
2021-01-23 00:07:16 +00:00
|
|
|
underscoredVersion = lib.strings.replaceStrings ["."] ["_"] version;
|
2008-07-29 14:26:03 +00:00
|
|
|
|
2016-12-29 01:56:47 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "weidai11";
|
|
|
|
repo = "cryptopp";
|
2019-10-28 21:10:05 +00:00
|
|
|
rev = "CRYPTOPP_${underscoredVersion}";
|
2022-11-27 10:47:14 +00:00
|
|
|
hash = "sha256-KtZXW7+J9a4uKHnK8sqj5WVaIjG3d6tzBBDxa7Wv4AE=";
|
2008-07-29 14:26:03 +00:00
|
|
|
};
|
|
|
|
|
2021-01-26 23:09:35 +00:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2019-10-28 21:10:05 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace GNUmakefile \
|
2022-02-06 15:55:45 +00:00
|
|
|
--replace "AR = /usr/bin/libtool" "AR = ar" \
|
2021-12-19 23:04:57 +00:00
|
|
|
--replace "ARFLAGS = -static -o" "ARFLAGS = -cru"
|
2019-04-21 17:06:50 +00:00
|
|
|
'';
|
2015-06-27 08:28:31 +00:00
|
|
|
|
2022-02-06 15:55:45 +00:00
|
|
|
buildInputs = lib.optionals (stdenv.cc.isClang && withOpenMP) [ llvmPackages.openmp ];
|
|
|
|
|
2019-10-28 21:10:05 +00:00
|
|
|
makeFlags = [ "PREFIX=${placeholder "out"}" ];
|
2022-02-06 15:55:45 +00:00
|
|
|
|
2021-01-26 23:09:35 +00:00
|
|
|
buildFlags =
|
|
|
|
lib.optional enableStatic "static"
|
|
|
|
++ lib.optional enableShared "shared"
|
|
|
|
++ [ "libcryptopp.pc" ];
|
2022-02-06 15:55:45 +00:00
|
|
|
|
2019-10-28 21:10:05 +00:00
|
|
|
enableParallelBuilding = true;
|
2021-12-19 23:04:57 +00:00
|
|
|
hardeningDisable = [ "fortify" ];
|
2022-02-06 15:55:45 +00:00
|
|
|
CXXFLAGS = lib.optionals (withOpenMP) [ "-fopenmp" ];
|
2009-08-10 23:50:07 +00:00
|
|
|
|
|
|
|
doCheck = true;
|
2008-07-29 14:26:03 +00:00
|
|
|
|
2021-12-19 23:04:57 +00:00
|
|
|
# always built for checks but install static lib only when necessary
|
2022-01-07 10:36:33 +00:00
|
|
|
preInstall = lib.optionalString (!enableStatic) "rm -f libcryptopp.a";
|
2021-01-26 23:09:35 +00:00
|
|
|
|
2019-11-04 11:23:53 +00:00
|
|
|
installTargets = [ "install-lib" ];
|
2019-10-28 21:10:05 +00:00
|
|
|
installFlags = [ "LDCONF=true" ];
|
2015-06-27 08:28:31 +00:00
|
|
|
|
2022-02-06 15:55:45 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "A free C++ class library of cryptographic schemes";
|
2019-10-28 21:10:05 +00:00
|
|
|
homepage = "https://cryptopp.com/";
|
2022-02-06 15:55:45 +00:00
|
|
|
changelog = [
|
|
|
|
"https://raw.githubusercontent.com/weidai11/cryptopp/CRYPTOPP_${underscoredVersion}/History.txt"
|
|
|
|
"https://github.com/weidai11/cryptopp/releases/tag/CRYPTOPP_${underscoredVersion}"
|
|
|
|
];
|
|
|
|
license = with licenses; [ boost publicDomain ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ c0bw3b ];
|
2008-07-29 14:26:03 +00:00
|
|
|
};
|
2009-08-10 23:50:07 +00:00
|
|
|
}
|