1{
2 lib,
3 stdenv,
4 fetchurl,
5}:
6
7stdenv.mkDerivation rec {
8 pname = "levmar";
9 version = "2.6";
10
11 src = fetchurl {
12 url = "https://www.ics.forth.gr/~lourakis/levmar/${pname}-${version}.tgz";
13 sha256 = "1mxsjip9x782z6qa6k5781wjwpvj5aczrn782m9yspa7lhgfzx1v";
14 };
15
16 patchPhase = ''
17 substituteInPlace levmar.h --replace "define HAVE_LAPACK" "undef HAVE_LAPACK"
18 sed -i 's/LAPACKLIBS=.*/LAPACKLIBS=/' Makefile
19 substituteInPlace Makefile --replace "gcc" "${stdenv.cc.targetPrefix}cc"
20 '';
21
22 installPhase = ''
23 mkdir -p $out/include $out/lib
24 cp lm.h $out/include
25 cp liblevmar.a $out/lib
26 '';
27
28 meta = {
29 description = "ANSI C implementations of Levenberg-Marquardt, usable also from C++";
30 homepage = "https://www.ics.forth.gr/~lourakis/levmar/";
31 license = lib.licenses.gpl2Plus;
32 platforms = lib.platforms.all;
33 };
34}