1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5}:
6
7let
8 soVersion = "5";
9in
10stdenv.mkDerivation rec {
11 pname = "liblinear";
12 version = "2.47";
13
14 src = fetchFromGitHub {
15 owner = "cjlin1";
16 repo = "liblinear";
17 rev = "v${builtins.replaceStrings [ "." ] [ "" ] version}";
18 sha256 = "sha256-so7uCc/52NdN0V2Ska8EUdw/wSegaudX5AF+c0xe5jk=";
19 };
20
21 makeFlags = [
22 "AR=${stdenv.cc.targetPrefix}ar"
23 "RANLIB=${stdenv.cc.targetPrefix}ranlib"
24 ];
25
26 outputs = [
27 "bin"
28 "dev"
29 "out"
30 ];
31
32 buildFlags = [
33 "lib"
34 "predict"
35 "train"
36 ];
37
38 installPhase = ''
39 ${
40 if stdenv.hostPlatform.isDarwin then
41 ''
42 install -D liblinear.so.${soVersion} $out/lib/liblinear.${soVersion}.dylib
43 ln -s $out/lib/liblinear.${soVersion}.dylib $out/lib/liblinear.dylib
44 ''
45 else
46 ''
47 install -Dt $out/lib liblinear.so.${soVersion}
48 ln -s $out/lib/liblinear.so.${soVersion} $out/lib/liblinear.so
49 ''
50 }
51 install -D train $bin/bin/liblinear-train
52 install -D predict $bin/bin/liblinear-predict
53 install -Dm444 -t $dev/include linear.h
54 '';
55
56 meta = with lib; {
57 description = "Library for large linear classification";
58 homepage = "https://www.csie.ntu.edu.tw/~cjlin/liblinear/";
59 license = licenses.bsd3;
60 maintainers = [ ];
61 platforms = platforms.unix;
62 };
63}