Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 fixDarwinDylibNames, 6 llvmPackages, 7 withOpenMP ? true, 8}: 9 10stdenv.mkDerivation rec { 11 pname = "libsvm"; 12 version = "3.33"; 13 14 src = fetchurl { 15 url = "https://www.csie.ntu.edu.tw/~cjlin/libsvm/libsvm-${version}.tar.gz"; 16 sha256 = "sha256-1doSzMPQ7thFP732+sfZ8AUvPopfB6IXTk7wqdg9zfg="; 17 }; 18 19 patches = lib.optionals withOpenMP [ ./openmp.patch ]; 20 21 buildInputs = lib.optionals (stdenv.cc.isClang && withOpenMP) [ llvmPackages.openmp ]; 22 23 buildFlags = [ 24 "lib" 25 "all" 26 ]; 27 28 outputs = [ 29 "out" 30 "bin" 31 "dev" 32 ]; 33 34 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ]; 35 36 installPhase = 37 let 38 libSuff = stdenv.hostPlatform.extensions.sharedLibrary; 39 soVersion = "3"; 40 libName = 41 if stdenv.hostPlatform.isDarwin then 42 "libsvm.${soVersion}${libSuff}" 43 else 44 "libsvm${libSuff}.${soVersion}"; 45 in 46 '' 47 runHook preInstall 48 49 install -D libsvm.so.${soVersion} $out/lib/${libName} 50 ln -s $out/lib/${libName} $out/lib/libsvm${libSuff} 51 52 install -Dt $bin/bin/ svm-scale svm-train svm-predict 53 54 install -Dm644 -t $dev/include svm.h 55 mkdir $dev/include/libsvm 56 ln -s $dev/include/svm.h $dev/include/libsvm/svm.h 57 58 runHook postInstall 59 ''; 60 61 meta = with lib; { 62 description = "Library for support vector machines"; 63 homepage = "https://www.csie.ntu.edu.tw/~cjlin/libsvm/"; 64 license = licenses.bsd3; 65 maintainers = [ ]; 66 platforms = platforms.unix; 67 }; 68}