2023-03-24 00:07:29 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, fixDarwinDylibNames
|
|
|
|
, llvmPackages
|
|
|
|
, withOpenMP ? true
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libsvm";
|
2023-08-04 22:07:22 +00:00
|
|
|
version = "3.32";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://www.csie.ntu.edu.tw/~cjlin/libsvm/libsvm-${version}.tar.gz";
|
2023-08-04 22:07:22 +00:00
|
|
|
sha256 = "sha256-hkTMZRjKiLvFDYyOrRc08aubbxcBcEXvmuOHc6plPa0=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
patches = lib.optionals withOpenMP [ ./openmp.patch ];
|
|
|
|
|
|
|
|
buildInputs = lib.optionals (stdenv.cc.isClang && withOpenMP) [ llvmPackages.openmp ];
|
|
|
|
|
|
|
|
buildFlags = [ "lib" "all" ];
|
|
|
|
|
|
|
|
outputs = [ "out" "bin" "dev" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = lib.optionals stdenv.isDarwin [ fixDarwinDylibNames ];
|
|
|
|
|
|
|
|
installPhase =
|
|
|
|
let
|
|
|
|
libSuff = stdenv.hostPlatform.extensions.sharedLibrary;
|
|
|
|
soVersion = "3";
|
2024-01-13 08:15:51 +00:00
|
|
|
libName = if stdenv.isDarwin then "libsvm.${soVersion}${libSuff}" else "libsvm${libSuff}.${soVersion}";
|
2023-03-24 00:07:29 +00:00
|
|
|
in
|
|
|
|
''
|
|
|
|
runHook preInstall
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
install -D libsvm.so.${soVersion} $out/lib/${libName}
|
|
|
|
ln -s $out/lib/${libName} $out/lib/libsvm${libSuff}
|
2023-03-24 00:07:29 +00:00
|
|
|
|
|
|
|
install -Dt $bin/bin/ svm-scale svm-train svm-predict
|
|
|
|
|
|
|
|
install -Dm644 -t $dev/include svm.h
|
|
|
|
mkdir $dev/include/libsvm
|
|
|
|
ln -s $dev/include/svm.h $dev/include/libsvm/svm.h
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A library for support vector machines";
|
|
|
|
homepage = "https://www.csie.ntu.edu.tw/~cjlin/libsvm/";
|
|
|
|
license = licenses.bsd3;
|
2023-05-24 13:37:59 +00:00
|
|
|
maintainers = [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|