From bb51e3084af98c952bfcf7e0561571b69ba6211a Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Fri, 14 Oct 2016 11:25:23 +0200 Subject: [PATCH] preprocessor: add support for MinGW. #1226 --- DynareMain.cc | 19 +++++++++++-------- DynareMain2.cc | 8 ++++---- ModFile.cc | 17 ++++++++++------- ModFile.hh | 5 +++-- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/DynareMain.cc b/DynareMain.cc index 0c81f00d..adbb1b68 100644 --- a/DynareMain.cc +++ b/DynareMain.cc @@ -42,8 +42,8 @@ void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool WarningConsolidation &warnings_arg, bool nostrict, bool check_model_changes, bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode, LanguageOutputType lang, int params_derivs_order -#if defined(_WIN32) || defined(__CYGWIN32__) - , bool cygwin, bool msvc +#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) + , bool cygwin, bool msvc, bool mingw #endif ); @@ -58,8 +58,8 @@ usage() << " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test]" << " [-D[=]] [-I/path] [nostrict] [fast] [minimal_workspace] [compute_xrefs] [output=dynamic|first|second|third] [language=C|C++|julia]" << " [params_derivs_order=0|1|2]" -#if defined(_WIN32) || defined(__CYGWIN32__) - << " [cygwin] [msvc]" +#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) + << " [cygwin] [msvc] [mingw]" #endif << endl; exit(EXIT_FAILURE); @@ -96,9 +96,10 @@ main(int argc, char **argv) bool console = false; bool nograph = false; bool nointeractive = false; -#if defined(_WIN32) || defined(__CYGWIN32__) +#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) bool cygwin = false; bool msvc = false; + bool mingw = false; #endif string parallel_config_file; bool parallel = false; @@ -167,11 +168,13 @@ main(int argc, char **argv) nograph = true; else if (!strcmp(argv[arg], "nointeractive")) nointeractive = true; -#if defined(_WIN32) || defined(__CYGWIN32__) +#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) else if (!strcmp(argv[arg], "cygwin")) cygwin = true; else if (!strcmp(argv[arg], "msvc")) msvc = true; + else if (!strcmp(argv[arg], "mingw")) + mingw = true; #endif else if (strlen(argv[arg]) >= 8 && !strncmp(argv[arg], "conffile", 8)) { @@ -331,8 +334,8 @@ main(int argc, char **argv) no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive, parallel, config_file, warnings, nostrict, check_model_changes, minimal_workspace, compute_xrefs, output_mode, language, params_derivs_order -#if defined(_WIN32) || defined(__CYGWIN32__) - , cygwin, msvc +#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) + , cygwin, msvc, mingw #endif ); diff --git a/DynareMain2.cc b/DynareMain2.cc index a023328e..7d867831 100644 --- a/DynareMain2.cc +++ b/DynareMain2.cc @@ -31,8 +31,8 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear WarningConsolidation &warnings, bool nostrict, bool check_model_changes, bool minimal_workspace, bool compute_xrefs, FileOutputType output_mode, LanguageOutputType language, int params_derivs_order -#if defined(_WIN32) || defined(__CYGWIN32__) - , bool cygwin, bool msvc +#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) + , bool cygwin, bool msvc, bool mingw #endif ) { @@ -59,8 +59,8 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear else mod_file->writeOutputFiles(basename, clear_all, clear_global, no_log, no_warn, console, nograph, nointeractive, config_file, check_model_changes, minimal_workspace, compute_xrefs -#if defined(_WIN32) || defined(__CYGWIN32__) - , cygwin, msvc +#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) + , cygwin, msvc, mingw #endif ); diff --git a/ModFile.cc b/ModFile.cc index e828fa45..041ee3ef 100644 --- a/ModFile.cc +++ b/ModFile.cc @@ -561,7 +561,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo bool console, bool nograph, bool nointeractive, const ConfigFile &config_file, bool check_model_changes, bool minimal_workspace, bool compute_xrefs #if defined(_WIN32) || defined(__CYGWIN32__) - , bool cygwin, bool msvc + , bool cygwin, bool msvc, bool mingw #endif ) const { @@ -723,22 +723,22 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo { if (dynamic_model.isUnaryOpUsed(oAcosh)) { - cerr << "ERROR: acosh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin compiler instead." << endl; + cerr << "ERROR: acosh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin or MinGW compiler instead." << endl; exit(EXIT_FAILURE); } if (dynamic_model.isUnaryOpUsed(oAsinh)) { - cerr << "ERROR: asinh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin compiler instead." << endl; + cerr << "ERROR: asinh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin or MinGW compiler instead." << endl; exit(EXIT_FAILURE); } if (dynamic_model.isUnaryOpUsed(oAtanh)) { - cerr << "ERROR: atanh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin compiler instead." << endl; + cerr << "ERROR: atanh() function is not supported with USE_DLL option and MSVC compiler; use Cygwin or MinGW compiler instead." << endl; exit(EXIT_FAILURE); } if (dynamic_model.isTrinaryOpUsed(oNormcdf)) { - cerr << "ERROR: normcdf() function is not supported with USE_DLL option and MSVC compiler; use Cygwin compiler instead." << endl; + cerr << "ERROR: normcdf() function is not supported with USE_DLL option and MSVC compiler; use Cygwin MinGW compiler instead." << endl; exit(EXIT_FAILURE); } } @@ -748,15 +748,18 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo // When check_model_changes is true, don't force compile if MEX is fresher than source if (use_dll) { -#if defined(_WIN32) || defined(__CYGWIN32__) +#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) if (msvc) // MATLAB/Windows + Microsoft Visual C++ mOutputFile << "dyn_mex('msvc', '" << basename << "', " << !check_model_changes << ")" << endl; else if (cygwin) // MATLAB/Windows + Cygwin g++ mOutputFile << "dyn_mex('cygwin', '" << basename << "', " << !check_model_changes << ")" << endl; + else if (mingw) + // MATLAB/Windows + MinGW g++ + mOutputFile << "dyn_mex('mingw', '" << basename << "', " << !check_model_changes << ")" << endl; else - mOutputFile << " error('When using the USE_DLL option, you must give either ''cygwin'' or ''msvc'' option to the ''dynare'' command')" << endl; + mOutputFile << " error('When using the USE_DLL option, you must give the ''cygwin'', ''msvc'', or ''mingw'' option to the ''dynare'' command')" << endl; #else // other configurations mOutputFile << "dyn_mex('', '" << basename << "', " << !check_model_changes << ")" << endl; diff --git a/ModFile.hh b/ModFile.hh index 4635ac1c..3dcfebc5 100644 --- a/ModFile.hh +++ b/ModFile.hh @@ -143,13 +143,14 @@ public: \param nointeractive Should Dynare request user input? \param cygwin Should the MEX command of use_dll be adapted for Cygwin? \param msvc Should the MEX command of use_dll be adapted for MSVC? + \param mingw Should the MEX command of use_dll be adapted for MinGW? \param compute_xrefs if true, equation cross references will be computed */ void writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn, bool console, bool nograph, bool nointeractive, const ConfigFile &config_file, bool check_model_changes, bool minimal_workspace, bool compute_xrefs -#if defined(_WIN32) || defined(__CYGWIN32__) - , bool cygwin, bool msvc +#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) + , bool cygwin, bool msvc, bool mingw #endif ) const; void writeExternalFiles(const string &basename, FileOutputType output, LanguageOutputType language) const;