about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/science/math/libamplsolver/default.nix
blob: c0bc89b492ea2f14fbcd8913347db8fb98afa74a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ lib, stdenv, substitute, fetchurl, fetchpatch }:

stdenv.mkDerivation rec {
  pname = "libamplsolver";
  version = "20211109";

  src = fetchurl {
    url = "https://ampl.com/netlib/ampl/solvers.tgz";
    sha256 = "sha256-LVmScuIvxmZzywPSBl9T9YcUBJP7UFAa3eWs9r4q3JM=";
  };

  patches = [
    (substitute {
      src = ./libamplsolver-sharedlib.patch;
      replacements = [ "--replace" "@sharedlibext@" "${stdenv.hostPlatform.extensions.sharedLibrary}" ];
    })
  ];

  installPhase = ''
    runHook preInstall
    pushd sys.$(uname -m).$(uname -s)
    install -D -m 0644 *.h -t $out/include
    install -D -m 0644 *${stdenv.hostPlatform.extensions.sharedLibrary}* -t $out/lib
    install -D -m 0644 *.a -t $out/lib
    popd
  '' + lib.optionalString stdenv.isDarwin ''
    install_name_tool -id $out/lib/libamplsolver.dylib $out/lib/libamplsolver.dylib
  '' + ''
    runHook postInstall
  '';

  meta = with lib; {
    description = "A library of routines that help solvers work with AMPL";
    homepage = "https://ampl.com/netlib/ampl/";
    license = [ licenses.mit ];
    platforms = platforms.unix;
    maintainers = with maintainers; [ aanderse ];
  };
}