homebrew-core/Formula/ipopt.rb

89 lines
3.1 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.13.4.tar.gz"
sha256 "1fdd0f8ea637856d66b1ebdd7d52ad1b8b8c1142d1a4ce0976b200ab280e5683"
license "EPL-1.0"
revision 1
head "https://github.com/coin-or/Ipopt.git"
bottle do
sha256 arm64_big_sur: "396ad371e6974a1e7e5b45bcc881eea080762619e073a8b27a0ec6720e09ca9d"
sha256 cellar: :any, big_sur: "2ac8289bea324aec494ef909a7f9930b26dbb2c909689d3c075d97bac3068fe4"
sha256 cellar: :any, catalina: "1ba7c81476a17c12070c5b4c8e4ea960103635edbb9bcaf990f97f151d689071"
sha256 cellar: :any, mojave: "cfac31a9a99ff0ccb1c3bcbc95bc105f50ea33b1fef6b3878ddbfca05d2a65be"
end
depends_on "openjdk" => :build
depends_on "pkg-config" => [:build, :test]
depends_on "ampl-mp"
depends_on "gcc"
depends_on "openblas"
resource "mumps" do
url "http://mumps.enseeiht.fr/MUMPS_5.3.5.tar.gz"
sha256 "e5d665fdb7043043f0799ae3dbe3b37e5b200d1ab7a6f7b2a4e463fd89507fa4"
# MUMPS does not provide a Makefile.inc customized for macOS.
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/ab96a8b8e510a8a022808a9be77174179ac79e85/ipopt/mumps-makefile-inc-generic-seq.patch"
sha256 "0c570ee41299073ec2232ad089d8ee10a2010e6dfc9edc28f66912dae6999d75"
end
end
resource "test" do
url "https://github.com/coin-or/Ipopt/archive/releases/3.13.4.tar.gz"
sha256 "1fdd0f8ea637856d66b1ebdd7d52ad1b8b8c1142d1a4ce0976b200ab280e5683"
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}/"
# 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