btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / cr / crc32c / package.nix
blob07da71e326706869b6017b90a0b99d4f8b0f733f
1 { stdenv
2 , lib
3 , fetchFromGitHub
4 , cmake
5 , gflags
6 , staticOnly ? stdenv.hostPlatform.isStatic
7 }:
9 stdenv.mkDerivation rec {
10   pname = "crc32c";
11   version = "1.1.2";
13   src = fetchFromGitHub {
14     owner = "google";
15     repo = "crc32c";
16     rev = version;
17     sha256 = "0c383p7vkfq9rblww6mqxz8sygycyl27rr0j3bzb8l8ga71710ii";
18     fetchSubmodules = true;
19   };
21   nativeBuildInputs = [ cmake ];
22   buildInputs = [ gflags ];
24   env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isAarch64 "-march=armv8-a+crc";
26   cmakeFlags = [
27     "-DCRC32C_INSTALL=1"
28     "-DCRC32C_BUILD_TESTS=1"
29     "-DCRC32C_BUILD_BENCHMARKS=0"
30     "-DCRC32C_USE_GLOG=0"
31     "-DINSTALL_GTEST=0"
32     "-DBUILD_SHARED_LIBS=${if staticOnly then "0" else "1"}"
33   ];
35   doCheck = false;
36   doInstallCheck = true;
38   installCheckPhase = ''
39     runHook preInstallCheck
41     ctest
43     runHook postInstallCheck
44   '';
46   postFixup = ''
47     # fix bogus include paths
48     for f in $(find $out/lib/cmake -name '*.cmake'); do
49       substituteInPlace "$f" --replace "\''${_IMPORT_PREFIX}/$out/include" "\''${_IMPORT_PREFIX}/include"
50     done
51   '';
53   meta = with lib; {
54     homepage = "https://github.com/google/crc32c";
55     description = "CRC32C implementation with support for CPU-specific acceleration instructions";
56     license = with licenses; [ bsd3 ];
57     maintainers = with maintainers; [ cpcloud ];
58   };