diff -r 000000000000 -r 92d00ff32c56 misc/monkeypatches.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/monkeypatches.rb Fri Aug 15 15:43:38 2008 +0000 @@ -0,0 +1,71 @@ +### Monkeypatch to work around the broken Rakefile generated by Mkrf <= 0.2.3 + +# This fixes: +# * Some weird unnecessary string interpolation +# * The :install task doesn't work unless you have RUBYARCHDIR in your environment, instead of +# falling back to CONFIG['sitearchdir']. +# * The :install task created the target install directory every time instead of just +# declaring a dependency on a directory task + +require 'mkrf/generator' + +class Mkrf::Generator + + def rakefile_contents # :nodoc: + objext = CONFIG['OBJEXT'] + + <<-END_RAKEFILE +# Generated by mkrf +require 'rake/clean' +require 'rbconfig' + +include Config + +SRC = FileList[#{sources.join(',')}] +OBJ = SRC.ext('#{objext}') +CC = '#{@cc}' + +ADDITIONAL_OBJECTS = '#{objects}' + +LDSHARED = "#{@available.ldshared_string} #{ldshared}" + +LIBPATH = "#{library_path(CONFIG['libdir'])} #{@available.library_paths_compile_string}" + +INCLUDES = "#{@available.includes_compile_string}" + +LIBS = "#{@available.library_compile_string}" + +CFLAGS = "#{cflags} #{defines_compile_string}" + +RUBYARCHDIR = ENV["RUBYARCHDIR"] || CONFIG['sitearchdir'] +LIBRUBYARG_SHARED = "#{CONFIG['LIBRUBYARG_SHARED']}" +EXT = '#{@extension_name}' + +CLEAN.include( EXT, '*.#{objext}' ) +CLOBBER.include( 'mkrf.log' ) + +task :default => EXT + +rule '.#{objext}' => '.#{@source_extension}' do |t| + sh "\#{CC} \#{CFLAGS} \#{INCLUDES} -c \#{t.source}" +end + +desc "Build this extension" +file EXT => OBJ do + sh "\#{LDSHARED} \#{LIBPATH} #{@available.ld_outfile(@extension_name)} \#{OBJ} \#{ADDITIONAL_OBJECTS} \#{LIBS} \#{LIBRUBYARG_SHARED}" +end + + +directory RUBYARCHDIR + +desc "Install this extension" +task :install => [EXT, RUBYARCHDIR] do + install EXT, RUBYARCHDIR, :verbose => true +end + +#{additional_code} + END_RAKEFILE + end + +end +