2019-09-16 18:28:34 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-01-06 17:25:33 +01:00
|
|
|
# Copyright © 2019-2021 Dynare Team
|
2019-09-30 16:46:02 +02:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
|
2019-09-16 18:28:34 +02:00
|
|
|
set -ex
|
|
|
|
|
2019-11-04 17:10:33 +01:00
|
|
|
ROOTDIR=$(pwd)/..
|
|
|
|
|
2019-09-30 16:45:36 +02:00
|
|
|
# Set the compilers
|
2020-09-01 14:39:17 +02:00
|
|
|
CC=gcc-10
|
|
|
|
CXX=g++-10
|
2019-09-30 16:45:36 +02:00
|
|
|
|
2019-09-20 14:43:48 +02:00
|
|
|
# Set the number of threads
|
|
|
|
NTHREADS=$(nproc)
|
|
|
|
|
2019-11-04 17:10:33 +01:00
|
|
|
# Set dependency directory
|
|
|
|
LIB64="$ROOTDIR"/macOS/deps/lib64
|
|
|
|
|
|
|
|
|
2019-09-16 18:28:34 +02:00
|
|
|
##
|
2019-09-23 11:23:28 +02:00
|
|
|
## Find Dynare Version
|
2019-09-16 18:28:34 +02:00
|
|
|
##
|
2019-11-04 17:10:33 +01:00
|
|
|
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
|
|
|
|
|
2019-09-16 18:28:34 +02:00
|
|
|
if [[ -z $VERSION ]]; then
|
|
|
|
VERSION=$(grep '^AC_INIT(' ../configure.ac | sed 's/AC_INIT(\[dynare\], \[\(.*\)\])/\1/')
|
|
|
|
if [[ -d ../.git/ ]]; then
|
2019-11-04 17:10:33 +01:00
|
|
|
VERSION="$VERSION"-"$SHASHORT"
|
2019-09-16 18:28:34 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-03-18 15:42:28 +01:00
|
|
|
# Install location must not be too long for gcc.
|
|
|
|
# Otherwise, the headers of the compiled libraries cannot be modified
|
|
|
|
# obliging recompilation on the user's system.
|
|
|
|
# If VERSION is not a official release number, then do some magic
|
|
|
|
# to get something not too long, still more or less unique.
|
|
|
|
if [[ "$VERSION" =~ ^[0-9\.]+$ ]]; then
|
|
|
|
LOCATION=$VERSION
|
|
|
|
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"
|
2019-11-04 17:10:33 +01:00
|
|
|
fi
|
2019-09-30 16:45:36 +02:00
|
|
|
|
2019-09-16 18:28:34 +02:00
|
|
|
##
|
2019-10-15 16:41:24 +02:00
|
|
|
## Compile Dynare doc, dynare++, preprocessor, mex for MATLAB < 2018a
|
2019-09-16 18:28:34 +02:00
|
|
|
##
|
|
|
|
cd "$ROOTDIR"
|
|
|
|
[[ -f configure ]] || autoreconf -si
|
2020-12-17 19:11:36 +01:00
|
|
|
./configure \
|
2019-10-15 16:41:24 +02:00
|
|
|
PACKAGE_VERSION="$VERSION" \
|
|
|
|
PACKAGE_STRING="dynare $VERSION" \
|
2020-12-17 19:11:36 +01:00
|
|
|
CC=$CC \
|
|
|
|
CXX=$CXX \
|
|
|
|
CPPFLAGS=-I/usr/local/include \
|
2019-10-15 16:41:24 +02:00
|
|
|
LDFLAGS=-static-libgcc \
|
2021-01-07 18:40:01 +01:00
|
|
|
LEX=/usr/local/opt/flex/bin/flex \
|
|
|
|
YACC=/usr/local/opt/bison/bin/bison \
|
2019-10-15 16:41:24 +02:00
|
|
|
--with-gsl="$LIB64"/gsl \
|
|
|
|
--with-matio="$LIB64"/matio \
|
|
|
|
--with-slicot="$LIB64"/Slicot/with-underscore \
|
|
|
|
--disable-octave \
|
2020-09-30 17:50:24 +02:00
|
|
|
--with-matlab=/Applications/MATLAB_R2016b.app
|
2019-09-20 15:08:11 +02:00
|
|
|
if [[ -z $CI ]]; then
|
|
|
|
# If not in Gitlab CI, clean the source and build the doc
|
|
|
|
make clean
|
2019-09-20 14:43:48 +02:00
|
|
|
make -j"$NTHREADS" pdf html
|
2019-09-20 15:08:11 +02:00
|
|
|
fi
|
2019-09-20 14:43:48 +02:00
|
|
|
make -j"$NTHREADS"
|
2019-09-16 18:28:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
## Create package
|
|
|
|
##
|
|
|
|
NAME=dynare-"$VERSION"
|
|
|
|
PKGFILES="$ROOTDIR"/macOS/pkg/"$NAME"
|
2019-11-04 17:10:33 +01:00
|
|
|
mkdir -p \
|
2021-01-06 17:25:33 +01:00
|
|
|
"$PKGFILES"/preprocessor \
|
2020-04-07 12:24:16 +02:00
|
|
|
"$PKGFILES"/mex/matlab/maci64-8.3-9.3 \
|
2021-03-17 17:47:27 +01:00
|
|
|
"$PKGFILES"/mex/matlab/maci64-9.4-9.10 \
|
2019-11-04 17:10:33 +01:00
|
|
|
"$PKGFILES"/doc/dynare++ \
|
|
|
|
"$PKGFILES"/dynare++ \
|
|
|
|
"$PKGFILES"/scripts \
|
|
|
|
"$PKGFILES"/contrib/ms-sbvar/TZcode
|
|
|
|
|
|
|
|
if [[ $VERSION == *-unstable* ]]; then
|
|
|
|
echo "$SHA" > "$PKGFILES"/sha.txt
|
|
|
|
fi
|
2020-02-17 23:12:12 +01:00
|
|
|
cp -p "$ROOTDIR"/NEWS.md "$PKGFILES"
|
2019-09-16 18:28:34 +02:00
|
|
|
cp -p "$ROOTDIR"/COPYING "$PKGFILES"
|
|
|
|
cp -p "$ROOTDIR"/VERSION "$PKGFILES"
|
|
|
|
cp -p "$ROOTDIR"/license.txt "$PKGFILES"
|
|
|
|
|
|
|
|
cp -pr "$ROOTDIR"/matlab "$PKGFILES"
|
|
|
|
cp -pr "$ROOTDIR"/examples "$PKGFILES"
|
|
|
|
|
2021-01-06 17:25:33 +01:00
|
|
|
cp -p "$ROOTDIR"/preprocessor/src/dynare-preprocessor "$PKGFILES"/preprocessor
|
|
|
|
|
|
|
|
# Recreate backward-compatibility symlink
|
|
|
|
rm -f "$ROOTDIR"/matlab/preprocessor64/dynare_m
|
|
|
|
ln -sf ../../preprocessor/dynare-preprocessor "$PKGFILES"/matlab/preprocessor64/dynare_m
|
|
|
|
|
2020-04-07 12:24:16 +02:00
|
|
|
cp -L "$ROOTDIR"/mex/matlab/* "$PKGFILES"/mex/matlab/maci64-8.3-9.3
|
2019-09-16 18:28:34 +02:00
|
|
|
|
|
|
|
cp -p "$ROOTDIR"/scripts/dynare.el "$PKGFILES"/scripts
|
2019-10-04 09:50:50 +02:00
|
|
|
cp -pr "$ROOTDIR"/contrib/ms-sbvar/TZcode/MatlabFiles "$PKGFILES"/contrib/ms-sbvar/TZcode
|
2019-09-16 18:28:34 +02:00
|
|
|
cp -pr "$ROOTDIR"/contrib/jsonlab "$PKGFILES"/contrib
|
|
|
|
|
|
|
|
cp "$ROOTDIR"/doc/*.pdf "$PKGFILES"/doc
|
|
|
|
cp "$ROOTDIR"/doc/gsa/gsa.pdf "$PKGFILES"/doc
|
|
|
|
cp "$ROOTDIR"/doc/parallel/parallel.pdf "$PKGFILES"/doc
|
|
|
|
cp "$ROOTDIR"/doc/dseries-and-reporting/dseriesReporting.pdf "$PKGFILES"/doc
|
|
|
|
cp "$ROOTDIR"/preprocessor/doc/preprocessor/preprocessor.pdf "$PKGFILES"/doc
|
|
|
|
cp "$ROOTDIR"/preprocessor/doc/macroprocessor/macroprocessor.pdf "$PKGFILES"/doc
|
|
|
|
cp "$ROOTDIR"/doc/manual/build/latex/dynare-manual.pdf "$PKGFILES"/doc
|
|
|
|
cp -r "$ROOTDIR"/doc/manual/build/html "$PKGFILES"/doc/dynare-manual.html
|
|
|
|
|
|
|
|
cp "$ROOTDIR"/dynare++/doc/*.pdf "$PKGFILES"/doc/dynare++
|
|
|
|
|
|
|
|
cp "$ROOTDIR"/dynare++/src/dynare++ "$PKGFILES"/dynare++
|
2020-02-25 16:33:32 +01:00
|
|
|
cp "$ROOTDIR"/dynare++/dynare_simul/dynare_simul.m "$PKGFILES"/dynare++
|
2019-09-16 18:28:34 +02:00
|
|
|
|
2019-10-03 18:06:37 +02:00
|
|
|
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
|
2019-09-30 16:45:36 +02:00
|
|
|
|
2019-09-16 18:28:34 +02:00
|
|
|
|
|
|
|
##
|
2019-10-15 16:41:24 +02:00
|
|
|
## Create mex for MATLAB ≥ 2018a
|
2019-09-16 18:28:34 +02:00
|
|
|
##
|
|
|
|
cd "$ROOTDIR"/mex/build/matlab
|
|
|
|
make clean
|
2020-12-17 19:11:36 +01:00
|
|
|
./configure \
|
2019-10-15 16:41:24 +02:00
|
|
|
PACKAGE_VERSION="$VERSION" \
|
|
|
|
PACKAGE_STRING="dynare $VERSION" \
|
2020-12-17 19:11:36 +01:00
|
|
|
CC=$CC \
|
|
|
|
CXX=$CXX \
|
|
|
|
CPPFLAGS=-I/usr/local/include \
|
2019-10-15 16:41:24 +02:00
|
|
|
LDFLAGS=-static-libgcc \
|
|
|
|
--with-gsl="$LIB64"/gsl \
|
|
|
|
--with-matio="$LIB64"/matio \
|
|
|
|
--with-slicot="$LIB64"/Slicot/with-underscore \
|
2020-09-30 17:50:24 +02:00
|
|
|
--with-matlab=/Applications/MATLAB_R2019b.app
|
2019-09-20 14:43:48 +02:00
|
|
|
make -j"$NTHREADS"
|
2021-03-17 17:47:27 +01:00
|
|
|
cp -L "$ROOTDIR"/mex/matlab/* "$PKGFILES"/mex/matlab/maci64-9.4-9.10
|
2019-09-16 18:28:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
## Make package
|
|
|
|
##
|
|
|
|
cd "$ROOTDIR"/macOS/pkg
|
2019-11-04 17:10:33 +01:00
|
|
|
|
|
|
|
# Dynare option
|
2020-05-28 16:27:23 +02:00
|
|
|
pkgbuild --root "$PKGFILES" --identifier org.dynare --version "$VERSION" --install-location /Applications/Dynare/"$LOCATION" "$NAME".pkg
|
2019-11-04 17:10:33 +01:00
|
|
|
|
|
|
|
# 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
|
2020-05-28 16:27:23 +02:00
|
|
|
pkgbuild --root "$ROOTDIR"/macOS/brewfiles --identifier org.dynare.gcc --version "$VERSION" --scripts "$ROOTDIR"/macOS/scripts --install-location /Applications/Dynare/"$LOCATION" "$NAME"-gcc.pkg
|
2019-11-04 17:10:33 +01:00
|
|
|
|
|
|
|
# Replace variables in displayed files
|
|
|
|
sed "s/VERSION_READ/$VERSION/g" "$ROOTDIR"/macOS/distribution_template.xml > distribution_tmp.xml
|
2019-09-16 18:28:34 +02:00
|
|
|
sed "s/VERSION_NO_SPACE/$VERSION/g" distribution_tmp.xml > distribution.xml
|
2019-11-04 17:10:33 +01:00
|
|
|
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
|
2019-09-16 18:28:34 +02:00
|
|
|
productbuild --distribution distribution.xml --resources "$ROOTDIR"/macOS --package-path ./"$NAME".pkg "$NAME"-new.pkg
|
2019-11-04 17:10:33 +01:00
|
|
|
|
|
|
|
# cleanup
|
2019-09-30 16:45:36 +02:00
|
|
|
rm -f ./*.xml
|
2019-09-16 18:28:34 +02:00
|
|
|
rm -rf "$PKGFILES"
|
2019-11-04 17:10:33 +01:00
|
|
|
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
|
2019-09-16 18:28:34 +02:00
|
|
|
mv "$NAME"-new.pkg "$NAME".pkg
|