From b2f603091a8d41f0a5f7b13700d4d31ed7b27886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Fri, 19 Jan 2024 16:24:24 +0100 Subject: [PATCH] MATLAB Online package: update build script for meson Also, use the local git checkout instead of downloading a source tarball from the website. --- scripts/matlab-online/packageDynare.sh | 53 ++++++++------------------ 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/scripts/matlab-online/packageDynare.sh b/scripts/matlab-online/packageDynare.sh index 90e3b622c..e8d3a6b20 100755 --- a/scripts/matlab-online/packageDynare.sh +++ b/scripts/matlab-online/packageDynare.sh @@ -4,12 +4,8 @@ set -exo pipefail # Creates a dynare-X.Y.mltbx in the current repository, using the settings below. # Needs to be run from Ubuntu 22.04 LTS, with the needed packages installed. -DYNAREVER=5.5 X13ASVER=1-1-b60 -LIBLOCATION="/MATLAB Add-Ons/Toolboxes/Dynare/mex/matlab/libs" MATLABPATH=/opt/MATLAB/R2023b -# MatIO has been recompiled by hand to avoid the dependency on HDF5, which is a nightmare -MATIO_PREFIX=/home/sebastien/usr # TODO: change size and put white background for better rendering in MATLAB Add-Ons browser DYNARE_PNG_LOGO=../../preprocessor/doc/logos/dlogo.png @@ -21,48 +17,31 @@ cleanup () } trap cleanup EXIT -pushd "$tmpdir" +pushd ../.. +meson setup -Dmatlab_path="$MATLABPATH" -Dbuildtype=release -Dprefer_static=true "$tmpdir"/build-matlab-online -# Get Dynare -wget -q https://www.dynare.org/release/source/dynare-$DYNAREVER.tar.xz -tar xf dynare-$DYNAREVER.tar.xz +cd "$tmpdir"/build-matlab-online +meson compile +meson install --destdir "$tmpdir" +DYNAREVER=$(meson introspect --projectinfo | jq -r '.version') -# Build Dynare -cd dynare-$DYNAREVER - -# Use static libstdc++ otherwise the one shipped with MATLAB creates problem (since it overrides the systemd-wide one from Ubuntu) -./configure --with-matlab="$MATLABPATH" --with-matio="$MATIO_PREFIX" --disable-octave --disable-doc --disable-dynare++ LDFLAGS=-static-libstdc++ -make -j$(nproc) - -strip preprocessor/dynare-preprocessor -strip mex/matlab/*.mexa64 - -# Patch mex files to look into ./lib folder -for f in mex/matlab/*.mexa64 -do - patchelf --set-rpath "$LIBLOCATION" $f -done - -# Grab the shared libraries needed -mkdir mex/matlab/libs -for l in libgsl.so.27 libgslcblas.so.0 -do - cp /usr/lib/x86_64-linux-gnu/$l mex/matlab/libs/ - # Patch rpath to find dependencies at runtime - patchelf --set-rpath "$LIBLOCATION" mex/matlab/libs/$l -done -cp "$MATIO_PREFIX"/lib/libmatio.so.11 mex/matlab/libs/ -patchelf --set-rpath "$LIBLOCATION" mex/matlab/libs/libmatio.so.11 # Probably not needed +cd .. +strip usr/local/bin/dynare-preprocessor +strip usr/local/lib/dynare/mex/matlab/*.mexa64 # Get X13 binary from the Census Bureau website # The binary from Ubuntu has some shared library dependencies, so it is safer to use a static binary wget -q https://www2.census.gov/software/x-13arima-seats/x13as/unix-linux/program-archives/x13as_ascii-v${X13ASVER}.tar.gz tar xf x13as_ascii-v${X13ASVER}.tar.gz -mkdir -p matlab/modules/dseries/externals/x13/linux/64 -cp x13as/x13as_ascii matlab/modules/dseries/externals/x13/linux/64/x13as + +# Populate staging area for the zip +cp -pRL usr/local/lib/dynare dynare # -L is needed to dereference the preprocessor symlink +mkdir -p dynare/matlab/dseries/externals/x13/linux/64 +cp -p x13as/x13as_ascii dynare/matlab/dseries/externals/x13/linux/64/x13as # zip dynare -zip -q -r "$tmpdir"/dynare.zip contrib/jsonlab contrib/ms-sbvar/TZcode/MatlabFiles examples matlab mex/matlab preprocessor/dynare-preprocessor license.txt NEWS.md README.md VERSION +cd dynare +zip -q -r "$tmpdir"/dynare.zip * # make toolbox popd