2021-01-21 17:00:13 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, autoconf, automake, libtool, pkg-config }:
|
2018-05-11 16:00:48 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "libb2";
|
2019-03-23 10:57:47 +00:00
|
|
|
version = "0.98.1";
|
2015-08-23 18:00:31 +01:00
|
|
|
|
2019-03-23 10:57:47 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "BLAKE2";
|
|
|
|
repo = "libb2";
|
|
|
|
rev = "v${version}";
|
|
|
|
sha256 = "0qj8aaqvfcavj1vj5asm4pqm03ap7q8x4c2fy83cqggvky0frgya";
|
libbb2: Use "--enable-fat=yes" to avoid build nondeterminism
Otherwise it would pick various -march flags based on the CPU of the
compiling system, using beautiful code like this:
````
63 AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
64 [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
65 int op = $1, eax, ebx, ecx, edx;
66 FILE *f;
67 __asm__("cpuid"
68 : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
69 : "a" (op));
70 f = fopen("conftest_cpuid", "w"); if (!f) return 1;
71 fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
72 fclose(f);
73 return 0;
74 ])],
...
121 AC_CACHE_CHECK([whether avx is supported], [ax_cv_have_avx_ext],
122 [
123 ax_cv_have_avx_ext=no
124 if test "$((0x$ecx>>28&0x01))" = 1; then
125 ax_cv_have_avx_ext=yes
126 fi
127 ])
````
2016-08-30 20:34:40 +01:00
|
|
|
};
|
|
|
|
|
2018-05-11 16:00:48 +01:00
|
|
|
preConfigure = ''
|
|
|
|
patchShebangs autogen.sh
|
|
|
|
./autogen.sh
|
|
|
|
'';
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
configureFlags = lib.optional stdenv.hostPlatform.isx86 "--enable-fat=yes";
|
libbb2: Use "--enable-fat=yes" to avoid build nondeterminism
Otherwise it would pick various -march flags based on the CPU of the
compiling system, using beautiful code like this:
````
63 AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
64 [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
65 int op = $1, eax, ebx, ecx, edx;
66 FILE *f;
67 __asm__("cpuid"
68 : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
69 : "a" (op));
70 f = fopen("conftest_cpuid", "w"); if (!f) return 1;
71 fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
72 fclose(f);
73 return 0;
74 ])],
...
121 AC_CACHE_CHECK([whether avx is supported], [ax_cv_have_avx_ext],
122 [
123 ax_cv_have_avx_ext=no
124 if test "$((0x$ecx>>28&0x01))" = 1; then
125 ax_cv_have_avx_ext=yes
126 fi
127 ])
````
2016-08-30 20:34:40 +01:00
|
|
|
|
2019-03-23 10:57:47 +00:00
|
|
|
nativeBuildInputs = [ autoconf automake libtool pkg-config ];
|
2018-05-11 16:00:48 +01:00
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
meta = with lib; {
|
2015-08-23 18:00:31 +01:00
|
|
|
description = "The BLAKE2 family of cryptographic hash functions";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://blake2.net/";
|
2015-08-23 18:00:31 +01:00
|
|
|
platforms = platforms.all;
|
2019-03-23 10:57:47 +00:00
|
|
|
maintainers = with maintainers; [ dfoxfranke dotlambda ];
|
2015-08-23 18:00:31 +01:00
|
|
|
license = licenses.cc0;
|
|
|
|
};
|
|
|
|
}
|