From 38383575ab3244bb62362956a43994a0953db37e Mon Sep 17 00:00:00 2001 From: Alexey Borzenkov Date: Sat, 7 Feb 2009 10:49:31 +0300 Subject: [PATCH 3/3] Allow building ruby with mingw --- lib/mkmf.rb | 32 ++++++++++++++++++++++++++++---- 1 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/mkmf.rb b/lib/mkmf.rb index a532b5c..b2a7635 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -1233,6 +1233,30 @@ def winsep(s) s.tr('/', '\\') end +# Converts native path to format acceptable in Makefile +# +# Internal use only. +# +def _quote_for_make(path) + if !CROSS_COMPILING + case CONFIG['build_os'] + when 'mingw32' + # mingw uses make from msys and it needs special care + # converts from C:\some\path to /C/some/path + path = path.dup + path.gsub!(/\\/, '/') + path.gsub!(/^\s*([A-Za-z]):(\/.*)\s*$/, '/\1\2') + end + end + path.quote +end + +class String + def quote_for_make + _quote_for_make self + end +end + def configuration(srcdir) mk = [] vpath = %w[$(srcdir) $(topdir) $(hdrdir)] @@ -1242,7 +1266,7 @@ def configuration(srcdir) if CONFIG['target_os'] != 'cygwin' vpath.each {|p| p.sub!(/.*/, '$(shell cygpath -u \&)')} end - when 'msdosdjgpp', 'mingw32' + when 'msdosdjgpp' CONFIG['PATH_SEPARATOR'] = ';' end end @@ -1255,9 +1279,9 @@ if $extmk "top_srcdir = " + $top_srcdir.sub(%r"\A#{Regexp.quote($topdir)}/", "$(topdir)/") end } -srcdir = #{srcdir.gsub(/\$\((srcdir)\)|\$\{(srcdir)\}/) {CONFIG[$1||$2]}.quote} -topdir = #{($extmk ? CONFIG["topdir"] : $topdir).quote} -hdrdir = #{$extmk ? CONFIG["hdrdir"].quote : '$(topdir)'} +srcdir = #{srcdir.gsub(/\$\((srcdir)\)|\$\{(srcdir)\}/) {CONFIG[$1||$2]}.quote_for_make} +topdir = #{($extmk ? CONFIG["topdir"] : $topdir).quote_for_make} +hdrdir = #{$extmk ? CONFIG["hdrdir"].quote_for_make : '$(topdir)'} VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])} } if $extmk -- 1.6.1.4.g328f