From 514c8569aaaba59af30b06ee8d0418a9d64baa68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Mancilla?= Date: Fri, 13 Aug 2021 20:49:15 -0400 Subject: [PATCH] lp_solve: 5.5.2.5 -> 5.5.2.11 - Use the generic builder and override build and install phases instead of using buildCommand and missing phases and hooks, like fixup. - Fix build on Darwin by using the proper build script (ccc.osx). - Add cctools to build inputs because ccc.osx uses the libtool command. - The install_name of the library is not set so fix it with fixDarwinDylibNames. - Install headers into the expected location $out/include/lpsolve instead of $out/include. This follows what other distro do. --- .../science/math/lp_solve/default.nix | 61 ++++++++++--------- .../science/math/lp_solve/isnan.patch | 13 ---- pkgs/top-level/all-packages.nix | 4 +- 3 files changed, 35 insertions(+), 43 deletions(-) delete mode 100644 pkgs/applications/science/math/lp_solve/isnan.patch diff --git a/pkgs/applications/science/math/lp_solve/default.nix b/pkgs/applications/science/math/lp_solve/default.nix index f944499af401..876222772e86 100644 --- a/pkgs/applications/science/math/lp_solve/default.nix +++ b/pkgs/applications/science/math/lp_solve/default.nix @@ -1,40 +1,45 @@ -{ lib, stdenv, fetchurl }: +{ lib, stdenv, fetchurl, cctools, fixDarwinDylibNames }: stdenv.mkDerivation rec { pname = "lp_solve"; - version = "5.5.2.5"; + version = "5.5.2.11"; src = fetchurl { url = "mirror://sourceforge/project/lpsolve/lpsolve/${version}/lp_solve_${version}_source.tar.gz"; - sha256 = "12pj1idjz31r7c2mb5w03vy1cmvycvbkx9z29s40qdmkp1i7q6i0"; + sha256 = "sha256-bUq/9cxqqpM66ObBeiJt8PwLZxxDj2lxXUHQn+gfkC8="; }; - patches = [ ./isnan.patch ]; + nativeBuildInputs = lib.optionals stdenv.isDarwin [ + cctools + fixDarwinDylibNames + ]; - buildCommand = '' - . $stdenv/setup - tar xvfz $src - ( - cd lp_solve* - eval patchPhase - ) - ( - cd lp_solve*/lpsolve55 - bash ccc - mkdir -pv $out/lib - find bin -type f -exec cp -v "{}" $out/lib \; - ) - ( - cd lp_solve*/lp_solve - bash ccc - mkdir -pv $out/bin - find bin -type f -exec cp -v "{}" $out/bin \; - ) - ( - mkdir -pv $out/include - cp -v lp_solve*/*.h $out/include - ) + dontConfigure = true; + + buildPhase = let + ccc = if stdenv.isDarwin then "ccc.osx" else "ccc"; + in '' + runHook preBuild + + (cd lpsolve55 && bash -x -e ${ccc}) + (cd lp_solve && bash -x -e ${ccc}) + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + install -d -m755 $out/bin $out/lib $out/include/lpsolve + install -m755 lp_solve/bin/*/lp_solve -t $out/bin + install -m644 lpsolve55/bin/*/liblpsolve* -t $out/lib + install -m644 lp_*.h -t $out/include/lpsolve + + rm $out/lib/liblpsolve*.a + rm $out/include/lpsolve/lp_solveDLL.h # A Windows header + + runHook postInstall ''; meta = with lib; { @@ -44,6 +49,4 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ smironov ]; platforms = platforms.unix; }; - } - diff --git a/pkgs/applications/science/math/lp_solve/isnan.patch b/pkgs/applications/science/math/lp_solve/isnan.patch deleted file mode 100644 index bc1983d4423d..000000000000 --- a/pkgs/applications/science/math/lp_solve/isnan.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff -u a/lp_lib.h b/lp_lib.h ---- a/lp_lib.h 2016-05-04 19:45:15.753143720 +0900 -+++ b/lp_lib.h 2016-05-04 19:53:59.536920722 +0900 -@@ -59,9 +59,6 @@ - # if defined _WIN32 && !defined __GNUC__ - # define isnan _isnan - # endif --#if defined NOISNAN --# define isnan(x) FALSE --#endif - - #define SETMASK(variable, mask) variable |= mask - #define CLEARMASK(variable, mask) variable &= ~(mask) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8d6d2b4248ee..b4e341f1851e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4910,7 +4910,9 @@ with pkgs; libbtbb = callPackage ../development/libraries/libbtbb { }; - lp_solve = callPackage ../applications/science/math/lp_solve { }; + lp_solve = callPackage ../applications/science/math/lp_solve { + inherit (darwin) cctools; + }; fabric-installer = callPackage ../tools/games/minecraft/fabric-installer { };