From a16f5bc7090e8acdce72a9c9b1fcb3343256d5b0 Mon Sep 17 00:00:00 2001 From: Cary R Date: Sun, 30 Dec 2007 12:19:36 -0800 Subject: [PATCH] Update driver-vpi/* to match iverilog-vpi.sh This patch updates the MinGW C version of iverilog-vpi to match the shell version. This allows the vpi tests in the test suite to be run. --- driver-vpi/Makefile.in | 13 +- driver-vpi/config.h.in | 8 ++ driver-vpi/main.c | 279 +++++++++++++++++++++++++---------------- iverilog-vpi.sh | 2 +- 4 files changed, 190 insertions(+), 112 deletions(-) create mode 100644 driver-vpi/config.h.in diff --git a/driver-vpi/Makefile.in b/driver-vpi/Makefile.in index 78c50a860..d166d562f 100644 --- a/driver-vpi/Makefile.in +++ b/driver-vpi/Makefile.in @@ -16,12 +16,12 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.7 2004/10/13 22:01:34 steve Exp $" +#ident "$Id: Makefile.in,v 1.7.2.1 2006/10/04 17:08:59 steve Exp $" # # SHELL = /bin/sh -VERSION = 0.8 +VERSION = 0.8.3 prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -48,7 +48,7 @@ LDFLAGS = @LDFLAGS@ all: iverilog-vpi@EXEEXT@ clean: - rm -f *.o + rm -f *.o config.h rm -f iverilog-vpi@EXEEXT@ distclean: clean @@ -60,9 +60,14 @@ iverilog-vpi@EXEEXT@: $O $(CC) $(LDFLAGS) $O -o iverilog-vpi@EXEEXT@ @EXTRALIBS@ -main.o: main.c +main.o: main.c config.h $(CC) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/main.c +config.h: config.h.in + sed -e 's;@IVLCC@;@CC@;' -e 's;@IVLCXX@;@CXX@;' \ + -e 's;@IVLCFLAGS@;@CXXFLAGS@;' \ + -e 's;@SHARED@;@shared@;' $< > $@ + # Windows specific... res.o: res.rc windres -i res.rc -o res.o diff --git a/driver-vpi/config.h.in b/driver-vpi/config.h.in new file mode 100644 index 000000000..ca1005555 --- /dev/null +++ b/driver-vpi/config.h.in @@ -0,0 +1,8 @@ +/* For now do not put the Icarus Verilog include or library paths here. + * They are generated from a registry entry the user must set (-ivl=). + * This may change in the future once I have thought about it more. */ +#define IVERILOG_VPI_CC "@IVLCC@" +#define IVERILOG_VPI_CXX "@IVLCXX@" +#define IVERILOG_VPI_CFLAGS " @IVLCFLAGS@" +#define IVERILOG_VPI_LDFLAGS "@SHARED@" +#define IVERILOG_VPI_LDLIBS "-lveriuser -lvpi" diff --git a/driver-vpi/main.c b/driver-vpi/main.c index df325f8e9..9facd443e 100644 --- a/driver-vpi/main.c +++ b/driver-vpi/main.c @@ -32,28 +32,27 @@ #include -/* Macros used for compiling and linking */ +static void setup_ivl_environment(); -#define IVERILOG_VPI_CC "gcc" /* no .exe extension */ -#define IVERILOG_VPI_CXX "gcc" /* no .exe extension */ -#define IVERILOG_VPI_CFLAGS "-O" /* -I appended later */ -#define IVERILOG_VPI_LD "gcc" /* no .exe extension */ -#define IVERILOG_VPI_LDFLAGS "-shared -Wl,--enable-auto-image-base" -#define IVERILOG_VPI_LDLIBS "-lveriuser -lvpi" /* -L prepended later */ +/* The compile options: compiler, flags, etc. are in here */ +#include "config.h" /* pointers to global strings */ static struct global_strings { - char *pCCSRC; /* list of C source files */ - char *pCXSRC; /* list of C++ source files */ + char *pCCSRC; /* list of C source files (*.c) */ + char *pCXSRC; /* list of C++ source files (*.cc, *.cpp) */ char *pOBJ; /* list of object files */ char *pLIB; /* list of library files */ + char *pINCS; /* list of include directories */ + char *pDEFS; /* list of definitions */ char *pOUT; /* output file name (.vpi extension), if 0 length then no source files specified */ char *pMINGW; /* path to MinGW directory */ char *pIVL; /* path to IVL directory */ char *pCFLAGS; /* CFLAGS option */ char *pLDLIBS; /* LDLIBS option */ char *pNewPath; /* new PATH environment variable setting */ + char *pLD; /* what to use for a linker */ } gstr; @@ -70,6 +69,8 @@ static void myExit(int exitVal) deInitDynString(gstr.pCXSRC); deInitDynString(gstr.pOBJ); deInitDynString(gstr.pLIB); + deInitDynString(gstr.pINCS); + deInitDynString(gstr.pDEFS); deInitDynString(gstr.pOUT); deInitDynString(gstr.pMINGW); deInitDynString(gstr.pIVL); @@ -84,7 +85,7 @@ static void myExit(int exitVal) static void usage() { - fprintf(stderr,"usage: iverilog-vpi [--name=name] [-llibrary] [-mingw=dir] [-ivl=dir] sourcefile...\n"); + fprintf(stderr,"usage: iverilog-vpi [src and obj files]...\n"); fprintf(stderr," or iverilog-vpi -mingw=dir\n"); fprintf(stderr," or iverilog-vpi -ivl=dir\n"); myExit(1); @@ -110,12 +111,16 @@ static void init() initDynString(&gstr.pCXSRC); initDynString(&gstr.pOBJ); initDynString(&gstr.pLIB); + initDynString(&gstr.pINCS); + initDynString(&gstr.pDEFS); initDynString(&gstr.pOUT); initDynString(&gstr.pMINGW); initDynString(&gstr.pIVL); initDynString(&gstr.pCFLAGS); initDynString(&gstr.pLDLIBS); initDynString(&gstr.pNewPath); + /* By default use the C compiler to link the programs. */ + gstr.pLD = IVERILOG_VPI_CC; } /* return true if "str" is terminated with with "end", case insensitive */ @@ -281,67 +286,120 @@ static int parse(int argc, char *argv[]) char dot_o_ext[] = ".o"; char name_option[] = "--name="; char lib_option[] = "-l"; + char inc_option[] = "-I"; char mingw_option[] = "-mingw="; char ivl_option[] = "-ivl="; + char def_option[] = "-D"; - if (argc == 1) - return 0; + if (argc == 1) return 0; for (idx=1; idx