2022-02-06 16:55:45 +01:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2021-01-27 00:09:35 +01:00
|
|
|
, enableStatic ? stdenv.hostPlatform.isStatic
|
|
|
|
, enableShared ? !enableStatic
|
2022-02-06 16:55:45 +01:00
|
|
|
# Multi-threading with OpenMP is disabled by default
|
|
|
|
# more info on https://www.cryptopp.com/wiki/OpenMP
|
|
|
|
, withOpenMP ? false
|
|
|
|
, llvmPackages
|
2021-01-27 00:09:35 +01:00
|
|
|
}:
|
2008-07-29 16:26:03 +02:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "crypto++";
|
2021-12-20 00:04:57 +01:00
|
|
|
version = "8.6.0";
|
2021-01-23 01:07:16 +01:00
|
|
|
underscoredVersion = lib.strings.replaceStrings ["."] ["_"] version;
|
2008-07-29 16:26:03 +02:00
|
|
|
|
2016-12-29 02:56:47 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "weidai11";
|
|
|
|
repo = "cryptopp";
|
2019-10-28 22:10:05 +01:00
|
|
|
rev = "CRYPTOPP_${underscoredVersion}";
|
2021-12-20 00:04:57 +01:00
|
|
|
hash = "sha256-a3TYaK34WvKEXN7LKAfGwQ3ZL6a3k/zMZyyVfnkQqO4=";
|
2008-07-29 16:26:03 +02:00
|
|
|
};
|
|
|
|
|
2021-01-27 00:09:35 +01:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2019-10-28 22:10:05 +01:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace GNUmakefile \
|
2022-02-06 16:55:45 +01:00
|
|
|
--replace "AR = /usr/bin/libtool" "AR = ar" \
|
2021-12-20 00:04:57 +01:00
|
|
|
--replace "ARFLAGS = -static -o" "ARFLAGS = -cru"
|
2019-04-21 19:06:50 +02:00
|
|
|
'';
|
2015-06-27 10:28:31 +02:00
|
|
|
|
2022-02-06 16:55:45 +01:00
|
|
|
buildInputs = lib.optionals (stdenv.cc.isClang && withOpenMP) [ llvmPackages.openmp ];
|
|
|
|
|
2019-10-28 22:10:05 +01:00
|
|
|
makeFlags = [ "PREFIX=${placeholder "out"}" ];
|
2022-02-06 16:55:45 +01:00
|
|
|
|
2021-01-27 00:09:35 +01:00
|
|
|
buildFlags =
|
|
|
|
lib.optional enableStatic "static"
|
|
|
|
++ lib.optional enableShared "shared"
|
|
|
|
++ [ "libcryptopp.pc" ];
|
2022-02-06 16:55:45 +01:00
|
|
|
|
2019-10-28 22:10:05 +01:00
|
|
|
enableParallelBuilding = true;
|
2021-12-20 00:04:57 +01:00
|
|
|
hardeningDisable = [ "fortify" ];
|
2022-02-06 16:55:45 +01:00
|
|
|
CXXFLAGS = lib.optionals (withOpenMP) [ "-fopenmp" ];
|
2009-08-11 01:50:07 +02:00
|
|
|
|
|
|
|
doCheck = true;
|
2008-07-29 16:26:03 +02:00
|
|
|
|
2021-12-20 00:04:57 +01:00
|
|
|
# always built for checks but install static lib only when necessary
|
2022-01-07 11:36:33 +01:00
|
|
|
preInstall = lib.optionalString (!enableStatic) "rm -f libcryptopp.a";
|
2021-01-27 00:09:35 +01:00
|
|
|
|
2019-11-04 12:23:53 +01:00
|
|
|
installTargets = [ "install-lib" ];
|
2019-10-28 22:10:05 +01:00
|
|
|
installFlags = [ "LDCONF=true" ];
|
2022-02-06 16:55:45 +01:00
|
|
|
# TODO: remove postInstall hook with v8.7 -> https://github.com/weidai11/cryptopp/commit/230c558a
|
2021-01-23 01:07:16 +01:00
|
|
|
postInstall = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
|
|
|
|
ln -sr $out/lib/libcryptopp.so.${version} $out/lib/libcryptopp.so.${lib.versions.majorMinor version}
|
|
|
|
ln -sr $out/lib/libcryptopp.so.${version} $out/lib/libcryptopp.so.${lib.versions.major version}
|
2016-09-29 23:07:56 +02:00
|
|
|
'';
|
2015-06-27 10:28:31 +02:00
|
|
|
|
2022-02-06 16:55:45 +01:00
|
|
|
meta = with lib; {
|
|
|
|
description = "A free C++ class library of cryptographic schemes";
|
2019-10-28 22:10:05 +01:00
|
|
|
homepage = "https://cryptopp.com/";
|
2022-02-06 16:55:45 +01: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 16:26:03 +02:00
|
|
|
};
|
2009-08-11 01:50:07 +02:00
|
|
|
}
|