0
|
1 |
### Monkeypatch to work around the broken Rakefile generated by Mkrf <= 0.2.3
|
|
2 |
|
|
3 |
# This fixes:
|
|
4 |
# * Some weird unnecessary string interpolation
|
|
5 |
# * The :install task doesn't work unless you have RUBYARCHDIR in your environment, instead of
|
|
6 |
# falling back to CONFIG['sitearchdir'].
|
|
7 |
# * The :install task created the target install directory every time instead of just
|
|
8 |
# declaring a dependency on a directory task
|
|
9 |
|
|
10 |
require 'mkrf/generator'
|
|
11 |
|
|
12 |
class Mkrf::Generator
|
|
13 |
|
|
14 |
def rakefile_contents # :nodoc:
|
|
15 |
objext = CONFIG['OBJEXT']
|
|
16 |
|
|
17 |
<<-END_RAKEFILE
|
|
18 |
# Generated by mkrf
|
|
19 |
require 'rake/clean'
|
|
20 |
require 'rbconfig'
|
|
21 |
|
|
22 |
include Config
|
|
23 |
|
|
24 |
SRC = FileList[#{sources.join(',')}]
|
|
25 |
OBJ = SRC.ext('#{objext}')
|
|
26 |
CC = '#{@cc}'
|
|
27 |
|
|
28 |
ADDITIONAL_OBJECTS = '#{objects}'
|
|
29 |
|
|
30 |
LDSHARED = "#{@available.ldshared_string} #{ldshared}"
|
|
31 |
|
|
32 |
LIBPATH = "#{library_path(CONFIG['libdir'])} #{@available.library_paths_compile_string}"
|
|
33 |
|
|
34 |
INCLUDES = "#{@available.includes_compile_string}"
|
|
35 |
|
|
36 |
LIBS = "#{@available.library_compile_string}"
|
|
37 |
|
|
38 |
CFLAGS = "#{cflags} #{defines_compile_string}"
|
|
39 |
|
|
40 |
RUBYARCHDIR = ENV["RUBYARCHDIR"] || CONFIG['sitearchdir']
|
|
41 |
LIBRUBYARG_SHARED = "#{CONFIG['LIBRUBYARG_SHARED']}"
|
|
42 |
EXT = '#{@extension_name}'
|
|
43 |
|
|
44 |
CLEAN.include( EXT, '*.#{objext}' )
|
|
45 |
CLOBBER.include( 'mkrf.log' )
|
|
46 |
|
|
47 |
task :default => EXT
|
|
48 |
|
|
49 |
rule '.#{objext}' => '.#{@source_extension}' do |t|
|
|
50 |
sh "\#{CC} \#{CFLAGS} \#{INCLUDES} -c \#{t.source}"
|
|
51 |
end
|
|
52 |
|
|
53 |
desc "Build this extension"
|
|
54 |
file EXT => OBJ do
|
|
55 |
sh "\#{LDSHARED} \#{LIBPATH} #{@available.ld_outfile(@extension_name)} \#{OBJ} \#{ADDITIONAL_OBJECTS} \#{LIBS} \#{LIBRUBYARG_SHARED}"
|
|
56 |
end
|
|
57 |
|
|
58 |
|
|
59 |
directory RUBYARCHDIR
|
|
60 |
|
|
61 |
desc "Install this extension"
|
|
62 |
task :install => [EXT, RUBYARCHDIR] do
|
|
63 |
install EXT, RUBYARCHDIR, :verbose => true
|
|
64 |
end
|
|
65 |
|
|
66 |
#{additional_code}
|
|
67 |
END_RAKEFILE
|
|
68 |
end
|
|
69 |
|
|
70 |
end
|
|
71 |
|