Commit 9318856a authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

SWZ: finalize build system for MEX by adding a test for GSL

parent 53443fbd
......@@ -305,3 +305,16 @@ License: GPL-2+ with special Autoconf exception
configuration script generated by GNU Autoconf, you may include
it under the same distribution terms that you use for the rest
of that program.
Files: m4/gsl.m4
Copyright: 2000, Christopher R. Gabriel <cgabriel@linux.it>
License: GPL-3+
GSL is free software, you can redistribute it and/or modify it under
the terms of the GNU General Public License.
.
The GNU General Public License does not permit this software to be
redistributed in proprietary programs.
.
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.
# Configure path for the GNU Scientific Library
# Christopher R. Gabriel <cgabriel@linux.it>, April 2000
AC_DEFUN([AX_PATH_GSL],
[
AC_ARG_WITH(gsl-prefix,[ --with-gsl-prefix=PFX Prefix where GSL is installed (optional)],
gsl_prefix="$withval", gsl_prefix="")
AC_ARG_WITH(gsl-exec-prefix,[ --with-gsl-exec-prefix=PFX Exec prefix where GSL is installed (optional)],
gsl_exec_prefix="$withval", gsl_exec_prefix="")
AC_ARG_ENABLE(gsltest, [ --disable-gsltest Do not try to compile and run a test GSL program],
, enable_gsltest=yes)
if test "x${GSL_CONFIG+set}" != xset ; then
if test "x$gsl_prefix" != x ; then
GSL_CONFIG="$gsl_prefix/bin/gsl-config"
fi
if test "x$gsl_exec_prefix" != x ; then
GSL_CONFIG="$gsl_exec_prefix/bin/gsl-config"
fi
fi
AC_PATH_PROG(GSL_CONFIG, gsl-config, no)
min_gsl_version=ifelse([$1], ,0.2.5,$1)
AC_MSG_CHECKING(for GSL - version >= $min_gsl_version)
no_gsl=""
if test "$GSL_CONFIG" = "no" ; then
no_gsl=yes
else
GSL_CFLAGS=`$GSL_CONFIG --cflags`
GSL_LIBS=`$GSL_CONFIG --libs`
gsl_major_version=`$GSL_CONFIG --version | \
sed 's/^\([[0-9]]*\).*/\1/'`
if test "x${gsl_major_version}" = "x" ; then
gsl_major_version=0
fi
gsl_minor_version=`$GSL_CONFIG --version | \
sed 's/^\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\).*/\2/'`
if test "x${gsl_minor_version}" = "x" ; then
gsl_minor_version=0
fi
gsl_micro_version=`$GSL_CONFIG --version | \
sed 's/^\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\).*/\3/'`
if test "x${gsl_micro_version}" = "x" ; then
gsl_micro_version=0
fi
if test "x$enable_gsltest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $GSL_CFLAGS"
LIBS="$LIBS $GSL_LIBS"
rm -f conf.gsltest
AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* my_strdup (const char *str);
char*
my_strdup (const char *str)
{
char *new_str;
if (str)
{
new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
strcpy (new_str, str);
}
else
new_str = NULL;
return new_str;
}
int main (void)
{
int major = 0, minor = 0, micro = 0;
int n;
char *tmp_version;
system ("touch conf.gsltest");
/* HP/UX 9 (%@#!) writes to sscanf strings */
tmp_version = my_strdup("$min_gsl_version");
n = sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) ;
if (n != 2 && n != 3) {
printf("%s, bad version string\n", "$min_gsl_version");
exit(1);
}
if (($gsl_major_version > major) ||
(($gsl_major_version == major) && ($gsl_minor_version > minor)) ||
(($gsl_major_version == major) && ($gsl_minor_version == minor) && ($gsl_micro_version >= micro)))
{
exit(0);
}
else
{
exit(1);
}
}
],, no_gsl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
if test "x$no_gsl" = x ; then
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$GSL_CONFIG" = "no" ; then
echo "*** The gsl-config script installed by GSL could not be found"
echo "*** If GSL was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the GSL_CONFIG environment variable to the"
echo "*** full path to gsl-config."
else
if test -f conf.gsltest ; then
:
else
echo "*** Could not run GSL test program, checking why..."
CFLAGS="$CFLAGS $GSL_CFLAGS"
LIBS="$LIBS $GSL_LIBS"
AC_TRY_LINK([
#include <stdio.h>
], [ return 0; ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding GSL or finding the wrong"
echo "*** version of GSL. If it is not finding GSL, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means GSL was incorrectly installed"
echo "*** or that you have moved GSL since it was installed. In the latter case, you"
echo "*** may want to edit the gsl-config script: $GSL_CONFIG" ])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
# GSL_CFLAGS=""
# GSL_LIBS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(GSL_CFLAGS)
AC_SUBST(GSL_LIBS)
rm -f conf.gsltest
])
AU_ALIAS([AM_PATH_GSL], [AX_PATH_GSL])
......@@ -104,7 +104,7 @@
#include "mkl.h"
#else
#if defined (USE_GSL_LIBRARY)
#include "gsl_cblas.h"
#include <gsl/gsl_cblas.h>
#endif
#include "blas_lapack.h"
#undef SWITCHTOINTELCMATH
......@@ -112,8 +112,8 @@
#endif
#if defined(USE_GSL_LIBRARY)
#include "gsl_sf_gamma.h"
#include "gsl_cdf.h"
#include <gsl/gsl_sf_gamma.h>
#include <gsl/gsl_cdf.h>
#endif
#if defined(USE_IMSL_MATH_LIBRARY)
......
......@@ -2,7 +2,10 @@ ACLOCAL_AMFLAGS = -I ../../../m4
# libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_
if DO_SOMETHING
SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv k_order_perturbation dynare_simul_ swz
SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv k_order_perturbation dynare_simul_
if HAVE_GSL
SUBDIRS += swz
endif
endif
EXTRA_DIST = mex.def mexFunction-MacOSX.map
......@@ -59,19 +59,12 @@ AX_PTHREAD
# Check for dlopen(), needed by k_order_perturbation DLL
AC_CHECK_LIB([dl], [dlopen], [LIBADD_DLOPEN="-ldl"], [])
AC_SUBST([LIBADD_DLOPEN])
# Check for GSL, needed by SWZ
AX_PATH_GSL
AM_CONDITIONAL([HAVE_GSL], [test "x$no_gsl" = "x"])
AM_CONDITIONAL([DO_SOMETHING], [test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes"])
AC_CONFIG_FILES([Makefile
mjdgges/Makefile
kronecker/Makefile
gensylv/Makefile
libdynare++/Makefile
bytecode/Makefile
k_order_perturbation/Makefile
dynare_simul_/Makefile
swz/Makefile])
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_pthread_ok" = "xyes"; then
BUILD_MEX_MATLAB="yes"
......@@ -82,13 +75,30 @@ else
BUILD_MEX_MATLAB="no (missing MATLAB, or unknown version, or unknown architecture)"
fi
if test "x$ax_enable_matlab" = "xyes" -a "x$ax_matlab_version_ok" = "xyes" -a "x$ax_mexopts_ok" = "xyes" -a "x$no_gsl" = "x"; then
BUILD_SWZ_MEX_MATLAB="yes"
else
BUILD_SWZ_MEX_MATLAB="no (missing GSL)"
fi
AC_MSG_NOTICE([
Dynare is now configured for building the following components...
Binaries (with "make"):
MEX files for MATLAB: $BUILD_MEX_MATLAB
MEX files for MATLAB (except SWZ): $BUILD_MEX_MATLAB
SWZ MEX files for MATLAB: $BUILD_SWZ_MEX_MATLAB
])
AC_CONFIG_FILES([Makefile
mjdgges/Makefile
kronecker/Makefile
gensylv/Makefile
libdynare++/Makefile
bytecode/Makefile
k_order_perturbation/Makefile
dynare_simul_/Makefile
swz/Makefile])
AC_OUTPUT
include ../mex.am
include ../../swz.am
\ No newline at end of file
include ../../swz.am
......@@ -3,4 +3,7 @@ ACLOCAL_AMFLAGS = -I ../../../m4
# libdynare++ must come before gensylv, k_order_perturbation, dynare_simul_
if DO_SOMETHING
SUBDIRS = mjdgges kronecker bytecode libdynare++ gensylv k_order_perturbation dynare_simul_
if HAVE_GSL
SUBDIRS += swz
endif
endif
......@@ -40,6 +40,9 @@ AX_PTHREAD
# Check for dlopen(), needed by k_order_perturbation DLL
AC_CHECK_LIB([dl], [dlopen], [LIBADD_DLOPEN="-ldl"], [])
AC_SUBST([LIBADD_DLOPEN])
# Check for GSL, needed by SWZ
AX_PATH_GSL
AM_CONDITIONAL([HAVE_GSL], [test "x$no_gsl" = "x"])
AM_CONDITIONAL([DO_SOMETHING], [test "x$MKOCTFILE" != "x"])
......@@ -53,12 +56,20 @@ else
BUILD_MEX_OCTAVE="no (missing mkoctfile)"
fi
if test "x$MKOCTFILE" != "x" -a "x$no_gsl" = "x"; then
BUILD_SWZ_MEX_OCTAVE="yes"
else
BUILD_SWZ_MEX_OCTAVE="no (missing GSL)"
fi
AC_MSG_NOTICE([
Dynare is now configured for building the following components...
Binaries (with "make"):
MEX files for Octave: $BUILD_MEX_OCTAVE
MEX files for Octave (except SWZ): $BUILD_MEX_OCTAVE
SWZ MEX files for Octave: $BUILD_SWZ_MEX_OCTAVE
])
......@@ -69,6 +80,7 @@ AC_CONFIG_FILES([Makefile
libdynare++/Makefile
gensylv/Makefile
k_order_perturbation/Makefile
dynare_simul_/Makefile])
dynare_simul_/Makefile
swz/Makefile])
AC_OUTPUT
include ../mex.am
include ../../swz.am
\ No newline at end of file
include ../../swz.am
WORKING_DIR = ../../../..
SWZ_SRC_BASEDIR = ../../../../matlab/swz/c-code
SWZ_SRC_DIRS = $(WORKING_DIR)/matlab/swz/c-code/utilities/TZCcode $(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/matrix $(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/error $(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/arrays $(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/ascii $(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/stat $(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/spherical $(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/sort $(WORKING_DIR)/matlab/swz/c-code/sbvar/switching $(WORKING_DIR)/matlab/swz/c-code/sbvar/var $(WORKING_DIR)/matlab/swz/c-code/mex
SWZ_SRC_DIRS = $(SWZ_SRC_BASEDIR)/utilities/TZCcode $(SWZ_SRC_BASEDIR)/utilities/DWCcode/matrix $(SWZ_SRC_BASEDIR)/utilities/DWCcode/error $(SWZ_SRC_BASEDIR)/utilities/DWCcode/arrays $(SWZ_SRC_BASEDIR)/utilities/DWCcode/ascii $(SWZ_SRC_BASEDIR)/utilities/DWCcode/stat $(SWZ_SRC_BASEDIR)/utilities/DWCcode/spherical $(SWZ_SRC_BASEDIR)/utilities/DWCcode/sort $(SWZ_SRC_BASEDIR)/sbvar/switching $(SWZ_SRC_BASEDIR)/sbvar/var $(SWZ_SRC_BASEDIR)/mex
vpath %.c $(SWZ_SRC_DIRS)
###
# TO BE REMOVED
####
# 64
BIT = /usr/local64
# 32
#BIT = /usr/local
###
#GSL
GSL_INCLUDE_DIR = -I$(BIT)/include/gsl -I/usr/local/include
LIBS += -lgsl
#
###
CPPFLAGS += -DINTELCMATHLIBRARY $(GSL_CFLAGS) -I$(SWZ_SRC_BASEDIR)/utilities/TZCcode -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/matrix -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/error -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/arrays -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/ascii -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/stat -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/spherical -I$(SWZ_SRC_BASEDIR)/utilities/DWCcode/sort -I$(SWZ_SRC_BASEDIR)/sbvar/switching -I$(SWZ_SRC_BASEDIR)/sbvar/var -I$(SWZ_SRC_BASEDIR)/mex
DEBUG = -g
CPPFLAGS += $(DEBUG) -DINTELCMATHLIBRARY $(GSL_INCLUDE_DIR) -I$(WORKING_DIR)/matlab/swz/c-code/utilities/TZCcode -I$(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/matrix -I$(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/error -I$(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/arrays -I$(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/ascii -I$(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/stat -I$(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/spherical -I$(WORKING_DIR)/matlab/swz/c-code/utilities/DWCcode/sort -I$(WORKING_DIR)/matlab/swz/c-code/sbvar/switching -I$(WORKING_DIR)/matlab/swz/c-code/sbvar/var -I$(WORKING_DIR)/matlab/swz/c-code/mex
LDFLAGS += -L$(BIT)/lib
LIBS += $(GSL_LIBS)
noinst_PROGRAMS = mex_sbvar_init_file mex_sbvar_estimation mex_sbvar_mhm_1 mex_sbvar_mhm_2 mex_sbvar_probabilities mex_sbvar_draws
......@@ -35,4 +19,4 @@ nodist_mex_sbvar_estimation_SOURCES = $(common_mex) $(swz_common) $(swz_tao)
nodist_mex_sbvar_mhm_1_SOURCES = $(common_mex) $(swz_common) mhm_VAR_main_1.c mhm_VAR.c VARbase.c VARio.c command_line_VAR.c switch.c switchio.c
nodist_mex_sbvar_mhm_2_SOURCES = $(common_mex) $(swz_common) mhm_VAR_main_2.c spherical.c VARbase.c VARio.c switch.c switchio.c mhm_VAR.c
nodist_mex_sbvar_probabilities_SOURCES = $(common_mex) $(swz_common) probabilities.c switch.c switchio.c VARbase.c VARio.c command_line_VAR.c
nodist_mex_sbvar_draws_SOURCES = $(common_mex) $(swz_common) PrintDraws.c switch.c switchio.c VARbase.c VARio.c command_line_VAR.c
\ No newline at end of file
nodist_mex_sbvar_draws_SOURCES = $(common_mex) $(swz_common) PrintDraws.c switch.c switchio.c VARbase.c VARio.c command_line_VAR.c
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