27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'ext/lapack/extconf.rb', line 27
def self.write(dir, outname, version = nil)
outname = File.expand_path(outname)
Dir.chdir(dir) {
Dir.glob('*.P') { |f| File.unlink(f) }
if system("f2c -R -P -\!c *.f")
File.open(outname, "w") { |outfile|
macro = File.basename(outname.upcase.gsub(".","_"))
outfile.puts "#ifndef #{macro}"
outfile.puts "#define #{macro}"
outfile.puts "/* version #{version} */ " if version
outfile.puts "/* generated #{Time.now} */"
outfile.puts
Dir.glob('*.P') { |pname|
File.open(pname) { |pfile|
pfile.each { |line|
next unless line =~ %r!^extern!
while line.gsub!(%r!, ftnlen [a-z]+_len\)!, ")") ; end
outfile.write line
}
}
}
outfile.puts
outfile.puts "#endif"
}
end
}
end
|