Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 4.6
  • 5.x
  • 6.x
  • aux_vars_fix
  • julia
  • llvm-15
  • master
  • python-codegen
  • rework_pac
  • uop
  • julia-6.2.0
  • julia-6.3.0
  • julia-6.4.0
  • julia-7.0.0
14 results

Target

Select target project
No results found
Select Git revision
  • aux_vars_fix
  • master
  • rework_pac
  • created_preprocessor_repo
4 results
Show changes
113 files
+ 41439
35181
Compare changes
  • Side-by-side
  • Inline

Files

.clang-format

0 → 100644
+22 −0
Original line number Diff line number Diff line
# This file should be kept in sync with the one in dynare.git (which also
# contains more explanations).
Language: Cpp
Standard: c++20
ColumnLimit: 100
BasedOnStyle: GNU
AllowShortFunctionsOnASingleLine: None
AlwaysBreakTemplateDeclarations: Yes
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
Cpp11BracedListStyle: true
DeriveLineEnding: false
IndentPPDirectives: AfterHash
InsertNewlineAtEOF: true
PackConstructorInitializers: NextLine
PPIndentWidth: 1
PointerAlignment: Left
# RemoveParentheses: ReturnStatement
# RemoveSemicolon: true
SpaceAfterTemplateKeyword: false
SpaceBeforeParens: ControlStatements
SpaceBeforeCpp11BracedList: true

.clang-tidy

0 → 100644
+8 −0
Original line number Diff line number Diff line
# TODO: add the following check families:
# - bugprone-*
# - cppcoreguidelines-

# NB: as of clang-tidy 16, we get several false positives inside boost, notably this one:
#  https://github.com/llvm/llvm-project/issues/40486

Checks: 'performance-*,modernize-*,-modernize-use-trailing-return-type,-clang-diagnostic-unqualified-std-cast-call'
+0 −66
Original line number Diff line number Diff line
# For checking that no file has been unduly ignored, run:
# $ git ls-files -i --exclude-per-directory=.gitignore
# Any file that is displayed should be removed from the ignore list
# (possibly by an exclusion rule beginning with an exclamation mark)

# Generic ignore rules
*~
*.o
*.a
*.fig
\#*\#
*.txt

# Build system rules
build-aux/*
.deps
Makefile
Makefile.in
configure
config.log
config.status
aclocal.m4
autom4te.cache
TAGS

# Preprocessor
/src/dynare_m
/src/dynare_m.exe
/src/DynareBison.cc
/src/DynareBison.hh
/src/FlexLexer.h
/src/DynareFlex.cc
/src/location.hh
/src/position.hh
/src/stack.hh
/src/macro/MacroBison.cc
/src/macro/MacroBison.hh
/src/macro/MacroFlex.cc
/src/macro/location.hh
/src/macro/position.hh
/src/macro/stack.hh
/src/doc/

# macOS stuff
.DS_Store

# Doc rules
*.pdf
*.aux
*.log
*.nav
*.out
*.snm
*.toc
*.vrb
!/doc/macroprocessor/new-design.pdf
!/doc/macroprocessor/old-design.pdf

# test files
checksum
*.mod
*.tex
*.json
+*

# Bison verbose output file
*.output
+84 −6
Original line number Diff line number Diff line
build:
variables:
  TERM: linux
  MINGW64_BOOST_VERSION: 1.88.0-2
  WGET_OPTIONS: '--no-verbose --no-use-server-timestamps --retry-connrefused --retry-on-host-error'
  # To ensure that "false && true" fails, see https://gitlab.com/gitlab-org/gitlab-runner/-/issues/25394#note_412609647
  FF_ENABLE_BASH_EXIT_CODE_CHECK: 'true'

build_linux_x86_64:
  stage: build
  script:
    - autoreconf -si
    - ./configure
    - make -j$(nproc)
    - make -j$(nproc) pdf
    - make -j$(nproc) html
    - meson setup --buildtype=release -Db_lto=true build
    - meson compile -C build -v
  artifacts:
    paths:
      - build/src/dynare-preprocessor

build_linux_arm64:
  stage: build
  script:
    - meson setup --buildtype=release -Db_lto=true --cross-file scripts/linux-arm64-cross.ini build
    - meson compile -C build -v
  artifacts:
    paths:
      - build/src/dynare-preprocessor

build_windows_x86_64:
  stage: build
  script:
    - mkdir -p tarballs
    - '[[ -f tarballs/mingw-w64-x86_64-boost-$MINGW64_BOOST_VERSION-any.pkg.tar.zst ]] || wget $WGET_OPTIONS -P tarballs http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-boost-$MINGW64_BOOST_VERSION-any.pkg.tar.zst'
    - mkdir -p deps
    - tar xf tarballs/mingw-w64-x86_64-boost-$MINGW64_BOOST_VERSION-any.pkg.tar.zst --directory deps
    - echo -e "[properties]\nboost_root = '$(pwd)/deps/mingw64/'" > boost.ini
    - meson setup --buildtype=release -Db_lto=true --cross-file scripts/windows-cross.ini --cross-file boost.ini build
    - meson compile -C build -v
  cache:
    # This cache is shared between all branches, to save space
    key: $CI_JOB_NAME
    paths:
      - tarballs/
  artifacts:
    paths:
      - build/src/dynare-preprocessor.exe

build_macos_x86_64:
  stage: build
  tags:
    - macOS
  script:
    - arch -x86_64 meson setup --buildtype=release -Db_lto=true --native-file scripts/homebrew-native-x86_64.ini build
    - arch -x86_64 meson compile -C build -v
  artifacts:
    paths:
      - build/src/dynare-preprocessor

build_macos_arm64:
  stage: build
  tags:
    - macOS
  script:
    - export PATH="/opt/homebrew/bin:$PATH"
    - arch -arm64 meson setup --buildtype=release -Db_lto=true --native-file scripts/homebrew-native-arm64.ini build
    - arch -arm64 meson compile -C build -v
  artifacts:
    paths:
      - build/src/dynare-preprocessor

test_clang_format:
  stage: test
  script:
    - meson setup build-clang-format
    - ninja -C build-clang-format clang-format-check
  needs: []

test_clang_tidy:
  stage: test
  script:
    # Hack needed for meson < 1.6.0 which only looks for unversioned clang-tidy
    - mkdir -p ~/.local/bin && ln -s /usr/bin/clang-tidy-19 ~/.local/bin/clang-tidy
    - export PATH="$HOME/.local/bin:$PATH"
    - meson setup build-clang-tidy
    # Generate Flex and Bison files
    - meson compile -C build-clang-tidy
    - ninja -C build-clang-tidy clang-tidy
  needs: []
  when: manual
+4 −4
Original line number Diff line number Diff line
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

@@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

@@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.

Makefile.am

deleted100644 → 0
+0 −11
Original line number Diff line number Diff line
SUBDIRS = src doc

ACLOCAL_AMFLAGS = -I m4

EXTRA_DIST = \
	license.txt \
	COPYING

dist-hook:
	rm -rf `find $(distdir) -name '.git*'`
+4 −7
Original line number Diff line number Diff line
<a name="logo"/>
<div align="center">
<a href="http://www.dynare.org/" target="_blank">
<img src="http://www.dynare.org/img/dynare.png" alt="Dynare Logo"></img>
<a href="https://www.dynare.org/" target="_blank">
<img src="https://www.dynare.org/assets/images/logo/dlogo.svg" alt="Dynare Logo"></img>
</a>
</div>

@@ -9,12 +9,9 @@

The Dynare Preprocessor defines the Dynare model language. It takes in a `.mod`
file, computes the derivatives of the model represented therein, and produces
Matlab/Octave, C, Julia, or JSON output.

There is more to come here. For the moment, see the [Dynare
repository](https://git.dynare.org/Dynare/dynare)
MATLAB/Octave, Julia, or JSON output.

# License

Most of the source files are covered by the GNU General Public Licence version
3 or later. There are some exceptions. See [license.txt](license.txt) for specifics.
3 or later. There are some exceptions, see the respective file headers.

configure.ac

deleted100755 → 0
+0 −133
Original line number Diff line number Diff line
dnl Process this file with autoconf to produce a configure script.

dnl Copyright (C) 2009-2018 Dynare Team
dnl
dnl This file is part of Dynare.
dnl
dnl Dynare is free software: you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation, either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl Dynare is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with Dynare.  If not, see <http://www.gnu.org/licenses/>.

AC_PREREQ([2.62])
AC_INIT([dynare-preprocessor], [4.6-unstable])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_SRCDIR([src/DynareMain.cc])
AM_INIT_AUTOMAKE([1.11 -Wall -Wno-portability foreign no-dist-gzip dist-xz tar-pax])

AC_PROG_CC
AC_PROG_CXX
AX_CXX_COMPILE_STDCXX_14

AC_CANONICAL_HOST
case ${host_os} in
  *mingw32*)
    # On mingw32, we don't want dynamic libgcc
    # Note that static-libstdc++ is only supported since GCC 4.5 (but generates no error on older versions)
    LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++ -static-libgfortran"
    have_windows="yes"
    ;;
  *cygwin*)
    AC_MSG_WARN([You are compiling for the Cygwin target. This means that the preprocessor will])
    AC_MSG_WARN([not run from MATLAB unless you add the Cygwin DLL to the path.])
    AC_MSG_WARN([This is probably not what you want. Consider using a MinGW cross-compiler.])
    have_windows="yes"
    ;;
esac

# Use C++ for testing headers
AC_LANG([C++])

CXXFLAGS="$CXXFLAGS -Wall -Wno-parentheses"

# If default 'ar' is not available, try to find one with a host prefix (see ticket #145)
AC_CHECK_PROGS([AR], [ar ${host_alias}-ar])

AC_PROG_RANLIB
AM_PROG_AR

AM_PROG_LEX
# Hack to get lex include dir, ticket #575
AC_PATH_PROG([LEXPATH], [$LEX])
AC_SUBST([LEXINC], [`eval "echo $LEXPATH | sed 's|\(.*\)$LEX$|\1../include|'"`])

AC_CHECK_PROG([YACC], [bison], [bison])
if test "x$YACC" = "x"; then
  unset YACC # AM_MISSING_PROG needs an unset variable: an empty variable won't do
  AM_MISSING_PROG([YACC], [bison])
fi

# We need 1.36 because of unordered_{set,hash} used by Dynare++
AX_BOOST_BASE([1.36], [], [AC_MSG_ERROR([Can't find Boost >= 1.36])])
AX_BOOST_SYSTEM
AX_BOOST_FILESYSTEM

CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
AC_CHECK_HEADERS([boost/graph/adjacency_list.hpp], [], [AC_MSG_ERROR([Can't find Boost Graph Library])])
AC_CHECK_HEADERS([boost/algorithm/string/trim.hpp], [], [AC_MSG_ERROR([Can't find Boost String Library])])
AC_CHECK_HEADERS([boost/algorithm/string/split.hpp], [], [AC_MSG_ERROR([Can't find Boost String Library])])
CPPFLAGS="$CPPFLAGS_SAVED"

# Don't use deprecated hash structures
AC_DEFINE([BOOST_NO_HASH], [], [Don't use deprecated STL hash structures])

AC_CHECK_PROG([DOXYGEN], [doxygen], [doxygen])
AM_CONDITIONAL([HAVE_DOXYGEN], [test "x$DOXYGEN" != "x"])

AC_CHECK_PROG([PDFLATEX], [pdflatex], [pdflatex])
AM_CONDITIONAL([HAVE_PDFLATEX], [test "x$PDFLATEX" != "x"])

AC_CHECK_PROG([BIBTEX], [bibtex], [bibtex])
AM_CONDITIONAL([HAVE_BIBTEX], [test "x$BIBTEX" != "x"])

if test "x$PDFLATEX" != "x" -a "x$BIBTEX" != "x"; then
  AX_LATEX_CLASS([beamer], [ax_latex_have_beamer])
fi
AM_CONDITIONAL([HAVE_BEAMER], [test "x$ax_latex_have_beamer" = "xyes"])

AC_CONFIG_FILES([Makefile
                 src/Makefile
                 src/macro/Makefile
                 doc/Makefile
                 doc/preprocessor/Makefile
                 doc/macroprocessor/Makefile
])

if test "x$DOXYGEN" != "x"; then
  BUILD_DYNARE_PREPROC_DOC="yes"
else
  BUILD_DYNARE_PREPROC_DOC="no (missing doxygen)"
fi


if test "x$PDFLATEX" != "x" -a "x$ax_latex_have_beamer" = "xyes"; then
  BUILD_BEAMER_DOC="yes"
else
  BUILD_BEAMER_DOC="no (missing one of: pdflatex, beamer)"
fi

AC_MSG_NOTICE([

The Dynare Preprocessor is now configured to build...

Binaries (with "make")
 Dynare preprocessor:                         yes

PDF documentation (with "make pdf"):
 Preprocessor & Macroprocessor presentations: $BUILD_BEAMER_DOC

HTML documentation (with "make html"):
 Dynare preprocessor developer doc:           $BUILD_DYNARE_PREPROC_DOC

])

AC_OUTPUT

doc/Makefile.am

deleted100644 → 0
+0 −5
Original line number Diff line number Diff line
SUBDIRS = preprocessor macroprocessor

PDF_TARGETS =

pdf-local: $(PDF_TARGETS)

doc/macroprocessor/Makefile.am

deleted100644 → 0
+0 −16
Original line number Diff line number Diff line
if HAVE_PDFLATEX
if HAVE_BEAMER
pdf-local: macroprocessor.pdf
endif
endif

SRC = macroprocessor.tex new-design.pdf

EXTRA_DIST = $(SRC)

macroprocessor.pdf: $(SRC)
	$(PDFLATEX) macroprocessor
	$(PDFLATEX) macroprocessor

clean-local:
	rm -f macroprocessor.pdf *.toc *.aux *.log *.nav *.snm *.vrb *.out *~

doc/meson.build

0 → 100644
+42 −0
Original line number Diff line number Diff line
latexmk_exe = find_program('latexmk', required : false, disabler : true)

# We have to set TEXINPUTS because the current directory is not the source
# directory when latexmk is invoked (and using the -cd option in combination
# with -outdir/-auxdir does not work in all cases because @OUTDIR@ and
# @PRIVATE_DIR@ can be relative paths)

# Without the -g flag, latexmk remembers a previous build failure and will refuse
# to recompile even if the error has been fixed in the TeX source

latexmk_command = [ latexmk_exe, '-pdf', '-g', '-outdir=@OUTDIR@', '-auxdir=@PRIVATE_DIR@', '@INPUT@']

# The \graphicspath{} command does not compute directories relative to TEXINPUTS,
# so add these manually
logos_dir = meson.current_source_dir() / 'logos'

macroprocessor_pdf = custom_target('macroprocessor.pdf',
                                   output : 'macroprocessor.pdf',
                                   input : 'macroprocessor/macroprocessor.tex',
                                   command : latexmk_command,
                                   env : { 'TEXINPUTS': meson.current_source_dir()
                                                        + '/macroprocessor:' + logos_dir + ':' },
                                   depend_files : [ 'macroprocessor/new-design.pdf',
                                                    'logos/dlogo.png' ],
                                   build_by_default : false,
                                   install : true,
                                   install_dir : 'share/doc/dynare')

preprocessor_pdf = custom_target('preprocessor.pdf',
                                 output : 'preprocessor.pdf',
                                 input : 'preprocessor/preprocessor.tex',
                                 command : latexmk_command,
                                 env : { 'TEXINPUTS': meson.current_source_dir() + '/preprocessor:'
                                                      + logos_dir + ':' },
                                 depend_files : [ 'preprocessor/expr.png',
                                                  'preprocessor/expr-sharing.png',
                                                  'preprocessor/json-preprocessor.png',
                                                  'preprocessor/matrices.png',
                                                  'preprocessor/overview.png', 'logos/dlogo.png' ],
                                 build_by_default : false,
                                 install : true,
                                 install_dir : 'share/doc/dynare')

doc/preprocessor/Makefile.am

deleted100644 → 0
+0 −16
Original line number Diff line number Diff line
if HAVE_PDFLATEX
if HAVE_BEAMER
pdf-local: preprocessor.pdf
endif
endif

SRC = preprocessor.tex expr.png expr-sharing.png matrices.png overview.png json-preprocessor.png

EXTRA_DIST = $(SRC)

preprocessor.pdf: $(SRC)
	$(PDFLATEX) preprocessor
	$(PDFLATEX) preprocessor

clean-local:
	rm -f *.pdf *.toc *.aux *.log *.nav *.snm *.vrb *.out *~

license.txt

deleted100644 → 0
+0 −117
Original line number Diff line number Diff line
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Dynare-preprocessor
Upstream-Contact: Dynare Team, whose members in 2018 are:
                  Stéphane Adjemian <stephane.adjemian@univ-lemans.fr>
                  Houtan Bastani <houtan@dynare.org>
                  Michel Juillard <michel.juillard@mjui.fr>
                  Frédéric Karamé <frederic.karame@univ-lemans.fr>
                  Junior Maih <junior.maih@gmail.com>
                  Ferhat Mihoubi <fmihoubi@univ-evry.fr>
                  Johannes Pfeifer <jpfeifer@gmx.de>
                  Marco Ratto <marco.ratto@ec.europa.eu>
                  Sébastien Villemot <sebastien@dynare.org>
Source: http://www.dynare.org

Files: *
Copyright: 1996-2018 Dynare Team
License: GPL-3+

Files: m4/ax_boost_base.m4
       m4/ax_boost_system.m4
       m4/ax_boost_filesystem.m4
Copyright: 2008-2009 Thomas Porschberg <thomas@randspringer.de>
           2009 Peter Adolphs
           2008-2009 Michael Tindal
           2008 Daniel Casimiro <dan.casimiro@gmail.com>
           2009 Roman Rybalko <libtorrent@romanr.info>
License: permissive-autoconf

Files: m4/ax_cxx_compile_stdcxx.m4
       m4/ax_cxx_compile_stdcxx_14.m4
Copyright: 2008 Benjamin Kosnik <bkoz@redhat.com>
           2012 Zack Weinberg <zackw@panix.com>
           2013 Roy Stogner <roystgnr@ices.utexas.edu>
           2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
           2015 Paul Norman <penorman@mac.com>
           2015 Moritz Klammler <moritz@klammler.eu>
License: permissive-autoconf

Files: m4/ax_latex_class.m4 m4/ax_tex_test.m4
Copyright: 2008 Boretti Mathieu <boretti@eig.unige.ch>
           2009 Dynare Team
License: LGPL-2.1+

License: GPL-3+
 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/>.

License: GPL-3+ with Autoconf exception
 This program 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.
 .
 This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
 .
 As a special exception, the respective Autoconf Macro's copyright owner
 gives unlimited permission to copy, distribute and modify the configure
 scripts that are the output of Autoconf when processing the Macro. You
 need not follow the terms of the GNU General Public License when using
 or distributing such scripts, even though portions of the text of the
 Macro appear in them. The GNU General Public License (GPL) does govern
 all other use of the material that constitutes the Autoconf Macro.
 .
 This special exception to the GPL applies to versions of the Autoconf
 Macro released by the Autoconf Archive. When you make and distribute a
 modified version of the Autoconf Macro, you may extend this special
 exception to the GPL to apply to your modified version as well.

License: LGPL-2.1+
 This library is free software; you can redistribute it and/or modify it
 under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation; either version 2.1 of the License, or (at
 your option) any later version.
 .
 This library 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 Lesser
 General Public License for more details.
 .
 You should have received a copy of the GNU Lesser General Public License
 along with this library. If not, see <http://www.gnu.org/licenses/>.

License: LGPL-3+
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 .
 This program 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 Lesser General Public License for more details.
 .
 You should have received a copy of the GNU Lesser General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

License: permissive-autoconf
 Copying and distribution of this file, with or without modification, are
 permitted in any medium without royalty provided the copyright notice
 and this notice are preserved. This file is offered as-is, without any
 warranty.

m4/ax_boost_base.m4

deleted100644 → 0
+0 −285
Original line number Diff line number Diff line
# ===========================================================================
#       http://www.gnu.org/software/autoconf-archive/ax_boost_base.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# DESCRIPTION
#
#   Test for the Boost C++ libraries of a particular version (or newer)
#
#   If no path to the installed boost library is given the macro searchs
#   under /usr, /usr/local, /opt and /opt/local and evaluates the
#   $BOOST_ROOT environment variable. Further documentation is available at
#   <http://randspringer.de/boost/index.html>.
#
#   This macro calls:
#
#     AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
#
#   And sets:
#
#     HAVE_BOOST
#
# LICENSE
#
#   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
#   Copyright (c) 2009 Peter Adolphs
#
#   Copying and distribution of this file, with or without modification, are
#   permitted in any medium without royalty provided the copyright notice
#   and this notice are preserved. This file is offered as-is, without any
#   warranty.

#serial 27

AC_DEFUN([AX_BOOST_BASE],
[
AC_ARG_WITH([boost],
  [AS_HELP_STRING([--with-boost@<:@=ARG@:>@],
    [use Boost library from a standard location (ARG=yes),
     from the specified location (ARG=<path>),
     or disable it (ARG=no)
     @<:@ARG=yes@:>@ ])],
    [
    if test "$withval" = "no"; then
        want_boost="no"
    elif test "$withval" = "yes"; then
        want_boost="yes"
        ac_boost_path=""
    else
        want_boost="yes"
        ac_boost_path="$withval"
    fi
    ],
    [want_boost="yes"])


AC_ARG_WITH([boost-libdir],
        AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
        [Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
        [
        if test -d "$withval"
        then
                ac_boost_lib_path="$withval"
        else
                AC_MSG_ERROR(--with-boost-libdir expected directory name)
        fi
        ],
        [ac_boost_lib_path=""]
)

if test "x$want_boost" = "xyes"; then
    boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
    boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
    boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
    boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
    boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
    if test "x$boost_lib_version_req_sub_minor" = "x" ; then
        boost_lib_version_req_sub_minor="0"
        fi
    WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+  $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
    AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
    succeeded=no

    dnl On 64-bit systems check for system libraries in both lib64 and lib.
    dnl The former is specified by FHS, but e.g. Debian does not adhere to
    dnl this (as it rises problems for generic multi-arch support).
    dnl The last entry in the list is chosen by default when no libraries
    dnl are found, e.g. when only header-only libraries are installed!
    libsubdirs="lib"
    ax_arch=`uname -m`
    case $ax_arch in
      x86_64)
        libsubdirs="lib64 libx32 lib lib64"
        ;;
      ppc64|s390x|sparc64|aarch64|ppc64le)
        libsubdirs="lib64 lib lib64"
        ;;
    esac

    dnl allow for real multi-arch paths e.g. /usr/lib/x86_64-linux-gnu. Give
    dnl them priority over the other paths since, if libs are found there, they
    dnl are almost assuredly the ones desired.
    AC_REQUIRE([AC_CANONICAL_HOST])
    libsubdirs="lib/${host_cpu}-${host_os} $libsubdirs"

    case ${host_cpu} in
      i?86)
        libsubdirs="lib/i386-${host_os} $libsubdirs"
        ;;
    esac

    dnl first we check the system location for boost libraries
    dnl this location ist chosen if boost libraries are installed with the --layout=system option
    dnl or if you install boost with RPM
    if test "$ac_boost_path" != ""; then
        BOOST_CPPFLAGS="-I$ac_boost_path/include"
        for ac_boost_path_tmp in $libsubdirs; do
                if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
                        BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp"
                        break
                fi
        done
    elif test "$cross_compiling" != yes; then
        for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
            if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
                for libsubdir in $libsubdirs ; do
                    if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
                done
                BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir"
                BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
                break;
            fi
        done
    fi

    dnl overwrite ld flags if we have required special directory with
    dnl --with-boost-libdir parameter
    if test "$ac_boost_lib_path" != ""; then
       BOOST_LDFLAGS="-L$ac_boost_lib_path"
    fi

    CPPFLAGS_SAVED="$CPPFLAGS"
    CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
    export CPPFLAGS

    LDFLAGS_SAVED="$LDFLAGS"
    LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
    export LDFLAGS

    AC_REQUIRE([AC_PROG_CXX])
    AC_LANG_PUSH(C++)
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
    @%:@include <boost/version.hpp>
    ]], [[
    #if BOOST_VERSION >= $WANT_BOOST_VERSION
    // Everything is okay
    #else
    #  error Boost version is too old
    #endif
    ]])],[
        AC_MSG_RESULT(yes)
    succeeded=yes
    found_system=yes
        ],[
        ])
    AC_LANG_POP([C++])



    dnl if we found no boost with system layout we search for boost libraries
    dnl built and installed without the --layout=system option or for a staged(not installed) version
    if test "x$succeeded" != "xyes"; then
        CPPFLAGS="$CPPFLAGS_SAVED"
        LDFLAGS="$LDFLAGS_SAVED"
        BOOST_CPPFLAGS=
        BOOST_LDFLAGS=
        _version=0
        if test "$ac_boost_path" != ""; then
            if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
                for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
                    _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
                    V_CHECK=`expr $_version_tmp \> $_version`
                    if test "$V_CHECK" = "1" ; then
                        _version=$_version_tmp
                    fi
                    VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
                    BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
                done
                dnl if nothing found search for layout used in Windows distributions
                if test -z "$BOOST_CPPFLAGS"; then
                    if test -d "$ac_boost_path/boost" && test -r "$ac_boost_path/boost"; then
                        BOOST_CPPFLAGS="-I$ac_boost_path"
                    fi
                fi
            fi
        else
            if test "$cross_compiling" != yes; then
                for ac_boost_path in /usr /usr/local /opt /opt/local ; do
                    if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
                        for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
                            _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
                            V_CHECK=`expr $_version_tmp \> $_version`
                            if test "$V_CHECK" = "1" ; then
                                _version=$_version_tmp
                                best_path=$ac_boost_path
                            fi
                        done
                    fi
                done

                VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
                BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
                if test "$ac_boost_lib_path" = ""; then
                    for libsubdir in $libsubdirs ; do
                        if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
                    done
                    BOOST_LDFLAGS="-L$best_path/$libsubdir"
                fi
            fi

            if test "x$BOOST_ROOT" != "x"; then
                for libsubdir in $libsubdirs ; do
                    if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
                done
                if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
                    version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
                    stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
                        stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
                    V_CHECK=`expr $stage_version_shorten \>\= $_version`
                    if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
                        AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
                        BOOST_CPPFLAGS="-I$BOOST_ROOT"
                        BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
                    fi
                fi
            fi
        fi

        CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
        export CPPFLAGS
        LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
        export LDFLAGS

        AC_LANG_PUSH(C++)
            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
        @%:@include <boost/version.hpp>
        ]], [[
        #if BOOST_VERSION >= $WANT_BOOST_VERSION
        // Everything is okay
        #else
        #  error Boost version is too old
        #endif
        ]])],[
            AC_MSG_RESULT(yes)
        succeeded=yes
        found_system=yes
            ],[
            ])
        AC_LANG_POP([C++])
    fi

    if test "$succeeded" != "yes" ; then
        if test "$_version" = "0" ; then
            AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
        else
            AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
        fi
        # execute ACTION-IF-NOT-FOUND (if present):
        ifelse([$3], , :, [$3])
    else
        AC_SUBST(BOOST_CPPFLAGS)
        AC_SUBST(BOOST_LDFLAGS)
        AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
        # execute ACTION-IF-FOUND (if present):
        ifelse([$2], , :, [$2])
    fi

    CPPFLAGS="$CPPFLAGS_SAVED"
    LDFLAGS="$LDFLAGS_SAVED"
fi

])

m4/ax_boost_filesystem.m4

deleted100644 → 0
+0 −118
Original line number Diff line number Diff line
# ===========================================================================
#    http://www.gnu.org/software/autoconf-archive/ax_boost_filesystem.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_BOOST_FILESYSTEM
#
# DESCRIPTION
#
#   Test for Filesystem library from the Boost C++ libraries. The macro
#   requires a preceding call to AX_BOOST_BASE. Further documentation is
#   available at <http://randspringer.de/boost/index.html>.
#
#   This macro calls:
#
#     AC_SUBST(BOOST_FILESYSTEM_LIB)
#
#   And sets:
#
#     HAVE_BOOST_FILESYSTEM
#
# LICENSE
#
#   Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
#   Copyright (c) 2009 Michael Tindal
#   Copyright (c) 2009 Roman Rybalko <libtorrent@romanr.info>
#
#   Copying and distribution of this file, with or without modification, are
#   permitted in any medium without royalty provided the copyright notice
#   and this notice are preserved. This file is offered as-is, without any
#   warranty.

#serial 26

AC_DEFUN([AX_BOOST_FILESYSTEM],
[
	AC_ARG_WITH([boost-filesystem],
	AS_HELP_STRING([--with-boost-filesystem@<:@=special-lib@:>@],
                   [use the Filesystem library from boost - it is possible to specify a certain library for the linker
                        e.g. --with-boost-filesystem=boost_filesystem-gcc-mt ]),
        [
        if test "$withval" = "no"; then
			want_boost="no"
        elif test "$withval" = "yes"; then
            want_boost="yes"
            ax_boost_user_filesystem_lib=""
        else
		    want_boost="yes"
		ax_boost_user_filesystem_lib="$withval"
		fi
        ],
        [want_boost="yes"]
	)

	if test "x$want_boost" = "xyes"; then
        AC_REQUIRE([AC_PROG_CC])
		CPPFLAGS_SAVED="$CPPFLAGS"
		CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
		export CPPFLAGS

		LDFLAGS_SAVED="$LDFLAGS"
		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
		export LDFLAGS

		LIBS_SAVED=$LIBS
		LIBS="$LIBS $BOOST_SYSTEM_LIB"
		export LIBS

        AC_CACHE_CHECK(whether the Boost::Filesystem library is available,
					   ax_cv_boost_filesystem,
        [AC_LANG_PUSH([C++])
         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/filesystem/path.hpp>]],
                                   [[using namespace boost::filesystem;
                                   path my_path( "foo/bar/data.txt" );
                                   return 0;]])],
					       ax_cv_boost_filesystem=yes, ax_cv_boost_filesystem=no)
         AC_LANG_POP([C++])
		])
		if test "x$ax_cv_boost_filesystem" = "xyes"; then
			AC_DEFINE(HAVE_BOOST_FILESYSTEM,,[define if the Boost::Filesystem library is available])
            BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
            if test "x$ax_boost_user_filesystem_lib" = "x"; then
                for libextension in `ls -r $BOOSTLIBDIR/libboost_filesystem* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
                     ax_lib=${libextension}
				    AC_CHECK_LIB($ax_lib, exit,
                                 [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
                                 [link_filesystem="no"])
				done
                if test "x$link_filesystem" != "xyes"; then
                for libextension in `ls -r $BOOSTLIBDIR/boost_filesystem* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do
                     ax_lib=${libextension}
				    AC_CHECK_LIB($ax_lib, exit,
                                 [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
                                 [link_filesystem="no"])
				done
		    fi
            else
               for ax_lib in $ax_boost_user_filesystem_lib boost_filesystem-$ax_boost_user_filesystem_lib; do
				      AC_CHECK_LIB($ax_lib, exit,
                                   [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break],
                                   [link_filesystem="no"])
                  done

            fi
            if test "x$ax_lib" = "x"; then
                AC_MSG_ERROR(Could not find a version of the library!)
            fi
			if test "x$link_filesystem" != "xyes"; then
				AC_MSG_ERROR(Could not link against $ax_lib !)
			fi
		fi

		CPPFLAGS="$CPPFLAGS_SAVED"
		LDFLAGS="$LDFLAGS_SAVED"
		LIBS="$LIBS_SAVED"
	fi
])

m4/ax_boost_system.m4

deleted100644 → 0
+0 −121
Original line number Diff line number Diff line
# ===========================================================================
#      http://www.gnu.org/software/autoconf-archive/ax_boost_system.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_BOOST_SYSTEM
#
# DESCRIPTION
#
#   Test for System library from the Boost C++ libraries. The macro requires
#   a preceding call to AX_BOOST_BASE. Further documentation is available at
#   <http://randspringer.de/boost/index.html>.
#
#   This macro calls:
#
#     AC_SUBST(BOOST_SYSTEM_LIB)
#
#   And sets:
#
#     HAVE_BOOST_SYSTEM
#
# LICENSE
#
#   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
#   Copyright (c) 2008 Michael Tindal
#   Copyright (c) 2008 Daniel Casimiro <dan.casimiro@gmail.com>
#
#   Copying and distribution of this file, with or without modification, are
#   permitted in any medium without royalty provided the copyright notice
#   and this notice are preserved. This file is offered as-is, without any
#   warranty.

#serial 18

AC_DEFUN([AX_BOOST_SYSTEM],
[
	AC_ARG_WITH([boost-system],
	AS_HELP_STRING([--with-boost-system@<:@=special-lib@:>@],
                   [use the System library from boost - it is possible to specify a certain library for the linker
                        e.g. --with-boost-system=boost_system-gcc-mt ]),
        [
        if test "$withval" = "no"; then
			want_boost="no"
        elif test "$withval" = "yes"; then
            want_boost="yes"
            ax_boost_user_system_lib=""
        else
		    want_boost="yes"
		ax_boost_user_system_lib="$withval"
		fi
        ],
        [want_boost="yes"]
	)

	if test "x$want_boost" = "xyes"; then
        AC_REQUIRE([AC_PROG_CC])
        AC_REQUIRE([AC_CANONICAL_BUILD])
		CPPFLAGS_SAVED="$CPPFLAGS"
		CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
		export CPPFLAGS

		LDFLAGS_SAVED="$LDFLAGS"
		LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
		export LDFLAGS

        AC_CACHE_CHECK(whether the Boost::System library is available,
					   ax_cv_boost_system,
        [AC_LANG_PUSH([C++])
			 CXXFLAGS_SAVE=$CXXFLAGS
			 CXXFLAGS=

			 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/system/error_code.hpp>]],
				    [[boost::system::error_category *a = 0;]])],
                   ax_cv_boost_system=yes, ax_cv_boost_system=no)
			 CXXFLAGS=$CXXFLAGS_SAVE
             AC_LANG_POP([C++])
		])
		if test "x$ax_cv_boost_system" = "xyes"; then
			AC_SUBST(BOOST_CPPFLAGS)

			AC_DEFINE(HAVE_BOOST_SYSTEM,,[define if the Boost::System library is available])
            BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`

			LDFLAGS_SAVE=$LDFLAGS
            if test "x$ax_boost_user_system_lib" = "x"; then
                for libextension in `ls -r $BOOSTLIBDIR/libboost_system* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do
                     ax_lib=${libextension}
				    AC_CHECK_LIB($ax_lib, exit,
                                 [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
                                 [link_system="no"])
				done
                if test "x$link_system" != "xyes"; then
                for libextension in `ls -r $BOOSTLIBDIR/boost_system* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do
                     ax_lib=${libextension}
				    AC_CHECK_LIB($ax_lib, exit,
                                 [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
                                 [link_system="no"])
				done
                fi

            else
               for ax_lib in $ax_boost_user_system_lib boost_system-$ax_boost_user_system_lib; do
				      AC_CHECK_LIB($ax_lib, exit,
                                   [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break],
                                   [link_system="no"])
                  done

            fi
            if test "x$ax_lib" = "x"; then
                AC_MSG_ERROR(Could not find a version of the library!)
            fi
			if test "x$link_system" = "xno"; then
				AC_MSG_ERROR(Could not link against $ax_lib !)
			fi
		fi

		CPPFLAGS="$CPPFLAGS_SAVED"
	LDFLAGS="$LDFLAGS_SAVED"
	fi
])

m4/ax_cxx_compile_stdcxx.m4

deleted100644 → 0
+0 −562
Original line number Diff line number Diff line
# ===========================================================================
#   http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
#   Check for baseline language coverage in the compiler for the specified
#   version of the C++ standard.  If necessary, add switches to CXX and
#   CXXCPP to enable support.  VERSION may be '11' (for the C++11 standard)
#   or '14' (for the C++14 standard).
#
#   The second argument, if specified, indicates whether you insist on an
#   extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
#   -std=c++11).  If neither is specified, you get whatever works, with
#   preference for an extended mode.
#
#   The third argument, if specified 'mandatory' or if left unspecified,
#   indicates that baseline support for the specified C++ standard is
#   required and that the macro should error out if no mode with that
#   support is found.  If specified 'optional', then configuration proceeds
#   regardless, after defining HAVE_CXX${VERSION} if and only if a
#   supporting mode is found.
#
# LICENSE
#
#   Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
#   Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
#   Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
#   Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
#   Copyright (c) 2015 Paul Norman <penorman@mac.com>
#   Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
#   Copying and distribution of this file, with or without modification, are
#   permitted in any medium without royalty provided the copyright notice
#   and this notice are preserved.  This file is offered as-is, without any
#   warranty.

#serial 4

dnl  This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl  (serial version number 13).

AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
  m4_if([$1], [11], [],
        [$1], [14], [],
        [$1], [17], [m4_fatal([support for C++17 not yet implemented in AX_CXX_COMPILE_STDCXX])],
        [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
  m4_if([$2], [], [],
        [$2], [ext], [],
        [$2], [noext], [],
        [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
  m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
        [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
        [$3], [optional], [ax_cxx_compile_cxx$1_required=false],
        [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
  AC_LANG_PUSH([C++])dnl
  ac_success=no
  AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
  ax_cv_cxx_compile_cxx$1,
  [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
    [ax_cv_cxx_compile_cxx$1=yes],
    [ax_cv_cxx_compile_cxx$1=no])])
  if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
    ac_success=yes
  fi

  m4_if([$2], [noext], [], [dnl
  if test x$ac_success = xno; then
    for switch in -std=gnu++$1 -std=gnu++0x; do
      cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
      AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
                     $cachevar,
        [ac_save_CXX="$CXX"
         CXX="$CXX $switch"
         AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
          [eval $cachevar=yes],
          [eval $cachevar=no])
         CXX="$ac_save_CXX"])
      if eval test x\$$cachevar = xyes; then
        CXX="$CXX $switch"
        if test -n "$CXXCPP" ; then
          CXXCPP="$CXXCPP $switch"
        fi
        ac_success=yes
        break
      fi
    done
  fi])

  m4_if([$2], [ext], [], [dnl
  if test x$ac_success = xno; then
    dnl HP's aCC needs +std=c++11 according to:
    dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
    dnl Cray's crayCC needs "-h std=c++11"
    for switch in -std=c++$1 -std=c++0x +std=c++$1 "-h std=c++$1"; do
      cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
      AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
                     $cachevar,
        [ac_save_CXX="$CXX"
         CXX="$CXX $switch"
         AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
          [eval $cachevar=yes],
          [eval $cachevar=no])
         CXX="$ac_save_CXX"])
      if eval test x\$$cachevar = xyes; then
        CXX="$CXX $switch"
        if test -n "$CXXCPP" ; then
          CXXCPP="$CXXCPP $switch"
        fi
        ac_success=yes
        break
      fi
    done
  fi])
  AC_LANG_POP([C++])
  if test x$ax_cxx_compile_cxx$1_required = xtrue; then
    if test x$ac_success = xno; then
      AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
    fi
  fi
  if test x$ac_success = xno; then
    HAVE_CXX$1=0
    AC_MSG_NOTICE([No compiler with C++$1 support was found])
  else
    HAVE_CXX$1=1
    AC_DEFINE(HAVE_CXX$1,1,
              [define if the compiler supports basic C++$1 syntax])
  fi
  AC_SUBST(HAVE_CXX$1)
])


dnl  Test body for checking C++11 support

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
  _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
)


dnl  Test body for checking C++14 support

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
  _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
  _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
)


dnl  Tests for new features in C++11

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[

// If the compiler admits that it is not ready for C++11, why torture it?
// Hopefully, this will speed up the test.

#ifndef __cplusplus

#error "This is not a C++ compiler"

#elif __cplusplus < 201103L

#error "This is not a C++11 compiler"

#else

namespace cxx11
{

  namespace test_static_assert
  {

    template <typename T>
    struct check
    {
      static_assert(sizeof(int) <= sizeof(T), "not big enough");
    };

  }

  namespace test_final_override
  {

    struct Base
    {
      virtual void f() {}
    };

    struct Derived : public Base
    {
      virtual void f() override {}
    };

  }

  namespace test_double_right_angle_brackets
  {

    template < typename T >
    struct check {};

    typedef check<void> single_type;
    typedef check<check<void>> double_type;
    typedef check<check<check<void>>> triple_type;
    typedef check<check<check<check<void>>>> quadruple_type;

  }

  namespace test_decltype
  {

    int
    f()
    {
      int a = 1;
      decltype(a) b = 2;
      return a + b;
    }

  }

  namespace test_type_deduction
  {

    template < typename T1, typename T2 >
    struct is_same
    {
      static const bool value = false;
    };

    template < typename T >
    struct is_same<T, T>
    {
      static const bool value = true;
    };

    template < typename T1, typename T2 >
    auto
    add(T1 a1, T2 a2) -> decltype(a1 + a2)
    {
      return a1 + a2;
    }

    int
    test(const int c, volatile int v)
    {
      static_assert(is_same<int, decltype(0)>::value == true, "");
      static_assert(is_same<int, decltype(c)>::value == false, "");
      static_assert(is_same<int, decltype(v)>::value == false, "");
      auto ac = c;
      auto av = v;
      auto sumi = ac + av + 'x';
      auto sumf = ac + av + 1.0;
      static_assert(is_same<int, decltype(ac)>::value == true, "");
      static_assert(is_same<int, decltype(av)>::value == true, "");
      static_assert(is_same<int, decltype(sumi)>::value == true, "");
      static_assert(is_same<int, decltype(sumf)>::value == false, "");
      static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
      return (sumf > 0.0) ? sumi : add(c, v);
    }

  }

  namespace test_noexcept
  {

    int f() { return 0; }
    int g() noexcept { return 0; }

    static_assert(noexcept(f()) == false, "");
    static_assert(noexcept(g()) == true, "");

  }

  namespace test_constexpr
  {

    template < typename CharT >
    unsigned long constexpr
    strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
    {
      return *s ? strlen_c_r(s + 1, acc + 1) : acc;
    }

    template < typename CharT >
    unsigned long constexpr
    strlen_c(const CharT *const s) noexcept
    {
      return strlen_c_r(s, 0UL);
    }

    static_assert(strlen_c("") == 0UL, "");
    static_assert(strlen_c("1") == 1UL, "");
    static_assert(strlen_c("example") == 7UL, "");
    static_assert(strlen_c("another\0example") == 7UL, "");

  }

  namespace test_rvalue_references
  {

    template < int N >
    struct answer
    {
      static constexpr int value = N;
    };

    answer<1> f(int&)       { return answer<1>(); }
    answer<2> f(const int&) { return answer<2>(); }
    answer<3> f(int&&)      { return answer<3>(); }

    void
    test()
    {
      int i = 0;
      const int c = 0;
      static_assert(decltype(f(i))::value == 1, "");
      static_assert(decltype(f(c))::value == 2, "");
      static_assert(decltype(f(0))::value == 3, "");
    }

  }

  namespace test_uniform_initialization
  {

    struct test
    {
      static const int zero {};
      static const int one {1};
    };

    static_assert(test::zero == 0, "");
    static_assert(test::one == 1, "");

  }

  namespace test_lambdas
  {

    void
    test1()
    {
      auto lambda1 = [](){};
      auto lambda2 = lambda1;
      lambda1();
      lambda2();
    }

    int
    test2()
    {
      auto a = [](int i, int j){ return i + j; }(1, 2);
      auto b = []() -> int { return '0'; }();
      auto c = [=](){ return a + b; }();
      auto d = [&](){ return c; }();
      auto e = [a, &b](int x) mutable {
        const auto identity = [](int y){ return y; };
        for (auto i = 0; i < a; ++i)
          a += b--;
        return x + identity(a + b);
      }(0);
      return a + b + c + d + e;
    }

    int
    test3()
    {
      const auto nullary = [](){ return 0; };
      const auto unary = [](int x){ return x; };
      using nullary_t = decltype(nullary);
      using unary_t = decltype(unary);
      const auto higher1st = [](nullary_t f){ return f(); };
      const auto higher2nd = [unary](nullary_t f1){
        return [unary, f1](unary_t f2){ return f2(unary(f1())); };
      };
      return higher1st(nullary) + higher2nd(nullary)(unary);
    }

  }

  namespace test_variadic_templates
  {

    template <int...>
    struct sum;

    template <int N0, int... N1toN>
    struct sum<N0, N1toN...>
    {
      static constexpr auto value = N0 + sum<N1toN...>::value;
    };

    template <>
    struct sum<>
    {
      static constexpr auto value = 0;
    };

    static_assert(sum<>::value == 0, "");
    static_assert(sum<1>::value == 1, "");
    static_assert(sum<23>::value == 23, "");
    static_assert(sum<1, 2>::value == 3, "");
    static_assert(sum<5, 5, 11>::value == 21, "");
    static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");

  }

  // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
  // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
  // because of this.
  namespace test_template_alias_sfinae
  {

    struct foo {};

    template<typename T>
    using member = typename T::member_type;

    template<typename T>
    void func(...) {}

    template<typename T>
    void func(member<T>*) {}

    void test();

    void test() { func<foo>(0); }

  }

}  // namespace cxx11

#endif  // __cplusplus >= 201103L

]])


dnl  Tests for new features in C++14

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[

// If the compiler admits that it is not ready for C++14, why torture it?
// Hopefully, this will speed up the test.

#ifndef __cplusplus

#error "This is not a C++ compiler"

#elif __cplusplus < 201402L

#error "This is not a C++14 compiler"

#else

namespace cxx14
{

  namespace test_polymorphic_lambdas
  {

    int
    test()
    {
      const auto lambda = [](auto&&... args){
        const auto istiny = [](auto x){
          return (sizeof(x) == 1UL) ? 1 : 0;
        };
        const int aretiny[] = { istiny(args)... };
        return aretiny[0];
      };
      return lambda(1, 1L, 1.0f, '1');
    }

  }

  namespace test_binary_literals
  {

    constexpr auto ivii = 0b0000000000101010;
    static_assert(ivii == 42, "wrong value");

  }

  namespace test_generalized_constexpr
  {

    template < typename CharT >
    constexpr unsigned long
    strlen_c(const CharT *const s) noexcept
    {
      auto length = 0UL;
      for (auto p = s; *p; ++p)
        ++length;
      return length;
    }

    static_assert(strlen_c("") == 0UL, "");
    static_assert(strlen_c("x") == 1UL, "");
    static_assert(strlen_c("test") == 4UL, "");
    static_assert(strlen_c("another\0test") == 7UL, "");

  }

  namespace test_lambda_init_capture
  {

    int
    test()
    {
      auto x = 0;
      const auto lambda1 = [a = x](int b){ return a + b; };
      const auto lambda2 = [a = lambda1(x)](){ return a; };
      return lambda2();
    }

  }

  namespace test_digit_seperators
  {

    constexpr auto ten_million = 100'000'000;
    static_assert(ten_million == 100000000, "");

  }

  namespace test_return_type_deduction
  {

    auto f(int& x) { return x; }
    decltype(auto) g(int& x) { return x; }

    template < typename T1, typename T2 >
    struct is_same
    {
      static constexpr auto value = false;
    };

    template < typename T >
    struct is_same<T, T>
    {
      static constexpr auto value = true;
    };

    int
    test()
    {
      auto x = 0;
      static_assert(is_same<int, decltype(f(x))>::value, "");
      static_assert(is_same<int&, decltype(g(x))>::value, "");
      return x;
    }

  }

}  // namespace cxx14

#endif  // __cplusplus >= 201402L

]])

m4/ax_cxx_compile_stdcxx_14.m4

deleted100644 → 0
+0 −34
Original line number Diff line number Diff line
# ============================================================================
#  http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_14.html
# ============================================================================
#
# SYNOPSIS
#
#   AX_CXX_COMPILE_STDCXX_14([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
#   Check for baseline language coverage in the compiler for the C++14
#   standard; if necessary, add switches to CXX and CXXCPP to enable
#   support.
#
#   This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
#   macro with the version set to C++14.  The two optional arguments are
#   forwarded literally as the second and third argument respectively.
#   Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
#   more information.  If you want to use this macro, you also need to
#   download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
#   Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
#   Copying and distribution of this file, with or without modification, are
#   permitted in any medium without royalty provided the copyright notice
#   and this notice are preserved. This file is offered as-is, without any
#   warranty.

#serial 4

AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_14], [AX_CXX_COMPILE_STDCXX([14], [$1], [$2])])

m4/ax_latex_class.m4

deleted100644 → 0
+0 −68
Original line number Diff line number Diff line
# ===========================================================================
#         http://www.nongnu.org/autoconf-archive/ax_latex_class.html
# ===========================================================================
#
# OBSOLETE MACRO
#
#   Deprecated because of licensing issues. The Lesser GPL imposes licensing
#   restrictions on the generated configure script unless it is augmented
#   with an Autoconf Exception clause.
#
# SYNOPSIS
#
#   AX_LATEX_CLASS(CLASSNAME,VARIABLETOSET[,ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
#   This macros test is class CLASSNAME exists and work and set
#   VARIABLETOSET to yes or no If ACTION-IF-FOUND (and ACTION-IF-NOT-FOUND)
#   are set, do the correct action
#
# LICENSE
#
#   Copyright (c) 2008 Boretti Mathieu <boretti@eig.unige.ch>
#   Copyright (c) 2009 Dynare Team
#
#   This library is free software; you can redistribute it and/or modify it
#   under the terms of the GNU Lesser General Public License as published by
#   the Free Software Foundation; either version 2.1 of the License, or (at
#   your option) any later version.
#
#   This library 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 Lesser
#   General Public License for more details.
#
#   You should have received a copy of the GNU Lesser General Public License
#   along with this library. If not, see <http://www.gnu.org/licenses/>.

AC_DEFUN([AX_LATEX_CLASS],[
AC_CACHE_CHECK([for usability of class $1],[ac_cv_latex_class_]translit($1,[-],[_]),[
AX_LATEX_TEST([\documentclass{$1}
\begin{document}
\end{document}],[ac_cv_latex_class_]translit($1,[-],[_]))
])
$2=$[ac_cv_latex_class_]translit($1,[-],[_]) ; export $2;
AC_SUBST($2)
ifelse($#,2,[],$#,3,[
    if test "[$]$2" = "yes" ;
    then
        $3
    fi
],$#,4,[
    ifelse($3,[],[
        if test "[$]$2" = "no" ;
        then
            $4
        fi
    ],[
        if test "[$]$2" = "yes" ;
        then
            $3
        else
            $4
        fi
    ])
])

])

m4/ax_latex_test.m4

deleted100644 → 0
+0 −56
Original line number Diff line number Diff line
# ===========================================================================
#          http://www.nongnu.org/autoconf-archive/ax_latex_test.html
# ===========================================================================
#
# OBSOLETE MACRO
#
#   Deprecated because of licensing issues. The Lesser GPL imposes licensing
#   restrictions on the generated configure script unless it is augmented
#   with an Autoconf Exception clause.
#
# SYNOPSIS
#
#   AX_LATEX_TEST(FILEDATA,VARIABLETOSET,[NOCLEAN])
#
# DESCRIPTION
#
#   This macros execute the latex application with FILEDATA as input and set
#   VARIABLETOSET the yes or no depending of the result if NOCLEAN is set,
#   the folder used for the test is not delete after testing.
#
#   The macro assumes that the variable PDFLATEX is set.
#
# LICENSE
#
#   Copyright (c) 2008 Boretti Mathieu <boretti@eig.unige.ch>
#   Copyright (c) 2009 Dynare Team
#
#   This library is free software; you can redistribute it and/or modify it
#   under the terms of the GNU Lesser General Public License as published by
#   the Free Software Foundation; either version 2.1 of the License, or (at
#   your option) any later version.
#
#   This library 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 Lesser
#   General Public License for more details.
#
#   You should have received a copy of the GNU Lesser General Public License
#   along with this library. If not, see <http://www.gnu.org/licenses/>.

AC_DEFUN([AX_LATEX_TEST],[
rm -rf conftest.dir/.acltx
AS_MKDIR_P([conftest.dir/.acltx])
cd conftest.dir/.acltx
m4_ifval([$2],[$2="no"; export $2;])
cat > conftest.tex << ACLEOF
$1
ACLEOF
cat conftest.tex | $PDFLATEX 2>&1 1>output m4_ifval([$2],[&& $2=yes])
cd ..
cd ..
sed 's/^/| /' conftest.dir/.acltx/conftest.tex >&5
echo "$as_me:$LINENO: executing cat conftest.tex | $PDFLATEX" >&5
sed 's/^/| /' conftest.dir/.acltx/output >&5
m4_ifval([$3],,[rm -rf conftest.dir/.acltx])
])

meson.build

0 → 100644
+19 −0
Original line number Diff line number Diff line
# Meson file for building the preprocessor in a standalone fashion.
# It is not used when building Dynare as a whole.

project('dynare-preprocessor', 'cpp',
        version : '7-unstable',
        # NB: update C++ standard in .clang-format whenever the following is modified
        default_options : [ 'cpp_std=gnu++20', 'warning_level=2' ],
        meson_version : '>=0.64.0')

add_global_arguments('-DPACKAGE_VERSION="' + meson.project_version() + '"', language : 'cpp')

if get_option('warning_level').to_int() >= 2
  add_global_arguments('-Wold-style-cast', language : 'cpp')
endif

cpp_compiler = meson.get_compiler('cpp')

subdir('src')
subdir('doc')
+10 −0
Original line number Diff line number Diff line
# Meson native file for compiling under Homebrew / arm64

[binaries]
cpp = '/opt/homebrew/bin/g++-15'
flex = '/opt/homebrew/opt/flex/bin/flex'
bison = '/opt/homebrew/opt/bison/bin/bison'

[built-in options]
# 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' ]
 No newline at end of file
+10 −0
Original line number Diff line number Diff line
# Meson native file for compiling under Homebrew / x86-64

[binaries]
cpp = '/usr/local/bin/g++-15'
flex = '/usr/local/opt/flex/bin/flex'
bison = '/usr/local/opt/bison/bin/bison'

[built-in options]
# 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' ]
 No newline at end of file
+11 −0
Original line number Diff line number Diff line
# Meson cross file for targeting Linux arm64

[binaries]
cpp = 'aarch64-linux-gnu-g++'
strip = 'aarch64-linux-gnu-strip'

[host_machine]
system = 'linux'
cpu_family = 'aarch64'
cpu = 'aarch64'
endian = 'little'

scripts/wasm.ini

0 → 100644
+44 −0
Original line number Diff line number Diff line
# Meson cross file for creating a WebAssembly version of the preprocessor.
#
# Requires emscripten to be installed.
# Was successfully tested with emscripten 3.1.69 installed through emsdk
# tool, as described on: https://emscripten.org/docs/getting_started/downloads.html
# Don’t forget to source script snippet in current shell before running meson.
#
# Compilation creates a .wasm and .js wrapper under <builddir>/src/
#
# Can be run locally with node.js using:
#  node dynare-preprocessor.js file.mod
# NB: a version of node.js is shipped with emscripten (under the node/
# subdirectory), but another version should also work.

[binaries]
cpp = 'em++'

[host_machine]
system = 'emscripten'
# Could be changed to wasm64 if 4GB memory constraint is hit
# Some background: https://v8.dev/blog/4gb-wasm-memory
cpu_family = 'wasm32'
cpu = 'wasm32'
endian = 'little'

[built-in options]
# Never do a debug build, because otherwise the lack of optimisations can
# overflow the memory capacities.
buildtype = 'release'
# The -fexceptions flag (for both compilation and linking) is needed for an
# unknown reason (C++ compilers are supposed to always add exception support).
# The -Wno-unqualified-std-cast-call flag removes many warnings about “move”
# not being qualified with “std::” namespace.
# The -fexperimental-library flag is needed to get std::jthread support (it was
# supposed to no longer be necessary for LLVM 20, but for some reason we still
# need it).
cpp_args = [ '-fexceptions', '-Wno-unqualified-std-cast-call', '-fexperimental-library' ]
# NODERAWFS=1 is needed for accessing the local filesystem
cpp_link_args = [ '-s', 'NODERAWFS=1', '-fexceptions' ]

[properties]
# It’s necessary to use a different copy of Boost than the one under
# /usr/include, because otherwise GCC headers confuse Clang
boost_root = '/tmp/boost_1_86_0'
+22 −0
Original line number Diff line number Diff line
# Meson cross file for targeting Windows from Linux
# NB: The boost_root property must be set, possibly through a second cross file

[binaries]
cpp = 'x86_64-w64-mingw32-g++-posix'
strip = 'x86_64-w64-mingw32-strip'

[host_machine]
system = 'windows'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'

[built-in options]
prefer_static = true 

# See the comments in the main Dynare Meson cross-file
cpp_args = [ '-fstack-protector', '-march=nocona', '-msahf', '-mtune=generic' ]
cpp_link_args = [ '-fstack-protector' ]

#[properties]
#boost_root = '/home/sebastien/dynare/unstable/preprocessor/deps/mingw64/'

src/Bytecode.cc

0 → 100644
+106 −0
Original line number Diff line number Diff line
/*
 * Copyright © 2022-2024 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/>.
 */

#include <algorithm>
#include <cstdlib>
#include <ios>
#include <iostream>

#include "Bytecode.hh"

namespace Bytecode
{

Writer::Writer(const filesystem::path& filename)
{
  open(filename, ios::out | ios::binary);
  if (!is_open())
    {
      cerr << R"(Error : Can't open file ")" << filename.string() << R"(" for writing)" << endl;
      exit(EXIT_FAILURE);
    }
}

template<>
Writer&
operator<<(Writer& code_file, const FCALL& instr)
{
  code_file.instructions_positions.push_back(code_file.tellp());

  auto write_member = [&code_file](const auto& member) {
    code_file.write(reinterpret_cast<const char*>(&member), sizeof member);
  };

  write_member(instr.tag);
  write_member(instr.nb_output_arguments);
  write_member(instr.nb_input_arguments);
  write_member(instr.indx);
  write_member(instr.add_input_arguments);
  write_member(instr.row);
  write_member(instr.col);
  write_member(instr.call_type);

  int size = static_cast<int>(instr.func_name.size());
  write_member(size);
  code_file.write(instr.func_name.c_str(), size + 1);

  size = static_cast<int>(instr.arg_func_name.size());
  write_member(size);
  code_file.write(instr.arg_func_name.c_str(), size + 1);

  return code_file;
}

template<>
Writer&
operator<<(Writer& code_file, const FBEGINBLOCK& instr)
{
  code_file.instructions_positions.push_back(code_file.tellp());

  auto write_member = [&code_file](const auto& member) {
    code_file.write(reinterpret_cast<const char*>(&member), sizeof member);
  };

  write_member(instr.tag);
  write_member(instr.size);
  write_member(instr.type);
  for (int i = 0; i < instr.size; i++)
    {
      write_member(instr.variables[i]);
      write_member(instr.equations[i]);
    }
  if (instr.type == BlockSimulationType::solveTwoBoundariesSimple
      || instr.type == BlockSimulationType::solveTwoBoundariesComplete
      || instr.type == BlockSimulationType::solveBackwardComplete
      || instr.type == BlockSimulationType::solveForwardComplete)
    {
      write_member(instr.is_linear);
      write_member(instr.u_count_int);
    }
  write_member(instr.nb_col_jacob);
  write_member(instr.det_exo_size);
  write_member(instr.exo_size);

  ranges::for_each_n(instr.det_exogenous.begin(), instr.det_exo_size, write_member);
  ranges::for_each_n(instr.exogenous.begin(), instr.exo_size, write_member);

  return code_file;
}

}

src/Bytecode.hh

0 → 100644
+814 −0

File added.

Preview size limit exceeded, changes collapsed.

src/CodeInterpreter.hh

deleted100644 → 0
+0 −2059

File deleted.

Preview size limit exceeded, changes collapsed.

src/CommonEnums.hh

0 → 100644
+165 −0
Original line number Diff line number Diff line
/*
 * Copyright © 2007-2024 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/>.
 */

#ifndef COMMON_ENUMS_HH
#define COMMON_ENUMS_HH

//! Enumeration of possible symbol types
/*! Warning: do not to change existing values for 0 to 4: the values matter for homotopy_setup
 * command */
enum class SymbolType
{
  endogenous = 0,              // Endogenous (non-heterogeneous)
  exogenous = 1,               // Exogenous (non-heterogeneous)
  exogenousDet = 2,            // Exogenous deterministic (non-heterogeneous)
  parameter = 4,               // Parameter (non-heterogeneous)
  heterogeneousEndogenous = 5, // Endogenous that is heterogeneous across some dimension
  heterogeneousExogenous = 6,  // Exogenous that is heterogeneous across some dimension
  heterogeneousParameter = 7,  // Parameter that is heterogeneous across some dimension
  modelLocalVariable = 10,     // Local variable whose scope is model (pound expression)
  modFileLocalVariable = 11,   // Local variable whose scope is mod file (model excluded)
  externalFunction = 12,       // External (user-defined) function
  trend = 13,                  // Trend variable
  statementDeclaredVariable
  = 14, //!< Local variable assigned within a Statement (see subsample statement for example)
  logTrend = 15, //!< Log-trend variable
  unusedEndogenous
  = 16, //!< Type to mark unused endogenous variables when `nostrict` option is passed

  // Value 17 is unused for the time being (but could be reused)

  epilogue = 18,        //!< Variables created in epilogue block
  excludedVariable = 19 //!< Variable excluded via model_remove/var_remove/include_eqs/exclude_eqs
};

constexpr bool
isHeterogeneous(SymbolType type)
{
  return type == SymbolType::heterogeneousEndogenous || type == SymbolType::heterogeneousExogenous
         || type == SymbolType::heterogeneousParameter;
}

enum class UnaryOpcode
{
  uminus,
  exp,
  log,
  log10,
  cos,
  sin,
  tan,
  acos,
  asin,
  atan,
  cosh,
  sinh,
  tanh,
  acosh,
  asinh,
  atanh,
  sqrt,
  cbrt,
  abs,
  sign,
  steadyState,
  steadyStateParamDeriv,    // for the derivative of the STEADY_STATE operator w.r.t. to a parameter
  steadyStateParam2ndDeriv, // for the 2nd derivative of the STEADY_STATE operator w.r.t. to a
                            // parameter
  expectation,
  erf,
  erfc,
  diff,
  adl,
  sum
};

enum class BinaryOpcode
{
  plus,
  minus,
  times,
  divide,
  power,
  powerDeriv, // for the derivative of the power function (see trac ticket #78)
  equal,
  max,
  min,
  less,
  greater,
  lessEqual,
  greaterEqual,
  equalEqual,
  different
};

// Small number value used when evaluating powerDeriv opcodes.
// Put here instead of inside BinaryOpNode class, because needed by bytecode MEX.
constexpr double power_deriv_near_zero {1e-12};

enum class TrinaryOpcode
{
  normcdf,
  normpdf
};

enum class PriorDistributions
{
  noShape = 0,
  beta = 1,
  gamma = 2,
  normal = 3,
  invGamma = 4,
  invGamma1 = 4,
  uniform = 5,
  invGamma2 = 6,
  dirichlet = 7,
  weibull = 8
};

enum class EquationType
{
  evaluate, //!< Simple evaluation, normalized variable on left-hand side (written as such by the
            //!< user)
  evaluateRenormalized, //!< Simple evaluation, normalized variable on left-hand side (normalization
                        //!< computed by the preprocessor)
  solve                 //!< No simple evaluation of the equation, it has to be solved
};

enum class BlockSimulationType
{
  evaluateForward = 1,       //!< Simple evaluation, normalized variable on left-hand side, forward
  evaluateBackward,          //!< Simple evaluation, normalized variable on left-hand side, backward
  solveForwardSimple,        //!< Block of one equation, newton solver needed, forward
  solveBackwardSimple,       //!< Block of one equation, newton solver needed, backward
  solveTwoBoundariesSimple,  //!< Block of one equation, Newton solver needed, forward and backward
  solveForwardComplete,      //!< Block of several equations, Newton solver needed, forward
  solveBackwardComplete,     //!< Block of several equations, Newton solver needed, backward
  solveTwoBoundariesComplete //!< Block of several equations, Newton solver needed, forward and
                             //!< backwar
};

enum class PacTargetKind
{
  unspecified, // Must be the first one, because it’s the default initializer
  ll,
  dl,
  dd
};

#endif
+2949 −2387

File changed.

Preview size limit exceeded, changes collapsed.

+690 −544

File changed.

Preview size limit exceeded, changes collapsed.

src/ConfigFile.cc

deleted100644 → 0
+0 −769

File deleted.

Preview size limit exceeded, changes collapsed.

src/ConfigFile.hh

deleted100644 → 0
+0 −142
Original line number Diff line number Diff line
/*
 * Copyright (C) 2010-2017 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/>.
 */

#ifndef _CONFIG_FILE_HH
#define _CONFIG_FILE_HH

#include <map>
#include <vector>

#include "WarningConsolidation.hh"

using namespace std;

using member_nodes_t = map<string, double>;

class Hook
{
public:
  explicit Hook(string global_init_file_arg);
private:
  map<string, string> hooks;
public:
  inline map<string, string>
  get_hooks() const
  {
    return hooks;
  };
};

class Path
{
public:
  explicit Path(vector<string> includepath_arg);
private:
  map<string, vector<string>> paths;
public:
  inline map<string, vector<string>>
  get_paths() const
  {
    return paths;
  };
};

class SlaveNode
{
  friend class ConfigFile;
public:
  SlaveNode(string computerName_arg, string port_arg, int minCpuNbr_arg, int maxCpuNbr_arg, string userName_arg,
            string password_arg, string remoteDrive_arg, string remoteDirectory_arg,
            string dynarePath_arg, string matlabOctavePath_arg, bool singleCompThread_arg, int numberOfThreadsPerJob_arg,
            string operatingSystem_arg);

protected:
  const string computerName;
  const string port;
  int minCpuNbr;
  int maxCpuNbr;
  const string userName;
  const string password;
  const string remoteDrive;
  const string remoteDirectory;
  const string dynarePath;
  const string matlabOctavePath;
  const bool singleCompThread;
  const int numberOfThreadsPerJob;
  const string operatingSystem;
};

class Cluster
{
  friend class ConfigFile;
public:
  Cluster(member_nodes_t member_nodes_arg);

protected:
  member_nodes_t member_nodes;
};

//! The abstract representation of a "config" file
class ConfigFile
{
public:
  ConfigFile(bool parallel_arg, bool parallel_test_arg, bool parallel_slave_open_mode_arg, string cluster_name);

private:
  const bool parallel;
  const bool parallel_test;
  const bool parallel_slave_open_mode;
  const string cluster_name;
  string firstClusterName;
  //! Hooks
  vector<Hook> hooks;
  //! Paths
  vector<Path> paths;
  //! Cluster Table
  map<string, Cluster> clusters;
  //! Node Map
  map<string, SlaveNode> slave_nodes;
  //! Add Hooks
  void addHooksConfFileElement(string global_init_file);
  //! Add Paths
  void addPathsConfFileElement(vector<string> includepath);
  //! Add a SlaveNode or a Cluster object
  void addParallelConfFileElement(bool inNode, bool inCluster, const member_nodes_t &member_nodes, const string &name,
                                  const string &computerName, const string &port, int minCpuNbr, int maxCpuNbr, const string &userName,
                                  const string &password, const string &remoteDrive, const string &remoteDirectory,
                                  const string &dynarePath, const string &matlabOctavePath, bool singleCompThread, int numberOfThreadsPerJob,
                                  const string &operatingSystem);
public:
  //! Parse config file
  void getConfigFileInfo(const string &parallel_config_file);
  //! Check Pass
  void checkPass(WarningConsolidation &warnings) const;
  //! Check Pass
  void transformPass();
  //! Get Path Info
  vector<string> getIncludePaths() const;
  //! Write any hooks
  void writeHooks(ostream &output) const;
  //! Create options_.parallel structure, write options
  void writeCluster(ostream &output) const;
  //! Close slave nodes if needed
  void writeEndParallel(ostream &output) const;
};

#endif // ! CONFIG_FILE_HH

src/Configuration.cc

0 → 100644
+807 −0

File added.

Preview size limit exceeded, changes collapsed.

src/Configuration.hh

0 → 100644
+126 −0
Original line number Diff line number Diff line
/*
 * Copyright © 2010-2023 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/>.
 */

#ifndef CONFIGURATION_HH
#define CONFIGURATION_HH

#include <filesystem>
#include <map>
#include <vector>

#include "WarningConsolidation.hh"

using namespace std;

/* The abstract representation of the configuration.
   Merges information from the command-line and from the configuration file. */
class Configuration
{
public:
  Configuration(bool parallel_arg, bool parallel_test_arg, bool parallel_follower_open_mode_arg,
                bool parallel_use_psexec_arg, string cluster_name);

private:
  using member_nodes_t = map<string, double>;

  class Path
  {
  public:
    explicit Path(vector<string> includepath_arg);
    [[nodiscard]] map<string, vector<string>>
    get_paths() const
    {
      return paths;
    }

  private:
    map<string, vector<string>> paths;
  };

  struct FollowerNode
  {
    FollowerNode(string computerName_arg, string port_arg, int minCpuNbr_arg, int maxCpuNbr_arg,
                 string userName_arg, string password_arg, string remoteDrive_arg,
                 string remoteDirectory_arg, string programPath_arg, string programConfig_arg,
                 string matlabOctavePath_arg, bool singleCompThread_arg,
                 int numberOfThreadsPerJob_arg, string operatingSystem_arg);
    const string computerName, port;
    int minCpuNbr, maxCpuNbr;
    const string userName, password;
    const string remoteDrive, remoteDirectory;
    const string programPath, programConfig, matlabOctavePath;
    const bool singleCompThread;
    const int numberOfThreadsPerJob;
    const string operatingSystem;
  };

  struct Cluster
  {
    explicit Cluster(member_nodes_t member_nodes_arg);
    member_nodes_t member_nodes;
  };

  const bool parallel, parallel_test, parallel_follower_open_mode, parallel_use_psexec;
  const string cluster_name;
  string firstClusterName;
  //! Hooks
  string global_init_file;
  //! Paths
  vector<Path> paths;
  //! Cluster Table
  map<string, Cluster> clusters;
  //! Node Map
  map<string, FollowerNode> follower_nodes;
  //! Add Paths
  void addPathsConfFileElement(vector<string> includepath);
  //! Add a FollowerNode or a Cluster object
  void addParallelConfFileElement(bool inNode, bool inCluster, const member_nodes_t& member_nodes,
                                  const string& name, const string& computerName,
                                  const string& port, int minCpuNbr, int maxCpuNbr,
                                  const string& userName, const string& password,
                                  const string& remoteDrive, const string& remoteDirectory,
                                  const string& programPath, const string& programConfig,
                                  const string& matlabOctavePath, bool singleCompThread,
                                  int numberOfThreadsPerJob, const string& operatingSystem);
  /* Given a filename (e.g. dynare.ini), looks for it in the configuration directory:
     – if under Linux or macOS, look into the “dynare” subdirectory of the XDG
       configuration directories (following the default values and the precedence order specified in
       the XDG specification)
     – if under Windows, look into %APPDATA%\dynare\
     The returned path will be empty if the file is not found. */
  [[nodiscard]] static filesystem::path findConfigFile(const string& filename);

public:
  //! Parse config file
  void getConfigFileInfo(const filesystem::path& conffile_option, WarningConsolidation& warnings);
  //! Check Pass
  void checkPass(WarningConsolidation& warnings) const;
  //! Check Pass
  void transformPass();
  //! Get Path Info
  [[nodiscard]] vector<filesystem::path> getIncludePaths() const;
  //! Write any hooks
  void writeHooks(ostream& output) const;
  //! Create options_.parallel structure, write options
  void writeCluster(ostream& output) const;
  //! Close follower nodes if needed
  void writeEndParallel(ostream& output) const;
};

#endif
+484 −305

File changed.

Preview size limit exceeded, changes collapsed.

+215 −136

File changed.

Preview size limit exceeded, changes collapsed.

+3059 −5247

File changed.

Preview size limit exceeded, changes collapsed.

+755 −456

File changed.

Preview size limit exceeded, changes collapsed.

+2093 −1351

File changed.

Preview size limit exceeded, changes collapsed.

+360 −191

File changed.

Preview size limit exceeded, changes collapsed.

+350 −205

File changed.

Preview size limit exceeded, changes collapsed.

src/DynareMain2.cc

deleted100644 → 0
+0 −84

File deleted.

Preview size limit exceeded, changes collapsed.

src/EquationTags.cc

0 → 100644
+149 −0

File added.

Preview size limit exceeded, changes collapsed.

src/EquationTags.hh

0 → 100644
+125 −0

File added.

Preview size limit exceeded, changes collapsed.

+4473 −4422

File changed.

Preview size limit exceeded, changes collapsed.

+1917 −1403

File changed.

Preview size limit exceeded, changes collapsed.

src/Makefile.am

deleted100644 → 0
+0 −86

File deleted.

Preview size limit exceeded, changes collapsed.

src/MinimumFeedbackSet.cc

deleted100644 → 0
+0 −459

File deleted.

Preview size limit exceeded, changes collapsed.

src/MinimumFeedbackSet.hh

deleted100644 → 0
+0 −83

File deleted.

Preview size limit exceeded, changes collapsed.

+1066 −833

File changed.

Preview size limit exceeded, changes collapsed.

+89 −58

File changed.

Preview size limit exceeded, changes collapsed.

+1688 −1549

File changed.

Preview size limit exceeded, changes collapsed.

+3090 −301

File changed.

Preview size limit exceeded, changes collapsed.

+1981 −1224

File changed.

Preview size limit exceeded, changes collapsed.

+449 −334

File changed.

Preview size limit exceeded, changes collapsed.

+941 −272

File changed.

Preview size limit exceeded, changes collapsed.

+232 −62

File changed.

Preview size limit exceeded, changes collapsed.

src/SigmaeInitialization.cc

deleted100644 → 0
+0 −100

File deleted.

Preview size limit exceeded, changes collapsed.

+268 −259

File changed.

Preview size limit exceeded, changes collapsed.

+234 −91

File changed.

Preview size limit exceeded, changes collapsed.

+543 −2826

File changed.

Preview size limit exceeded, changes collapsed.

+292 −267

File changed.

Preview size limit exceeded, changes collapsed.

+1442 −278

File changed.

Preview size limit exceeded, changes collapsed.

+250 −76

File changed.

Preview size limit exceeded, changes collapsed.

+121 −27

File changed.

Preview size limit exceeded, changes collapsed.

+29 −24

File changed.

Preview size limit exceeded, changes collapsed.

+630 −596

File changed.

Preview size limit exceeded, changes collapsed.

+332 −195

File changed.

Preview size limit exceeded, changes collapsed.

+311 −0

File added.

Preview size limit exceeded, changes collapsed.

+235 −0

File added.

Preview size limit exceeded, changes collapsed.

src/macro/Driver.cc

0 → 100644
+70 −0

File added.

Preview size limit exceeded, changes collapsed.

src/macro/Driver.hh

0 → 100644
+128 −0

File added.

Preview size limit exceeded, changes collapsed.

+178 −0

File added.

Preview size limit exceeded, changes collapsed.

+73 −0

File added.

Preview size limit exceeded, changes collapsed.

+1585 −0

File added.

Preview size limit exceeded, changes collapsed.

+1231 −0

File added.

Preview size limit exceeded, changes collapsed.

src/macro/MacroBison.yy

deleted100644 → 0
+0 −283

File deleted.

Preview size limit exceeded, changes collapsed.

src/macro/MacroDriver.cc

deleted100644 → 0
+0 −420

File deleted.

Preview size limit exceeded, changes collapsed.

src/macro/MacroDriver.hh

deleted100644 → 0
+0 −300

File deleted.

Preview size limit exceeded, changes collapsed.

src/macro/MacroFlex.ll

deleted100644 → 0
+0 −650

File deleted.

Preview size limit exceeded, changes collapsed.

src/macro/MacroValue.cc

deleted100644 → 0
+0 −789

File deleted.

Preview size limit exceeded, changes collapsed.

src/macro/MacroValue.hh

deleted100644 → 0
+0 −247

File deleted.

Preview size limit exceeded, changes collapsed.

src/macro/Makefile.am

deleted100644 → 0
+0 −23

File deleted.

Preview size limit exceeded, changes collapsed.

src/macro/Parser.yy

0 → 100644
+508 −0

File added.

Preview size limit exceeded, changes collapsed.

src/macro/Tokenizer.ll

0 → 100644
+224 −0

File added.

Preview size limit exceeded, changes collapsed.

src/meson.build

0 → 100644
+77 −0

File added.

Preview size limit exceeded, changes collapsed.