diff --git a/.gitignore b/.gitignore index 540839f1c598f30aa9d702713846eb025a244fd6..a75bb34530ef01c54d3be529df9c76b587933161 100644 --- a/.gitignore +++ b/.gitignore @@ -23,10 +23,12 @@ /matlab/supported_octave_version.m # Created by the macOS package build script -/macOS/deps/sources64/ +/macOS/deps/arm64/sources64/ +/macOS/deps/x86_64/sources64/ /macOS/deps/tarballs/ -/macOS/deps/lib64/ +/macOS/deps/arm64/lib64/ +/macOS/deps/x86_64/lib64/ +build-doc # Emacs stuff scripts/dynare.elc - diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 137f85f488c815b7f0c376b23ca9209b7afe82d8..ae82ca54072dbb7295d48b01461bb0d8c5ffd871 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -97,18 +97,38 @@ pkg_windows: expire_in: 3 days needs: [ "build_doc" ] -pkg_macOS: +pkg_macOS_x86_64: stage: pkg script: # Enforce the arm64 meson for rewrite, as a workaround to https://github.com/mesonbuild/meson/issues/12282 - env PATH="/opt/homebrew/bin:$PATH" meson rewrite kwargs set project / version "$VERSION" - - ln -s ~/tarballs macOS/deps/ - - arch -x86_64 make -C macOS + - ln -s ~/tarballs macOS/deps/x86_64 + - make -C macOS build-x86_64 cache: key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" paths: - - macOS/deps/sources64/ - - macOS/deps/lib64/ + - macOS/deps/x86_64/sources64/ + - macOS/deps/x86_64/lib64/ + tags: + - macOS + artifacts: + paths: + - macOS/pkg/* + expire_in: 3 days + needs: [ "build_doc" ] + +pkg_macOS_arm64: + stage: pkg + script: + # Enforce the arm64 meson for rewrite, as a workaround to https://github.com/mesonbuild/meson/issues/12282 + - env PATH="/opt/homebrew/bin:$PATH" meson rewrite kwargs set project / version "$VERSION" + - ln -s ~/tarballs macOS/deps/arm64 + - make -C macOS build-arm64 + cache: + key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" + paths: + - macOS/deps/arm64/sources64/ + - macOS/deps/arm64/lib64/ tags: - macOS artifacts: @@ -126,6 +146,7 @@ test_matlab: - build-matlab/meson-logs/testlog.txt when: always needs: [ "build_matlab" ] + when: manual test_old_matlab: stage: test @@ -200,12 +221,12 @@ deploy_snapshot_unstable: - pkg_source - pkg_windows - sign_windows - - pkg_macOS + - pkg_macOS_x86_64 script: - cp build-src/meson-dist/*.tar.xz /srv/www.dynare.org/snapshot/source/ && ln -sf *.tar.xz /srv/www.dynare.org/snapshot/source/dynare-latest-src.tar.xz - f=(windows/exe-signed/*) && cp ${f[0]} /srv/www.dynare.org/snapshot/windows/ && ln -sf ${f[0]##*/} /srv/www.dynare.org/snapshot/windows/dynare-latest-win.exe - f=(windows/7z/*) && cp ${f[0]} /srv/www.dynare.org/snapshot/windows-7z/ && ln -sf ${f[0]##*/} /srv/www.dynare.org/snapshot/windows-7z/dynare-latest-win.7z - f=(windows/zip/*) && cp ${f[0]} /srv/www.dynare.org/snapshot/windows-zip/ && ln -sf ${f[0]##*/} /srv/www.dynare.org/snapshot/windows-zip/dynare-latest-win.zip - - f=(macOS/pkg/*) && cp ${f[0]} /srv/www.dynare.org/snapshot/macos/ && ln -sf ${f[0]##*/} /srv/www.dynare.org/snapshot/macos/dynare-latest-macos.pkg + - f=(macOS/pkg/*-x86_64.pkg) && cp ${f[0]} /srv/www.dynare.org/snapshot/macos/ && ln -sf ${f[0]##*/} /srv/www.dynare.org/snapshot/macos/dynare-latest-macos.pkg - ~/update-snapshot-list.sh - curl -X POST -F token="$WEBSITE_PIPELINE_TRIGGER_TOKEN" -F ref=master https://git.dynare.org/api/v4/projects/40/trigger/pipeline diff --git a/README.md b/README.md index ad50e2a4cea393ad46a348029cb3811f217cd296..e267171fe38b617e33ef455a3c780224222487c9 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ If you want a certain version (e.g. 5.x) , then add `--single-branch --branch 5. If you want to compile for MATLAB, please run the following (after adapting the path to MATLAB): ```sh -meson setup -Dmatlab_path=/usr/local/MATLAB/R2023a -Dbuildtype=debugoptimized build-matlab +meson setup -Dmatlab_path=/usr/local/MATLAB/R2023b -Dbuildtype=debugoptimized build-matlab ``` The build directory will thus be `build-matlab`. @@ -269,7 +269,7 @@ Now use the following commands if using MATLAB (adapt them for Octave, see above cd /home/$USER/dynare git clone --recurse-submodules https://git.dynare.org/dynare/dynare.git unstable cd unstable -meson setup -Dmatlab_path=/usr/local/MATLAB/R2020b -Dfortran_args="[ '-B', '/home/$USER/dynare/slicot']" -Dbuildtype=debugoptimized build-matlab +meson setup -Dmatlab_path=/usr/local/MATLAB/R2023b -Dfortran_args="[ '-B', '/home/$USER/dynare/slicot']" -Dbuildtype=debugoptimized build-matlab meson compile -C build-matlab ``` @@ -405,26 +405,29 @@ export PATH="$BREWDIR/bin:$PATH" ``` -- Install required Homebrew packages and link sphinx-doc: +- Install required Homebrew packages: ```sh -arch -$ARCH $BREWDIR/bin/brew install meson bison flex boost gcc gsl libmatio veclibfort octave sphinx-doc docutils wget +arch -$ARCH $BREWDIR/bin/brew install meson bison flex boost gcc gsl libmatio veclibfort octave sphinx-doc docutils wget pkg-config git-lfs ``` -If you want to build the documentation, you need to link sphinx-doc: +If you are installing `git-lfs` for the first time, you need to run `git lfs install` once after installing it. + +- Link the sphinx-doc package to be able to compile the documentation: ```sh arch -$ARCH $BREWDIR/bin/brew link --force sphinx-doc ``` -- Install [MacTeX](http://www.tug.org/mactex/index.html) using the universal installer, if you want to build the documentation. MacTeX runs natively on both ARM and Intel machines. On Apple Silicon, it is advised to symlink `pdflatex` and `bibtex` into `/usr/local/bin`: +- Install [MacTeX](http://www.tug.org/mactex/index.html) using the universal installer, if you want to build the documentation. MacTeX runs natively on both ARM and Intel machines. On Apple Silicon, it is advised to symlink `pdflatex`, `bibtex` and `latexmk` into `/usr/local/bin`: ```sh sudo ln -s /Library/TeX/texbin/pdflatex /usr/local/bin/pdflatex sudo ln -s /Library/TeX/texbin/bibtex /usr/local/bin/bibtex +sudo ln -s /Library/TeX/texbin/latexmk /usr/local/bin/latexmk ``` +If you don't have admin privileges, then you can also symlink them into `$HOME/.local/bin` and add this folder to your PATH. + - Install MATLAB and additional toolboxes. We recommend, but don't require, the following: Optimization, Global Optimization, Statistics and Machine Learning, Econometrics, and Control System. -For Apple Silicon: MATLAB offers a native Apple silicon version of R2022b as an open beta. You can sign up and install it (including a suitable Java 8 JRE, e.g. Amazon Corretto 8) using -[the official instructions](https://de.mathworks.com/support/apple-silicon-r2022b-beta.html). -Unfortunately, this version does not support yet the Optimization, Global Optimization and Econometrics toolboxes. -If you need these, please run the Intel version (under Rosetta 2) instead. +For Apple Silicon: MATLAB offers a native Apple silicon version (arm64) as of version R2023b, see [the official instructions](https://de.mathworks.com/support/requirements/apple-silicon.html) how to install it. +You can also run the Intel version (x86_64) under Rosetta 2. Don't forget to run MATLAB at least once to make sure you have a valid license. - Create a folder for Dynare and its dependencies @@ -444,7 +447,6 @@ cp slicot.a $DYNAREDIR/slicot/lib/libslicot_pic.a make clean make -j$(sysctl -n hw.ncpu) FORTRAN=$BREWDIR/bin/gfortran OPTS="-O2 -fdefault-integer-8" LOADER=gfortran lib cp slicot.a $DYNAREDIR/slicot/lib/libslicot64_pic.a -cd $HOME/dynare ``` - Compile and install the X-13ARIMA-SEATS Seasonal Adjustment Program @@ -455,11 +457,11 @@ curl -O https://www2.census.gov/software/x-13arima-seats/x13as/unix-linux/progra tar xf x13as_asciisrc-v1-1-b60.tar.gz sed -i '' 's/-static//g' makefile.gf make -j$(sysctl -n hw.ncpu) -f makefile.gf FC=$BREWDIR/bin/gfortran LINKER=$BREWDIR/bin/gcc-13 FFLAGS="-O2 -std=legacy" LDFLAGS=-static-libgcc LIBS="$BREWDIR/lib/gcc/current/libgfortran.a /$BREWDIR/lib/gcc/current/libquadmath.a" PROGRAM=x13as -mkdir -p $HOME/.local/bin -cp x13as $HOME/.local/bin/x13as -cd ; +sudo cp $DYNAREDIR/x13as/x13as /usr/local/bin/x13as +cd $DYNAREDIR x13as ``` +Alternatively, if you don't have admin privileges you can install it into `$HOME/.local/bin` and add this folder to your PATH. ### Compile Dynare from source The following commands will download the Dynare source code and compile @@ -468,42 +470,46 @@ folder where you want Dynare installed. - Prepare the Dynare sources for the unstable version: ```sh -mkdir -p $DYNAREDIR/unstable git clone --recurse-submodules https://git.dynare.org/Dynare/dynare.git $DYNAREDIR/unstable cd $DYNAREDIR/unstable ``` -You can also choose a specific version of Dynare by checking out the corresponding branch or a specific tag with git. +If you want a certain version (e.g. 5.x) , then add `--single-branch --branch 5.x` to the git clone command. - Configure Dynare from the source directory: ```sh -arch -$ARCH meson setup --native-file scripts/homebrew-native.ini -Dmatlab_path=/Applications/MATLAB_R2022b_Beta.app -Dbuildtype=debugoptimized -Dfortran_args="['-B','$DYNAREDIR/slicot/lib']" build-matlab +export BUILDDIR=build-matlab +export MATLABPATH=/Applications/MATLAB_R2023b.app +arch -$ARCH meson setup --native-file scripts/homebrew-native-$ARCH.ini -Dmatlab_path=$MATLABPATH -Dbuildtype=debugoptimized -Dfortran_args="['-B','$DYNAREDIR/slicot/lib']" $BUILDDIR ``` where you need to adapt the path to MATLAB. -Similarly, if you don't want to compile for Octave, replace the `-Dmatlab_path` option by `-Dbuild_for=octave`, and change the build directory to `build-octave`. +Similarly, if you want to compile for Octave, replace the `-Dmatlab_path` option by `-Dbuild_for=octave`, and change the build directory to `build-octave`. - Compile: ```sh -arch -$ARCH meson compile -C <builddir> +arch -$ARCH meson compile -C $BUILDDIR ``` -where `<builddir>` is either `build-matlab` or `build-octave`. - If no errors occured, you are done. Dynare is now ready to use. -If you additionally want to compile the documentation run: + +- If you additionally want to compile the documentation run: +```sh +arch -$ARCH meson compile -C $BUILDDIR doc +``` + +- Optionally, run the testsuite: ```sh -arch -$ARCH meson compile -C <builddir> doc +arch -$ARCH meson test -C $BUILDDIR --num-processes=$(sysctl -n hw.perflevel0.physicalcpu) ``` +where `--num-processes` specifies the number of parallel processes to use for the testsuite (here set to the number of performance cores on your mac). ### Optional: pass the full PATH to MATLAB to run system commands If you start MATLAB from a terminal, you will get the PATH inherited from the shell. However, when you click on the application icon in macOS, you are not running at the terminal level: the program is run by launcher, which does not go through a shell login session. In other words, you get the system default PATH which includes `/usr/bin:/bin:/usr/sbin:/sbin`, but not `/usr/local/bin` or `$HOME/.local/bin`. -So if you want to use system commands like `pdflatex` or `x13as` you should either call them by their full path (e.g `/Library/TeX/texbin/pdflatex`) -or append the PATH in MATLAB by running `setenv('PATH', [getenv('PATH') ':/usr/local/bin:$HOME/.local/bin:/Library/TeX/texbin']);`. -Alternatively, you can create a `startup.m` file or change the system default PATH in the `/etc/paths` file. +So if you want to use system commands like `pdflatex`, `latexmk` or `x13as` you should either call them by their full path (e.g `/Library/TeX/texbin/pdflatex`) +or append the PATH by running `setenv('PATH', [getenv('PATH') ':/usr/local/bin:$HOME/.local/bin:/Library/TeX/texbin']);` in your MATLAB command line once, +e.g. by adding this to your mod file. Alternatively, you can create a `startup.m` file or change the system default PATH in the `/etc/paths` file. -Last tested on: -- macOS Ventura 13.3.1 (MacBook Air M1, MacBook Pro M2 MAX, M2 Virtual Machine using Parallels, Intel Virtual Machine using Quickemu) ## Docker We offer a variety of pre-configured Docker containers for Dynare, pre-configured with Octave and MATLAB including all recommended toolboxes. diff --git a/doc/manual/source/installation-and-configuration.rst b/doc/manual/source/installation-and-configuration.rst index ed8eb23351a9876ad2257a9686768e6d299eb206..1840b16f370660cfc2f15074871eea7c987a4310 100644 --- a/doc/manual/source/installation-and-configuration.rst +++ b/doc/manual/source/installation-and-configuration.rst @@ -8,8 +8,8 @@ Software requirements ===================== Packaged versions of Dynare are available for Windows (10 and 11), several -GNU/Linux distributions (Debian, Ubuntu, Linux Mint, Arch Linux), macOS (12 -“Monterey”), and FreeBSD. Dynare should work on other systems, but some +GNU/Linux distributions (Debian, Ubuntu, Linux Mint, Arch Linux), macOS (13 +Ventura), and FreeBSD. Dynare should work on other systems, but some compilation steps are necessary in that case. In order to run Dynare, you need one of the following: @@ -95,29 +95,23 @@ With MATLAB ^^^^^^^^^^^ To install Dynare for use with MATLAB, execute the automated installer called -``dynare-x.y.pkg`` (where *x.y* is the version number), and follow the -instructions. The default installation directory is -``/Applications/Dynare/x.y``. After installation, this directory will contain -several sub-directories, among which are ``matlab``, ``mex``, and ``doc``. - -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. +``dynare-x.y-arch.pkg`` (where *x.y* is the version number and *arch* is either arm64 for Apple Silicon or x86_64 for Intel architectures), +and follow the instructions. +This installation does not require administrative privileges. +If for some reason admin rights are requested, use *Change Install Location* and select *Install for me only*. +The default installation directory is ``/Applications/Dynare/x.y-arch``. +Installing into ``/Applications/dynare`` might fail if you have older versions of Dynare already installed in ``/Applications/Dynare``. +To fix this, modify the ownership by executing the following command in Terminal.app:: + + sudo chown -R "$USER":staff /Applications/Dynare + +Alternatively, you can modify the installation path in the automated installed using *Customize* and *Location*. +After installation, the folder will contain several sub-directories, among which are ``matlab``, ``mex``, and ``doc``. +Several versions of Dynare can coexist (by default in ``/Applications/Dynare``), +as long as you correctly adjust your path settings (see :ref:`words-warning`). + +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 ^^^^^^^^^^^ @@ -192,8 +186,26 @@ Dynare now ships a compilation environment that can be used with the :opt:`use_dll` option. To install this environment correctly, the Dynare installer ensures that the Xcode Command Line Tools (an Apple product) have been installed on a system folder. To install the Xcode Command Line Tools -yourself, simply type ``xcode-select --install`` into the Terminal +yourself, simply type ``xcode-select --install`` into the terminal (``/Applications/Utilities/Terminal.app``) prompt. +Additionally, to make MATLAB aware that you agree to the terms of Xcode, run the following two commands in the Terminal prompt:: + + CLT_VERSION=$(pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version | awk '{print $2}' | cut -d'.' -f1-2) + defaults write com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense "${CLT_VERSION}" + defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense + +Otherwise you will see a warning that Xcode is installed, but its license has not been accepted. +You can check this e.g. by running the following command in the MATLAB command window:: + + mex -setup + +Moreover, 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 either in ``/opt/homebrew/bin`` on Apple Silicon (arm64) or in ``/usr/local/bin`` on Intel (x86_64) systems. +Otherwise, it will fall back to Clang in ``/usr/bin/clang``, which works both on arm64 and x86_64 systems. With Octave ^^^^^^^^^^^ diff --git a/macOS/Makefile b/macOS/Makefile index 3a51bd58a58776dba4d014ceed328fca1e9e2b54..e331abef213849665b471b571fec31128895a2cc 100644 --- a/macOS/Makefile +++ b/macOS/Makefile @@ -15,22 +15,28 @@ # You should have received a copy of the GNU General Public License # along with Dynare. If not, see <https://www.gnu.org/licenses/>. -.PHONY: all deps clean-deps clean clean-all build +ARCHS = arm64 x86_64 +BUILDS = $(addprefix build-, $(ARCHS)) +DEPS = $(addprefix deps-, $(ARCHS)) +CLEAN_DEPS = $(addprefix clean-deps-, $(ARCHS)) +CLEAN_ALL = $(addprefix clean-all-, $(ARCHS)) -NTHREADS=$(shell sysctl -n hw.ncpu) +.PHONY: all $(BUILDS) $(DEPS) clean-pkg $(CLEAN_DEPS) $(CLEAN_ALL) clean-all -all: build +all: $(BUILDS) -deps: - make -C deps -j$(NTHREADS) +$(BUILDS): build-%: deps-% + ./build.sh $* -clean-deps: - make -C deps clean-all +$(DEPS): deps-%: + make -C deps DEPS_ARCH=$* -clean: +$(CLEAN_DEPS): clean-deps-%: + make -C deps clean-all DEPS_ARCH=$* + +clean-pkg: rm -rf pkg -clean-all: clean-deps clean +$(CLEAN_ALL): clean-all-%: clean-deps-% clean-pkg -build: deps - ./build.sh +clean-all: $(CLEAN_ALL) diff --git a/macOS/brewfiles/gcc.rb b/macOS/brewfiles/gcc.rb deleted file mode 100644 index d636f85d5d702a160c44d5dabb5967223003dea9..0000000000000000000000000000000000000000 --- a/macOS/brewfiles/gcc.rb +++ /dev/null @@ -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 diff --git a/macOS/brewfiles/gmp.rb b/macOS/brewfiles/gmp.rb deleted file mode 100644 index e210d4840e55881cf52818c9b8a41e0f37813b93..0000000000000000000000000000000000000000 --- a/macOS/brewfiles/gmp.rb +++ /dev/null @@ -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 diff --git a/macOS/brewfiles/isl.rb b/macOS/brewfiles/isl.rb deleted file mode 100644 index 474fb6ba3d322d11bac7dc0366c72d52174e6f9e..0000000000000000000000000000000000000000 --- a/macOS/brewfiles/isl.rb +++ /dev/null @@ -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 diff --git a/macOS/brewfiles/libmpc.rb b/macOS/brewfiles/libmpc.rb deleted file mode 100644 index 8ce93a32b0b4c10b2df39a8bd439335e885f0103..0000000000000000000000000000000000000000 --- a/macOS/brewfiles/libmpc.rb +++ /dev/null @@ -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 diff --git a/macOS/brewfiles/mpfr.rb b/macOS/brewfiles/mpfr.rb deleted file mode 100644 index 06c6b579a40c3f9eabc183aa9e676bc6f99a9136..0000000000000000000000000000000000000000 --- a/macOS/brewfiles/mpfr.rb +++ /dev/null @@ -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 diff --git a/macOS/brewfiles/zstd.rb b/macOS/brewfiles/zstd.rb deleted file mode 100644 index 09f2d358ed2a742d52a63962efef923b32b4002c..0000000000000000000000000000000000000000 --- a/macOS/brewfiles/zstd.rb +++ /dev/null @@ -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 diff --git a/macOS/build.sh b/macOS/build.sh index 3a79f192bbcb4fe04093acf68c4736982b881c60..d4680da7249201c2405c4b0df8fa7a547c942b01 100755 --- a/macOS/build.sh +++ b/macOS/build.sh @@ -18,11 +18,35 @@ # along with Dynare. If not, see <https://www.gnu.org/licenses/>. set -ex +#exec > >(tee build-logfile.log) 2>&1 # uncomment for debugging ROOTDIR=$(pwd)/.. +## +## Set settings based on architecture +## +path_remove () { export "$1"="$(echo -n "${!1}" | awk -v RS=: -v ORS=: '$1 != "'"$2"'"' | sed 's/:$//')"; } +path_prepend () { path_remove "$1" "$2"; export "$1"="$2:${!1}"; } +PKG_ARCH=${1:-x86_64} # default to x86_64 +if [[ "$PKG_ARCH" == arm64 ]]; then + BREWDIR=/opt/homebrew + # Make sure /opt/homebrew/bin is set first in PATH (as it might come last) + path_prepend PATH /opt/homebrew/bin + MATLAB_ARCH=maca64 +else + BREWDIR=/usr/local + # Remove /opt/homebrew/bin from PATH, so it does not intervene with the x86_64 compilations + path_remove PATH /opt/homebrew/bin + MATLAB_ARCH=maci64 + # On x86_64 we need to differentiate between older and newer MATLAB versions + OLD_MATLAB_PATH=/Applications/MATLAB_R2016b.app +fi +MATLAB_PATH=/Applications/"$PKG_ARCH"/MATLAB_R2023b.app + +# Append texbin to PATH to access latexmk and friends +path_prepend PATH /Library/TeX/texbin # Set dependency directory -LIB64="$ROOTDIR"/macOS/deps/lib64 +LIB64="$ROOTDIR"/macOS/deps/"$PKG_ARCH"/lib64 ## Hack for statically linking libquadmath, similar to the one used in ## deps/Makefile for several libraries (there is no -static-libquadmath flag, @@ -32,9 +56,10 @@ LIB64="$ROOTDIR"/macOS/deps/lib64 ## - the macOS linker is different from GNU ld and does not have the equivalent of -Bstatic/-Bdynamic ## - libgfortran.spec does not include --as-needed on macOS, hence it will link the library anyways ## Also, it does not seem possible to override libgfortran.spec with the --specs option. -GCC_VERSION=$(sed -En "/^c[[:space:]]*=/s/c[[:space:]]*=[[:space:]]*'gcc-([0-9]+)'/\1/p" "$ROOTDIR"/scripts/homebrew-native.ini) +GCC_VERSION=$(sed -En "/^c[[:space:]]*=/s/c[[:space:]]*=[[:space:]]*'.*gcc-([0-9]+)'/\1/p" "$ROOTDIR"/scripts/homebrew-native-"$PKG_ARCH".ini) + QUADMATH_DIR=$(mktemp -d) -ln -s /usr/local/opt/gcc/lib/gcc/$GCC_VERSION/libquadmath.a $QUADMATH_DIR +ln -s "$BREWDIR"/opt/gcc/lib/gcc/"$GCC_VERSION"/libquadmath.a "$QUADMATH_DIR" ## ## Compile Dynare @@ -44,19 +69,21 @@ cd "$ROOTDIR" # NB: the addition of -Wl,-ld_classic is a workaround for https://github.com/mesonbuild/meson/issues/12282 (see also the native file) common_meson_opts=(-Dbuild_for=matlab -Dbuildtype=release -Dprefer_static=true -Dfortran_args="[ '-B', '$LIB64/Slicot/' ]" \ -Dc_link_args="[ '-Wl,-ld_classic', '-L$QUADMATH_DIR' ]" -Dcpp_link_args="[ '-Wl,-ld_classic', '-L$QUADMATH_DIR' ]" -Dfortran_link_args="[ '-Wl,-ld_classic', '-L$QUADMATH_DIR' ]" \ - --native-file scripts/homebrew-native.ini) + --native-file scripts/homebrew-native-$PKG_ARCH.ini) -# Build for MATLAB ⩾ R2018a -meson setup "${common_meson_opts[@]}" -Dmatlab_path=/Applications/x86_64/MATLAB_R2023b.app build-matlab -meson compile -v -C build-matlab +# Build for MATLAB ⩾ R2018a (x86_64) and MATLAB ⩾ R2023b (arm64) +arch -"$PKG_ARCH" meson setup "${common_meson_opts[@]}" -Dmatlab_path="$MATLAB_PATH" build-matlab --wipe +arch -"$PKG_ARCH" meson compile -v -C build-matlab -# Build for MATLAB < R2018a -meson setup "${common_meson_opts[@]}" -Dmatlab_path=/Applications/MATLAB_R2016b.app build-old-matlab -meson compile -v -C build-old-matlab +if [[ "$PKG_ARCH" == x86_64 ]]; then + # Build for MATLAB < R2018a + arch -"$PKG_ARCH" meson setup "${common_meson_opts[@]}" -Dmatlab_path="$OLD_MATLAB_PATH" build-old-matlab --wipe + arch -"$PKG_ARCH" meson compile -v -C build-old-matlab +fi # If not in CI, build the docs if [[ -z $CI ]]; then - meson compile -v -C build-matlab doc + arch -"$PKG_ARCH" meson compile -v -C build-matlab doc ln -s build-matlab build-doc fi @@ -86,16 +113,23 @@ else # Get the first component, truncate it to 5 characters, and add the date LOCATION=$(echo "$VERSION" | cut -f1 -d"-" | cut -c 1-5)-"$DATE" fi +# Add architecture to LOCATION and VERSION +VERSION="$VERSION"-"$PKG_ARCH" +LOCATION="$LOCATION"-"$PKG_ARCH" NAME=dynare-"$VERSION" PKGFILES="$ROOTDIR"/macOS/pkg/"$NAME" mkdir -p \ "$PKGFILES"/preprocessor \ - "$PKGFILES"/mex/matlab/maci64-8.3-9.3 \ - "$PKGFILES"/mex/matlab/maci64-9.4-23.2 \ "$PKGFILES"/doc \ "$PKGFILES"/scripts \ "$PKGFILES"/contrib/ms-sbvar/TZcode +if [[ "$PKG_ARCH" == x86_64 ]]; then + mkdir -p "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-8.3-9.3 \ + "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-9.4-23.2 +else + mkdir -p "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-23.2 +fi cp -p "$ROOTDIR"/NEWS.md "$PKGFILES" cp -p "$ROOTDIR"/COPYING "$PKGFILES" @@ -112,8 +146,12 @@ cp -p "$ROOTDIR"/build-matlab/preprocessor/src/dynare-preprocessor "$PKGFILES" mkdir -p "$PKGFILES"/matlab/preprocessor64 ln -sf ../../preprocessor/dynare-preprocessor "$PKGFILES"/matlab/preprocessor64/dynare_m -cp -L "$ROOTDIR"/build-matlab/*.mexmaci64 "$PKGFILES"/mex/matlab/maci64-9.4-23.2 -cp -L "$ROOTDIR"/build-old-matlab/*.mexmaci64 "$PKGFILES"/mex/matlab/maci64-8.3-9.3 +if [[ "$PKG_ARCH" == x86_64 ]]; then + cp -L "$ROOTDIR"/build-matlab/*.mex"$MATLAB_ARCH" "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-9.4-23.2 + cp -L "$ROOTDIR"/build-old-matlab/*.mex"$MATLAB_ARCH" "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-8.3-9.3 +else + cp -L "$ROOTDIR"/build-matlab/*.mex"$MATLAB_ARCH" "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-23.2 +fi cp -p "$ROOTDIR"/scripts/dynare.el "$PKGFILES"/scripts cp -pr "$ROOTDIR"/contrib/ms-sbvar/TZcode/MatlabFiles "$PKGFILES"/contrib/ms-sbvar/TZcode @@ -124,36 +162,36 @@ cp "$ROOTDIR"/build-doc/preprocessor/doc/*.pdf "$PKGFILES" cp -r "$ROOTDIR"/build-doc/dynare-manual.html "$PKGFILES"/doc mkdir -p "$PKGFILES"/matlab/modules/dseries/externals/x13/macOS/64 -cp -p "$ROOTDIR"/macOS/deps/lib64/x13as/x13as "$PKGFILES"/matlab/modules/dseries/externals/x13/macOS/64 +cp -p "$ROOTDIR"/macOS/deps/"$PKG_ARCH"/lib64/x13as/x13as "$PKGFILES"/matlab/modules/dseries/externals/x13/macOS/64 cd "$ROOTDIR"/macOS/pkg # Dynare option -pkgbuild --root "$PKGFILES" --identifier org.dynare --version "$VERSION" --install-location /Applications/Dynare/"$LOCATION" "$NAME".pkg +arch -"$PKG_ARCH" pkgbuild --root "$PKGFILES" --identifier org.dynare."$VERSION" --version "$VERSION" --install-location /Applications/Dynare/"$LOCATION" "$NAME".pkg + +# Create distribution.xml by replacing variables in distribution_template.xml +sed -e "s/VERSION_NO_SPACE/$VERSION/g" \ + -e "s/LOCATION/$LOCATION/g" \ + "$ROOTDIR"/macOS/distribution_template.xml > distribution.xml -# 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 welcome.html by replacing variables in welcome_template.html +sed -e "s/VERSION_NO_SPACE/$VERSION/g" \ + -e "s/DATE/$DATELONG/g" \ + "$ROOTDIR"/macOS/welcome_template.html > "$ROOTDIR"/macOS/welcome.html -# 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 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 +arch -"$PKG_ARCH" productbuild --distribution distribution.xml --resources "$ROOTDIR"/macOS --package-path ./"$NAME".pkg "$NAME"-productbuild.pkg -# cleanup -rm -f ./*.xml +# Cleanup +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 +mv "$NAME"-productbuild.pkg "$NAME".pkg diff --git a/macOS/conclusion_template.html b/macOS/conclusion_template.html new file mode 100644 index 0000000000000000000000000000000000000000..b78baec8f7ebaaf56923d99468d33575d118e506 --- /dev/null +++ b/macOS/conclusion_template.html @@ -0,0 +1,45 @@ +<html lang="en"> + <head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Recommendations</title> + <style> + .center-text { + text-align: center; + } + .bold-text { + font-weight: bold; + } + code { + font-family: "Courier New", Courier, monospace; + } + </style> + </head> + + <body> + <header class="center-text"> + <h1>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. Check this by running the following command in the MATLAB command window:</p> + <code> + mex -setup + </code> + <p>If you get a warning in MATLAB, that Xcode is installed, but its license has not been accepted, please refer to the <a href="https://www.dynare.org/manual/installation-and-configuration.html#prerequisites-on-macos" target="_blank" rel="noopener noreferrer">manual</a> for a workaround.</p> + <p>Moreover, we recommend making use of optimized compilation flags and for this you need to install GCC via Homebrew. + 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, Dynare will automatically prefer it for use_dll if the binaries are either in /opt/homebrew/bin/gcc-GCC_VERSION (arm64) or in /usr/local/bin/gcc-GCC_VERSION (x86_64). Otherwise, it will fall back to Clang in /usr/bin/clang (for both arm64 and x86_64).</p> + </main> + </body> +</html> \ No newline at end of file diff --git a/macOS/deps/Makefile b/macOS/deps/Makefile index 799553c7fee9d2f4cbf808cc7ac74a78e00b633c..316b2776dc4b9798158560affec5b0107cfadd7e 100644 --- a/macOS/deps/Makefile +++ b/macOS/deps/Makefile @@ -17,11 +17,19 @@ include versions.mk -GCC_VERSION = $(shell sed -En "/^c[[:space:]]*=/s/c[[:space:]]*=[[:space:]]*'gcc-([0-9]+)'/\1/p" ../../scripts/homebrew-native.ini) +# settings for different architectures +DEPS_ARCH ?= x86_64 # use x86_64 by default + +BREWDIR := $(if $(filter arm64,$(DEPS_ARCH)),/opt/homebrew,/usr/local) + +GCC_VERSION = $(shell sed -En "/^c[[:space:]]*=/s/c[[:space:]]*=[[:space:]]*'.*gcc-([0-9]+)'/\1/p" ../../scripts/homebrew-native-$(DEPS_ARCH).ini) + ROOT_PATH = $(realpath .) WGET_OPTIONS := --no-verbose --no-use-server-timestamps --retry-connrefused --retry-on-host-error +NTHREADS=$(shell sysctl -n hw.perflevel0.physicalcpu) + .PHONY: all build build-slicot build-x13as \ clean-lib clean-libslicot clean-x13as-bin \ clean-src clean-slicot-src clean-x13as-src \ @@ -41,34 +49,34 @@ clean-tar: clean-slicot-tar clean-x13as-tar clean-all: clean-lib clean-src clean-tar # -# Slicot +# slicot # tarballs/slicot-$(SLICOT_VERSION).tar.gz: mkdir -p tarballs wget $(WGET_OPTIONS) -O $@ https://deb.debian.org/debian/pool/main/s/slicot/slicot_$(SLICOT_VERSION).orig.tar.gz -sources64/slicot-$(SLICOT_VERSION): tarballs/slicot-$(SLICOT_VERSION).tar.gz - rm -rf sources64/slicot-* +$(DEPS_ARCH)/sources64/slicot-$(SLICOT_VERSION): tarballs/slicot-$(SLICOT_VERSION).tar.gz + rm -rf $(DEPS_ARCH)/sources64/slicot-* mkdir -p $@ tar xf $< --directory $@ --strip-components=1 touch $@ -lib64/Slicot/libslicot64_pic.a: sources64/slicot-$(SLICOT_VERSION) - make -C $< FORTRAN=gfortran LOADER=gfortran SLICOTLIB=../libslicot64_pic.a OPTS="-O2 -g -fdefault-integer-8" lib +$(DEPS_ARCH)/lib64/slicot/libslicot64_pic.a: $(DEPS_ARCH)/sources64/slicot-$(SLICOT_VERSION) + make -C $< FORTRAN=$(BREWDIR)/bin/gfortran LOADER=$(BREWDIR)/bin/gfortran SLICOTLIB=../libslicot64_pic.a OPTS="-O2 -g -fdefault-integer-8" lib -j$(NTHREADS) strip -S $</libslicot64_pic.a mkdir -p $(dir $@) cp $</libslicot64_pic.a $@ -build-slicot: lib64/Slicot/libslicot64_pic.a +build-slicot: $(DEPS_ARCH)/lib64/slicot/libslicot64_pic.a clean-slicot-tar: rm -f tarballs/slicot-$(SLICOT_VERSION).tar.gz clean-slicot-src: - rm -rf sources64/slicot-$(SLICOT_VERSION) + rm -rf $(DEPS_ARCH)/sources64/slicot-$(SLICOT_VERSION) clean-libslicot: - rm -rf lib64/Slicot + rm -rf $(DEPS_ARCH)/lib64/slicot clean-slicot-all: clean-slicot-src clean-slicot-tar clean-libslicot @@ -81,12 +89,12 @@ tarballs/x13as_asciisrc-v$(X13AS_VERSION).tar.gz: mkdir -p tarballs wget $(WGET_OPTIONS) -O $@ https://www2.census.gov/software/x-13arima-seats/x13as/unix-linux/program-archives/x13as_asciisrc-v$(X13AS_VERSION).tar.gz -sources64/x13as-$(X13AS_VERSION): tarballs/x13as_asciisrc-v$(X13AS_VERSION).tar.gz - rm -rf sources64/x13as-* +$(DEPS_ARCH)/sources64/x13as-$(X13AS_VERSION): tarballs/x13as_asciisrc-v$(X13AS_VERSION).tar.gz + rm -rf $(DEPS_ARCH)/sources64/x13as-* mkdir -p $@ tar xf $< --directory $@ -lib64/x13as/x13as: sources64/x13as-$(X13AS_VERSION) +$(DEPS_ARCH)/lib64/x13as/x13as: $(DEPS_ARCH)/sources64/x13as-$(X13AS_VERSION) # Statically link x13as (see #1865). # Using -static is not possible, it does not work under Darwin. # Implement an ugly workaround in the absence of -static-libquadmath flag. @@ -97,20 +105,21 @@ lib64/x13as/x13as: sources64/x13as-$(X13AS_VERSION) # gfortran as the linker with -static-libgfortran and # -static-libquadmath flags, and drop the GCC_VERSION variable. cd $< && sed -i '' 's/-static//g' makefile.gf - make -C $< -f makefile.gf FC=gfortran LINKER=gcc-$(GCC_VERSION) FFLAGS="-O2 -std=legacy" LDFLAGS=-static-libgcc LIBS="/usr/local/lib/gcc/$(GCC_VERSION)/libgfortran.a /usr/local/lib/gcc/$(GCC_VERSION)/libquadmath.a" PROGRAM=x13as + make -C $< -f makefile.gf FC=$(BREWDIR)/bin/gfortran LINKER=$(BREWDIR)/bin/gcc-$(GCC_VERSION) FFLAGS="-O2 -std=legacy" LDFLAGS=-static-libgcc LIBS="$(BREWDIR)/lib/gcc/$(GCC_VERSION)/libgfortran.a $(BREWDIR)/lib/gcc/$(GCC_VERSION)/libquadmath.a" PROGRAM=x13as -j$(NTHREADS) + strip $</x13as mkdir -p $(dir $@) cp $</x13as $@ -build-x13as: lib64/x13as/x13as +build-x13as: $(DEPS_ARCH)/lib64/x13as/x13as clean-x13as-tar: rm -f tarballs/x13as_asciisrc-v$(X13AS_VERSION).tar.gz clean-x13as-src: - rm -rf sources64/x13as-$(X13AS_VERSION) + rm -rf $(DEPS_ARCH)/sources64/x13as-$(X13AS_VERSION) clean-x13as-bin: - rm -rf lib64/x13as + rm -rf $(DEPS_ARCH)/lib64/x13as clean-x13as-all: clean-x13as-tar clean-x13as-src clean-x13as-bin diff --git a/macOS/distribution_template.xml b/macOS/distribution_template.xml index fa213eb3a1b0626862043ddbebf201f34e4213b0..e5988b680b7553fe677d196da5e7ecdedc5ce45d 100644 --- a/macOS/distribution_template.xml +++ b/macOS/distribution_template.xml @@ -1,22 +1,19 @@ <?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" /> - <options customize="allow" require-scripts="false" hostArchitectures="x86_64" /> + <domains enable_anywhere="false" enable_currentUserHome="true" enable_localSystem="false"/> <!-- on enable_currentUserHome="true" does not require admin rights! enable_localSystem="true" or enable_anywhere="true" requires admin rights by default, even though this can be changed in the installer though under Change Installation. --> + <pkg-ref id="default" /> + <options customize="allow" require-scripts="false" hostArchitectures="x86_64,arm64" /> <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"> - <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> - <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> + <choice id="default" title="Dynare" description="Dynare Required Files" start_enabled="false" enabled="false" customLocation="/Applications/Dynare/LOCATION"> + <pkg-ref id="org.dynare.VERSION_NO_SPACE" /> + </choice> + <pkg-ref id="org.dynare.VERSION_NO_SPACE" version="VERSION_NO_SPACE">dynare-VERSION_NO_SPACE.pkg</pkg-ref> +</installer-gui-script> \ No newline at end of file diff --git a/macOS/scripts/postinstall b/macOS/scripts/postinstall deleted file mode 100755 index 387dd69c8855812613011ec02b6bbe850d536e12..0000000000000000000000000000000000000000 --- a/macOS/scripts/postinstall +++ /dev/null @@ -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 diff --git a/macOS/welcome_template.html b/macOS/welcome_template.html index 43b5295d773128a72e32e2af19b471942b5890fa..c769f743817bad3b01386485e9942db35087db6c 100644 --- a/macOS/welcome_template.html +++ b/macOS/welcome_template.html @@ -1,15 +1,37 @@ <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 Compiler Collection (GCC). Installing GCC is necessary if you want to use the <tt>use_dll</tt> option in Dynare, but otherwise unnecessary.</p> + <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; + } + code { + font-family: "Courier New", Courier, monospace; + } + </style> + </head> - <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> + <body> + <header class="center-text"> + <h1>Welcome to Dynare</h1> + <p>Version VERSION_NO_SPACE</p> + <p>DATE</p> + </header> - <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> + <main> + <p>Thank you for choosing Dynare!</p> + <p>This installation does not require administrative privileges. If for some reason admin rights are requested, use 'Change Install Location' and select 'Install for me only'.</p> + <p>By default Dynare will be installed into /Applications/Dynare. To modify the installation path, click <strong>Customize</strong> after accepting the license. Then, under <strong>Location</strong>, select your desired folder.</p> + <p>Installing into /Applications/dynare might fail if you have older versions of Dynare installed in /Applications/Dynare. To fix this, modify the ownership by executing the following command in Terminal.app:</p> + <code> + sudo chown -R "$USER":staff /Applications/Dynare + </code> + </main> - <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> +</html> \ No newline at end of file diff --git a/scripts/homebrew-native-arm64.ini b/scripts/homebrew-native-arm64.ini new file mode 100644 index 0000000000000000000000000000000000000000..39bdea15045d2b6a5c70bc32521c386e1ee6510a --- /dev/null +++ b/scripts/homebrew-native-arm64.ini @@ -0,0 +1,15 @@ +# Meson native file for compiling under Homebrew for arm64 architecture + +[binaries] +cpp = '/opt/homebrew/bin/g++-13' +c = '/opt/homebrew/bin/gcc-13' +flex = '/opt/homebrew/opt/flex/bin/flex' +bison = '/opt/homebrew/opt/bison/bin/bison' + +[built-in options] +cpp_args = [ '-I/opt/homebrew/include', '-B', '/opt/homebrew/lib' ] +# XCode 15 (on Ventura and Sonoma) has a linker issue, see https://github.com/mesonbuild/meson/issues/12282, workaround is to use ld_classic +cpp_link_args = [ '-Wl,-ld_classic' ] +c_link_args = [ '-Wl,-ld_classic' ] +fortran_link_args = [ '-Wl,-ld_classic' ] +#fortran_args = [ '-B', '/Users/sebastien/slicot' ] \ No newline at end of file diff --git a/scripts/homebrew-native.ini b/scripts/homebrew-native-x86_64.ini similarity index 78% rename from scripts/homebrew-native.ini rename to scripts/homebrew-native-x86_64.ini index 41efd280bf90e6ec527de75700b86ef8e932b2af..42a189fe2035fbb2ddb56818d17554a627831211 100644 --- a/scripts/homebrew-native.ini +++ b/scripts/homebrew-native-x86_64.ini @@ -1,8 +1,8 @@ -# Meson native file for compiling under Homebrew / x86_64 +# Meson native file for compiling under Homebrew for x86_64 architecture [binaries] -cpp = 'g++-13' -c = 'gcc-13' +cpp = '/usr/local/bin/g++-13' +c = '/usr/local/bin/gcc-13' flex = '/usr/local/opt/flex/bin/flex' bison = '/usr/local/opt/bison/bin/bison'