diff --git a/driver/Makefile.in b/driver/Makefile.in index 9a8ded7dd..224396532 100644 --- a/driver/Makefile.in +++ b/driver/Makefile.in @@ -79,7 +79,7 @@ dep: mv $*.d dep main.o: main.c globals.h ../version_base.h ../version_tag.h Makefile - $(CC) $(CPPFLAGS) $(CFLAGS) -MD -c -DIVL_ROOT='"@libdir@/ivl$(suffix)"' -DIVL_INC='"@includedir@"' -DIVL_LIB='"@libdir@"' -DDLLIB='"@DLLIB@"' $(srcdir)/main.c + $(CC) $(CPPFLAGS) $(CFLAGS) -MD -c -DIVL_ROOT='"@libdir@/ivl$(suffix)"' -DIVL_SUFFIX='"$(suffix)"' -DIVL_INC='"@includedir@"' -DIVL_LIB='"@libdir@"' -DDLLIB='"@DLLIB@"' $(srcdir)/main.c mv $*.d dep cflexor.o: cflexor.c cfparse.h diff --git a/driver/main.c b/driver/main.c index 1cf94da1a..c47149b8f 100644 --- a/driver/main.c +++ b/driver/main.c @@ -760,25 +760,23 @@ int main(int argc, char **argv) int opt, idx; #ifdef __MINGW32__ - { char * s; - char basepath[1024], tmp[1024]; + /* Calculate the ivl_root from the path to the command. This + is necessary because of the installation process on + Windows. Mostly, it is those darn drive letters, but oh + well. We know the command path is formed like this: + + D:\iverilog\bin\iverilog.exe + + The module path in a Windows installation is the path: + + D:\iverilog\lib\ivl$(suffix) + + so we chop the file name and the last directory by + turning the last two \ characters to null. Then we append + the lib\ivl$(suffix) to finish. */ + { char *s; + char basepath[4096], tmp[4096]; GetModuleFileName(NULL, tmp, sizeof tmp); - - /* Calculate the ivl_root from the path to the command. This - is necessary because of the installation process in - Windows. Mostly, it is those darn drive letters, but oh - well. We know the command path is formed like this: - - D:\iverilog\bin\iverilog.exe - - The IVL_ROOT in a Windows installation is the path: - - D:\iverilog\lib\ivl - - so we chop the file name and the last directory by - turning the last two \ characters to null. Then we append - the lib\ivl to finish. */ - /* Convert to a short name to remove any embedded spaces. */ GetShortPathName(tmp, basepath, sizeof basepath); strncpy(ivl_root, basepath, MAXSIZE); @@ -786,7 +784,7 @@ int main(int argc, char **argv) if (s) *s = 0; s = strrchr(ivl_root, sep); if (s) *s = 0; - strcat(ivl_root, "\\lib\\ivl"); + strcat(ivl_root, "\\lib\\ivl" IVL_SUFFIX); base = ivl_root; } diff --git a/vvp/Makefile.in b/vvp/Makefile.in index b17380602..7ca3b2fa8 100644 --- a/vvp/Makefile.in +++ b/vvp/Makefile.in @@ -53,7 +53,7 @@ LIBS = @LIBS@ @EXTRALIBS@ dllib=@DLLIB@ -MDIR1 = -DMODULE_DIR1=\"$(libdir)/ivl$(suffix)/.\" +MDIR1 = -DMODULE_DIR1='"$(libdir)/ivl$(suffix)"' all: dep vvp@EXEEXT@ libvpi.a vvp.man @@ -105,7 +105,7 @@ dep: mkdir dep %.o: %.cc config.h - $(CXX) $(CPPFLAGS) $(MDIR1) $(MDIR2) $(CXXFLAGS) -MD -c $< -o $*.o + $(CXX) $(CPPFLAGS) -DIVL_SUFFIX='"$(suffix)"' $(MDIR1) $(MDIR2) $(CXXFLAGS) -MD -c $< -o $*.o mv $*.d dep/$*.d %.o: %.c config.h diff --git a/vvp/main.cc b/vvp/main.cc index 3e9785b8d..7f6fbc700 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -211,16 +211,31 @@ int main(int argc, char*argv[]) extern int stop_is_finish_exit_code; #ifdef __MINGW32__ - /* In the Windows world, we get the first module path - component relative the location where the binary lives. */ - { char path[4096], *s; - GetModuleFileName(NULL,path,1024); - /* Get to the end. Search back twice for backslashes */ - s = path + strlen(path); - while (*s != '\\') s--; s--; - while (*s != '\\') s--; - strcpy(s,"\\lib\\ivl"); - vpip_module_path[0] = strdup(path); + /* Calculate the module path from the path to the command. + This is necessary because of the installation process on + Windows. Mostly, it is those darn drive letters, but oh + well. We know the command path is formed like this: + + D:\iverilog\bin\iverilog.exe + + The IVL_ROOT in a Windows installation is the path: + + D:\iverilog\lib\ivl$(suffix) + + so we chop the file name and the last directory by + turning the last two \ characters to null. Then we append + the lib\ivl$(suffix) to finish. */ + { char *s; + char basepath[4096], tmp[4096]; + GetModuleFileName(NULL, tmp, sizeof tmp); + /* Convert to a short na,e to remove any embedded spaces. */ + GetShortPathName(tmp, basepath, sizeof basepath); + s = strrchr(basepath, '\\'); + if (s) *s = 0; + s = strrchr(basepath, '\\'); + if (s) *s = 0; + strcat(s, "\\lib\\ivl" IVL_SUFFIX); + vpip_module_path[0] = strdup(basepath); } #endif