| 1 |
|
| 2 |
#==============================================================================# |
| 3 |
# $Id: extconf.rb,v 1.2 2004/01/22 21:14:11 yuya Exp $ |
| 4 |
#==============================================================================# |
| 5 |
|
| 6 |
require 'fileutils' |
| 7 |
|
| 8 |
#==============================================================================# |
| 9 |
|
| 10 |
INFILE = 'etklib.in' |
| 11 |
OUTFILE = 'etklib.so' |
| 12 |
|
| 13 |
#==============================================================================# |
| 14 |
|
| 15 |
case RUBY_PLATFORM |
| 16 |
when 'i386-mswin32' |
| 17 |
# copy the file. |
| 18 |
FileUtils.cp(INFILE, OUTFILE) |
| 19 |
when 'i386-cygwin' |
| 20 |
# replace filename of ruby's dynamic-library in the import table. |
| 21 |
sec = 0x00000210 # Raw address of [.rdata] section |
| 22 |
bin = File.open(INFILE, 'rb') { |file| file.read } |
| 23 |
name = bin[sec + 0x00000000, 8] |
| 24 |
size = bin[sec + 0x00000010, 4].unpack('L')[0] |
| 25 |
addr = bin[sec + 0x00000014, 4].unpack('L')[0] |
| 26 |
|
| 27 |
raise('invalid section name') unless name == ".rdata\0\0" |
| 28 |
|
| 29 |
bin[addr, size] = bin[addr, size].sub(/msvcrt-ruby18.dll\0/, "cygruby18.dll\0\0\0\0\0") |
| 30 |
|
| 31 |
File.open(OUTFILE, 'wb') { |file| file.write(bin) } |
| 32 |
else |
| 33 |
raise("[#{RUBY_PLATFORM}] which is your platform is not supported.") |
| 34 |
end |
| 35 |
|
| 36 |
#==============================================================================# |
| 37 |
|
| 38 |
File.open('Makefile', 'w') { |file| |
| 39 |
file.puts('all: etklib.so') |
| 40 |
file.puts('etklib.so:') |
| 41 |
} |
| 42 |
|
| 43 |
#==============================================================================# |
| 44 |
#==============================================================================# |