@@ -1,6 +1,12 @@
1−{ lib, stdenv, fetchFromGitHub
1+{ lib
2+, stdenv
3+, fetchFromGitHub
24, enableStatic ? stdenv.hostPlatform.isStatic
35, enableShared ? !enableStatic
6+# Multi-threading with OpenMP is disabled by default
7+# more info on https://www.cryptopp.com/wiki/OpenMP
8+, withOpenMP ? false
9+, llvmPackages
410}:
511
612stdenv.mkDerivation rec {
@@ -19,17 +25,22 @@ stdenv.mkDerivation rec {
1925
2026 postPatch = ''
2127 substituteInPlace GNUmakefile \
22− --replace "AR = libtool" "AR = ar" \
28+ --replace "AR = /usr/bin/libtool" "AR = ar" \
2329 --replace "ARFLAGS = -static -o" "ARFLAGS = -cru"
2430 '';
2531
32+ buildInputs = lib.optionals (stdenv.cc.isClang && withOpenMP) [ llvmPackages.openmp ];
33+
2634 makeFlags = [ "PREFIX=${placeholder "out"}" ];
35+
2736 buildFlags =
2837 lib.optional enableStatic "static"
2938 ++ lib.optional enableShared "shared"
3039 ++ [ "libcryptopp.pc" ];
40+
3141 enableParallelBuilding = true;
3242 hardeningDisable = [ "fortify" ];
43+ CXXFLAGS = lib.optionals (withOpenMP) [ "-fopenmp" ];
3344
3445 doCheck = true;
3546
@@ -38,17 +49,21 @@ stdenv.mkDerivation rec {
3849
3950 installTargets = [ "install-lib" ];
4051 installFlags = [ "LDCONF=true" ];
52+ # TODO: remove postInstall hook with v8.7 -> https://github.com/weidai11/cryptopp/commit/230c558a
4153 postInstall = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
4254 ln -sr $out/lib/libcryptopp.so.${version} $out/lib/libcryptopp.so.${lib.versions.majorMinor version}
4355 ln -sr $out/lib/libcryptopp.so.${version} $out/lib/libcryptopp.so.${lib.versions.major version}
4456 '';
4557
46− meta = {
47− description = "Crypto++, a free C++ class library of cryptographic schemes";
58+ meta = with lib; {
59+ description = "A free C++ class library of cryptographic schemes";
4860 homepage = "https://cryptopp.com/";
49− changelog = "https://raw.githubusercontent.com/weidai11/cryptopp/CRYPTOPP_${underscoredVersion}/History.txt";
50− license = with lib.licenses; [ boost publicDomain ];
51− platforms = lib.platforms.all;
52− maintainers = with lib.maintainers; [ c0bw3b ];
61+ changelog = [
62+ "https://raw.githubusercontent.com/weidai11/cryptopp/CRYPTOPP_${underscoredVersion}/History.txt"
63+ "https://github.com/weidai11/cryptopp/releases/tag/CRYPTOPP_${underscoredVersion}"
64+ ];
65+ license = with licenses; [ boost publicDomain ];
66+ platforms = platforms.all;
67+ maintainers = with maintainers; [ c0bw3b ];
5368 };
5469}