diff --git a/pkgs/development/libraries/science/math/mkl/default.nix b/pkgs/development/libraries/science/math/mkl/default.nix index 7cbc50bc5b37..7b91940033dd 100644 --- a/pkgs/development/libraries/science/math/mkl/default.nix +++ b/pkgs/development/libraries/science/math/mkl/default.nix @@ -1,4 +1,5 @@ -{ stdenvNoCC +{ callPackage +, stdenvNoCC , fetchurl , rpmextract , undmg @@ -157,6 +158,8 @@ in stdenvNoCC.mkDerivation { dontStrip = true; dontPatchELF = true; + passthru.tests.pkg-config = callPackage ./test { }; + meta = with stdenvNoCC.lib; { description = "Intel Math Kernel Library"; longDescription = '' diff --git a/pkgs/development/libraries/science/math/mkl/test/default.nix b/pkgs/development/libraries/science/math/mkl/test/default.nix new file mode 100644 index 000000000000..688c0ec7c399 --- /dev/null +++ b/pkgs/development/libraries/science/math/mkl/test/default.nix @@ -0,0 +1,33 @@ +{ stdenv, pkg-config, mkl }: + +stdenv.mkDerivation { + pname = "mkl-test"; + version = mkl.version; + + src = ./.; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ mkl ]; + + doCheck = true; + + buildPhase = '' + # Check regular Nix build. + gcc $(pkg-config --cflags --libs mkl-dynamic-ilp64-seq) test.c -o test + + # Clear flags to ensure that we are purely relying on options + # provided by pkg-config. + NIX_CFLAGS_COMPILE="" \ + NIX_LDFLAGS="" \ + gcc $(pkg-config --cflags --libs mkl-dynamic-ilp64-seq) test.c -o test + ''; + + installPhase = '' + touch $out + ''; + + checkPhase = '' + ./test + ''; +} diff --git a/pkgs/development/libraries/science/math/mkl/test/test.c b/pkgs/development/libraries/science/math/mkl/test/test.c new file mode 100644 index 000000000000..9413ac0c68e9 --- /dev/null +++ b/pkgs/development/libraries/science/math/mkl/test/test.c @@ -0,0 +1,12 @@ +#include + +#include + +int main() { + float u[] = {1., 2., 3.}; + float v[] = {4., 5., 6.}; + + float dp = cblas_sdot(3, u, 1, v, 1); + + assert(dp == 32.); +}