From e3b3156995345042b0b5d08d86c7b94c22d80120 Mon Sep 17 00:00:00 2001 From: Grace Dinh Date: Tue, 23 Aug 2022 15:18:45 -0700 Subject: [PATCH 1/2] libamplsolver: add darwin support --- .../science/math/libamplsolver/default.nix | 15 ++++--- .../libamplsolver-sharedlib.patch | 39 +++++++++++++++++++ 2 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 pkgs/development/libraries/science/math/libamplsolver/libamplsolver-sharedlib.patch diff --git a/pkgs/development/libraries/science/math/libamplsolver/default.nix b/pkgs/development/libraries/science/math/libamplsolver/default.nix index bcbde5f61359..d6e9db9d341d 100644 --- a/pkgs/development/libraries/science/math/libamplsolver/default.nix +++ b/pkgs/development/libraries/science/math/libamplsolver/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, fetchpatch }: +{ lib, stdenv, substitute, fetchurl, fetchpatch }: stdenv.mkDerivation rec { pname = "libamplsolver"; @@ -10,18 +10,17 @@ stdenv.mkDerivation rec { }; patches = [ - # Debian provides a patch to build a shared library - (fetchpatch { - url = "https://sources.debian.org/data/main/liba/libamplsolver/0~20190702-2/debian/patches/fix-makefile-shared-lib.patch"; - sha256 = "sha256-96qwj3fLugzbsfxguKMce13cUo7XGC4VUE7xKcJs42Y="; + (substitute { + src = ./libamplsolver-sharedlib.patch; + replacements = [ "--replace" "@sharedlibext@" "${stdenv.hostPlatform.extensions.sharedLibrary}" ]; }) ]; installPhase = '' runHook preInstall - pushd sys.`uname -m`.`uname -s` + pushd sys.$(uname -m).$(uname -s) install -D -m 0644 *.h -t $out/include - install -D -m 0644 *.so* -t $out/lib + install -D -m 0644 *${stdenv.hostPlatform.extensions.sharedLibrary}* -t $out/lib install -D -m 0644 *.a -t $out/lib popd runHook postInstall @@ -31,7 +30,7 @@ stdenv.mkDerivation rec { description = "A library of routines that help solvers work with AMPL"; homepage = "https://ampl.com/netlib/ampl/"; license = [ licenses.mit ]; - platforms = platforms.linux; + platforms = platforms.unix; maintainers = with maintainers; [ aanderse ]; }; } diff --git a/pkgs/development/libraries/science/math/libamplsolver/libamplsolver-sharedlib.patch b/pkgs/development/libraries/science/math/libamplsolver/libamplsolver-sharedlib.patch new file mode 100644 index 000000000000..f2af2910e89c --- /dev/null +++ b/pkgs/development/libraries/science/math/libamplsolver/libamplsolver-sharedlib.patch @@ -0,0 +1,39 @@ +Authors: Andrei Rozanski and Grace Dinh +Last-Update: 2022-08-23 +Description: fix makefile.u in order to get libamplsover.so (Linux) or libamplsolver.dylib (Mac) + +--- a/makefile.u ++++ b/makefile.u + +@@ -26,8 +26,9 @@ + + .SUFFIXES: .c .o + CC = cc +-CFLAGS = -O ++CFLAGS := $(CFLAGS) -pipe -DASL_BUILD -fPIC -DPIC + SHELL=/bin/sh ++OFILES=$(addsuffix .o,$(basename $(a))) + + # Add -DNO_RUSAGE to the CFLAGS assignment if your system + # lacks getrusage(). This only matters for compiling xectim.c. +@@ -86,7 +87,7 @@ + .c.o: + $(CC) -c $(CFLAGS) $*.c + +-all: arith.h stdio1.h amplsolver.a funcadd0.o ++all: arith.h stdio1.h amplsolver.a funcadd0.o libamplsolver@sharedlibext@ + + a = \ + asldate.c \ +@@ -189,6 +190,11 @@ + # search path, e.g. + # exec true + # or just comment out the ranlib invocation above. ++libamplsolver.so: $(OFILES) ++ $(CC) $^ -shared -Wl,-soname,libamplsolver.so.0 $(LDFLAGS) -o $@.0 ++ ln -s $@.0 $@ ++libamplsolver.dylib: amplsolver.a ++ $(CC) -fpic -shared -Wl,-all_load amplsolver.a $(LDFLAGS) -o libamplsolver.dylib + + Aslh = arith.h asl.h funcadd.h stdio1.h + auxinfo.o libnamsave.o: funcadd.h stdio1.h \ No newline at end of file From a4f0975a2cb2b46384204fd17f658046c66ac115 Mon Sep 17 00:00:00 2001 From: Grace Dinh Date: Tue, 23 Aug 2022 15:19:22 -0700 Subject: [PATCH 2/2] ipopt: build with AMPL by default on darwin --- pkgs/development/libraries/science/math/ipopt/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/science/math/ipopt/default.nix b/pkgs/development/libraries/science/math/ipopt/default.nix index 325a6b82a6f9..f7d4714701bc 100644 --- a/pkgs/development/libraries/science/math/ipopt/default.nix +++ b/pkgs/development/libraries/science/math/ipopt/default.nix @@ -5,7 +5,7 @@ , blas , lapack , gfortran -, enableAMPL ? stdenv.isLinux, libamplsolver +, enableAMPL ? true, libamplsolver }: assert (!blas.isILP64) && (!lapack.isILP64);