From 826c5c379dbeea3887d3c5ddc974898fe56fe951 Mon Sep 17 00:00:00 2001 From: Alexey Borzenkov Date: Sun, 8 Feb 2009 00:39:07 +0300 Subject: [PATCH] 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 31f4878..12bd19c 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -1031,6 +1031,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)] @@ -1040,7 +1064,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 @@ -1049,9 +1073,9 @@ SHELL = /bin/sh #### Start of system configuration section. #### -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