summary refs log tree commit diff
path: root/pkgs/development/libraries
diff options
context:
space:
mode:
authorRenaud <c0bw3b@users.noreply.github.com>2022-02-06 16:55:45 +0100
committerc0bw3b <c0bw3b@users.noreply.github.com>2022-02-06 20:50:03 +0100
commit4c6d49282b1d63de6a2977a1d3ed97656cb58963 (patch)
tree5dc943bf4949b197f12d7d3070dbee5e458c0919 /pkgs/development/libraries
parent189f73465b9b1c7534e28e327283c4cdd34ddf41 (diff)
downloadnixpkgs-4c6d49282b1d63de6a2977a1d3ed97656cb58963.tar
nixpkgs-4c6d49282b1d63de6a2977a1d3ed97656cb58963.tar.gz
nixpkgs-4c6d49282b1d63de6a2977a1d3ed97656cb58963.tar.bz2
nixpkgs-4c6d49282b1d63de6a2977a1d3ed97656cb58963.tar.lz
nixpkgs-4c6d49282b1d63de6a2977a1d3ed97656cb58963.tar.xz
nixpkgs-4c6d49282b1d63de6a2977a1d3ed97656cb58963.tar.zst
nixpkgs-4c6d49282b1d63de6a2977a1d3ed97656cb58963.zip
cryptopp: add an option to build with OpenMP
and (attempt to) fix Darwin build
Diffstat (limited to 'pkgs/development/libraries')
-rw-r--r--pkgs/development/libraries/crypto++/default.nix31
1 files changed, 23 insertions, 8 deletions
diff --git a/pkgs/development/libraries/crypto++/default.nix b/pkgs/development/libraries/crypto++/default.nix
index c57525c01d9..a31a4472e1c 100644
--- a/pkgs/development/libraries/crypto++/default.nix
+++ b/pkgs/development/libraries/crypto++/default.nix
@@ -1,6 +1,12 @@
-{ lib, stdenv, fetchFromGitHub
+{ lib
+, stdenv
+, fetchFromGitHub
 , enableStatic ? stdenv.hostPlatform.isStatic
 , enableShared ? !enableStatic
+# Multi-threading with OpenMP is disabled by default
+# more info on https://www.cryptopp.com/wiki/OpenMP
+, withOpenMP ? false
+, llvmPackages
 }:
 
 stdenv.mkDerivation rec {
@@ -19,17 +25,22 @@ stdenv.mkDerivation rec {
 
   postPatch = ''
     substituteInPlace GNUmakefile \
-      --replace "AR = libtool" "AR = ar" \
+      --replace "AR = /usr/bin/libtool" "AR = ar" \
       --replace "ARFLAGS = -static -o" "ARFLAGS = -cru"
   '';
 
+  buildInputs = lib.optionals (stdenv.cc.isClang && withOpenMP) [ llvmPackages.openmp ];
+
   makeFlags = [ "PREFIX=${placeholder "out"}" ];
+
   buildFlags =
        lib.optional enableStatic "static"
     ++ lib.optional enableShared "shared"
     ++ [ "libcryptopp.pc" ];
+
   enableParallelBuilding = true;
   hardeningDisable = [ "fortify" ];
+  CXXFLAGS = lib.optionals (withOpenMP) [ "-fopenmp" ];
 
   doCheck = true;
 
@@ -38,17 +49,21 @@ stdenv.mkDerivation rec {
 
   installTargets = [ "install-lib" ];
   installFlags = [ "LDCONF=true" ];
+  # TODO: remove postInstall hook with v8.7 -> https://github.com/weidai11/cryptopp/commit/230c558a
   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}
   '';
 
-  meta = {
-    description = "Crypto++, a free C++ class library of cryptographic schemes";
+  meta = with lib; {
+    description = "A free C++ class library of cryptographic schemes";
     homepage = "https://cryptopp.com/";
-    changelog = "https://raw.githubusercontent.com/weidai11/cryptopp/CRYPTOPP_${underscoredVersion}/History.txt";
-    license = with lib.licenses; [ boost publicDomain ];
-    platforms = lib.platforms.all;
-    maintainers = with lib.maintainers; [ c0bw3b ];
+    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 ];
   };
 }