Merge pull request #186878 from gdinh/libamplsolver-darwin
This commit is contained in:
commit
71df9f98fc
3 changed files with 47 additions and 9 deletions
|
@ -5,7 +5,7 @@
|
|||
, blas
|
||||
, lapack
|
||||
, gfortran
|
||||
, enableAMPL ? stdenv.isLinux, libamplsolver
|
||||
, enableAMPL ? true, libamplsolver
|
||||
}:
|
||||
|
||||
assert (!blas.isILP64) && (!lapack.isILP64);
|
||||
|
|
|
@ -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 ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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
|
Loading…
Reference in a new issue