summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--configure.in17
-rw-r--r--win32/Makefile.sub6
-rw-r--r--win32/setup.mak71
4 files changed, 90 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index a12808bfaa..82fc16e4d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Apr 13 19:25:31 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * configure.in (mingw32): use actual runtime DLL name as ruby DLL
+ name and default load path.
+
+ * win32/Makefile.sub, win32/setup.mak: ditto.
+
Tue Apr 12 19:30:36 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/optparse.rb (OptionParser#make_switch, OptionParser#order!):
diff --git a/configure.in b/configure.in
index 0b7988b43c..c7f3491985 100644
--- a/configure.in
+++ b/configure.in
@@ -169,6 +169,19 @@ cygwin*|mingw*)
AC_CHECK_TOOL(WINDRES, windres)
AC_CHECK_TOOL(DLLWRAP, dllwrap)
target_cpu=`echo $target_cpu | sed s/i.86/i386/`
+ case "$target_os" in
+ mingw*)
+ test "$rb_cv_msvcrt" = "" && unset rb_cv_msvcrt
+ AC_CHECK_TOOL(OBJDUMP, objdump)
+ AC_CACHE_CHECK(for mingw32 runtime DLL, rb_cv_msvcrt, [
+ AC_TRY_LINK([#include <stdio.h>],
+ [FILE* volatile f = stdin; return 0;],
+ [rb_cv_msvcrt=`$OBJDUMP -p conftest$ac_exeext |
+ sed -n '/^[[ ]]*DLL Name: /{s///p;q;}' |
+ tr A-Z a-z | sed 's/\.dll$//'`],
+ [rb_cv_msvcrt=msvcrt])])
+ test "$rb_cv_msvcrt" = "" && AC_MSG_ERROR([must be linked to DLL])
+ esac
: ${enable_shared=yes}
;;
aix*)
@@ -1298,7 +1311,7 @@ case "$target_os" in
AC_LIBOBJ([strftime])
;;
mingw*)
- RUBY_SO_NAME=msvcrt-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}
+ RUBY_SO_NAME=${rb_cv_msvcrt}-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}
if test x"$enable_shared" = xyes; then
LIBRUBY_SO='$(RUBY_SO_NAME)'.dll
LIBRUBY='lib$(LIBRUBY_SO).a'
@@ -1429,7 +1442,7 @@ else
fi
case "$target_os" in
- mingw*) sitearch="i386-msvcrt" ;;
+ mingw*) sitearch="i386-$rb_cv_msvcrt" ;;
*) sitearch="${arch}" ;;
esac
diff --git a/win32/Makefile.sub b/win32/Makefile.sub
index 8a59bda74c..45b7fd4be2 100644
--- a/win32/Makefile.sub
+++ b/win32/Makefile.sub
@@ -70,9 +70,11 @@ DEBUGFLAGS = -Zi
!if !defined(OPTFLAGS)
OPTFLAGS = -O2b2xg-
!endif
-!if !defined(OS) || !defined(RT)
+!if !defined(OS)
OS = mswin32
-RT = msvcrt
+!endif
+!if !defined(RT)
+!error RT not defined. Retry from configure pass.
!endif
!ifndef RUBY_SO_NAME
diff --git a/win32/setup.mak b/win32/setup.mak
index fa0c260001..a8ba23586e 100644
--- a/win32/setup.mak
+++ b/win32/setup.mak
@@ -13,8 +13,7 @@ srcdir = $(WIN32DIR)/..
prefix = /usr
!endif
OS = mswin32
-RT = msvcrt
-INCLUDE = !include
+BANG = !
APPEND = echo>>$(MAKEFILE)
!ifdef MAKEFILE
MAKE = $(MAKE) -f $(MAKEFILE)
@@ -23,7 +22,8 @@ MAKEFILE = Makefile
!endif
ARCH = PROCESSOR_ARCHITECTURE
CPU = PROCESSOR_LEVEL
-CPP = cl -nologo -EP
+CC = cl -nologo
+CPP = $(CC) -EP
all: -prologue- -generic- -epilogue-
i386-$(OS): -prologue- -i386- -epilogue-
@@ -32,7 +32,9 @@ i586-$(OS): -prologue- -i586- -epilogue-
i686-$(OS): -prologue- -i686- -epilogue-
alpha-$(OS): -prologue- -alpha- -epilogue-
--prologue-: nul
+-prologue-: -basic-vars- -system-vars- -version-
+
+-basic-vars-: nul
@type << > $(MAKEFILE)
### Makefile for ruby $(OS) ###
srcdir = $(srcdir:\=/)
@@ -42,7 +44,63 @@ EXTSTATIC = $(EXTSTATIC)
RDOCTARGET = $(RDOCTARGET)
!endif
<<
- @$(CPP) -I$(srcdir) -DRUBY_EXTERN="//" <<"Creating $(MAKEFILE)" >> $(MAKEFILE)
+
+-system-vars-: -osname- -runtime-
+
+-osname-: nul
+ @echo OS = mswin32 >>$(MAKEFILE)
+
+-runtime-: nul
+ @$(CC) -MD <<rtname.c user32.lib > nul
+#include <windows.h>
+#include <memory.h>
+#include <string.h>
+#include <stddef.h>
+#include <stdio.h>
+#ifndef MAXPATHLEN
+# define MAXPATHLEN 1024
+#endif
+
+int
+runtime_name()
+{
+ char libpath[MAXPATHLEN+1];
+ char *p, *base = NULL;
+ HMODULE msvcrt = NULL;
+ MEMORY_BASIC_INFORMATION m;
+
+ memset(&m, 0, sizeof(m));
+ if (VirtualQuery(stdin, &m, sizeof(m)) && m.State == MEM_COMMIT)
+ msvcrt = (HMODULE)m.AllocationBase;
+ GetModuleFileName(msvcrt, libpath, sizeof libpath);
+
+ libpath[sizeof(libpath) - 1] = '\0';
+ for (p = libpath; *p; p = CharNext(p)) {
+ if (*p == '\\') {
+ base = ++p;
+ }
+ }
+ if (!base) return 0;
+ if (p = strchr(base, '.')) *p = '\0';
+ for (p = base; *p; p = CharNext(p)) {
+ if (isascii(*p) && isupper(*p))
+ *p = tolower(*p);
+ }
+ printf("RT = %s\n", base);
+ return 1;
+}
+
+int main(int argc, char **argv)
+{
+ if (!runtime_name()) return EXIT_FAILURE;
+ return EXIT_SUCCESS;
+}
+<<
+ @.\rtname >>$(MAKEFILE)
+ @del rtname.*
+
+-version-: nul
+ @$(CPP) -I$(srcdir) -DRUBY_EXTERN="//" <<"Creating $(MAKEFILE)" | findstr /v /r ^^$$ >>$(MAKEFILE)
#include "version.h"
MAJOR = RUBY_VERSION_MAJOR
MINOR = RUBY_VERSION_MINOR
@@ -79,7 +137,6 @@ $(CPU) = $(PROCESSOR_LEVEL)
-epilogue-: nul
@type << >>$(MAKEFILE)
# OS = $(OS)
-# RT = $(RT)
# RUBY_INSTALL_NAME = ruby
# RUBY_SO_NAME = $$(RT)-$$(RUBY_INSTALL_NAME)$$(MAJOR)$$(MINOR)
# CFLAGS = -nologo -MD $$(DEBUGFLAGS) $$(OPTFLAGS) $$(PROCESSOR_FLAG)
@@ -90,7 +147,7 @@ $(CPU) = $(PROCESSOR_LEVEL)
# RFLAGS = -r
# EXTLIBS =
-$(INCLUDE) $$(srcdir)/win32/Makefile.sub
+$(BANG)include $$(srcdir)/win32/Makefile.sub
<<
@$(srcdir:/=\)\win32\rm.bat config.h config.status
@echo type `$(MAKE)' to make ruby for $(OS).