macOS installer: remove gcc option and local homebrew install

Fixes #1893
Closes #1894
Explain how to get Xcode CLT and gcc via homebrew in installer at the end using a conclusion.html file.
Clarify this also in the manual.
kalman-mex
Willi Mutschler 2023-10-11 17:23:42 +02:00
parent 9d95dadb13
commit de5b37fca7
No known key found for this signature in database
GPG Key ID: 91E724BF17A73F6D
12 changed files with 96 additions and 814 deletions

View File

@ -104,20 +104,8 @@ Note that several versions of Dynare can coexist (by default in
``/Applications/Dynare``), as long as you correctly adjust your path
settings (see :ref:`words-warning`).
By default, the installer installs a version of GCC (for use with :opt:`use_dll`)
in the installation directory, under the ``.brew`` folder. To do so, it also
installs a version of Homebrew_ in the same folder and
Xcode Command Line Tools (this is an Apple product) in a system folder.
All of this requires a bit of time and hard disk space. The amount of time it
takes will depend on your computing power and internet connection. To reduce
the time the Dynare installer takes, you can install Xcode Command Line Tools
yourself (see :ref:`prerequisites-macos`). Dynare, Homebrew, and GCC use
about 600 MB of disk space while the Xcode Command Line Tools require about 400
MB.
If you do not use the :opt:`use_dll` option, you have the choice to forgo the
installation of GCC and hence Dynare will only take about 50 MB of disk space.
It is recommended to install the Xcode Command Line Tools (this is an Apple product)
and gcc via Homebrew_ (see :ref:`prerequisites-macos`).
With Octave
^^^^^^^^^^^
@ -195,6 +183,12 @@ been installed on a system folder. To install the Xcode Command Line Tools
yourself, simply type ``xcode-select --install`` into the Terminal
(``/Applications/Utilities/Terminal.app``) prompt.
We recommend making use of optimized compilation flags when using :opt:`use_dll` and for this you need to install gcc via Homebrew_::
brew install gcc
If you already have installed gcc, Dynare will automatically prefer it for :opt:`use_dll` if the binaries are in /usr/local/bin.
Otherwise, it will fall back to Clang in /usr/bin/gcc.
With Octave
^^^^^^^^^^^

View File

@ -1,279 +0,0 @@
class Gcc < Formula
desc "GNU compiler collection"
homepage "https://gcc.gnu.org/"
license "GPL-3.0-or-later" => { with: "GCC-exception-3.1" }
head "https://gcc.gnu.org/git/gcc.git", branch: "master"
stable do
url "https://ftp.gnu.org/gnu/gcc/gcc-13.1.0/gcc-13.1.0.tar.xz"
mirror "https://ftpmirror.gnu.org/gcc/gcc-13.1.0/gcc-13.1.0.tar.xz"
sha256 "61d684f0aa5e76ac6585ad8898a2427aade8979ed5e7f85492286c4dfc13ee86"
# Branch from the Darwin maintainer of GCC, with a few generic fixes and
# Apple Silicon support, located at https://github.com/iains/gcc-13-branch
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/5c206c47/gcc/gcc-13.1.0.diff"
sha256 "cb4e8a89387f748a744da0273025d0dc2e3c76780cc390b18ada704676afea11"
end
end
livecheck do
url :stable
regex(%r{href=["']?gcc[._-]v?(\d+(?:\.\d+)+)(?:/?["' >]|\.t)}i)
end
bottle do
sha256 cellar: :any, arm64_ventura: "d2b21a257c73e9b8f9c6bc03e6330ea8ba9fb3e7cdb9eb945d7ff7d96ba9708c"
sha256 cellar: :any, arm64_monterey: "5405f3b1ecdabb68e161308f35d72af907af21694a0e2b67f10edb25b2dd8f90"
sha256 cellar: :any, arm64_big_sur: "cc92fced3516bc72b69e31b0495fe416f206b540be02f1c817db96afbcc38f28"
sha256 cellar: :any, ventura: "3abd8c2c88a8e74b5df5c44f9c151ff7e760cf705307ecf3c95762492e777f1e"
sha256 cellar: :any, monterey: "f9cbc7eb14781df9228518a2d02590941206947e7dc419c0b232d523f39b1475"
sha256 cellar: :any, big_sur: "2eb458ed309ea4fa9451ab547fa3d797bd523ba4f50f01d5c997212109b74e5e"
sha256 cellar: :any_skip_relocation, x86_64_linux: "cca77a5d6625d3bb711ce40551751974d4cb5c74306329fc2fc8cdcade2ef564"
end
# The bottles are built on systems with the CLT installed, and do not work
# out of the box on Xcode-only systems due to an incorrect sysroot.
pour_bottle? only_if: :clt_installed
depends_on "gmp"
depends_on "isl"
depends_on "libmpc"
depends_on "mpfr"
depends_on "zstd"
uses_from_macos "zlib"
on_linux do
depends_on "binutils"
end
# GCC bootstraps itself, so it is OK to have an incompatible C++ stdlib
cxxstdlib_check :skip
def version_suffix
if build.head?
"HEAD"
else
version.major.to_s
end
end
def install
# GCC will suffer build errors if forced to use a particular linker.
ENV.delete "LD"
# We avoiding building:
# - Ada and D, which require a pre-existing GCC to bootstrap
# - Go, currently not supported on macOS
# - BRIG
languages = %w[c c++ objc obj-c++ fortran]
pkgversion = "Homebrew GCC #{pkg_version} #{build.used_options*" "}".strip
# Use `lib/gcc/current` to provide a path that doesn't change with GCC's version.
args = %W[
--prefix=#{opt_prefix}
--libdir=#{opt_lib}/gcc/current
--disable-nls
--enable-checking=release
--with-gcc-major-version-only
--enable-languages=#{languages.join(",")}
--program-suffix=-#{version_suffix}
--with-gmp=#{Formula["gmp"].opt_prefix}
--with-mpfr=#{Formula["mpfr"].opt_prefix}
--with-mpc=#{Formula["libmpc"].opt_prefix}
--with-isl=#{Formula["isl"].opt_prefix}
--with-zstd=#{Formula["zstd"].opt_prefix}
--with-pkgversion=#{pkgversion}
--with-bugurl=#{tap.issues_url}
--with-system-zlib
]
if OS.mac?
cpu = Hardware::CPU.arm? ? "aarch64" : "x86_64"
args << "--build=#{cpu}-apple-darwin#{OS.kernel_version.major}"
# System headers may not be in /usr/include
sdk = MacOS.sdk_path_if_needed
args << "--with-sysroot=#{sdk}" if sdk
else
# Fix cc1: error while loading shared libraries: libisl.so.15
args << "--with-boot-ldflags=-static-libstdc++ -static-libgcc #{ENV.ldflags}"
# Fix Linux error: gnu/stubs-32.h: No such file or directory.
args << "--disable-multilib"
# Enable to PIE by default to match what the host GCC uses
args << "--enable-default-pie"
# Change the default directory name for 64-bit libraries to `lib`
# https://stackoverflow.com/a/54038769
inreplace "gcc/config/i386/t-linux64", "m64=../lib64", "m64="
end
mkdir "build" do
system "../configure", *args
system "make"
# Do not strip the binaries on macOS, it makes them unsuitable
# for loading plugins
install_target = OS.mac? ? "install" : "install-strip"
# To make sure GCC does not record cellar paths, we configure it with
# opt_prefix as the prefix. Then we use DESTDIR to install into a
# temporary location, then move into the cellar path.
system "make", install_target, "DESTDIR=#{Pathname.pwd}/../instdir"
mv Dir[Pathname.pwd/"../instdir/#{opt_prefix}/*"], prefix
end
bin.install_symlink bin/"gfortran-#{version_suffix}" => "gfortran"
# Provide a `lib/gcc/xy` directory to align with the versioned GCC formulae.
# We need to create `lib/gcc/xy` as a directory and not a symlink to avoid `brew link` conflicts.
(lib/"gcc"/version_suffix).install_symlink (lib/"gcc/current").children
# Only the newest brewed gcc should install gfortan libs as we can only have one.
lib.install_symlink lib.glob("gcc/current/libgfortran.*") if OS.linux?
# Handle conflicts between GCC formulae and avoid interfering
# with system compilers.
# Rename man7.
man7.glob("*.7") { |file| add_suffix file, version_suffix }
# Even when we disable building info pages some are still installed.
info.rmtree
# Work around GCC install bug
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105664
rm_rf bin.glob("*-gcc-tmp")
end
def add_suffix(file, suffix)
dir = File.dirname(file)
ext = File.extname(file)
base = File.basename(file, ext)
File.rename file, "#{dir}/#{base}-#{suffix}#{ext}"
end
def post_install
if OS.linux?
gcc = bin/"gcc-#{version_suffix}"
libgcc = Pathname.new(Utils.safe_popen_read(gcc, "-print-libgcc-file-name")).parent
raise "command failed: #{gcc} -print-libgcc-file-name" if $CHILD_STATUS.exitstatus.nonzero?
glibc = Formula["glibc"]
glibc_installed = glibc.any_version_installed?
# Symlink system crt1.o and friends where gcc can find it.
crtdir = if glibc_installed
glibc.opt_lib
else
Pathname.new(Utils.safe_popen_read("/usr/bin/cc", "-print-file-name=crti.o")).parent
end
ln_sf Dir[crtdir/"*crt?.o"], libgcc
# Create the GCC specs file
# See https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html
# Locate the specs file
specs = libgcc/"specs"
ohai "Creating the GCC specs file: #{specs}"
specs_orig = Pathname.new("#{specs}.orig")
rm_f [specs_orig, specs]
system_header_dirs = ["#{HOMEBREW_PREFIX}/include"]
if glibc_installed
# https://github.com/Linuxbrew/brew/issues/724
system_header_dirs << glibc.opt_include
else
# Locate the native system header dirs if user uses system glibc
target = Utils.safe_popen_read(gcc, "-print-multiarch").chomp
raise "command failed: #{gcc} -print-multiarch" if $CHILD_STATUS.exitstatus.nonzero?
system_header_dirs += ["/usr/include/#{target}", "/usr/include"]
end
# Save a backup of the default specs file
specs_string = Utils.safe_popen_read(gcc, "-dumpspecs")
raise "command failed: #{gcc} -dumpspecs" if $CHILD_STATUS.exitstatus.nonzero?
specs_orig.write specs_string
# Set the library search path
# For include path:
# * `-isysroot #{HOMEBREW_PREFIX}/nonexistent` prevents gcc searching built-in
# system header files.
# * `-idirafter <dir>` instructs gcc to search system header
# files after gcc internal header files.
# For libraries:
# * `-nostdlib -L#{libgcc} -L#{glibc.opt_lib}` instructs gcc to use
# brewed glibc if applied.
# * `-L#{libdir}` instructs gcc to find the corresponding gcc
# libraries. It is essential if there are multiple brewed gcc
# with different versions installed.
# Noted that it should only be passed for the `gcc@*` formulae.
# * `-L#{HOMEBREW_PREFIX}/lib` instructs gcc to find the rest
# brew libraries.
# Note: *link will silently add #{libdir} first to the RPATH
libdir = HOMEBREW_PREFIX/"lib/gcc/current"
specs.write specs_string + <<~EOS
*cpp_unique_options:
+ -isysroot #{HOMEBREW_PREFIX}/nonexistent #{system_header_dirs.map { |p| "-idirafter #{p}" }.join(" ")}
*link_libgcc:
#{glibc_installed ? "-nostdlib -L#{libgcc} -L#{glibc.opt_lib}" : "+"} -L#{libdir} -L#{HOMEBREW_PREFIX}/lib
*link:
+ --dynamic-linker #{HOMEBREW_PREFIX}/lib/ld.so -rpath #{libdir}
*homebrew_rpath:
-rpath #{HOMEBREW_PREFIX}/lib
EOS
inreplace(specs, " %o ", "\\0%(homebrew_rpath) ")
end
end
test do
(testpath/"hello-c.c").write <<~EOS
#include <stdio.h>
int main()
{
puts("Hello, world!");
return 0;
}
EOS
system "#{bin}/gcc-#{version_suffix}", "-o", "hello-c", "hello-c.c"
assert_equal "Hello, world!\n", shell_output("./hello-c")
(testpath/"hello-cc.cc").write <<~EOS
#include <iostream>
struct exception { };
int main()
{
std::cout << "Hello, world!" << std::endl;
try { throw exception{}; }
catch (exception) { }
catch (...) { }
return 0;
}
EOS
system "#{bin}/g++-#{version_suffix}", "-o", "hello-cc", "hello-cc.cc"
assert_equal "Hello, world!\n", shell_output("./hello-cc")
(testpath/"test.f90").write <<~EOS
integer,parameter::m=10000
real::a(m), b(m)
real::fact=0.5
do concurrent (i=1:m)
a(i) = a(i) + fact*b(i)
end do
write(*,"(A)") "Done"
end
EOS
system "#{bin}/gfortran", "-o", "test", "test.f90"
assert_equal "Done\n", shell_output("./test")
end
end

View File

@ -1,102 +0,0 @@
class Gmp < Formula
desc "GNU multiple precision arithmetic library"
homepage "https://gmplib.org/"
license any_of: ["LGPL-3.0-or-later", "GPL-2.0-or-later"]
revision 1
stable do
url "https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz"
mirror "https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz"
sha256 "fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2"
# Fix -flat_namespace being used on Big Sur and later.
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/03cf8088210822aa2c1ab544ed58ea04c897d9c4/libtool/configure-big_sur.diff"
sha256 "35acd6aebc19843f1a2b3a63e880baceb0f5278ab1ace661e57a502d9d78c93c"
end
end
livecheck do
url "https://gmplib.org/download/gmp/"
regex(/href=.*?gmp[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 cellar: :any, arm64_ventura: "2436cd120e5678d67c24020a50cbbf7c0220e7ecaac63981335872b9d666bcad"
sha256 cellar: :any, arm64_monterey: "a43a2ae4c44d90626b835a968a32327c8b8bbf754ec1d2590f8ac656c71dace9"
sha256 cellar: :any, arm64_big_sur: "491220f1ff2c662b96295d931a80702523eeaee681d7305fb02b561e527dcbb8"
sha256 cellar: :any, ventura: "4c6488dfd53b8287702827a4e6d50569926417f2cd08613d37720de54b6afe0c"
sha256 cellar: :any, monterey: "dddc6d8c871c92f6e5fb1249c28768aa2b4b47c38836a69cf787a639cf5eee73"
sha256 cellar: :any, big_sur: "e566452815d2ff5dc66da160bd1cd3d9cf02a17a07284cf0bac46496133383ae"
sha256 cellar: :any, catalina: "5ee7a460668864c28e541db15420e1480c3d31c5f216797a453a5310106fbc97"
sha256 cellar: :any, mojave: "b9d7d36c8d263be0e02e17d435350546f9f7008eb21b6e86bf42f719efcba85e"
sha256 cellar: :any_skip_relocation, x86_64_linux: "786ae29f0c0b06ea86e42bd9c6ac2c49bd5757da037dead7053e8bd612c4cf8c"
end
head do
url "https://gmplib.org/repo/gmp/", using: :hg
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
uses_from_macos "m4" => :build
# Prevent crash on macOS 12 betas with release gmp 6.2.1, can be removed after the next gmp release.
patch do
url "https://gmplib.org/repo/gmp/raw-rev/5f32dbc41afc"
sha256 "a44ef57903b240df6fde6c9d2fe40063f785995c43b6bfc7a237c571f53613e0"
end
def install
system "./.bootstrap" if build.head?
args = std_configure_args
args << "--enable-cxx"
# Enable --with-pic to avoid linking issues with the static library
args << "--with-pic"
cpu = Hardware::CPU.arm? ? "aarch64" : Hardware.oldest_cpu
if OS.mac?
args << "--build=#{cpu}-apple-darwin#{OS.kernel_version.major}"
else
args << "--build=#{cpu}-linux-gnu"
args << "ABI=32" if Hardware::CPU.is_32_bit?
end
system "./configure", *args
system "make"
system "make", "check"
system "make", "install"
# Prevent brew from trying to install metafiles that
# are actually symlinks to files in autotools kegs
buildpath.children.select(&:symlink?).map(&:unlink) if build.head?
end
test do
(testpath/"test.c").write <<~EOS
#include <gmp.h>
#include <stdlib.h>
int main() {
mpz_t i, j, k;
mpz_init_set_str (i, "1a", 16);
mpz_init (j);
mpz_init (k);
mpz_sqrtrem (j, k, i);
if (mpz_get_si (j) != 5 || mpz_get_si (k) != 1) abort();
return 0;
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-lgmp", "-o", "test"
system "./test"
# Test the static library to catch potential linking issues
system ENV.cc, "test.c", "#{lib}/libgmp.a", "-o", "test"
system "./test"
end
end

View File

@ -1,65 +0,0 @@
class Isl < Formula
# NOTE: Always use tarball instead of git tag for stable version.
#
# Currently isl detects its version using source code directory name
# and update isl_version() function accordingly. All other names will
# result in isl_version() function returning "UNKNOWN" and hence break
# package detection.
desc "Integer Set Library for the polyhedral model"
homepage "https://libisl.sourceforge.io/"
url "https://libisl.sourceforge.io/isl-0.26.tar.xz"
sha256 "a0b5cb06d24f9fa9e77b55fabbe9a3c94a336190345c2555f9915bb38e976504"
license "MIT"
livecheck do
url :homepage
regex(/href=.*?isl[._-]v?(\d+(?:\.\d+)+)\.t/i)
end
bottle do
sha256 cellar: :any, arm64_ventura: "1814fe867c61b34cd5c763cf2ebda99d7883db78348c8b663f98cc95a1348d16"
sha256 cellar: :any, arm64_monterey: "0a3e83c458420e4b469ad7464d16d6c9cd26a888059358eb5f1f9d3cff54bbd7"
sha256 cellar: :any, arm64_big_sur: "a68a647249ad644cd8d1e1057bac65e5b4e1e08f9adaf15a07121853b0ed40cc"
sha256 cellar: :any, ventura: "0301489db7b26967657be0f6c89f11ea7e1e5fb50631686f86c597b01c00dc85"
sha256 cellar: :any, monterey: "0dcc555fd2517c6c93bca8999c741029bbdd821bfeb397505ec1f98deb79c551"
sha256 cellar: :any, big_sur: "91965ce2f54c7d1b16747ed05de989a3a122f5dbee67546bbf9bf065873b13c5"
sha256 cellar: :any_skip_relocation, x86_64_linux: "db14ba1e4ea23ab41e06930dcf25ae9023c5e395c88602da2a9b6a98d54c92d3"
end
head do
url "https://repo.or.cz/isl.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
depends_on "gmp"
def install
system "./autogen.sh" if build.head?
system "./configure", "--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=#{prefix}",
"--with-gmp=system",
"--with-gmp-prefix=#{Formula["gmp"].opt_prefix}"
system "make"
system "make", "install"
(share/"gdb/auto-load").install Dir["#{lib}/*-gdb.py"]
end
test do
(testpath/"test.c").write <<~EOS
#include <isl/ctx.h>
int main()
{
isl_ctx* ctx = isl_ctx_alloc();
isl_ctx_free(ctx);
return 0;
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-lisl", "-o", "test"
system "./test"
end
end

View File

@ -1,60 +0,0 @@
class Libmpc < Formula
desc "C library for the arithmetic of high precision complex numbers"
homepage "http://www.multiprecision.org/mpc/"
url "https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz"
mirror "https://ftpmirror.gnu.org/mpc/mpc-1.3.1.tar.gz"
sha256 "ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8"
license "LGPL-3.0-or-later"
bottle do
sha256 cellar: :any, arm64_ventura: "da4ff781bc469c82af17f98f0bdbf20932e222d0520ab784cd1b322b789ad7a5"
sha256 cellar: :any, arm64_monterey: "dd3994160b3625b1f14e34abf632b90bf49e71db1cc85c12e9ab529d4cae2a87"
sha256 cellar: :any, arm64_big_sur: "43bbe994c7bbb40f7172ef7a750bc6d2687275a76a25f67fc2d53ef00728d912"
sha256 cellar: :any, ventura: "aa4ddb0e50ace93746e6af2e6185493698b501e9359cf73ce41cfbb70369db09"
sha256 cellar: :any, monterey: "c32f2c3fe7ab06e308e6fa74874e1d4d92ff6eb3598da6e0f8e6fa7a333350f5"
sha256 cellar: :any, big_sur: "47b50c3df6a35ea3c876397eac4a7dc157b5f4109247671a16599a9a41b9c035"
sha256 cellar: :any_skip_relocation, x86_64_linux: "f6542ae5bcf643ca0c980c7000cde1585922e76be080b3cc3422dac0d4a50904"
end
head do
url "https://gitlab.inria.fr/mpc/mpc.git", branch: "master"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
depends_on "gmp"
depends_on "mpfr"
def install
system "autoreconf", "--force", "--install", "--verbose" if build.head?
system "./configure", *std_configure_args,
"--with-gmp=#{Formula["gmp"].opt_prefix}",
"--with-mpfr=#{Formula["mpfr"].opt_prefix}"
system "make"
system "make", "check"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include <mpc.h>
#include <assert.h>
#include <math.h>
int main() {
mpc_t x;
mpc_init2 (x, 256);
mpc_set_d_d (x, 1., INFINITY, MPC_RNDNN);
mpc_tanh (x, x, MPC_RNDNN);
assert (mpfr_nan_p (mpc_realref (x)) && mpfr_nan_p (mpc_imagref (x)));
mpc_clear (x);
return 0;
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-L#{Formula["mpfr"].opt_lib}",
"-L#{Formula["gmp"].opt_lib}", "-lmpc", "-lmpfr",
"-lgmp", "-o", "test"
system "./test"
end
end

View File

@ -1,101 +0,0 @@
class Mpfr < Formula
desc "C library for multiple-precision floating-point computations"
homepage "https://www.mpfr.org/"
license "LGPL-3.0-or-later"
stable do
url "https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.0.tar.xz"
mirror "https://ftpmirror.gnu.org/mpfr/mpfr-4.2.0.tar.xz"
sha256 "06a378df13501248c1b2db5aa977a2c8126ae849a9d9b7be2546fb4a9c26d993"
version "4.2.0-p9"
# Upstream patches, list at https://www.mpfr.org/mpfr-current/#fixed
%w[
01 2e465c31689e780a93b24bf2959917443fb882da85b7f1ef23ae53d3de614aa4
02 e1ef3d4dab999f4e0ad5ee046c3a2823d3a9395fb8092c3dcb85d3fe29994b52
03 a906f9ed8e4a7230980322a0154702664164690614e5ff55ae7049c3fae55584
04 ece14ee57596dc2e4f67d2e857c5c6b23d76b20183a50a8b6759b640df001b78
05 c4144564097a1be89c9cc2e7ee255c9fe59eb1b94a17c9d4a08169223e705ac1
06 70456748a8072265ba103d93ba94e9f93ae64565e6a5742194c56030086540fa
07 472386aa5f8c51fbdf60154c19268ce2212be03e1c2f9004c1673b6c270508f6
08 6ecd3bd2edf178f4ede4be612964d1b2d0a0bb10ad6f8c51d1a8011fff87d5ea
09 3e9aed5bcea95d34d0bd179a61cd7acb712c89c9a745535f18f0ef619833ba3b
].each_slice(2) do |p, checksum|
patch do
url "https://www.mpfr.org/mpfr-4.2.0/patch#{p}"
sha256 checksum
end
end
end
livecheck do
url "https://www.mpfr.org/mpfr-current/"
regex(/href=.*?mpfr[._-]v?(\d+(?:\.\d+)+)\.t/i)
strategy :page_match do |page, regex|
version = page.scan(regex).map { |match| Version.new(match[0]) }.max&.to_s
next if version.blank?
patch = page.scan(%r{href=["']?/?patch(\d+)["' >]}i)
.map { |match| Version.new(match[0]) }
.max
&.to_s
next version if patch.blank?
"#{version}-p#{patch.to_i}"
end
end
bottle do
sha256 cellar: :any, arm64_ventura: "176114984411aeb1187a50fd9ffc39d7dfe0bf5dc29ab13b0ecc95307d619ff9"
sha256 cellar: :any, arm64_monterey: "77a979ab547618549fc85a12212abd57b085b1712c53299847966d76a4e261f9"
sha256 cellar: :any, arm64_big_sur: "f5776604dbb68288c8dfe371e46398a671b6c34329ad473ada5d4e1fa7562086"
sha256 cellar: :any, ventura: "781d9c4887b8b18ccb96653ce59bb9aa5ee49dd1fb6c7d804750f58ce8726a2f"
sha256 cellar: :any, monterey: "a8eb9e75c01527d80843daba945a7581942362e689e3f3b7c6c891daa2655e9e"
sha256 cellar: :any, big_sur: "22360e6d89681f3d3d326a5654ab0cfb22d5ac42241c40e9f8f91eb06bb1b77c"
sha256 cellar: :any_skip_relocation, x86_64_linux: "d0cafd93a5957220615ae6478033031b750ba5eb6a830cf86d4cbde5bffec8d5"
end
head do
url "https://gitlab.inria.fr/mpfr/mpfr.git", branch: "master"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
depends_on "gmp"
def install
system "./autogen.sh" if build.head?
system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}",
"--disable-silent-rules"
system "make"
system "make", "check"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include <mpfr.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main() {
mpfr_t x, y;
mpfr_inits2 (256, x, y, NULL);
mpfr_set_ui (x, 2, MPFR_RNDN);
mpfr_rootn_ui (y, x, 2, MPFR_RNDN);
mpfr_pow_si (x, y, 4, MPFR_RNDN);
mpfr_add_si (y, x, -4, MPFR_RNDN);
mpfr_abs (y, y, MPFR_RNDN);
if (fabs(mpfr_get_d (y, MPFR_RNDN)) > 1.e-30) abort();
if (strcmp("#{version}", mpfr_get_version())) abort();
return 0;
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-L#{Formula["gmp"].opt_lib}",
"-lgmp", "-lmpfr", "-o", "test"
system "./test"
end
end

View File

@ -1,61 +0,0 @@
class Zstd < Formula
desc "Zstandard is a real-time compression algorithm"
homepage "https://facebook.github.io/zstd/"
url "https://github.com/facebook/zstd/archive/v1.5.5.tar.gz"
mirror "http://fresh-center.net/linux/misc/zstd-1.5.5.tar.gz"
mirror "http://fresh-center.net/linux/misc/legacy/zstd-1.5.5.tar.gz"
sha256 "98e9c3d949d1b924e28e01eccb7deed865eefebf25c2f21c702e5cd5b63b85e1"
license "BSD-3-Clause"
head "https://github.com/facebook/zstd.git", branch: "dev"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 cellar: :any, arm64_ventura: "b709835f4cd5d339b97103f0dfa343489a02d2073f8e80ba7b04d682f1d29bd4"
sha256 cellar: :any, arm64_monterey: "e3cb579108afe4794143b33f24b6020648ca166f0104eb3d13cee56da62c949f"
sha256 cellar: :any, arm64_big_sur: "faf929cf92dad72eca2b16fb5aedb695f5d291aac18b496061b8b14003b2e224"
sha256 cellar: :any, ventura: "e4eb8cc0473c699ec424bfecc67fcfd30631f7fe5eacf26c727bfed73dcf7c12"
sha256 cellar: :any, monterey: "9c1cfe9158a48f6bd3eeb92608ed2799a048d1d27e70e7acef82d5eb4a7a1cea"
sha256 cellar: :any, big_sur: "73d78b5fef5ba31d3c37b8201310fe042f30c6000a97b8ba0d91208e1e1de231"
sha256 cellar: :any_skip_relocation, x86_64_linux: "68c8655224f058316c16462507b6cdd061bd546e161bf8419c68ca526d3a9a48"
end
depends_on "cmake" => :build
depends_on "lz4"
depends_on "xz"
uses_from_macos "zlib"
def install
# Legacy support is the default after
# https://github.com/facebook/zstd/commit/db104f6e839cbef94df4df8268b5fecb58471274
# Set it to `ON` to be explicit about the configuration.
system "cmake", "-S", "build/cmake", "-B", "builddir",
"-DZSTD_PROGRAMS_LINK_SHARED=ON", # link `zstd` to `libzstd`
"-DZSTD_BUILD_CONTRIB=ON",
"-DCMAKE_INSTALL_RPATH=#{rpath}",
"-DZSTD_LEGACY_SUPPORT=ON",
"-DZSTD_ZLIB_SUPPORT=ON",
"-DZSTD_LZMA_SUPPORT=ON",
"-DZSTD_LZ4_SUPPORT=ON",
"-DCMAKE_CXX_STANDARD=11",
*std_cmake_args
system "cmake", "--build", "builddir"
system "cmake", "--install", "builddir"
end
test do
[bin/"zstd", bin/"pzstd", "xz", "lz4", "gzip"].each do |prog|
data = "Hello, #{prog}"
assert_equal data, pipe_output("#{bin}/zstd -d", pipe_output(prog, data))
if prog.to_s.end_with?("zstd")
# `pzstd` can only decompress zstd-compressed data.
assert_equal data, pipe_output("#{bin}/pzstd -d", pipe_output(prog, data))
else
assert_equal data, pipe_output("#{prog} -d", pipe_output("#{bin}/zstd --format=#{prog}", data))
end
end
end
end

View File

@ -132,28 +132,28 @@ cd "$ROOTDIR"/macOS/pkg
# Dynare option
pkgbuild --root "$PKGFILES" --identifier org.dynare --version "$VERSION" --install-location /Applications/Dynare/"$LOCATION" "$NAME".pkg
# GCC option
# Create dummy payload for GCC package; otherwise the size is displayed as 0 bytes in the installer
dd if=/dev/zero of="$ROOTDIR"/macOS/brewfiles/dummy bs=1m count=800
pkgbuild --root "$ROOTDIR"/macOS/brewfiles --identifier org.dynare.gcc --version "$VERSION" --scripts "$ROOTDIR"/macOS/scripts --install-location /Applications/Dynare/"$LOCATION" "$NAME"-gcc.pkg
# Create distribution.xml by replacing variables in distribution_template.xml
sed -e "s/VERSION_NO_SPACE/$VERSION/g" \
"$ROOTDIR"/macOS/distribution_template.xml > distribution.xml
# Replace variables in displayed files
sed "s/VERSION_READ/$VERSION/g" "$ROOTDIR"/macOS/distribution_template.xml > distribution_tmp.xml
sed "s/VERSION_NO_SPACE/$VERSION/g" distribution_tmp.xml > distribution.xml
sed "s/GCC_BINARY/$CC/g" "$ROOTDIR"/macOS/welcome_template.html > "$ROOTDIR"/macOS/welcome.html
sed "s/VERSION_NO_SPACE/$VERSION/g" "$ROOTDIR"/macOS/welcome.html > "$ROOTDIR"/macOS/welcome_tmp.html
sed "s/DATE/$DATELONG/g" "$ROOTDIR"/macOS/welcome_tmp.html > "$ROOTDIR"/macOS/welcome.html
# Create welcome.html by replacing variables in welcome_template.html
sed -e "s/VERSION_NO_SPACE/$VERSION/g" \
-e "s/DATE/$DATELONG/g" \
-e "s/GCC_VERSION/$GCC_VERSION/g" \
"$ROOTDIR"/macOS/welcome_template.html > "$ROOTDIR"/macOS/welcome.html
# Create conclusion.html by replacing variables in conclusion_template.html
sed -e "s/GCC_VERSION/$GCC_VERSION/g" \
"$ROOTDIR"/macOS/conclusion_template.html > "$ROOTDIR"/macOS/conclusion.html
# Create installer
productbuild --distribution distribution.xml --resources "$ROOTDIR"/macOS --package-path ./"$NAME".pkg "$NAME"-new.pkg
# cleanup
rm -f ./*.xml
rm -f ./distribution.xml
rm -rf "$PKGFILES"
rm -f "$NAME"-gcc.pkg
rm -f "$ROOTDIR"/macOS/brewfiles/dummy
rm -f "$ROOTDIR"/macOS/welcome.html
rm -f "$ROOTDIR"/macOS/welcome_tmp.html
rm -f "$ROOTDIR"/macOS/conclusion.html
# Final pkg
mv "$NAME"-new.pkg "$NAME".pkg

View File

@ -0,0 +1,44 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Postinstallation Recommendations</title>
<style>
.center-text {
text-align: center;
}
.bold-text {
font-weight: bold;
}
code {
font-family: "Courier New", Courier, monospace;
background-color: #f9f9f9;
border: 1px solid #ccc;
padding: 2px 4px;
border-radius: 4px;
}
</style>
</head>
<body>
<header class="center-text">
<h1>Postinstallation Recommendations</h1>
</header>
<main>
<p class="bold-text">Xcode Command Line Tools</p>
<p>Dynare highly benefits from installing Xcode Command Line Tools (an Apple product). To install the Xcode Command Line Tools type the following into Terminal.app:</p>
<code>
xcode-select --install
</code>
<p class="bold-text">Compilation Environment for use_dll option</p>
<p>Dynare ships a compilation environment that can be used with the use_dll option. To install this environment correctly, the Xcode Command Line Tools are sufficient.</p>
<p>However, we recommend making use of optimized compilation flags and for this you need to install gcc-GCC_VERSION via Homebrew.
For this, follow <a href="https://brew.sh" target="_blank" rel="noopener noreferrer">https://brew.sh</a> to install Homebrew and then type the following into Terminal.app:</p>
<code>brew install gcc@GCC_VERSION</code>
<p>If you already have installed gcc-GCC_VERSION, Dynare will automatically prefer it for use_dll if the binaries are in /usr/local/bin/gcc-GCC_VERSION. Otherwise, it will fall back to Clang in /usr/bin/gcc.</p>
</main>
</body>
</html>

View File

@ -1,22 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<installer-gui-script minSpecVersion="1">
<title>Dynare VERSION_READ</title>
<title>Dynare VERSION_NO_SPACE</title>
<background file="background.png" scaling="tofit" mime-type="image/png" alignment="topleft" />
<background-darkAqua file="background.png" scaling="tofit" mime-type="image/png" alignment="topleft" />
<welcome file="welcome.html" mime-type="text/html" />
<conclusion file="conclusion.html" mime-type="text/html" />
<license file="gpl-3.0-standalone.html" mime-type="text/html" />
<pkg-ref id="org.dynare" />
<pkg-ref id="default" />
<options customize="allow" require-scripts="false" hostArchitectures="x86_64" />
<choices-outline>
<line choice="org.dynare" />
<line choice="org.dynare.gcc" />
<line choice="default" />
</choices-outline>
<choice id="org.dynare" title="Dynare" description="Dynare Required Files" start_enabled="false" enabled="false">
<choice id="default" title="Dynare" description="Dynare Required Files" start_enabled="false" enabled="false">
<pkg-ref id="org.dynare" />
</choice>
<choice id="org.dynare.gcc" title="GCC for `use_dll`" description="This is necessary for the use of Dynare with the `use_dll` option. NB: This takes a few minutes and requires an active internet connection.">
<pkg-ref id="org.dynare.gcc" />
</choice>
</choice>
<pkg-ref id="org.dynare" version="VERSION_NO_SPACE">dynare-VERSION_NO_SPACE.pkg</pkg-ref>
<pkg-ref id="org.dynare.gcc" version="VERSION_NO_SPACE">dynare-VERSION_NO_SPACE-gcc.pkg</pkg-ref>
</installer-gui-script>
</installer-gui-script>

View File

@ -1,96 +0,0 @@
#!/usr/bin/env bash
# Copyright © 2019-2021 Dynare Team
#
# This file is part of Dynare.
#
# Dynare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Dynare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare. If not, see <https://www.gnu.org/licenses/>.
set -ex
set -o errexit
readonly LOG_FILE="$2"/install.log
sudo touch "$LOG_FILE"
exec 1>"$LOG_FILE"
exec 2>&1
# Remove dummy payload
rm -f "$2"/dummy
# Test for Internet connection
if ! curl -s -m 4 https://github.com >/dev/null; then
osascript -e 'display alert "Dynare Installation Error" message "Not able to connect to github.com. Either you are not connected to the internet or github.com is blocked where you are.\n\nAccess to GitHub is necessary to make Dynare work with the `use_dll` option on macOS.\n\nIf you cannot establish this connection or do not want to use the `use_dll` option of Dynare, please run the installer again and choose \"Customize\" from the \"Installation Type\" screen and uncheck the `GCC` option." as critical'
echo "No internet connection to github.com"
exit 1
fi
# Install Command Line Tools
# Checking that “xcode-select -print-path” returns a valid path is not enough, because
# the contents of that directory might have been removed (this is the official way of
# uninstalling CLT, see https://developer.apple.com/library/archive/technotes/tn2339/_index.html#//apple_ref/doc/uid/DTS40014588-CH1-HOW_CAN_I_UNINSTALL_THE_COMMAND_LINE_TOOLS_)
# Hence we also check that the directory contains the git binary.
if ! xcpath=$(/usr/bin/xcode-select -print-path) || [[ ! -x "$xcpath"/usr/bin/git ]]; then
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
SUC=$(softwareupdate -l |
grep "\*.*Command Line" |
grep -m1 "" |
awk -F"*" '{print $2}' |
sed -e 's/^ *//' |
tr -d '\n')
# On macOS 10.15 softwareupdate output is preceded by "Label: "
[[ $SUC == Label:* ]] && SUC=${SUC#"Label: "}
softwareupdate -i "$SUC" --verbose
rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
softwareupdate -l
fi
# If CLT installation didn't work, exit
if ! xcpath=$(/usr/bin/xcode-select -print-path) || [[ ! -x "$xcpath"/usr/bin/git ]]; then
osascript -e 'display alert "Dynare Installation Error" message "Not able to find Command Line Tools.\n\nCommand Line Tools is necessary to make Dynare work with the `use_dll` option on macOS.\n\nIf you cannot establish this connection or do not want to use the `use_dll` option of Dynare, please run the installer again and choose \"Customize\" from the \"Installation Type\" screen and uncheck the `GCC` option." as critical'
echo "Command Line Tools not installed"
exit 1
fi
# Ensure git is in the path
if ! which git >/dev/null; then
osascript -e 'display alert "Dynare Installation Error" message "Not able to find Git even though the Command Line Tools have already been installed. This is likely a problem with your PATH environment variable.\n\nGit is necessary to make Dynare work with the `use_dll` option on macOS.\n\nIf you cannot establish this connection or do not want to use the `use_dll` option of Dynare, please run the installer again and choose \"Customize\" from the \"Installation Type\" screen and uncheck the `GCC` option." as critical'
echo $PATH
echo "Git not found in PATH"
exit 1
fi
# Install Homebrew
BREWDIR="$2"/.brew
[ -d "$BREWDIR" ] || mkdir -p "$BREWDIR"
BREW_URL="https://github.com/Homebrew/brew"
BREW_BRANCH="master"
curl -\# -L "$BREW_URL"/tarball/"$BREW_BRANCH" | tar xz -m --strip 1 -C "$BREWDIR"
# Change ownership of Dynare directory
chown -R "$USER":staff "$2"
sudo -u "$USER" "$BREWDIR"/bin/brew tap homebrew/core
HOMEBREW_CACHE="$HOME"/Library/Caches/Homebrew-Dynare
HOMEBREW_NO_AUTO_UPDATE=1
[[ -z "${HOMEBREW_NO_ANALYTICS}" ]] && HOMEBREW_NO_ANALYTICS=1
# Move modified formulas to Homebrew Formula directory
mv "$2"/*.rb "$BREWDIR"/Library/Taps/homebrew/homebrew-core/Formula
# Install GCC & deps
sudo -u "$USER" "$BREWDIR"/bin/brew install gcc -v --force-bottle
exit 0

View File

@ -1,15 +1,27 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dynare Installer</title>
<style>
.center-text {
text-align: center;
}
.bold-text {
font-weight: bold;
}
</style>
</head>
<body>
<h3 style="text-align: center;">Welcome to Dynare</h3>
<p style="text-align: center;">Version VERSION_NO_SPACE</p>
<p style="text-align: center;">DATE</p>
<header class="center-text">
<h1>Welcome to Dynare</h1>
<p>Version VERSION_NO_SPACE</p>
<p>DATE</p>
</header>
<p><b>Just a few things to note</b>. This installation can be customized as you can choose not to install the GNU Compiler Collection (GCC). Installing GCC is necessary if you want to use the <tt>use_dll</tt> option in Dynare, but otherwise unnecessary.</p>
<p>To install GCC we run a script that first installs the XCode Command Line Tools (an Apple product). The script then installs Homebrew, a package manager for macOS and, finally, GCC itself. Both Homebrew and GCC will be installed in your Dynare installation folder. So, when you delete this folder, they too will be deleted.</p>
<p>Installing GCC will require an active internet connection with the ability to connect to the Apple servers and GitHub. The installation will take anywhere from a few minutes to a half an hour during the <i>Running package scripts</i> phase of Installation. The time it takes depends on your internet speed, the speed of your computer, and whether or not you already have XCode Command Line Tools installed. The progress bar will not advance during this phase. Please be patient.</p>
<p> You can choose not to install GCC by choosing <i>Customize</i> from the <i>Installation Type</i> screen and deselecting <i>GCC compiler</i>. If you already have <tt>GCC_BINARY</tt> installed under <tt>/usr/local</tt>, you can forgo the installation of GCC here as Dynare will find your system compiler when you use <tt>use_dll</tt>.</p>
<main>
<p>Please read the <strong>Postinstallation Recommendations</strong> at the end of the installation process on how to (optionally) install Xcode Command Line Tools and gcc-GCC_VERSION via Homebrew.</p>
</main>
</body>
</html>
</html>