From b5ef6d7a375cf8b544c762ec3def20a8181309e8 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 22 Feb 2008 18:22:44 -0800 Subject: [PATCH] Fix some problems in driver-vpi/main.c Fixed a few problems in driver-vpi/main.c that were preventing the Verilog-A math library from compiling. --- driver-vpi/main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/driver-vpi/main.c b/driver-vpi/main.c index 9facd443e..a249f9788 100644 --- a/driver-vpi/main.c +++ b/driver-vpi/main.c @@ -33,6 +33,7 @@ #include static void setup_ivl_environment(); +static void assign(char **ptr, char *str); /* The compile options: compiler, flags, etc. are in here */ #include "config.h" @@ -77,6 +78,7 @@ static void myExit(int exitVal) deInitDynString(gstr.pCFLAGS); deInitDynString(gstr.pLDLIBS); deInitDynString(gstr.pNewPath); + free(gstr.pLD); exit(exitVal); } @@ -120,7 +122,7 @@ static void init() initDynString(&gstr.pLDLIBS); initDynString(&gstr.pNewPath); /* By default use the C compiler to link the programs. */ - gstr.pLD = IVERILOG_VPI_CC; + assign(&gstr.pLD, IVERILOG_VPI_CC); } /* return true if "str" is terminated with with "end", case insensitive */ @@ -306,7 +308,7 @@ static int parse(int argc, char *argv[]) /* Check for C++ source files (*.cc) */ else if (endsIn(dot_cc_ext, argv[idx])) { /* We need to link with the C++ compiler. */ - gstr.pLD = IVERILOG_VPI_CXX; + assign(&gstr.pLD, IVERILOG_VPI_CXX); ++srcFileCnt; append(&gstr.pCXSRC, argv[idx]); append(&gstr.pCXSRC, " "); @@ -317,7 +319,7 @@ static int parse(int argc, char *argv[]) /* Check for C++ source files (*.cpp) */ else if (endsIn(dot_cpp_ext, argv[idx])) { /* We need to link with the C++ compiler. */ - gstr.pLD = IVERILOG_VPI_CXX; + assign(&gstr.pLD, IVERILOG_VPI_CXX); ++srcFileCnt; append(&gstr.pCXSRC, argv[idx]); append(&gstr.pCXSRC, " "); @@ -482,6 +484,7 @@ static void setup_mingw_environment() assign(&gstr.pNewPath,"PATH="); append(&gstr.pNewPath,gstr.pMINGW); appendBackSlash(&gstr.pNewPath); + append(&gstr.pNewPath, "\\"); append(&gstr.pNewPath,"bin;"); append(&gstr.pNewPath,pOldPATH); @@ -512,12 +515,14 @@ static void setup_ivl_environment() append(&gstr.pCFLAGS," -I"); append(&gstr.pCFLAGS,gstr.pIVL); appendBackSlash(&gstr.pCFLAGS); + append(&gstr.pCFLAGS, "\\"); append(&gstr.pCFLAGS,"include"); /* Build up the LDFLAGS option string */ assign(&gstr.pLDLIBS,"-L"); append(&gstr.pLDLIBS,gstr.pIVL); appendBackSlash(&gstr.pLDLIBS); + append(&gstr.pLDLIBS, "\\"); append(&gstr.pLDLIBS,"lib "); append(&gstr.pLDLIBS,IVERILOG_VPI_LDLIBS); } @@ -537,7 +542,9 @@ static void compile(char *pSource, char **pObject, int *compile_errors, char *co assignn(&src, ptr1, len); /* Build the object file name */ - ostart = strrchr(ptr1, '/') + 1; + ostart = strrchr(ptr1, '/'); + if (ostart == NULL) ostart = ptr1; + else ostart += 1; olen = strrchr(ptr1, '.') - ostart; assignn(&obj, ostart, olen); append(&obj, ".o");