From b26bdd3c19dce85a06839b34f36834cb5bb0330f Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 22 May 2008 16:31:09 -0700 Subject: [PATCH] MinGW fixes (development) The MinGW system() implementation appears to return the straight return value instead of the waitpid() like result that more normal systems return. Because of this just return the system() result without processing for MinGW compilations. Older version of the MinGW runtime (pre 3.14) just used the underlying vsnprintf(). Which has some problems. The 3.14 version has some nice improvements, but it has a sever bug when processing "%*.*f", -1, -1, . Because of this we need to use the underlying version without the enhancements for now. snprintf prints %p differently than the other printf routines so use _snprintf to get consistent results. Only build the PDF files if both man and ps2pdf exist. MinGW does not know about the z modifier for %d, %u, etc. Add some missing Makefile check targets. --- Makefile.in | 30 +++++++++++++++++++++--------- cadpli/Makefile.in | 7 ++----- configure.in | 3 +++ driver-vpi/Makefile.in | 7 +++---- driver/Makefile.in | 21 ++++++++++++++------- driver/main.c | 4 ++++ ivlpp/lexor.lex | 4 ++++ tgt-null/Makefile.in | 7 +++---- tgt-stub/Makefile.in | 7 +++---- tgt-vvp/draw_vpi.c | 4 ++++ tgt-vvp/modpath.c | 4 ++++ tgt-vvp/vvp_scope.c | 8 ++++++++ vpi/Makefile.in | 9 ++++----- vvp/Makefile.in | 16 +++++++++++++--- vvp/configure.in | 2 ++ vvp/udp.cc | 10 +++++----- vvp/vpi_mcd.cc | 8 ++++++++ 17 files changed, 105 insertions(+), 46 deletions(-) diff --git a/Makefile.in b/Makefile.in index 6e4c96ab3..90b9d4aaf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -16,9 +16,6 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.181 2007/05/24 04:07:11 steve Exp $" -# -# SHELL = /bin/sh # This version string is only used in the version message printed @@ -51,6 +48,9 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ LEX = @LEX@ YACC = @YACC@ +MAN = @MAN@ +PS2PDF = @PS2PDF@ +GIT = @GIT@ CPPFLAGS = @ident_support@ @DEFS@ -I. -I$(srcdir) @CPPFLAGS@ CXXFLAGS = -Wall @CXXFLAGS@ @@ -65,7 +65,7 @@ all: dep version.h ivl@EXEEXT@ # In the windows world, the installer will need a dosify program to # dosify text files. -ifeq (@MING32@,yes) +ifeq (@MINGW32@,yes) all: dep dosify.exe dosify.exe: dosify.c $(CC) -o dosify.exe dosify.c @@ -177,19 +177,22 @@ lexor_keyword.cc: lexor_keyword.gperf gperf -o -i 7 -C -k 1-4,$$ -L ANSI-C -H keyword_hash -N check_identifier -t $(srcdir)/lexor_keyword.gperf > lexor_keyword.cc || (rm -f lexor_keyword.cc ; false) iverilog-vpi.ps: $(srcdir)/iverilog-vpi.man - man -t $(srcdir)/iverilog-vpi.man > iverilog-vpi.ps + $(MAN) -t $(srcdir)/iverilog-vpi.man > iverilog-vpi.ps iverilog-vpi.pdf: iverilog-vpi.ps - ps2pdf iverilog-vpi.ps iverilog-vpi.pdf + $(PS2PDF) iverilog-vpi.ps iverilog-vpi.pdf # For VERSION_TAG in driver/main.c, first try git-describe, then look for a # version.h file in the source tree (included in snapshots and releases), and # finally use nothing. .PHONY: version.h version.h: +ifeq ($(GIT),none) + @echo '#define VERSION_TAG ""' > $@; +else @if test -d $(srcdir)/.git; then \ echo "Using git-describe for VERSION_TAG"; \ - tmp=`git --git-dir $(srcdir)/.git describe \ + tmp=`$(GIT) --git-dir $(srcdir)/.git describe \ | sed -e 's;\(.*\);#define VERSION_TAG "\1";'`; \ echo "$$tmp" | diff - $@ > /dev/null 2>&1 || echo "$$tmp" > $@ || exit 1; \ elif test -r $(srcdir)/$@; then \ @@ -199,11 +202,20 @@ version.h: echo "Using empty VERSION_TAG"; \ echo '#define VERSION_TAG ""' > $@; \ fi +endif -ifeq (@MING32@,yes) +ifeq (@MINGW32@,yes) +ifeq ($(MAN),none) +INSTALL_DOC = $(mandir)/man1/iverilog-vpi.1 +else +ifeq ($(PS2PDF),none) +INSTALL_DOC = $(mandir)/man1/iverilog-vpi.1 +else INSTALL_DOC = $(prefix)/iverilog-vpi.pdf $(mandir)/man1/iverilog-vpi.1 -INSTALL_DOCDIR = $(mandir)/man1 all: dep iverilog-vpi.pdf +endif +endif +INSTALL_DOCDIR = $(mandir)/man1 else INSTALL_DOC = $(mandir)/man1/iverilog-vpi.1 INSTALL_DOCDIR = $(mandir)/man1 diff --git a/cadpli/Makefile.in b/cadpli/Makefile.in index e98089888..9d8885847 100644 --- a/cadpli/Makefile.in +++ b/cadpli/Makefile.in @@ -16,12 +16,9 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.13 2007/02/06 05:07:31 steve Exp $" -# -# SHELL = /bin/sh -VERSION = 0.0 +VERSION = 0.9.devel prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -63,7 +60,7 @@ dep: O = cadpli.o SYSTEM_VPI_LDFLAGS = -L../vvp -lvpi -ifeq (@MING32@,yes) +ifeq (@MINGW32@,yes) SYSTEM_VPI_LDFLAGS += @EXTRALIBS@ endif diff --git a/configure.in b/configure.in index 4f4220c69..46529fbe9 100644 --- a/configure.in +++ b/configure.in @@ -9,6 +9,9 @@ AC_PROG_CC AC_PROG_CXX AC_CHECK_TOOL(STRIP, strip, true) AC_CHECK_PROGS(XGPERF,gperf,none) +AC_CHECK_PROGS(MAN,man,none) +AC_CHECK_PROGS(PS2PDF,ps2pdf,none) +AC_CHECK_PROGS(GIT,git,none) if test "$XGPERF" = "none" then echo "" diff --git a/driver-vpi/Makefile.in b/driver-vpi/Makefile.in index f9cd6def6..a33053ae1 100644 --- a/driver-vpi/Makefile.in +++ b/driver-vpi/Makefile.in @@ -16,12 +16,9 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.7.2.1 2006/10/04 17:08:59 steve Exp $" -# -# SHELL = /bin/sh -VERSION = 0.8.3 +VERSION = 0.9.devel prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -48,6 +45,8 @@ LDFLAGS = @LDFLAGS@ all: iverilog-vpi@EXEEXT@ +check: all + clean: rm -f *.o config.h rm -f iverilog-vpi@EXEEXT@ diff --git a/driver/Makefile.in b/driver/Makefile.in index 9968923e9..254b65dfd 100644 --- a/driver/Makefile.in +++ b/driver/Makefile.in @@ -16,9 +16,6 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.26 2007/02/06 05:07:31 steve Exp $" -# -# SHELL = /bin/sh VERSION = 0.9.devel @@ -41,6 +38,8 @@ CC = @CC@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ +MAN = @MAN@ +PS2PDF = @PS2PDF@ CPPFLAGS = @ident_support@ -I. -I.. -I$(srcdir)/.. -I$(srcdir) -DVERSION='"$(VERSION)"' @CPPFLAGS@ @DEFS@ CFLAGS = -Wall @CFLAGS@ @@ -76,15 +75,23 @@ cflexor.o: cflexor.c cfparse.h cfparse_misc.h globals.h cfparse.o: cfparse.c globals.h cfparse_misc.h iverilog.ps: $(srcdir)/iverilog.man - man -t $(srcdir)/iverilog.man > iverilog.ps + $(MAN) -t $(srcdir)/iverilog.man > iverilog.ps iverilog.pdf: iverilog.ps - ps2pdf iverilog.ps iverilog.pdf + $(PS2PDF) iverilog.ps iverilog.pdf -ifeq (@MING32@,yes) +ifeq (@MINGW32@,yes) +ifeq ($(MAN),none) +INSTALL_DOC = $(mandir)/man1/iverilog.1 +else +ifeq ($(PS2PDF),none) +INSTALL_DOC = $(mandir)/man1/iverilog.1 +else INSTALL_DOC = $(prefix)/iverilog.pdf $(mandir)/man1/iverilog.1 -INSTALL_DOCDIR = $(mandir)/man1 all: iverilog.pdf +endif +endif +INSTALL_DOCDIR = $(mandir)/man1 else INSTALL_DOC = $(mandir)/man1/iverilog.1 INSTALL_DOCDIR = $(mandir)/man1 diff --git a/driver/main.c b/driver/main.c index a9f5236e4..55fac84b3 100644 --- a/driver/main.c +++ b/driver/main.c @@ -327,6 +327,9 @@ static int t_default(char*cmd, unsigned ncmd) remove(defines_path); remove(compiled_defines_path); } +#ifdef __MINGW32__ /* MinGW just returns the exit status, so return it! */ + return rc; +#else if (rc != 0) { if (rc == 127) { @@ -342,6 +345,7 @@ static int t_default(char*cmd, unsigned ncmd) } return 0; +#endif } diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 08bdc3f66..2997e371c 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -1616,7 +1616,11 @@ static int load_next_input() static void do_dump_precompiled_defines(FILE* out, struct define_t* table) { if (!table->keyword) +#ifdef __MINGW32__ /* MinGW does not know about z. */ + fprintf(out, "%s:%d:%d:%s\n", table->name, table->argc, strlen(table->value), table->value); +#else fprintf(out, "%s:%d:%zd:%s\n", table->name, table->argc, strlen(table->value), table->value); +#endif if (table->left) do_dump_precompiled_defines(out, table->left); diff --git a/tgt-null/Makefile.in b/tgt-null/Makefile.in index cba6d9c16..204e6a00c 100644 --- a/tgt-null/Makefile.in +++ b/tgt-null/Makefile.in @@ -16,12 +16,9 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.11 2004/02/10 19:25:01 steve Exp $" -# -# SHELL = /bin/sh -VERSION = 0.0 +VERSION = 0.9.devel prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -44,6 +41,8 @@ LDFLAGS = @LDFLAGS@ all: dep null.tgt +check: all + dep: mkdir dep diff --git a/tgt-stub/Makefile.in b/tgt-stub/Makefile.in index b93a8452b..fd726431d 100644 --- a/tgt-stub/Makefile.in +++ b/tgt-stub/Makefile.in @@ -16,12 +16,9 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.20 2007/02/06 05:07:32 steve Exp $" -# -# SHELL = /bin/sh -VERSION = 0.0 +VERSION = 0.9.devel prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -44,6 +41,8 @@ LDFLAGS = @LDFLAGS@ all: dep stub.tgt +check: all + dep: mkdir dep diff --git a/tgt-vvp/draw_vpi.c b/tgt-vvp/draw_vpi.c index 43821385f..89c6f3771 100644 --- a/tgt-vvp/draw_vpi.c +++ b/tgt-vvp/draw_vpi.c @@ -25,6 +25,10 @@ # include # include +#ifdef __MINGW32__ /* MinGW has inconsistent %p output. */ +#define snprintf _snprintf +#endif + static const char* magic_sfuncs[] = { "$time", "$stime", diff --git a/tgt-vvp/modpath.c b/tgt-vvp/modpath.c index 07b37df22..031257f70 100644 --- a/tgt-vvp/modpath.c +++ b/tgt-vvp/modpath.c @@ -22,6 +22,10 @@ # include # include +#ifdef __MINGW32__ /* MinGW has inconsistent %p output. */ +#define snprintf _snprintf +#endif + static ivl_signal_t find_path_source_port(ivl_delaypath_t path) { int idx; diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index 05944f639..1d361934d 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -27,6 +27,10 @@ # include # include +#ifdef __MINGW32__ /* MinGW has inconsistent %p output. */ +#define snprintf _snprintf +#endif + struct vvp_nexus_data { /* draw_net_input uses this */ const char*net_input; @@ -1759,7 +1763,11 @@ static void draw_lpm_add(ivl_lpm_t net) type = "pow.s"; if (width > 8*sizeof(long)) { fprintf(stderr, "%s:%u: sorry (vvp-tgt): Signed power " +#ifdef __MINGW32__ /* MinGW does not know about z. */ + "result must be no more than %u bits.\n", +#else "result must be no more than %zu bits.\n", +#endif ivl_lpm_file(net), ivl_lpm_lineno(net), 8*sizeof(long)); exit(1); diff --git a/vpi/Makefile.in b/vpi/Makefile.in index ed719718b..4b8bca964 100644 --- a/vpi/Makefile.in +++ b/vpi/Makefile.in @@ -16,12 +16,9 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.61 2007/02/06 05:07:32 steve Exp $" -# -# SHELL = /bin/sh -VERSION = 0.0 +VERSION = 0.9.devel prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -48,6 +45,8 @@ LDFLAGS = @LDFLAGS@ all: dep system.vpi va_math.vpi $(ALL32) +check: all + dep: mkdir dep @@ -75,7 +74,7 @@ V = va_math.o LIBS = @LIBS@ SYSTEM_VPI_LDFLAGS = $(LIBS) VA_MATH_LDFLAGS = -ifeq (@MING32@,yes) +ifeq (@MINGW32@,yes) SYSTEM_VPI_LDFLAGS += @EXTRALIBS@ VA_MATH_LDFLAGS += @EXTRALIBS@ endif diff --git a/vvp/Makefile.in b/vvp/Makefile.in index 65cab97f4..fdc199431 100644 --- a/vvp/Makefile.in +++ b/vvp/Makefile.in @@ -43,6 +43,8 @@ INSTALL_DATA = @INSTALL_DATA@ RANLIB = @RANLIB@ LEX = @LEX@ YACC = @YACC@ +MAN = @MAN@ +PS2PDF = @PS2PDF@ CPPFLAGS = @ident_support@ -I. -I.. -I $(srcdir) -I$(srcdir)/.. @CPPFLAGS@ @DEFS@ CXXFLAGS = -Wall @CXXFLAGS@ @@ -133,12 +135,20 @@ lexor.cc: $(srcdir)/lexor.lex $(LEX) -s -olexor.cc $(srcdir)/lexor.lex vvp.pdf: $(srcdir)/vvp.man - man -t $(srcdir)/vvp.man | ps2pdf - vvp.pdf + $(MAN) -t $(srcdir)/vvp.man | $(PS2PDF) - vvp.pdf -ifeq (@MING32@,yes) +ifeq (@MINGW32@,yes) +ifeq ($(MAN),none) +INSTALL_DOC = $(mandir)/man1/vvp.1 +else +ifeq ($(PS2PDF),none) +INSTALL_DOC = $(mandir)/man1/vvp.1 +else INSTALL_DOC = $(prefix)/vvp.pdf $(mandir)/man1/vvp.1 -INSTALL_DOCDIR = $(mandir)/man1 all: vvp.pdf +endif +endif +INSTALL_DOCDIR = $(mandir)/man1 else INSTALL_DOC = $(mandir)/man1/vvp.1 INSTALL_DOCDIR = $(mandir)/man1 diff --git a/vvp/configure.in b/vvp/configure.in index 6d11b2a99..a9ae1799b 100644 --- a/vvp/configure.in +++ b/vvp/configure.in @@ -5,6 +5,8 @@ AC_PROG_CC AC_PROG_CXX AC_PROG_RANLIB AC_CHECK_TOOL(STRIP, strip, true) +AC_CHECK_PROGS(MAN,man,none) +AC_CHECK_PROGS(PS2PDF,ps2pdf,none) AC_EXEEXT AC_SUBST(EXEEXT) diff --git a/vvp/udp.cc b/vvp/udp.cc index da041c183..4bee78c3d 100644 --- a/vvp/udp.cc +++ b/vvp/udp.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2007 Stephen Williams (steve@icarus.com) + * Copyright (c) 2005-2008 Stephen Williams (steve@icarus.com) * * (This is a rewrite of code that was ... * Copyright (c) 2001 Stephan Boettcher ) @@ -19,9 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifdef HAVE_CVS_IDENT -#ident "$Id: udp.cc,v 1.35 2007/03/04 06:26:33 steve Exp $" -#endif #include "udp.h" #include "schedule.h" @@ -228,7 +225,11 @@ void vvp_udp_comb_s::compile_table(char**tab) cur.maskx = 0; if (port_count() > 8*sizeof(cur.mask0)) { fprintf(stderr, "internal error: primitive port count=%u " +#ifdef __MINGW32__ /* MinGW does not know about z. */ + " > %u\n", port_count(), sizeof(cur.mask0)); +#else " > %zu\n", port_count(), sizeof(cur.mask0)); +#endif assert(port_count() <= 8*sizeof(cur.mask0)); } for (unsigned pp = 0 ; pp < port_count() ; pp += 1) { @@ -954,4 +955,3 @@ void compile_udp_functor(char*label, char*type, wide_inputs_connect(core, argc, argv); free(argv); } - diff --git a/vvp/vpi_mcd.cc b/vvp/vpi_mcd.cc index b72406630..f81e1d381 100644 --- a/vvp/vpi_mcd.cc +++ b/vvp/vpi_mcd.cc @@ -152,7 +152,15 @@ vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap) mcd, fmt); } +#ifdef __MINGW32__ + /* + * The MinGW runtime (version 3.14) fixes some things, but breaks + * %f for us, so we have to us the underlying version. + */ + rc = _vsnprintf(buffer, sizeof buffer, fmt, ap); +#else rc = vsnprintf(buffer, sizeof buffer, fmt, ap); +#endif for(int i = 0; i < 31; i++) { if((mcd>>i) & 1) {