Permalink
Browse files

Mingw32 support (Venkat Iyer)

  • Loading branch information...
1 parent d4b2958 commit de8c725890e710aa67b691711fd42be7333f6e81 steve committed May 20, 2001
View
@@ -16,7 +16,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
-#ident "$Id: Makefile.in,v 1.95 2001/03/25 05:59:46 steve Exp $"
+#ident "$Id: Makefile.in,v 1.96 2001/05/20 15:09:39 steve Exp $"
#
#
SHELL = /bin/sh
@@ -120,14 +120,14 @@ Makefile: Makefile.in config.status
./config.status
-ifeq (@CYGWIN@,yes)
+ifeq (@WIN32@,yes)
ivl@EXEEXT@: $O ivl.def
dlltool --dllname ivl@EXEEXT@ --def ivl.def \
--output-lib libivl.a --output-exp ivl.exp
# $(CXX) -o ivl@EXEEXT@ -Wl,--base-file,ivl.base ivl.exp $O $(dllib)
# dlltool --dllname ivl@EXEEXT@ --base-file ivl.base \
# --output-exp ivl.exp --def ivl.def
- $(CXX) -o ivl@EXEEXT@ ivl.exp $O $(dllib)
+ $(CXX) -o ivl@EXEEXT@ ivl.exp $O $(dllib) @EXTRALIBS@
else
ivl@EXEEXT@: $O
$(CXX) $(CXXFLAGS) $(rdynamic) $(LDFLAGS) -o ivl@EXEEXT@ $O $(dllib)
View
@@ -9,8 +9,7 @@
echo "Autoconf in root..."
autoconf
-for dir
-in vpip vvp tgt-vvp
+for dir in vpip vvp tgt-vvp
do
echo "Autoconf in $dir..."
( cd $dir ; autoconf )
View
@@ -48,9 +48,20 @@ AC_CANONICAL_HOST
AC_CYGWIN
AC_EXEEXT
-AC_SUBST(CYGWIN)
+AC_MINGW32
+
+
+WIN32=no
+AC_MSG_CHECKING("Checking for windows")
+if test "$CYGWIN" = "yes" -o "$MINGW32" = "yes"
+then
+ WIN32=yes
+fi
+AC_SUBST(WIN32)
+AC_MSG_RESULT($WIN32)
AC_SUBST(EXEEXT)
+
AC_MSG_CHECKING("for leading and/or trailing underscores")
cat << EOF > underscore.c
void underscore(void){}
@@ -61,7 +72,7 @@ CC_LEADING_UNDERSCORE=no
CC_TRAILING_UNDERSCORE=no
output=`nm underscore.o|grep _underscore 2>&1`
-if test ! -z "$output" -a -z "$CYGWIN" ; then
+if test ! -z "$output" -a -z "$CYGWIN" -a -z "$MINGW32"; then
CC_LEADING_UNDERSCORE=yes
AC_DEFINE(NEED_LU)
fi
@@ -109,6 +120,21 @@ AC_SUBST(PICFLAG)
AC_MSG_RESULT($PICFLAG)
+# mingw needs to link with libiberty.a
+
+AC_MSG_CHECKING("for extra libs needed")
+EXTRALIBS=
+case "${host}" in
+ *-*-cygwin*)
+ if test $ac_cv_mingw32 = yes; then
+ EXTRALIBS="-liberty"
+ fi
+ ;;
+esac
+AC_SUBST(EXTRALIBS)
+AC_MSG_RESULT($EXTRALIBS)
+
+
# The -rdynamic flag is used by iverilog when compiling the target,
# to know how to export symbols of the main program to loadable modules
# that are brought in by -ldl
@@ -142,6 +168,9 @@ case "${host}" in
*-*-cygwin*)
shared="-mdll -Wl,--enable-auto-image-base"
+ if test $ac_cv_mingw32 = yes; then
+ shared="-shared -Wl,--enable-auto-image-base"
+ fi
;;
*-*-hpux*)
View
@@ -18,7 +18,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
-#ident "$Id: Makefile.in,v 1.3 2001/01/09 03:11:27 steve Exp $"
+#ident "$Id: Makefile.in,v 1.4 2001/05/20 15:09:40 steve Exp $"
#
#
SHELL = /bin/sh
@@ -57,7 +57,7 @@ clean:
O = main.o build_string.o lexor.o parse.o
iverilog@EXEEXT@: $O
- $(CC) $(LDFLAGS) $O -o iverilog@EXEEXT@
+ $(CC) $(LDFLAGS) $O -o iverilog@EXEEXT@ @EXTRALIBS@
lexor.c: lexor.lex
flex -s -olexor.c $(srcdir)/lexor.lex
@@ -67,7 +67,7 @@ parse.h parse.c: parse.y
main.o: main.c globals.h
- $(CC) $(CPPFLAGS) -c -DCXX='"@CXX@"' -DIVL_ROOT='"@libdir@/ivl"' -DIVL_INC='"@includedir@"' -DIVL_LIB='"@libdir@"' -DRDYNAMIC=\"$(rdynamic)\" -DDLLIB='"@DLLIB@"' $(srcdir)/main.c
+ $(CC) $(CPPFLAGS) -c -DCXX='"@CXX@"' -DIVL_ROOT='"@libdir@/ivl"' -DIVL_INC='"@includedir@"' -DIVL_LIB='"@libdir@"' -DRDYNAMIC=\"$(rdynamic)\" -DDLLIB='"@DLLIB@"' -DEXEEXT='"@EXEEXT@"' $(srcdir)/main.c
build_string.o: build_string.c globals.h
lexor.o: lexor.c parse.h globals.h
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
-#ident "$Id: main.c,v 1.10 2001/05/17 03:14:26 steve Exp $"
+#ident "$Id: main.c,v 1.11 2001/05/20 15:09:40 steve Exp $"
#endif
const char HELP[] =
@@ -39,6 +39,10 @@ See man page for details.";
#include <sys/types.h>
#include <sys/wait.h>
+#ifdef __MINGW32__
+#include <windows.h>
+#endif
+
#if HAVE_GETOPT_H
#include <getopt.h>
#endif
@@ -53,9 +57,15 @@ See man page for details.";
# include "globals.h"
+#ifdef __MINGW32__
+const char *sep = "\\";
+#else
+const char *sep = "/";
+#endif
+
const char*base = IVL_ROOT;
const char*mtm = 0;
-const char*opath = "a.out";
+const char*opath = "a.out" EXEEXT;
const char*npath = 0;
const char*targ = "vvm";
const char*start = 0;
@@ -100,6 +110,16 @@ static int t_default(char*cmd, unsigned ncmd)
tmp[2] = ' ';
rc = build_string(tmp+3, sizeof tmp - 3, pattern);
cmd = realloc(cmd, ncmd+3+rc+1);
+#ifdef __MINGW32__
+ {
+ char *t;
+ for (t = tmp; *t; t++)
+ {
+ if (*t == '/') *t = '\\';
+ }
+ }
+#endif
+
strcpy(cmd+ncmd, tmp);
@@ -139,8 +159,21 @@ static int t_vvm(char*cmd, unsigned ncmd)
tmp[2] = ' ';
rc = build_string(tmp+3, sizeof tmp - 3, pattern);
cmd = realloc(cmd, ncmd+3+rc+1);
+
+#ifdef __MINGW32__
+ {
+ char *t;
+ for (t = tmp; *t; t++)
+ {
+ if (*t == '/') *t = '\\';
+ }
+ }
+#endif
+
+
strcpy(cmd+ncmd, tmp);
+
if (verbose_flag)
printf("translate: %s\n", cmd);
@@ -183,11 +216,20 @@ static int t_xnf(char*cmd, unsigned ncmd)
{
int rc;
- sprintf(tmp, " | %s/ivl %s -o %s -txnf -Fcprop -Fsynth -Fsyn-rules "
- "-Fnodangle -Fxnfio", base, warning_flags, opath);
+ sprintf(tmp, " | %s%sepivl %s -o %s -txnf -Fcprop -Fsynth -Fsyn-rules "
+ "-Fnodangle -Fxnfio", base, sep,warning_flags, opath);
rc = strlen(tmp);
cmd = realloc(cmd, ncmd+rc+1);
+#ifdef __MINGW32__
+ {
+ char *t;
+ for (t = tmp; *t; t++)
+ {
+ if (*t == '/') *t = '\\';
+ }
+ }
+#endif
strcpy(cmd+ncmd, tmp);
ncmd += rc;
@@ -391,6 +433,19 @@ int main(int argc, char **argv)
return 1;
}
+#ifdef __MINGW32__
+ {
+ char basepath[1024],*s;
+ GetModuleFileName(NULL,basepath,1024);
+ /* Get to the end. Search back twice for backslashes */
+ s = basepath + strlen(basepath);
+ while (*s != '\\') s--; s--;
+ while (*s != '\\') s--;
+ strcpy(s,"\\lib\\ivl");
+ base = basepath;
+ }
+#endif
+
/* Load the iverilog.conf file to get our substitution
strings. */
@@ -399,7 +454,7 @@ int main(int argc, char **argv)
if (config_path) {
strcpy(path, config_path);
} else {
- sprintf(path, "%s/iverilog.conf", base);
+ sprintf(path, "%s%siverilog.conf", base,sep);
}
fd = fopen(path, "r");
if (fd == 0) {
@@ -412,7 +467,7 @@ int main(int argc, char **argv)
/* Start building the preprocess command line. */
- sprintf(tmp, "%s/ivlpp %s%s", base,
+ sprintf(tmp, "%s%sivlpp %s%s", base,sep,
verbose_flag?" -v":"",
e_flag?"":" -L");
@@ -525,6 +580,9 @@ int main(int argc, char **argv)
/*
* $Log: main.c,v $
+ * Revision 1.11 2001/05/20 15:09:40 steve
+ * Mingw32 support (Venkat Iyer)
+ *
* Revision 1.10 2001/05/17 03:14:26 steve
* Update help message.
*
View
@@ -18,7 +18,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
-#ident "$Id: Makefile.in,v 1.9 2001/01/09 03:11:28 steve Exp $"
+#ident "$Id: Makefile.in,v 1.10 2001/05/20 15:09:40 steve Exp $"
#
#
SHELL = /bin/sh
@@ -42,7 +42,7 @@ INSTALL_DATA = @INSTALL_DATA@
CPPFLAGS = @CPPFLAGS@ @DEFS@
CFLAGS = @CFLAGS@ -I.
-LDFLAGS = @LDFLAGS@
+LDFLAGS = @LDFLAGS@
all: ivlpp
@@ -52,7 +52,7 @@ clean:
O = main.o lexor.o parse.o
ivlpp: $O
- $(CC) $(LDFLAGS) $O -o ivlpp
+ $(CC) $(LDFLAGS) $O -o ivlpp @EXTRALIBS@
lexor.c: lexor.lex
flex -s -olexor.c $(srcdir)/lexor.lex
View
@@ -17,14 +17,48 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: t-dll.cc,v 1.41 2001/05/12 03:18:45 steve Exp $"
+#ident "$Id: t-dll.cc,v 1.42 2001/05/20 15:09:39 steve Exp $"
#endif
# include "compiler.h"
# include "t-dll.h"
# include <malloc.h>
-#if defined(HAVE_DLFCN_H)
+#if defined(__WIN32__)
+
+inline ivl_dll_t ivl_dlopen(const char *name)
+{
+ return (ivl_dll_t) LoadLibrary(name);
+}
+
+
+inline void * ivl_dlsym(ivl_dll_t dll, const char *nm)
+{
+ FARPROC sym;
+ return GetProcAddress((HMODULE)dll, nm);
+}
+
+inline void ivl_dlclose(ivl_dll_t dll)
+{
+ FreeLibrary((HMODULE)dll);
+}
+
+const char *dlerror(void)
+{
+ static char msg[255];
+
+ FormatMessage(
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &msg,
+ 0,
+ NULL
+ );
+ return msg;
+}
+#elif defined(HAVE_DLFCN_H)
inline ivl_dll_t ivl_dlopen(const char*name)
{ return dlopen(name,RTLD_NOW); }
@@ -986,6 +1020,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj };
/*
* $Log: t-dll.cc,v $
+ * Revision 1.42 2001/05/20 15:09:39 steve
+ * Mingw32 support (Venkat Iyer)
+ *
* Revision 1.41 2001/05/12 03:18:45 steve
* Make sure LPM devices have drives on outputs.
*
View
10 t-dll.h
@@ -19,13 +19,16 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: t-dll.h,v 1.44 2001/05/17 04:37:02 steve Exp $"
+#ident "$Id: t-dll.h,v 1.45 2001/05/20 15:09:39 steve Exp $"
#endif
# include "target.h"
# include "ivl_target.h"
-#if defined(HAVE_DLFCN_H)
+#if defined(__MINGW32__)
+#include <windows.h>
+typedef void *ivl_dll_t;
+#elif defined(HAVE_DLFCN_H)
# include <dlfcn.h>
typedef void* ivl_dll_t;
#elif defined(HAVE_DL_H)
@@ -520,6 +523,9 @@ struct ivl_statement_s {
/*
* $Log: t-dll.h,v $
+ * Revision 1.45 2001/05/20 15:09:39 steve
+ * Mingw32 support (Venkat Iyer)
+ *
* Revision 1.44 2001/05/17 04:37:02 steve
* Behavioral ternary operators for vvp.
*
Oops, something went wrong.

0 comments on commit de8c725

Please sign in to comment.