Skip to content

Commit

Permalink
Merge pull request #221325 from Leixb/libsvm3.31
Browse files Browse the repository at this point in the history
libsvm: 3.25 -> 3.31
  • Loading branch information
wegank authored Mar 21, 2023
2 parents d671c86 + ee71bbc commit 2ab88f5
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 22 deletions.
60 changes: 38 additions & 22 deletions pkgs/development/libraries/libsvm/default.nix
Original file line number Diff line number Diff line change
@@ -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
'';

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
'';

postFixup = lib.optionalString stdenv.isDarwin ''
install_name_tool -id libsvm.2.dylib $out/lib/libsvm.2.dylib;
'';
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";
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";
Expand Down
13 changes: 13 additions & 0 deletions pkgs/development/libraries/libsvm/openmp.patch
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2ab88f5

Please sign in to comment.