class Ipopt < Formula desc "Interior point optimizer" homepage "https://projects.coin-or.org/Ipopt/" url "https://www.coin-or.org/download/source/Ipopt/Ipopt-3.12.13.tgz" sha256 "aac9bb4d8a257fdfacc54ff3f1cbfdf6e2d61fb0cf395749e3b0c0664d3e7e96" revision 1 head "https://github.com/coin-or/Ipopt.git" bottle do cellar :any sha256 "ddbffa2920e589a6503a356a9637c64f837bec63a1e4e0b4577b825f93b9536e" => :mojave sha256 "58d0c8155fcc7299aa882707f03353af9ff3e19ecc317cc179c9728859e40f84" => :high_sierra sha256 "9e92954475a756d86ef366784f754932b5462b4ef5d08caa4474720cec12de5e" => :sierra end depends_on "pkg-config" => [:build, :test] depends_on "gcc" depends_on "openblas" resource "mumps" do url "http://mumps.enseeiht.fr/MUMPS_5.2.0.tar.gz" sha256 "41f2c7cb20d69599fb47e2ad6f628f3798c429f49e72e757e70722680f70853f" # MUMPS does not provide a Makefile.inc customized for macOS. patch do url "https://raw.githubusercontent.com/Homebrew/formula-patches/ab96a8b/ipopt/mumps-makefile-inc-generic-seq.patch" sha256 "0c570ee41299073ec2232ad089d8ee10a2010e6dfc9edc28f66912dae6999d75" end 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}/" ENV.deparallelize { system "make", "d" } (buildpath/"mumps_include").install Dir["include/*.h", "libseq/mpi.h"] lib.install Dir["lib/*.dylib", "libseq/*.dylib", "PORD/lib/*.dylib"] end args = [ "--disable-debug", "--disable-dependency-tracking", "--disable-silent-rules", "--enable-shared", "--prefix=#{prefix}", "--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas", "--with-mumps-incdir=#{buildpath}/mumps_include", "--with-mumps-lib=-L#{lib} -ldmumps -lmpiseq -lmumps_common -lopenblas -lpord", ] system "./configure", *args system "make" ENV.deparallelize system "make", "install" end test do (testpath/"test.cpp").write <<~EOS #include #include #include #include int main() { Ipopt::SmartPtr app = IpoptApplicationFactory(); const Ipopt::ApplicationReturnStatus status = app->Initialize(); assert(status == Ipopt::Solve_Succeeded); return 0; } EOS pkg_config_flags = `pkg-config --cflags --libs ipopt`.chomp.split system ENV.cxx, "test.cpp", *pkg_config_flags system "./a.out" end end