configure.ac 6.26 KB
Newer Older
1
2
dnl Process this file with autoconf to produce a configure script.

3
dnl Copyright © 2009-2020 Dynare Team
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
18
dnl along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
19

20
AC_PREREQ([2.62])
21
AC_INIT([dynare], [4.7-unstable])
22
AC_CONFIG_SRCDIR([configure.ac])
23
AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign])
24

sebastien's avatar
sebastien committed
25
26
27
dnl The following must occur before we modify CFLAGS/CXXFLAGS
AC_CANONICAL_HOST

28
AX_MATLAB
29
30
31
32
AX_MATLAB_VERSION
AX_DOT_MEXEXT
AX_MATLAB_ARCH
AX_MEXOPTS
33

34
35
if test "$ax_enable_matlab" != yes -o "$ax_matlab_version_ok" != yes -o "$ax_mexopts_ok" != yes; then
  AC_MSG_ERROR([MATLAB cannot be found])
36
37
fi

38
AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [8.3], [AC_MSG_ERROR([Your MATLAB is too old, please upgrade to version 8.3 (R2014a) at least (or disable MATLAB support with --disable-matlab).])])
39

40
41
case ${host_os} in
  *cygwin*)
42
43
44
    AC_MSG_WARN([You are compiling for the Cygwin target. This means that the MEX files will])
    AC_MSG_WARN([not run from MATLAB, because it cannot load the Cygwin DLL.])
    AC_MSG_WARN([This is probably not what you want. Consider using a MinGW cross-compiler.])
45
46
47
    ;;
esac

48
AC_PROG_FC
49
AC_PROG_CC
50
AC_PROG_CC_C99
51
AC_PROG_CXX
Sébastien Villemot's avatar
Sébastien Villemot committed
52
AX_CXX_COMPILE_STDCXX_17
sebastien's avatar
sebastien committed
53
AC_PROG_RANLIB
54
AX_PROG_LN_S
55
AC_PROG_MKDIR_P
56
AM_PROG_AR
57

58
AX_CXX11_THREAD
59

60
# Check for dlopen(), needed by k_order_perturbation DLL
61
62
AC_CHECK_LIB([dl], [dlopen], [LIBADD_DLOPEN="-ldl"], [])
AC_SUBST([LIBADD_DLOPEN])
63
64
65
66
67
68
69
70
71
72
73
74
75
76

# Define optional components and their corresponding flags and Automake conditionals
AC_ARG_ENABLE([mex-ms-sbvar], AS_HELP_STRING([--disable-mex-ms-sbvar], [disable compilation of the MS-SBVAR MEX]), [], [enable_mex_ms_sbvar=yes])
AM_CONDITIONAL([ENABLE_MEX_MS_SBVAR], [test "$enable_mex_ms_sbvar" = yes])

AC_ARG_ENABLE([mex-dynare++], AS_HELP_STRING([--disable-mex-dynare++], [disable compilation of MEX based on Dynare++]), [], [enable_mex_dynareplusplus=yes])
AM_CONDITIONAL([ENABLE_MEX_DYNAREPLUSPLUS], [test "$enable_mex_dynareplusplus" = yes])

AC_ARG_ENABLE([mex-kalman-steady-state], AS_HELP_STRING([--disable-mex-kalman-steady-state], [disable compilation of the kalman_steady_state MEX]), [], [enable_mex_kalman_steady_state=yes])
AM_CONDITIONAL([ENABLE_MEX_KALMAN_STEADY_STATE], [test "$enable_mex_kalman_steady_state" = yes])

# Check for GSL, needed by MS-SBVAR MEX
if test "$enable_mex_ms_sbvar" = yes; then
  AX_GSL
77
  test "$has_gsl" != yes && AC_MSG_ERROR([GSL cannot be found. If you want to skip the compilation of the MS-SBVAR MEX, pass the --disable-mex-ms-sbvar flag.])
78
fi
79

80
# Check for libmatio, needed by MEX files using Dynare++ code
81
82
if test "$enable_mex_dynareplusplus" = yes; then
  AX_MATIO
83
  test "$has_matio" != yes && AC_MSG_ERROR([libmatio cannot be found. If you want to skip the compilation of MEX files based Dynare++, pass the --disable-mex-dynare++ flag.])
84
fi
85

86
# Check for libslicot, needed by kalman_steady_state
87
if test "$enable_mex_kalman_steady_state" = yes; then
88
89
90
91
92
  # FCFLAGS must be temporarily modified, because otherwise -fno-underscoring is not
  # taken into account by AC_FC_FUNC in the AX_SLICOT macro.
  # For some obscure reason, it is necessary to do it at this level and not within the macro.
  ac_save_FCFLAGS=$FCFLAGS
  FCFLAGS="$FCFLAGS $MATLAB_FCFLAGS"
93
  AX_SLICOT([matlab])
94
  FCFLAGS=$ac_save_FCFLAGS
95
  test "$has_slicot" != yes && AC_MSG_ERROR([slicot cannot be found. If you want to skip the compilation of the kalman_steady_state MEX, pass the --disable-mex-kalman-steady-state flag.])
96
fi
97

98
99
100
101
102
103
104
105
106
# On Windows, we want static linking of the external libraries
case ${host_os} in
  *mingw32*)
    GSL_LIBS="-Wl,-Bstatic $GSL_LIBS -Wl,-Bdynamic"
    LIBADD_MATIO="-Wl,-Bstatic $LIBADD_MATIO -Wl,-Bdynamic"
    LIBADD_SLICOT="-Wl,-Bstatic $LIBADD_SLICOT -Wl,-Bdynamic"
    ;;
esac

107
108
109
110
111
112
113
114
115
116
# Support for M2HTML
AC_ARG_WITH([m2html], AS_HELP_STRING([--with-m2html=DIR], [specify installation directory of M2HTML]), [
M2HTML=$withval
BUILD_M2HTML=yes
], [
M2HTML=
BUILD_M2HTML=no
])
AC_SUBST([M2HTML])
AM_CONDITIONAL([HAVE_M2HTML], [test "x$M2HTML" != "x"])
117

118
119
# Construct final output message
if test "$enable_mex_dynareplusplus" = yes; then
120
   BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_MATLAB="yes"
121
else
122
   BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_MATLAB="no"
123
124
fi

125
if test "$enable_mex_kalman_steady_state" = yes; then
126
   BUILD_KALMAN_STEADY_STATE_MATLAB="yes"
127
else
128
   BUILD_KALMAN_STEADY_STATE_MATLAB="no"
129
130
fi

131
if test "$enable_mex_ms_sbvar" = yes; then
132
133
   BUILD_MS_SBVAR_MEX_MATLAB="yes"
else
134
   BUILD_MS_SBVAR_MEX_MATLAB="no"
135
136
fi

137
138
139
140
141
AC_MSG_NOTICE([

Dynare is now configured for building the following components...

Binaries (with "make"):
142
 MEX files for MATLAB (except those listed below):                   yes
143
 Gensylv, k-order and dynare_simul MEX files for MATLAB:             $BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_MATLAB
144
145
146
 MS-SBVAR MEX files for MATLAB:                                      $BUILD_MS_SBVAR_MEX_MATLAB
 Kalman Steady State MEX file for MATLAB:                            $BUILD_KALMAN_STEADY_STATE_MATLAB
 M2HTML documentation:                                               $BUILD_M2HTML
147
148
149

])

150
151
152
153
AC_CONFIG_FILES([Makefile
                 mjdgges/Makefile
                 kronecker/Makefile
                 bytecode/Makefile
154
155
                 libdynare++/Makefile
                 gensylv/Makefile
156
                 libkorder/Makefile
157
                 k_order_perturbation/Makefile
158
                 k_order_welfare/Makefile
159
                 dynare_simul_/Makefile
160
                 kalman_steady_state/Makefile
161
                 ms_sbvar/Makefile
162
                 block_kalman_filter/Makefile
163
164
	             sobol/Makefile
		         local_state_space_iterations/Makefile
165
                 perfect_foresight_problem/Makefile
166
                 num_procs/Makefile
167
                 block_trust_region/Makefile
168
                 disclyap_fast/Makefile])
169

170
AC_OUTPUT