Merge pull request #221325 from Leixb/libsvm3.31

libsvm: 3.25 -> 3.31
This commit is contained in:
Weijia Wang 2023-03-21 09:13:56 +02:00 committed by GitHub
commit 2ab88f51f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 20 deletions

View File

@ -1,33 +1,49 @@
{lib, stdenv, fetchurl}:
{ lib
, stdenv
, fetchurl
, fixDarwinDylibNames
, llvmPackages
, withOpenMP ? true
}:
stdenv.mkDerivation rec {
pname = "libsvm";
version = "3.25";
version = "3.31";
src = fetchurl {
url = "https://www.csie.ntu.edu.tw/~cjlin/libsvm/libsvm-${version}.tar.gz";
sha256 = "sha256-UjUOiqdAsXbh13Pp3AjxNAIYw34BvsN6uQ2wEn5LteU=";
sha256 = "sha256-AKtWH0jfX8kqhCCa2P5Rmery5Rmzwnm6z8k1l4p1zx8=";
};
buildPhase = ''
make
make lib
'';
patches = lib.optionals withOpenMP [ ./openmp.patch ];
installPhase = let
libSuff = stdenv.hostPlatform.extensions.sharedLibrary;
in ''
install -D libsvm.so.2 $out/lib/libsvm.2${libSuff}
ln -s $out/lib/libsvm.2${libSuff} $out/lib/libsvm${libSuff}
install -Dt $out/bin/ svm-scale svm-train svm-predict
install -Dm644 -t $out/include svm.h
mkdir $out/include/libsvm
ln -s $out/include/svm.h $out/include/libsvm/svm.h
'';
buildInputs = lib.optionals (stdenv.cc.isClang && withOpenMP) [ llvmPackages.openmp ];
postFixup = lib.optionalString stdenv.isDarwin ''
install_name_tool -id libsvm.2.dylib $out/lib/libsvm.2.dylib;
'';
buildFlags = [ "lib" "all" ];
outputs = [ "out" "bin" "dev" ];
nativeBuildInputs = lib.optionals stdenv.isDarwin [ fixDarwinDylibNames ];
installPhase =
let
libSuff = stdenv.hostPlatform.extensions.sharedLibrary;
soVersion = "3";
in
''
runHook preInstall
install -D libsvm.so.${soVersion} $out/lib/libsvm.${soVersion}${libSuff}
ln -s $out/lib/libsvm.${soVersion}${libSuff} $out/lib/libsvm${libSuff}
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
'';
meta = with lib; {
description = "A library for support vector machines";

View File

@ -0,0 +1,13 @@
--- /Makefile 1970-01-01 01:00:01.000000000 +0100
+++ /Makefile 1970-01-01 01:00:01.000000000 +0100
@@ -9,8 +9,8 @@
endif
# Uncomment the following lines to enable parallelization with OpenMP
-# CFLAGS += -fopenmp
-# SHARED_LIB_FLAG += -fopenmp
+CFLAGS += -fopenmp
+SHARED_LIB_FLAG += -fopenmp
all: svm-train svm-predict svm-scale