base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / li / libsvm / package.nix
blob1fd5141c9084f16b67ee6bada4463bfcc030fcbd
1 { lib
2 , stdenv
3 , fetchurl
4 , fixDarwinDylibNames
5 , llvmPackages
6 , withOpenMP ? true
7 }:
9 stdenv.mkDerivation rec {
10   pname = "libsvm";
11   version = "3.33";
13   src = fetchurl {
14     url = "https://www.csie.ntu.edu.tw/~cjlin/libsvm/libsvm-${version}.tar.gz";
15     sha256 = "sha256-1doSzMPQ7thFP732+sfZ8AUvPopfB6IXTk7wqdg9zfg=";
16   };
18   patches = lib.optionals withOpenMP [ ./openmp.patch ];
20   buildInputs = lib.optionals (stdenv.cc.isClang && withOpenMP) [ llvmPackages.openmp ];
22   buildFlags = [ "lib" "all" ];
24   outputs = [ "out" "bin" "dev" ];
26   nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ];
28   installPhase =
29     let
30       libSuff = stdenv.hostPlatform.extensions.sharedLibrary;
31       soVersion = "3";
32       libName = if stdenv.hostPlatform.isDarwin then "libsvm.${soVersion}${libSuff}" else "libsvm${libSuff}.${soVersion}";
33     in
34     ''
35       runHook preInstall
37       install -D libsvm.so.${soVersion} $out/lib/${libName}
38       ln -s $out/lib/${libName} $out/lib/libsvm${libSuff}
40       install -Dt $bin/bin/ svm-scale svm-train svm-predict
42       install -Dm644 -t $dev/include svm.h
43       mkdir $dev/include/libsvm
44       ln -s $dev/include/svm.h $dev/include/libsvm/svm.h
46       runHook postInstall
47     '';
49   meta = with lib; {
50     description = "Library for support vector machines";
51     homepage = "https://www.csie.ntu.edu.tw/~cjlin/libsvm/";
52     license = licenses.bsd3;
53     maintainers = [ ];
54     platforms = platforms.unix;
55   };