98 lines
3.8 KiB
Ruby
98 lines
3.8 KiB
Ruby
class Ipopt < Formula
|
|
desc "Interior point optimizer"
|
|
homepage "https://coin-or.github.io/Ipopt/"
|
|
url "https://github.com/coin-or/Ipopt/archive/releases/3.14.9.tar.gz"
|
|
sha256 "e12eba451269ec30f4cf6e2acb8b35399f0d029c97dff10465416f5739c8cf7a"
|
|
license "EPL-2.0"
|
|
head "https://github.com/coin-or/Ipopt.git", branch: "stable/3.14"
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "92d079f60349b7cf736ad0d735e5b963c803fe304cd982f991881d566eb4d825"
|
|
sha256 cellar: :any, arm64_big_sur: "f873f1ed005cfcf664b91c496529ce2f275d349d3616be7e1f2efc0998d8fff2"
|
|
sha256 cellar: :any, monterey: "1bed93a1fd80a81acd34fc03e118a299fa1804dc9bfdb4861320675316672927"
|
|
sha256 cellar: :any, big_sur: "73662a54cb6d0b693e16c3488e281197f9085bb32b1225989f01eef3cdbd90ea"
|
|
sha256 cellar: :any, catalina: "0bfa306e0a52253f26340259d1852efbf7c36e5ac8837f975bb12683af5be0be"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "e0b4cd0f198bd3a071566e3d7742b69910b8de99b8055905ec21820bafb72e39"
|
|
end
|
|
|
|
depends_on "openjdk" => :build
|
|
depends_on "pkg-config" => [:build, :test]
|
|
depends_on "ampl-mp"
|
|
depends_on "gcc" # for gfortran
|
|
depends_on "openblas"
|
|
|
|
resource "mumps" do
|
|
url "http://mumps.enseeiht.fr/MUMPS_5.5.0.tar.gz"
|
|
sha256 "e54d17c5e42a36c40607a03279e0704d239d71d38503aab68ef3bfe0a9a79c13"
|
|
|
|
patch do
|
|
# MUMPS does not provide a Makefile.inc customized for macOS.
|
|
on_macos do
|
|
url "https://raw.githubusercontent.com/Homebrew/formula-patches/ab96a8b8e510a8a022808a9be77174179ac79e85/ipopt/mumps-makefile-inc-generic-seq.patch"
|
|
sha256 "0c570ee41299073ec2232ad089d8ee10a2010e6dfc9edc28f66912dae6999d75"
|
|
end
|
|
|
|
on_linux do
|
|
url "https://gist.githubusercontent.com/dawidd6/09f831daf608eb6e07cc80286b483030/raw/b5ab689dea5772e9b6a8b6d88676e8d76224c0cc/mumps-homebrew-linux.patch"
|
|
sha256 "13125be766a22aec395166bf015973f5e4d82cd3329c87895646f0aefda9e78e"
|
|
end
|
|
end
|
|
end
|
|
|
|
resource "test" do
|
|
url "https://github.com/coin-or/Ipopt/archive/releases/3.14.9.tar.gz"
|
|
sha256 "e12eba451269ec30f4cf6e2acb8b35399f0d029c97dff10465416f5739c8cf7a"
|
|
end
|
|
|
|
def install
|
|
ENV.delete("MPICC")
|
|
ENV.delete("MPICXX")
|
|
ENV.delete("MPIFC")
|
|
|
|
resource("mumps").stage do
|
|
cp "Make.inc/Makefile.inc.generic.SEQ", "Makefile.inc"
|
|
inreplace "Makefile.inc", "@rpath/", "#{opt_lib}/" if OS.mac?
|
|
|
|
# Fix for GCC 10
|
|
inreplace "Makefile.inc", "OPTF = -fPIC",
|
|
"OPTF = -fPIC -fallow-argument-mismatch"
|
|
|
|
ENV.deparallelize { system "make", "d" }
|
|
|
|
(buildpath/"mumps_include").install Dir["include/*.h", "libseq/mpi.h"]
|
|
lib.install Dir[
|
|
"lib/#{shared_library("*")}",
|
|
"libseq/#{shared_library("*")}",
|
|
"PORD/lib/#{shared_library("*")}"
|
|
]
|
|
end
|
|
|
|
args = [
|
|
"--disable-debug",
|
|
"--disable-dependency-tracking",
|
|
"--disable-silent-rules",
|
|
"--enable-shared",
|
|
"--prefix=#{prefix}",
|
|
"--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas",
|
|
"--with-mumps-cflags=-I#{buildpath}/mumps_include",
|
|
"--with-mumps-lflags=-L#{lib} -ldmumps -lmpiseq -lmumps_common -lopenblas -lpord",
|
|
"--with-asl-cflags=-I#{Formula["ampl-mp"].opt_include}/asl",
|
|
"--with-asl-lflags=-L#{Formula["ampl-mp"].opt_lib} -lasl",
|
|
]
|
|
|
|
system "./configure", *args
|
|
system "make"
|
|
|
|
ENV.deparallelize
|
|
system "make", "install"
|
|
end
|
|
|
|
test do
|
|
testpath.install resource("test")
|
|
pkg_config_flags = `pkg-config --cflags --libs ipopt`.chomp.split
|
|
system ENV.cxx, "examples/hs071_cpp/hs071_main.cpp", "examples/hs071_cpp/hs071_nlp.cpp", *pkg_config_flags
|
|
system "./a.out"
|
|
system "#{bin}/ipopt", "#{Formula["ampl-mp"].opt_pkgshare}/example/wb"
|
|
end
|
|
end
|