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