nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05 69 lines 2.3 kB view raw
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 10}: 11 12stdenv.mkDerivation rec { 13 pname = "crypto++"; 14 version = "8.6.0"; 15 underscoredVersion = lib.strings.replaceStrings ["."] ["_"] version; 16 17 src = fetchFromGitHub { 18 owner = "weidai11"; 19 repo = "cryptopp"; 20 rev = "CRYPTOPP_${underscoredVersion}"; 21 hash = "sha256-a3TYaK34WvKEXN7LKAfGwQ3ZL6a3k/zMZyyVfnkQqO4="; 22 }; 23 24 outputs = [ "out" "dev" ]; 25 26 postPatch = '' 27 substituteInPlace GNUmakefile \ 28 --replace "AR = /usr/bin/libtool" "AR = ar" \ 29 --replace "ARFLAGS = -static -o" "ARFLAGS = -cru" 30 ''; 31 32 buildInputs = lib.optionals (stdenv.cc.isClang && withOpenMP) [ llvmPackages.openmp ]; 33 34 makeFlags = [ "PREFIX=${placeholder "out"}" ]; 35 36 buildFlags = 37 lib.optional enableStatic "static" 38 ++ lib.optional enableShared "shared" 39 ++ [ "libcryptopp.pc" ]; 40 41 enableParallelBuilding = true; 42 hardeningDisable = [ "fortify" ]; 43 CXXFLAGS = lib.optionals (withOpenMP) [ "-fopenmp" ]; 44 45 doCheck = true; 46 47 # always built for checks but install static lib only when necessary 48 preInstall = lib.optionalString (!enableStatic) "rm -f libcryptopp.a"; 49 50 installTargets = [ "install-lib" ]; 51 installFlags = [ "LDCONF=true" ]; 52 # TODO: remove postInstall hook with v8.7 -> https://github.com/weidai11/cryptopp/commit/230c558a 53 postInstall = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 54 ln -sr $out/lib/libcryptopp.so.${version} $out/lib/libcryptopp.so.${lib.versions.majorMinor version} 55 ln -sr $out/lib/libcryptopp.so.${version} $out/lib/libcryptopp.so.${lib.versions.major version} 56 ''; 57 58 meta = with lib; { 59 description = "A free C++ class library of cryptographic schemes"; 60 homepage = "https://cryptopp.com/"; 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 ]; 68 }; 69}