homebrew-core/Formula/dynare.rb

146 lines
5.3 KiB
Ruby

class Dynare < Formula
desc "Platform for economic models, particularly DSGE and OLG models"
homepage "https://www.dynare.org/"
license "GPL-3.0-or-later"
revision 2
# Remove when patch is no longer needed.
stable do
url "https://www.dynare.org/release/source/dynare-5.3.tar.xz"
sha256 "bbbbd319f9a1cb7ffd4f7012be105a7c95842ca76d9d96e96305e1fbf8d8b585"
on_arm do
# Needed since we patch a `Makefile.am` below.
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "bison" => :build
depends_on "flex" => :build
# Fixes a build error on ARM.
# Remove the `Hardware::CPU.arm?` in the `autoreconf` call below when this is removed.
patch do
url "https://git.dynare.org/Dynare/preprocessor/-/commit/e0c3cb72b7337a5eecd32a77183af9f1609a86ef.diff"
sha256 "4fe156dce78fba9ec280bceff66f263c3a9dbcd230cc5bac96b5a59c14c7554f"
directory "preprocessor"
end
end
end
livecheck do
url "https://www.dynare.org/download/"
regex(/href=.*?dynare[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 cellar: :any, arm64_ventura: "20b37989736c67662aeec515d46f406848806b131625a857edd0799b4d7fb94c"
sha256 cellar: :any, arm64_monterey: "9d92d3a6d5fead8e034412fbaf5cdd8669bcd0940f1f95334816e8349c5a185b"
sha256 cellar: :any, arm64_big_sur: "ff54521415a80c326677f6378f356fac93405c3a44e8007634e8857c13053e7e"
sha256 cellar: :any, ventura: "a2dfdd0a87012c4a5715a1635fe3f4dcdb4632042ec17e0d48bc1170ba0a0e1a"
sha256 cellar: :any, monterey: "231a9d587611bda8d78414e7ad4a3fcf3f949187a32805ba79aba4bad5e25b7e"
sha256 cellar: :any, big_sur: "16f608ae993d152a6e1dd3939e4f1aa34cf3ac4fa736e1129e224613d3df5d75"
end
head do
url "https://git.dynare.org/Dynare/dynare.git", branch: "master"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "bison" => :build
depends_on "flex" => :build
end
depends_on "boost" => :build
depends_on "cweb" => :build
depends_on "fftw"
depends_on "gcc"
depends_on "gsl"
depends_on "hdf5"
depends_on "libmatio"
depends_on "metis"
depends_on "octave"
depends_on "openblas"
depends_on "suite-sparse"
resource "slicot" do
url "https://deb.debian.org/debian/pool/main/s/slicot/slicot_5.0+20101122.orig.tar.gz"
sha256 "fa80f7c75dab6bfaca93c3b374c774fd87876f34fba969af9133eeaea5f39a3d"
end
resource "homebrew-io" do
url "https://octave.sourceforge.io/download.php?package=io-2.6.4.tar.gz", using: :nounzip
sha256 "a74a400bbd19227f6c07c585892de879cd7ae52d820da1f69f1a3e3e89452f5a"
end
resource "homebrew-statistics" do
url "https://octave.sourceforge.io/download.php?package=statistics-1.4.3.tar.gz", using: :nounzip
sha256 "9801b8b4feb26c58407c136a9379aba1e6a10713829701bb3959d9473a67fa05"
end
def install
ENV.cxx11
resource("slicot").stage do
system "make", "lib", "OPTS=-fPIC", "SLICOTLIB=../libslicot_pic.a",
"FORTRAN=gfortran", "LOADER=gfortran"
system "make", "clean"
system "make", "lib", "OPTS=-fPIC -fdefault-integer-8",
"FORTRAN=gfortran", "LOADER=gfortran",
"SLICOTLIB=../libslicot64_pic.a"
(buildpath/"slicot/lib").install "libslicot_pic.a", "libslicot64_pic.a"
end
# GCC is the only compiler supported by upstream
# https://git.dynare.org/Dynare/dynare/-/blob/master/README.md#general-instructions
gcc = Formula["gcc"]
gcc_major_ver = gcc.any_installed_version.major
ENV["CC"] = Formula["gcc"].opt_bin/"gcc-#{gcc_major_ver}"
ENV["CXX"] = Formula["gcc"].opt_bin/"g++-#{gcc_major_ver}"
ENV.append "LDFLAGS", "-static-libgcc"
# Remove `Hardware::CPU.arm?` when the patch is no longer needed.
system "autoreconf", "--force", "--install", "--verbose" if build.head? || Hardware::CPU.arm?
system "./configure", *std_configure_args,
"--disable-silent-rules",
"--disable-doc",
"--disable-matlab",
"--with-boost=#{Formula["boost"].prefix}",
"--with-gsl=#{Formula["gsl"].prefix}",
"--with-matio=#{Formula["libmatio"].prefix}",
"--with-slicot=#{buildpath}/slicot"
# Octave hardcodes its paths which causes problems on GCC minor version bumps
flibs = "-L#{gcc.lib}/gcc/#{gcc_major_ver} -lgfortran -lquadmath -lm"
system "make", "install", "FLIBS=#{flibs}"
end
def caveats
<<~EOS
To get started with Dynare, open Octave and type
addpath #{opt_lib}/dynare/matlab
EOS
end
test do
ENV.cxx11
statistics = resource("homebrew-statistics")
io = resource("homebrew-io")
testpath.install statistics, io
cp lib/"dynare/examples/bkk.mod", testpath
# Replace `makeinfo` with dummy command `true` to prevent generating docs
# that are not useful to the test.
(testpath/"dyn_test.m").write <<~EOS
makeinfo_program true
pkg prefix #{testpath}/octave
pkg install io-#{io.version}.tar.gz
pkg install statistics-#{statistics.version}.tar.gz
dynare bkk.mod console
EOS
system Formula["octave"].opt_bin/"octave", "--no-gui",
"-H", "--path", "#{lib}/dynare/matlab", "dyn_test.m"
end
end