btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / cr / cryptopp / package.nix
blob741e9677f7102efb2fbb3455d12f40b8688a1a34
1 { lib
2 , stdenv
3 , fetchFromGitHub
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
8 , withOpenMP ? false
9 , llvmPackages
12 stdenv.mkDerivation rec {
13   pname = "crypto++";
14   version = "8.9.0";
15   underscoredVersion = lib.strings.replaceStrings ["."] ["_"] version;
17   src = fetchFromGitHub {
18     owner = "weidai11";
19     repo = "cryptopp";
20     rev = "CRYPTOPP_${underscoredVersion}";
21     hash = "sha256-HV+afSFkiXdy840JbHBTR8lLL0GMwsN3QdwaoQmicpQ=";
22   };
24   outputs = [ "out" "dev" ];
26   postPatch = ''
27     substituteInPlace GNUmakefile \
28       --replace "AR = /usr/bin/libtool" "AR = ar" \
29       --replace "ARFLAGS = -static -o" "ARFLAGS = -cru"
30   '';
32   buildInputs = lib.optionals (stdenv.cc.isClang && withOpenMP) [ llvmPackages.openmp ];
34   makeFlags = [ "PREFIX=${placeholder "out"}" ];
36   buildFlags =
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" ];
45   doCheck = true;
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" ];
53   meta = with lib; {
54     description = "Free C++ class library of cryptographic schemes";
55     homepage = "https://cryptopp.com/";
56     changelog = [
57       "https://raw.githubusercontent.com/weidai11/cryptopp/CRYPTOPP_${underscoredVersion}/History.txt"
58       "https://github.com/weidai11/cryptopp/releases/tag/CRYPTOPP_${underscoredVersion}"
59     ];
60     license = with licenses; [ boost publicDomain ];
61     platforms = platforms.all;
62     maintainers = with maintainers; [ c0bw3b ];
63   };