Build system improvements on Windows (MinGW / MSYS2)

- Use the -static flag when linking Dynare++, so that shipping libquadmath and
  libgcc DLL in the installer is no longer needed.

- Use AM_CXXFLAGS and AM_LDFLAGS variables for changing flags, since CXXFLAGS
  and LDFLAGS are user variables. Also, this avoids passing these flags down to
  configure scripts in subdirectories.

- Check for the SZIP library in the configure test for the MatIO, this is
  needed under MSYS2.

- Statically link MatIO and GSL in MEX files for MATLAB, this is needed under
  MSYS2.
parent 47596aa3
...@@ -30,9 +30,9 @@ AC_PROG_CXX ...@@ -30,9 +30,9 @@ AC_PROG_CXX
AC_CANONICAL_HOST AC_CANONICAL_HOST
case ${host_os} in case ${host_os} in
*mingw32*) *mingw32*)
# On mingw32, we don't want dynamic libgcc # On Windows, we want Dynare++ to be statically linked
# Note that static-libstdc++ is only supported since GCC 4.5 (but generates no error on older versions) AM_LDFLAGS="-static"
LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++ -static-libgfortran" AC_SUBST([AM_LDFLAGS])
have_windows="yes" have_windows="yes"
;; ;;
*cygwin*) *cygwin*)
...@@ -51,7 +51,8 @@ esac ...@@ -51,7 +51,8 @@ esac
# Use C++ for testing headers # Use C++ for testing headers
AC_LANG([C++]) AC_LANG([C++])
CXXFLAGS="$CXXFLAGS -Wall -Wno-parentheses" AM_CXXFLAGS="-Wall -Wno-parentheses"
AC_SUBST([AM_CXXFLAGS])
# If default 'ar' is not available, try to find one with a host prefix (see ticket #145) # 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_CHECK_PROGS([AR], [ar ${host_alias}-ar])
...@@ -125,11 +126,6 @@ AM_CONDITIONAL([HAVE_CWEAVE], [test "x$CWEAVE" != "x"]) ...@@ -125,11 +126,6 @@ AM_CONDITIONAL([HAVE_CWEAVE], [test "x$CWEAVE" != "x"])
AC_PROG_F77 AC_PROG_F77
AC_F77_LIBRARY_LDFLAGS AC_F77_LIBRARY_LDFLAGS
case ${host_os} in case ${host_os} in
*mingw32*)
# Hack to get static linking of libgfortran on MinGW
# (-static-libgfortran doesn't act on gcc/g++)
FLIBS=`echo $FLIBS | sed 's/-lgfortran/-Wl,-Bstatic -lgfortran -Wl,-Bdynamic/'`
;;
*darwin*) *darwin*)
# * OS X doesn't need to link against the Fortran libraries because # * OS X doesn't need to link against the Fortran libraries because
# everything is contained within the vecLib framework. # everything is contained within the vecLib framework.
...@@ -144,12 +140,6 @@ fi ...@@ -144,12 +140,6 @@ fi
AM_CONDITIONAL([HAVE_BLAS], [test x"$ax_blas_ok" = "xyes"]) AM_CONDITIONAL([HAVE_BLAS], [test x"$ax_blas_ok" = "xyes"])
AM_CONDITIONAL([HAVE_LAPACK], [test x"$ax_lapack_ok" = "xyes"]) AM_CONDITIONAL([HAVE_LAPACK], [test x"$ax_lapack_ok" = "xyes"])
case ${host_os} in
*mingw32*)
# Ensure that -lpthread is statically linked under MinGW
PTHREAD_LIBS="-Wl,-Bstatic -lpthread -Wl,-Bdynamic"
;;
esac
AX_PTHREAD AX_PTHREAD
AC_CONFIG_FILES([Makefile AC_CONFIG_FILES([Makefile
......
...@@ -26,7 +26,7 @@ noinst_LIBRARIES = libinteg.a ...@@ -26,7 +26,7 @@ noinst_LIBRARIES = libinteg.a
libinteg_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES) precalc_quadrature.dat libinteg_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES) precalc_quadrature.dat
libinteg_a_CPPFLAGS = -I../../sylv/cc -I../../tl/cc -I$(top_srcdir)/mex/sources libinteg_a_CPPFLAGS = -I../../sylv/cc -I../../tl/cc -I$(top_srcdir)/mex/sources
libinteg_a_CXXFLAGS = $(PTHREAD_CFLAGS) libinteg_a_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
BUILT_SOURCES = $(GENERATED_FILES) BUILT_SOURCES = $(GENERATED_FILES)
......
...@@ -2,5 +2,5 @@ noinst_PROGRAMS = quadrature-points ...@@ -2,5 +2,5 @@ noinst_PROGRAMS = quadrature-points
quadrature_points_SOURCES = quadrature-points.cpp quadrature_points_SOURCES = quadrature-points.cpp
quadrature_points_CPPFLAGS = -I../.. -I../../sylv/cc -I../../integ/cc -I../../tl/cc quadrature_points_CPPFLAGS = -I../.. -I../../sylv/cc -I../../integ/cc -I../../tl/cc
quadrature_points_CXXFLAGS = $(PTHREAD_CFLAGS) quadrature_points_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
quadrature_points_LDADD = ../cc/libinteg.a ../../tl/cc/libtl.a ../../parser/cc/libparser.a ../../sylv/cc/libsylv.a ../../utils/cc/libutils.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) quadrature_points_LDADD = ../cc/libinteg.a ../../tl/cc/libtl.a ../../parser/cc/libparser.a ../../sylv/cc/libsylv.a ../../utils/cc/libutils.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS)
...@@ -2,8 +2,8 @@ check_PROGRAMS = tests ...@@ -2,8 +2,8 @@ check_PROGRAMS = tests
tests_SOURCES = tests.cpp tests_SOURCES = tests.cpp
tests_CPPFLAGS = -I../cc -I../../tl/cc -I../../sylv/cc -I$(top_srcdir)/mex/sources tests_CPPFLAGS = -I../cc -I../../tl/cc -I../../sylv/cc -I$(top_srcdir)/mex/sources
tests_CXXFLAGS = $(PTHREAD_CFLAGS) tests_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
tests_LDFLAGS = $(LDFLAGS_MATIO) tests_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MATIO)
tests_LDADD = ../../tl/cc/libtl.a ../../sylv/cc/libsylv.a ../cc/libinteg.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO) tests_LDADD = ../../tl/cc/libtl.a ../../sylv/cc/libsylv.a ../cc/libinteg.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO)
check-local: check-local:
......
...@@ -54,7 +54,7 @@ noinst_LIBRARIES = libkord.a ...@@ -54,7 +54,7 @@ noinst_LIBRARIES = libkord.a
libkord_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES) libkord_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES)
libkord_a_CPPFLAGS = -I../sylv/cc -I../tl/cc -I../integ/cc -I$(top_srcdir)/mex/sources $(CPPFLAGS_MATIO) libkord_a_CPPFLAGS = -I../sylv/cc -I../tl/cc -I../integ/cc -I$(top_srcdir)/mex/sources $(CPPFLAGS_MATIO)
libkord_a_CXXFLAGS = $(PTHREAD_CFLAGS) libkord_a_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
BUILT_SOURCES = $(GENERATED_FILES) BUILT_SOURCES = $(GENERATED_FILES)
...@@ -64,8 +64,8 @@ check_PROGRAMS = tests ...@@ -64,8 +64,8 @@ check_PROGRAMS = tests
tests_SOURCES = tests.cpp tests_SOURCES = tests.cpp
tests_CPPFLAGS = -I../sylv/cc -I../tl/cc -I../integ/cc -I$(top_srcdir)/mex/sources tests_CPPFLAGS = -I../sylv/cc -I../tl/cc -I../integ/cc -I$(top_srcdir)/mex/sources
tests_CXXFLAGS = $(PTHREAD_CFLAGS) tests_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
tests_LDFLAGS = $(LDFLAGS_MATIO) tests_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MATIO)
tests_LDADD = libkord.a ../tl/cc/libtl.a ../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO) tests_LDADD = libkord.a ../tl/cc/libtl.a ../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO)
check-local: check-local:
......
...@@ -22,9 +22,9 @@ dynare___SOURCES = \ ...@@ -22,9 +22,9 @@ dynare___SOURCES = \
$(GENERATED_FILES) $(GENERATED_FILES)
dynare___CPPFLAGS = -I../sylv/cc -I../tl/cc -I../kord -I../integ/cc -I.. -I$(top_srcdir)/mex/sources -DDYNVERSION=\"$(PACKAGE_VERSION)\" $(BOOST_CPPFLAGS) $(CPPFLAGS_MATIO) dynare___CPPFLAGS = -I../sylv/cc -I../tl/cc -I../kord -I../integ/cc -I.. -I$(top_srcdir)/mex/sources -DDYNVERSION=\"$(PACKAGE_VERSION)\" $(BOOST_CPPFLAGS) $(CPPFLAGS_MATIO)
dynare___LDFLAGS = $(LDFLAGS_MATIO) $(BOOST_LDFLAGS) dynare___LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MATIO) $(BOOST_LDFLAGS)
dynare___LDADD = ../kord/libkord.a ../integ/cc/libinteg.a ../tl/cc/libtl.a ../parser/cc/libparser.a ../utils/cc/libutils.a ../sylv/cc/libsylv.a $(LIBADD_MATIO) $(noinst_LIBRARIES) $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) dynare___LDADD = ../kord/libkord.a ../integ/cc/libinteg.a ../tl/cc/libtl.a ../parser/cc/libparser.a ../utils/cc/libutils.a ../sylv/cc/libsylv.a $(LIBADD_MATIO) $(noinst_LIBRARIES) $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS)
dynare___CXXFLAGS = $(PTHREAD_CFLAGS) dynare___CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
BUILT_SOURCES = $(GENERATED_FILES) BUILT_SOURCES = $(GENERATED_FILES)
EXTRA_DIST = dynglob.lex dynglob.y EXTRA_DIST = dynglob.lex dynglob.y
......
...@@ -92,7 +92,7 @@ noinst_LIBRARIES = libtl.a ...@@ -92,7 +92,7 @@ noinst_LIBRARIES = libtl.a
libtl_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES) libtl_a_SOURCES = $(CWEBSRC) $(GENERATED_FILES)
libtl_a_CPPFLAGS = -I../../sylv/cc $(CPPFLAGS_MATIO) libtl_a_CPPFLAGS = -I../../sylv/cc $(CPPFLAGS_MATIO)
libtl_a_CXXFLAGS = $(PTHREAD_CFLAGS) libtl_a_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
BUILT_SOURCES = $(GENERATED_FILES) BUILT_SOURCES = $(GENERATED_FILES)
......
...@@ -2,8 +2,8 @@ check_PROGRAMS = tests ...@@ -2,8 +2,8 @@ check_PROGRAMS = tests
tests_SOURCES = factory.cpp factory.h monoms.cpp monoms.h tests.cpp tests_SOURCES = factory.cpp factory.h monoms.cpp monoms.h tests.cpp
tests_CPPFLAGS = -I../cc -I../../sylv/cc tests_CPPFLAGS = -I../cc -I../../sylv/cc
tests_CXXFLAGS = $(PTHREAD_CFLAGS) tests_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
tests_LDFLAGS = $(LDFLAGS_MATIO) tests_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_MATIO)
tests_LDADD = ../cc/libtl.a ../../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO) tests_LDADD = ../cc/libtl.a ../../sylv/cc/libsylv.a $(LAPACK_LIBS) $(BLAS_LIBS) $(LIBS) $(FLIBS) $(PTHREAD_LIBS) $(LIBADD_MATIO)
check-local: check-local:
......
...@@ -44,6 +44,8 @@ AC_ARG_WITH(matio, AC_HELP_STRING([--with-matio=DIR], [prefix to MATIO installat ...@@ -44,6 +44,8 @@ AC_ARG_WITH(matio, AC_HELP_STRING([--with-matio=DIR], [prefix to MATIO installat
dnl If detected, libz and libhdf5 are added to LIBS, used for matio test dnl If detected, libz and libhdf5 are added to LIBS, used for matio test
LIBS="" LIBS=""
AC_CHECK_LIB([z], [compress]) AC_CHECK_LIB([z], [compress])
dnl szip is needed under MSYS2
AC_CHECK_LIB([szip], [SZ_Compress])
AC_CHECK_LIB([hdf5], [H5Fcreate]) AC_CHECK_LIB([hdf5], [H5Fcreate])
AC_CHECK_HEADER([matio.h], [], [has_matio=no]) AC_CHECK_HEADER([matio.h], [], [has_matio=no])
......
...@@ -66,8 +66,6 @@ AM_PROG_AR ...@@ -66,8 +66,6 @@ AM_PROG_AR
case ${host_os} in case ${host_os} in
*mingw32*) *mingw32*)
# Ensure that -lpthread is statically linked under MinGW
PTHREAD_LIBS="-Wl,-Bstatic -lpthread -Wl,-Bdynamic"
# Kludge for bug in MinGW, that defines __STDC_UTF_16__ but not char16_t # Kludge for bug in MinGW, that defines __STDC_UTF_16__ but not char16_t
# This breaks the matrix.h of older MATLABs (e.g. R2009a) # This breaks the matrix.h of older MATLABs (e.g. R2009a)
# Also see <uchar.h> # Also see <uchar.h>
...@@ -94,6 +92,16 @@ AM_CONDITIONAL([HAVE_MATIO], [test "x$has_matio" = "xyes"]) ...@@ -94,6 +92,16 @@ AM_CONDITIONAL([HAVE_MATIO], [test "x$has_matio" = "xyes"])
AX_SLICOT([matlab]) AX_SLICOT([matlab])
AM_CONDITIONAL([HAVE_SLICOT], [test "x$has_slicot" = "xyes"]) AM_CONDITIONAL([HAVE_SLICOT], [test "x$has_slicot" = "xyes"])
# On Windows, we want static linking of the external libraries
case ${host_os} in
*mingw32*)
PTHREAD_LIBS="-Wl,-Bstatic $PTHREAD_LIBS -Wl,-Bdynamic"
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
AM_CONDITIONAL([DO_SOMETHING], [test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes"]) AM_CONDITIONAL([DO_SOMETHING], [test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes"])
if test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes"; then if test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes"; then
......
Subproject commit f223af91afaaec5fdaa9224c2386d25d5428eee3 Subproject commit beb99d98cdda587cc8341e0891e3be6ef6c98d4f
...@@ -140,7 +140,7 @@ SectionGroupEnd ...@@ -140,7 +140,7 @@ SectionGroupEnd
Section "Dynare++ (standalone executable)" Section "Dynare++ (standalone executable)"
SetOutPath $INSTDIR\dynare++ SetOutPath $INSTDIR\dynare++
File ..\dynare++\src\dynare++.exe ..\dynare++\extern\matlab\dynare_simul.m ..\dynare++\*.dll File ..\dynare++\src\dynare++.exe ..\dynare++\extern\matlab\dynare_simul.m
SectionEnd SectionEnd
Section "Documentation and examples (Dynare and Dynare++)" Section "Documentation and examples (Dynare and Dynare++)"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment