Fix MinGW compilation, bug184.

This commit is contained in:
Wilson Snyder 2009-11-13 11:08:30 -05:00
parent 92819f5082
commit 3fc55bba8e
4 changed files with 29 additions and 4 deletions

View File

@ -18,6 +18,8 @@ indicates the contributor was also the author of the fix; Thanks!
*** Add VARHIDDEN warning when signal name hides module name. *** Add VARHIDDEN warning when signal name hides module name.
**** Fix MinGW compilation, bug184. [by Shankar Giri]
**** Support optional cell parenthesis, bug179. [by Byron Bradley] **** Support optional cell parenthesis, bug179. [by Byron Bradley]
**** Support for loop i++, ++i, i--, --i, bug175. [by Byron Bradley] **** Support for loop i++, ++i, i--, --i, bug175. [by Byron Bradley]

View File

@ -43,11 +43,11 @@ The resulting executable will perform the actual simulation.
This version of verilator has been built and tested on: This version of verilator has been built and tested on:
SuSE AMD64 i686-linux-2.6.5 SuSE 11.1 AMD64 i686-linux-2.6.27, GCC 4.3.2
Other users report success with Redhat Linux, Windows under Cygwin, Macs, Other users report success with Redhat Linux, Windows under Cygwin, Windows
HPUX and Solaris. It should run with minor porting on any Linixish under MinGW, Macs, HPUX and Solaris. It should run with minor porting on
platform. any Linix-ish platform.
=head1 INSTALLATION =head1 INSTALLATION

View File

@ -146,7 +146,9 @@ inline void V3FileDependImp::writeTimes(const string& filename, const string& cm
string cmdline = stripQuotes(cmdlineIn); string cmdline = stripQuotes(cmdlineIn);
*ofp<<"C \""<<cmdline<<"\""<<endl; *ofp<<"C \""<<cmdline<<"\""<<endl;
#if !defined (__MINGW32__)
sync(); // Push files so sizes look correct sync(); // Push files so sizes look correct
#endif
for (set<DependFile>::iterator iter=m_filenameList.begin(); for (set<DependFile>::iterator iter=m_filenameList.begin();
iter!=m_filenameList.end(); ++iter) { iter!=m_filenameList.end(); ++iter) {
// Read stats of files we create after we're done making them (execpt for this file, of course) // Read stats of files we create after we're done making them (execpt for this file, of course)
@ -238,7 +240,11 @@ void V3File::createMakeDir() {
static bool created = false; static bool created = false;
if (!created) { if (!created) {
created = true; created = true;
#if !defined (__MINGW32__)
mkdir(v3Global.opt.makeDir().c_str(), 0777); mkdir(v3Global.opt.makeDir().c_str(), 0777);
#else
mkdir(v3Global.opt.makeDir().c_str());
#endif
} }
} }

View File

@ -23,7 +23,9 @@
#include "verilatedos.h" #include "verilatedos.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#if !defined(__MINGW32__)
#include <sys/utsname.h> #include <sys/utsname.h>
#endif
#include <cctype> #include <cctype>
#include <dirent.h> #include <dirent.h>
#include <unistd.h> #include <unistd.h>
@ -318,7 +320,16 @@ void V3Options::setenvStr(const string& envvar, const string& value, const strin
} else { } else {
UINFO(1,"export "<<envvar<<"="<<value<<endl); UINFO(1,"export "<<envvar<<"="<<value<<endl);
} }
//setenv() replaced by putenv() in MinGW environment. Prototype is different
//putenv() requires NAME=VALUE format
#if !defined (__MINGW32__)
setenv(envvar.c_str(),value.c_str(),true); setenv(envvar.c_str(),value.c_str(),true);
#else
int len = value.size() + envvar.size() + 5;
char *str = new char[len];
sprintf(str,"%s=%s", envvar.c_str(), value.c_str());
putenv(str);
#endif
} }
string V3Options::getenvSYSTEMC() { string V3Options::getenvSYSTEMC() {
@ -344,12 +355,18 @@ string V3Options::getenvSYSTEMC_ARCH() {
setenvStr("SYSTEMC_ARCH", var, "Hardcoded at build time"); setenvStr("SYSTEMC_ARCH", var, "Hardcoded at build time");
} }
if (var == "") { if (var == "") {
#if defined (__MINGW32__)
// Hardcoded with MINGW current version. Would like a better way.
string sysname = "MINGW32_NT-5.0";
var = "mingw32";
#else
struct utsname uts; struct utsname uts;
uname(&uts); uname(&uts);
string sysname = downcase(uts.sysname); // aka 'uname -s' string sysname = downcase(uts.sysname); // aka 'uname -s'
if (wildmatch(sysname.c_str(), "*solaris*")) { var = "gccsparcOS5"; } if (wildmatch(sysname.c_str(), "*solaris*")) { var = "gccsparcOS5"; }
else if (wildmatch(sysname.c_str(), "*cygwin*")) { var ="cygwin"; } else if (wildmatch(sysname.c_str(), "*cygwin*")) { var ="cygwin"; }
else { var = "linux"; } else { var = "linux"; }
#endif
setenvStr("SYSTEMC_ARCH", var,"From sysname '"+sysname+"'"); setenvStr("SYSTEMC_ARCH", var,"From sysname '"+sysname+"'");
} }
return var; return var;