Skip to content
Snippets Groups Projects
Verified Commit a0b58b2b authored by Houtan Bastani's avatar Houtan Bastani
Browse files

macOS packaging: install Homebrew + GCC under /Applications/Dynare/<<version>>

The installation of Homebrew + GCC necessitates Xcode Command Line Tools, which will be installed if it is not present.

The installation of Homebrew + GCC is optional and can be deselected by the user.
parent 63fe6609
Branches
Tags
No related merge requests found
class Gcc < Formula
desc "GNU compiler collection"
homepage "https://gcc.gnu.org/"
url "https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz"
mirror "https://ftpmirror.gnu.org/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz"
sha256 "ea6ef08f121239da5695f76c9b33637a118dcf63e24164422231917fa61fb206"
revision 2
head "https://gcc.gnu.org/git/gcc.git"
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
sha256 "1564397f461f629f3811f1ececc7f2bb614f7520242743fc41348d190d8b6aa9" => :catalina
sha256 "5012d43ce3ff9b31fc21f9df1075b9d5e205d1a727b75f6dbd098654aff0f0f2" => :mojave
sha256 "cc0e6c6a7f7ce5823d0578cf57a6e201727238905aa8a4726e5f90dbc252d94b" => :high_sierra
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? do
reason "The bottle needs the Xcode CLT to be installed."
satisfy { MacOS::CLT.installed? }
end
depends_on "gmp"
depends_on "isl"
depends_on "libmpc"
depends_on "mpfr"
# GCC bootstraps itself, so it is OK to have an incompatible C++ stdlib
cxxstdlib_check :skip
# Fix system headers for Catalina SDK
# (otherwise __OSX_AVAILABLE_STARTING ends up undefined)
if DevelopmentTools.clang_build_version >= 1100
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/b8b8e65e/gcc/9.2.0-catalina.patch"
sha256 "0b8d14a7f3c6a2f0d2498526e86e088926671b5da50a554ffa6b7f73ac4f132b"
end
end
def version_suffix
if build.head?
"HEAD"
else
version.to_s.slice(/\d/)
end
end
def install
# GCC will suffer build errors if forced to use a particular linker.
ENV.delete "LD"
# We avoiding building:
# - Ada, which requires a pre-existing GCC Ada compiler to bootstrap
# - Go, currently not supported on macOS
# - BRIG
languages = %w[c c++ objc obj-c++ fortran]
osmajor = `uname -r`.split(".").first
pkgversion = "Homebrew GCC #{pkg_version} #{build.used_options*" "}".strip
args = %W[
--build=x86_64-apple-darwin#{osmajor}
--prefix=#{prefix}
--libdir=#{lib}/gcc/#{version_suffix}
--disable-nls
--enable-checking=release
--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-system-zlib
--with-pkgversion=#{pkgversion}
--with-bugurl=https://github.com/Homebrew/homebrew-core/issues
]
# Xcode 10 dropped 32-bit support
args << "--disable-multilib" if DevelopmentTools.clang_build_version >= 1000
# Ensure correct install names when linking against libgcc_s;
# see discussion in https://github.com/Homebrew/legacy-homebrew/pull/34303
inreplace "libgcc/config/t-slibgcc-darwin", "@shlib_slibdir@", "#{HOMEBREW_PREFIX}/lib/gcc/#{version_suffix}"
mkdir "build" do
if !MacOS::CLT.installed?
# For Xcode-only systems, we need to tell the sysroot path
args << "--with-native-system-header-dir=/usr/include"
args << "--with-sysroot=#{MacOS.sdk_path}"
elsif MacOS.version >= :mojave
# System headers are no longer located in /usr/include
args << "--with-native-system-header-dir=/usr/include"
args << "--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX#{MacOS.version}.sdk"
end
system "../configure", *args
# Use -headerpad_max_install_names in the build,
# otherwise updated load commands won't fit in the Mach-O header.
# This is needed because `gcc` avoids the superenv shim.
system "make", "BOOT_LDFLAGS=-Wl,-headerpad_max_install_names"
system "make", "install"
bin.install_symlink bin/"gfortran-#{version_suffix}" => "gfortran"
end
# Handle conflicts between GCC formulae and avoid interfering
# with system compilers.
# Rename man7.
Dir.glob(man7/"*.7") { |file| add_suffix file, version_suffix }
# Even when we disable building info pages some are still installed.
info.rmtree
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
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", `./hello-c`
(testpath/"hello-cc.cc").write <<~EOS
#include <iostream>
int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
EOS
system "#{bin}/g++-#{version_suffix}", "-o", "hello-cc", "hello-cc.cc"
assert_equal "Hello, world!\n", `./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", `./test`
end
end
class Gmp < Formula
desc "GNU multiple precision arithmetic library"
homepage "https://gmplib.org/"
url "https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz"
mirror "https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz"
sha256 "87b565e89a9a684fe4ebeeddb8399dce2599f9c9049854ca8c0dfbdea0e21912"
revision 2
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
rebuild 1
sha256 "2409417943fceda33eac12a8229fbf7b990eee18ee341b543be575550a077bb0" => :catalina
sha256 "84f74594086bccc53bdb141f4d06d7847680374e255ebe016654da1e47db2dfc" => :mojave
sha256 "a536c51149806b73b2e1178be94300832b6b151455006bc7f2a32b9dc493c7a3" => :high_sierra
sha256 "ada22a8bbfe8532d71f2b565e00b1643beaf72bff6b36064cbad0cd7436e4948" => :sierra
end
def install
# Work around macOS Catalina / Xcode 11 code generation bug
# (test failure t-toom53, due to wrong code in mpn/toom53_mul.o)
ENV.append_to_cflags "-fno-stack-check"
# Enable --with-pic to avoid linking issues with the static library
args = %W[--prefix=#{prefix} --enable-cxx --with-pic]
args << "--build=#{Hardware.oldest_cpu}-apple-darwin#{`uname -r`.to_i}"
system "./configure", *args
system "make"
system "make", "check"
system "make", "install"
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
class Isl < Formula
desc "Integer Set Library for the polyhedral model"
homepage "https://isl.gforge.inria.fr/"
# 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.
url "http://isl.gforge.inria.fr/isl-0.21.tar.xz"
mirror "https://deb.debian.org/debian/pool/main/i/isl/isl_0.21.orig.tar.xz"
sha256 "777058852a3db9500954361e294881214f6ecd4b594c00da5eee974cd6a54960"
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
sha256 "1f42c08dd84a2f418c8446be2679f027d8b1250d337b5e3135c401eba578cbb7" => :catalina
sha256 "f9188b5d486b2a835cd865f219be1a9848ce3926e27089a1538ee989db65447d" => :mojave
sha256 "d997d49958218e521bc4f73369414ff9fad040d28601d94012e4c68cd090ea93" => :high_sierra
sha256 "d5dc353916cd98da04552a3d7cb86a3203612df422c4e9389e13e12f86945865" => :sierra
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", "check"
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
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.1.0.tar.gz"
sha256 "6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e"
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
sha256 "b9491bbc04d1e52dfb8311dc9aa0081fd3041cb6b2f6b59a4104d712d341979d" => :catalina
sha256 "1cb3a09238830d45d64a87f520f06122d24a020403fac1800c831d15c605282e" => :mojave
sha256 "3b28ec506ab53ef5f3163e87fb72ae735b7f91ee2fc20fe184cf1241481b72a5" => :high_sierra
sha256 "18d620a1612bc51b1fbd1b3b62c9c73766b90549c746740c5a27d2ab1ec5ede7" => :sierra
sha256 "6f19f936781dae0db248abdd84a72c3e25451c44379706bc3800760f0aa43888" => :el_capitan
end
depends_on "gmp"
depends_on "mpfr"
def install
args = %W[
--prefix=#{prefix}
--disable-dependency-tracking
--with-gmp=#{Formula["gmp"].opt_prefix}
--with-mpfr=#{Formula["mpfr"].opt_prefix}
]
system "./configure", *args
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
class Mpfr < Formula
desc "C library for multiple-precision floating-point computations"
homepage "https://www.mpfr.org/"
url "https://ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz"
mirror "https://ftpmirror.gnu.org/mpfr/mpfr-4.0.2.tar.xz"
sha256 "1d3be708604eae0e42d578ba93b390c2a145f17743a744d8f3f8c2ad5855a38a"
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
sha256 "140d29bfee0c8cf356fbb5391465f781df559e6076988de3ea8bcfd812f3c5bd" => :catalina
sha256 "cfce7ab866e98360c9364cd924da620ae7936d3a224d686aacc209c2107d19aa" => :mojave
sha256 "bf5d21e7e8e549f7e8d07791a90f44a487f4c7151897b7c64d02928b5bd73520" => :high_sierra
sha256 "4fb1860a481e24c70eefc8e5782030612840f1bb8f50586ca76a4c6c53629deb" => :sierra
end
depends_on "gmp"
def install
# Work around macOS Catalina / Xcode 11 code generation bug
# (test failure t-toom53, due to wrong code in mpn/toom53_mul.o)
ENV.append_to_cflags "-fno-stack-check"
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>
int main() {
mpfr_t x, y;
mpfr_inits2 (256, x, y, NULL);
mpfr_set_ui (x, 2, MPFR_RNDN);
mpfr_root (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();
return 0;
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-L#{Formula["gmp"].opt_lib}",
"-lgmp", "-lmpfr", "-o", "test"
system "./test"
end
end
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
set -ex set -ex
ROOTDIR=$(pwd)/..
# Set the compilers # Set the compilers
CC=gcc-9 CC=gcc-9
CXX=g++-9 CXX=g++-9
...@@ -26,21 +28,35 @@ CXX=g++-9 ...@@ -26,21 +28,35 @@ CXX=g++-9
# Set the number of threads # Set the number of threads
NTHREADS=$(nproc) NTHREADS=$(nproc)
# Set dependency directory
LIB64="$ROOTDIR"/macOS/deps/lib64
## ##
## Find Dynare Version ## Find Dynare Version
## ##
ROOTDIR=$(pwd)/.. DATE=$(date +%Y-%m-%d-%H%M)
DATELONG=$(date '+%d %B %Y')
if [[ -d ../.git/ ]]; then
SHA=$(git rev-parse HEAD)
SHASHORT=$(git rev-parse --short HEAD)
fi
if [[ -z $VERSION ]]; then if [[ -z $VERSION ]]; then
VERSION=$(grep '^AC_INIT(' ../configure.ac | sed 's/AC_INIT(\[dynare\], \[\(.*\)\])/\1/') VERSION=$(grep '^AC_INIT(' ../configure.ac | sed 's/AC_INIT(\[dynare\], \[\(.*\)\])/\1/')
if [[ -d ../.git/ ]]; then if [[ -d ../.git/ ]]; then
SHA=$(git rev-parse --short HEAD) VERSION="$VERSION"-"$SHASHORT"
VERSION_READ="$VERSION-$SHA"
VERSION=$VERSION-$(date +%Y-%m-%d-%H%M)-"$SHA"
fi fi
fi fi
# Set dependency directory # Install location must be truncated for installation of `gcc`
LIB64="$ROOTDIR"/macOS/deps/lib64 # If it's too long, the headers of the compiled libraries cannot be modified
# obliging recompilation on the user's system. Truncate to 5 characters
# To allow for distribution version to appear
LOCATION=$(echo "$VERSION" | cut -f1 -d"-" | cut -c 1-5)
if [[ "$VERSION" == *-unstable* || "$VERSION" == [a-zA-Z]* ]]; then
LOCATION="$LOCATION"-"$DATE"
fi
## ##
...@@ -71,14 +87,18 @@ make -j"$NTHREADS" ...@@ -71,14 +87,18 @@ make -j"$NTHREADS"
## ##
NAME=dynare-"$VERSION" NAME=dynare-"$VERSION"
PKGFILES="$ROOTDIR"/macOS/pkg/"$NAME" PKGFILES="$ROOTDIR"/macOS/pkg/"$NAME"
mkdir -p "$PKGFILES"/mex/matlab/maci64-7.9-9.3 mkdir -p \
mkdir "$PKGFILES"/mex/matlab/maci64-9.4-9.7 "$PKGFILES"/mex/matlab/maci64-7.9-9.3 \
mkdir "$PKGFILES"/mex/octave "$PKGFILES"/mex/matlab/maci64-9.4-9.7 \
mkdir -p "$PKGFILES"/doc/dynare++ "$PKGFILES"/mex/octave \
mkdir "$PKGFILES"/dynare++ "$PKGFILES"/doc/dynare++ \
mkdir "$PKGFILES"/scripts "$PKGFILES"/dynare++ \
mkdir -p "$PKGFILES"/contrib/ms-sbvar/TZcode "$PKGFILES"/scripts \
"$PKGFILES"/contrib/ms-sbvar/TZcode
if [[ $VERSION == *-unstable* ]]; then
echo "$SHA" > "$PKGFILES"/sha.txt
fi
cp -p "$ROOTDIR"/NEWS "$PKGFILES" cp -p "$ROOTDIR"/NEWS "$PKGFILES"
cp -p "$ROOTDIR"/COPYING "$PKGFILES" cp -p "$ROOTDIR"/COPYING "$PKGFILES"
cp -p "$ROOTDIR"/VERSION "$PKGFILES" cp -p "$ROOTDIR"/VERSION "$PKGFILES"
...@@ -149,12 +169,32 @@ echo -e "function v = supported_octave_version\nv=\"$(octave --eval "disp(OCTAVE ...@@ -149,12 +169,32 @@ echo -e "function v = supported_octave_version\nv=\"$(octave --eval "disp(OCTAVE
## Make package ## Make package
## ##
cd "$ROOTDIR"/macOS/pkg cd "$ROOTDIR"/macOS/pkg
pkgbuild --root "$PKGFILES" --identifier com.cepremap.dynare --version "$VERSION" --install-location /Applications/Dynare/"$VERSION" "$NAME".pkg
sed "s/VERSION_READ/$VERSION_READ/g" "$ROOTDIR"/macOS/distribution_template.xml > distribution_tmp.xml # Dynare option
pkgbuild --root "$PKGFILES" --identifier com.cepremap.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 com.cepremap.dynare.gcc --version "$VERSION" --scripts "$ROOTDIR"/macOS/scripts --install-location /Applications/Dynare/"$LOCATION" "$NAME"-gcc.pkg
# 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/VERSION_NO_SPACE/$VERSION/g" distribution_tmp.xml > distribution.xml
ln -s "$ROOTDIR"/COPYING "$ROOTDIR"/macOS/ 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 installer
productbuild --distribution distribution.xml --resources "$ROOTDIR"/macOS --package-path ./"$NAME".pkg "$NAME"-new.pkg productbuild --distribution distribution.xml --resources "$ROOTDIR"/macOS --package-path ./"$NAME".pkg "$NAME"-new.pkg
# cleanup
rm -f ./*.xml rm -f ./*.xml
rm -rf "$PKGFILES" rm -rf "$PKGFILES"
rm "$ROOTDIR"/macOS/COPYING rm -f "$NAME"-gcc.pkg
rm -f "$ROOTDIR"/macOS/brewfiles/dummy
rm -f "$ROOTDIR"/macOS/welcome.html
rm -f "$ROOTDIR"/macOS/welcome_tmp.html
# Final pkg
mv "$NAME"-new.pkg "$NAME".pkg mv "$NAME"-new.pkg "$NAME".pkg
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<installer-gui-script minSpecVersion="1"> <installer-gui-script minSpecVersion="1">
<pkg-ref id="com.cepremap.dynare"/> <title>Dynare VERSION_READ</title>
<options customize="never" require-scripts="false"/> <background file="background.png" scaling="tofit" mime-type="image/png" alignment="topleft" />
<choices-outline> <background-darkAqua file="background.png" scaling="tofit" mime-type="image/png" alignment="topleft" />
<line choice="default"> <welcome file="welcome.html" mime-type="text/html" />
<line choice="com.cepremap.dynare"/> <license file="gpl-3.0-standalone.html" mime-type="text/html" />
</line> <pkg-ref id="com.cepremap.dynare" />
</choices-outline> <options customize="allow" require-scripts="false" hostArchitectures="x86_64" />
<choice id="default"/> <choices-outline>
<choice id="com.cepremap.dynare" visible="false"> <line choice="com.cepremap.dynare" />
<pkg-ref id="com.cepremap.dynare"/> <line choice="com.cepremap.dynare.gcc" />
</choice> </choices-outline>
<pkg-ref id="com.cepremap.dynare" version="VERSION_NO_SPACE" onConclusion="none">dynare-VERSION_NO_SPACE.pkg</pkg-ref> <choice id="com.cepremap.dynare" title="Dynare" description="Dynare Required Files" start_enabled="false" enabled="false">
<title>Dynare VERSION_READ</title> <pkg-ref id="com.cepremap.dynare" />
<background file="background.png" scaling="tofit" mime-type="image/png" alignment="topleft" /> </choice>
<background-darkAqua file="background.png" scaling="tofit" mime-type="image/png" alignment="topleft" /> <choice id="com.cepremap.dynare.gcc" title="GCC compiler 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">
<license file="COPYING" mime-type="text/plain" /> <pkg-ref id="com.cepremap.dynare.gcc" />
</choice>
<pkg-ref id="com.cepremap.dynare" version="VERSION_NO_SPACE">dynare-VERSION_NO_SPACE.pkg</pkg-ref>
<pkg-ref id="com.cepremap.dynare.gcc" version="VERSION_NO_SPACE">dynare-VERSION_NO_SPACE-gcc.pkg</pkg-ref>
</installer-gui-script> </installer-gui-script>
This diff is collapsed.
#!/usr/bin/env bash
# Copyright © 2019 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 <http://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
[[ -z $(curl -s -m 4 www.google.com) ]] && { echo "No internet connection found"; exit 1; }
# Install Command Line Tools
if [[ -z $(/usr/bin/xcode-select -print-path) ]]; 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
[[ -z $(/usr/bin/xcode-select -print-path) ]] && \
{ echo "You must install Command Line Tools to proceed with installation of GCC"; exit 1; }
# 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
<html lang="en">
<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>
<p><b>Just a few things to note</b>. This installation can be customized as you can choose not to install the GNU C Compiler (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 and will take 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>
</body>
</html>
Subproject commit c6beb6c5c6360468b58b3b6e8d295dc22c8bde8b Subproject commit 3ec01b861215f3f001310ba029a474c19f4af386
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment