From: Alexey Borzenkov Date: 2009-01-20T07:48:47+09:00 Subject: [ruby-core:21448] [PATCH] Allow building ruby with mingw --- Hi, recently I've been trying to compile Ruby 1.8.7 with mingw and was surprised that mkmf.rb fails to create Makefile that would work with msys make. The reason for this is mainly VPATH that gets separated by semicolon. And when I finally install Ruby the same happens for any extension, only there's one more problem: paths would be something like: C:/Ruby/...;... and msys make chokes on that even worse, unable to find ruby.h. So this makes me really wonder how people are building Ruby with mingw and avoid this problem? Are you using something else beside msys? Would my patch break things for you then? lib/mkmf.rb | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/mkmf.rb b/lib/mkmf.rb index a532b5c..a914a48 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -1233,6 +1233,24 @@ def winsep(s) s.tr('/', '\\') end +# Converts native path to format acceptable in Makefile +# +# Internal use only. +# +def mkintpath(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 +end + def configuration(srcdir) mk = [] vpath = %w[$(srcdir) $(topdir) $(hdrdir)] @@ -1242,7 +1260,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 +1273,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)\}/) {mkintpath(CONFIG[$1||$2])}.quote} +topdir = #{mkintpath($extmk ? CONFIG["topdir"] : $topdir).quote} +hdrdir = #{$extmk ? mkintpath(CONFIG["hdrdir"]).quote : '$(topdir)'} VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])} } if $extmk -- 1.6.1.4.g328f