4 , enableStatic ? stdenv.hostPlatform.isStatic
5 , enableShared ? !enableStatic
6 # Multi-threading with OpenMP is disabled by default
7 # more info on https://www.cryptopp.com/wiki/OpenMP
12 stdenv.mkDerivation rec {
15 underscoredVersion = lib.strings.replaceStrings ["."] ["_"] version;
17 src = fetchFromGitHub {
20 rev = "CRYPTOPP_${underscoredVersion}";
21 hash = "sha256-HV+afSFkiXdy840JbHBTR8lLL0GMwsN3QdwaoQmicpQ=";
24 outputs = [ "out" "dev" ];
27 substituteInPlace GNUmakefile \
28 --replace "AR = /usr/bin/libtool" "AR = ar" \
29 --replace "ARFLAGS = -static -o" "ARFLAGS = -cru"
32 buildInputs = lib.optionals (stdenv.cc.isClang && withOpenMP) [ llvmPackages.openmp ];
34 makeFlags = [ "PREFIX=${placeholder "out"}" ];
37 lib.optional enableStatic "static"
38 ++ lib.optional enableShared "shared"
39 ++ [ "libcryptopp.pc" ];
41 enableParallelBuilding = true;
42 hardeningDisable = [ "fortify" ];
43 CXXFLAGS = lib.optionals (withOpenMP) [ "-fopenmp" ];
47 # always built for checks but install static lib only when necessary
48 preInstall = lib.optionalString (!enableStatic) "rm -f libcryptopp.a";
50 installTargets = [ "install-lib" ];
51 installFlags = [ "LDCONF=true" ];
54 description = "Free C++ class library of cryptographic schemes";
55 homepage = "https://cryptopp.com/";
57 "https://raw.githubusercontent.com/weidai11/cryptopp/CRYPTOPP_${underscoredVersion}/History.txt"
58 "https://github.com/weidai11/cryptopp/releases/tag/CRYPTOPP_${underscoredVersion}"
60 license = with licenses; [ boost publicDomain ];
61 platforms = platforms.all;
62 maintainers = with maintainers; [ c0bw3b ];