class Ibex < Formula desc "C++ library for constraint processing over real numbers." homepage "http://www.ibex-lib.org/" url "https://github.com/ibex-team/ibex-lib/archive/ibex-2.5.3.tar.gz" sha256 "f5ae337c75f7d3c6a6eab5c97b772b59daebd89095628f6b1ee31c8f4a82139d" head "https://github.com/ibex-team/ibex-lib.git" bottle do cellar :any sha256 "c38ad8be624e34076dc3c5758a968932b777db0bd304135e77ccc3f8896c71f7" => :high_sierra sha256 "dc78f48056adc99205820e93f44f515be9a654e154bb5da02b70044a965d25de" => :sierra sha256 "3f0f1711cd85b1c9ef4a8acd94a8ff4fae566e22478bc716405b9751c7562ab8" => :el_capitan end option "with-java", "Enable Java bindings for CHOCO solver." option "with-ampl", "Use AMPL file loader plugin" option "without-ensta-robotics", "Don't build the Contractors for robotics (SLAM) plugin" depends_on :java => ["1.8+", :optional] depends_on "bison" => :build depends_on "flex" => :build depends_on "pkg-config" => :build needs :cxx11 def install ENV.cxx11 if build.with?("java") && build.with?("ampl") odie "Cannot set options --with-java and --with-ampl simultaneously for now." end args = %W[ --prefix=#{prefix} --enable-shared --with-optim --optim-lib=soplex ] args << "--with-jni" if build.with? "java" args << "--with-ampl" if build.with? "ampl" args << "--with-param-estim" if build.with? "param-estim" system "./waf", "configure", *args system "./waf", "install" pkgshare.install %w[examples benchs-solver] (pkgshare/"examples/symb01.txt").write <<-EOS.undent function f(x) return ((2*x,-x);(-x,3*x)); end EOS end test do cp_r (pkgshare/"examples").children, testpath cp pkgshare/"benchs-solver/others/cyclohexan3D.bch", testpath/"c3D.bch" # so that pkg-config can remain a build-time only dependency inreplace %w[makefile slam/makefile] do |s| s.gsub! /CXXFLAGS.*pkg-config --cflags ibex./, "CXXFLAGS := -I#{include} -I#{include}/ibex "\ "-I#{include}/ibex/3rd" s.gsub! /LIBS.*pkg-config --libs ibex./, "LIBS := -L#{lib} -libex" end system "make", "ctc01", "ctc02", "symb01" system "make", "-C", "slam", "slam1", "slam2", "slam3" %w[ctc01 ctc02 symb01].each { |a| system "./#{a}" } %w[slam1 slam2 slam3].each { |a| system "./slam/#{a}" } end end