Merge pull request #206954 from Homebrew/bump-gollama-1.28.13
[homebrew-core.git] / Formula / d / dynare.rb
blob4df3662d94a06fb7575a8764852991c961ac962a
1 class Dynare < Formula
2   desc "Platform for economic models, particularly DSGE and OLG models"
3   homepage "https://www.dynare.org/"
4   url "https://www.dynare.org/release/source/dynare-6.2.tar.xz"
5   sha256 "312a3358bb0735f09b13f996e2d32cfd297292201897c1075c399554398862d9"
6   license "GPL-3.0-or-later"
7   revision 1
8   head "https://git.dynare.org/Dynare/dynare.git", branch: "master"
10   livecheck do
11     url "https://www.dynare.org/download/"
12     regex(/href=.*?dynare[._-]v?(\d+(?:\.\d+)+)\.t/i)
13   end
15   bottle do
16     sha256 cellar: :any, arm64_sonoma:  "a28cf6cccc0742692b0ef65f2411d5cde1abab467a579a83ee91d336f4a1f2e2"
17     sha256 cellar: :any, arm64_ventura: "9994ff061b2773818e0a16a4ab32da40261cb36cec135814386fea99f6b4d769"
18     sha256 cellar: :any, sonoma:        "f96ef72dc64a4d3fb109011e6c679e456995f8479e9e70b7d26e4869227103ea"
19     sha256 cellar: :any, ventura:       "7f8415a3c363e8ef1b0cd96c845118ba6dcadc57535db928d9062cf9870a9a1f"
20     sha256               x86_64_linux:  "da55fcfc0628121ec2fb1a85832ac6aeca1f485b1b31334b8848b49b5c33586d"
21   end
23   depends_on "bison" => :build
24   depends_on "boost" => :build
25   depends_on "cweb" => :build
26   depends_on "flex" => :build
27   depends_on "meson" => :build
28   depends_on "ninja" => :build
29   depends_on "pkgconf" => :build
30   depends_on "fftw"
31   depends_on "gcc"
32   depends_on "gsl"
33   depends_on "hdf5"
34   depends_on "libmatio"
35   depends_on "metis"
36   depends_on "octave"
37   depends_on "openblas"
38   depends_on "suite-sparse"
40   fails_with :clang do
41     cause <<~EOS
42       GCC is the only compiler supported by upstream
43       https://git.dynare.org/Dynare/dynare/-/blob/master/README.md#general-instructions
44     EOS
45   end
47   resource "slicot" do
48     url "https://deb.debian.org/debian/pool/main/s/slicot/slicot_5.0+20101122.orig.tar.gz"
49     sha256 "fa80f7c75dab6bfaca93c3b374c774fd87876f34fba969af9133eeaea5f39a3d"
50   end
52   def install
53     resource("slicot").stage do
54       system "make", "lib", "OPTS=-fPIC", "SLICOTLIB=../libslicot_pic.a",
55              "FORTRAN=gfortran", "LOADER=gfortran"
56       system "make", "clean"
57       system "make", "lib", "OPTS=-fPIC -fdefault-integer-8",
58              "FORTRAN=gfortran", "LOADER=gfortran",
59              "SLICOTLIB=../libslicot64_pic.a"
60       (buildpath/"slicot/lib").install "libslicot_pic.a", "libslicot64_pic.a"
61     end
63     # Work around used in upstream builds which helps avoid runtime preprocessor error.
64     # https://git.dynare.org/Dynare/dynare/-/blob/master/macOS/homebrew-native-arm64.ini
65     ENV.append "LDFLAGS", "-Wl,-ld_classic" if DevelopmentTools.clang_build_version >= 1500
67     # Help meson find `suite-sparse` and `slicot`
68     ENV.append_path "LIBRARY_PATH", Formula["suite-sparse"].opt_lib
69     ENV.append_path "LIBRARY_PATH", buildpath/"slicot/lib"
71     system "meson", "setup", "build", "-Dbuild_for=octave", *std_meson_args
72     system "meson", "compile", "-C", "build", "--verbose"
73     system "meson", "install", "-C", "build"
74     (pkgshare/"examples").install "examples/bkk.mod"
75   end
77   def caveats
78     <<~EOS
79       To get started with Dynare, open Octave and type
80         addpath #{opt_lib}/dynare/matlab
81     EOS
82   end
84   test do
85     resource "statistics" do
86       url "https://github.com/gnu-octave/statistics/archive/refs/tags/release-1.6.5.tar.gz", using: :nounzip
87       sha256 "0ea8258c92ce67e1bb75a9813b7ceb56fff1dacf6c47236d3da776e27b684cee"
88     end
90     ENV.cxx11
91     ENV.delete "LDFLAGS" # avoid overriding Octave flags
93     # Work around Xcode 15.0 ld error with GCC: https://github.com/Homebrew/homebrew-core/issues/145991
94     if OS.mac? && (MacOS::Xcode.version.to_s.start_with?("15.0") || MacOS::CLT.version.to_s.start_with?("15.0"))
95       ENV["LDFLAGS"] = shell_output("#{Formula["octave"].opt_bin}/mkoctfile --print LDFLAGS").chomp
96       ENV.append "LDFLAGS", "-Wl,-ld_classic"
97     end
99     statistics = resource("statistics")
100     testpath.install statistics
102     cp pkgshare/"examples/bkk.mod", testpath
104     # Replace `makeinfo` with dummy command `true` to prevent generating docs
105     # that are not useful to the test.
106     (testpath/"dyn_test.m").write <<~MATLAB
107       makeinfo_program true
108       pkg prefix #{testpath}/octave
109       pkg install statistics-release-#{statistics.version}.tar.gz
110       dynare bkk.mod console
111     MATLAB
113     system Formula["octave"].opt_bin/"octave", "--no-gui",
114            "--no-history", "--path", "#{lib}/dynare/matlab", "dyn_test.m"
115   end