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"
8 head "https://git.dynare.org/Dynare/dynare.git", branch: "master"
11 url "https://www.dynare.org/download/"
12 regex(/href=.*?dynare[._-]v?(\d+(?:\.\d+)+)\.t/i)
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"
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
38 depends_on "suite-sparse"
42 GCC is the only compiler supported by upstream
43 https://git.dynare.org/Dynare/dynare/-/blob/master/README.md#general-instructions
48 url "https://deb.debian.org/debian/pool/main/s/slicot/slicot_5.0+20101122.orig.tar.gz"
49 sha256 "fa80f7c75dab6bfaca93c3b374c774fd87876f34fba969af9133eeaea5f39a3d"
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"
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"
79 To get started with Dynare, open Octave and type
80 addpath #{opt_lib}/dynare/matlab
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"
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"
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
113 system Formula["octave"].opt_bin/"octave", "--no-gui",
114 "--no-history", "--path", "#{lib}/dynare/matlab", "dyn_test.m"