1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
require "rubygems"
require "rubygems/package_task"
require "rake/clean"
require "rake/testtask"
version = "1.8.1"
target_prefix = "numru"
# get options
destdir = ENV["DESTDIR"] || ""
libdir = ENV["SITELIBDIR"] || RbConfig::CONFIG["sitelibdir"]
archdir = ENV["SITEARCHDIR"] || RbConfig::CONFIG["sitearchdir"]
config_opts = ENV["CONFIG_OPTIONS"]
NAME = "lapack"
LIBS = FileList["lib/#{target_prefix}/*rb"]
case RbConfig::CONFIG["host_os"]
when /darwin/
extension = "bundle"
else
extension = "so"
end
DLLIB = "ext/#{NAME}.#{extension}"
so_file = File.join("lib", target_prefix, "#{NAME}.#{extension}")
task :default => so_file
desc "Building extensions"
file so_file => DLLIB do
mkdir_p File.dirname(so_file)
rm_f so_file
cp DLLIB, so_file
end
file DLLIB => "ext/Makefile" do
system("cd ext; make")
end
file "ext/Makefile" => "ext/rb_lapack.h" do
unless system("cd ext; ruby extconf.rb #{config_opts}")
warn <<-EOL
To give options to extconf.rb, set the options to CONFIG_OPTIONS
e.g.
% rake CONFIG_OPTIONS="--with-lapack=/opt/lapack"
EOL
end
end
file "ext/rb_lapack.h" => "dev/make_csrc.rb" do
system("ruby dev/make_csrc.rb")
end
desc "Install files to system"
task :install => [:install_so, :install_rb]
task :install_so => DLLIB do
dst = File.join(destdir, archdir, target_prefix)
mkdir_p dst
install DLLIB, dst, :mode => 0755
end
task :install_rb => LIBS do
dst = File.join(destdir, libdir, target_prefix)
mkdir_p dst
LIBS.each do |lib|
install lib, dst, :mode => 0644
end
end
CLEAN.include("ext/*.o")
CLOBBER.include(DLLIB, so_file)
CLOBBER.include("ext/Makefile")
PKG_FILES = FileList["lib/#{target_prefix}/*rb"]
PKG_FILES.include("ext/rb_lapack.h")
PKG_FILES.include("ext/f2c_minimal.h")
PKG_FILES.include("ext/*.c")
PKG_FILES.include("Rakefile")
PKG_FILES.include("COPYING", "GPL", "README.rdoc")
PKG_FILES.include("doc/*.html", "samples/**/*rb")
PKG_FILES.include("dev/*.rb", "dev/defs/*")
TEST_FILES = FileList["tests/**/*.rb"]
Rake::TestTask.new do |t|
t.libs << "lib"
t.libs << "tests"
t.test_files = TEST_FILES
end
spec = Gem::Specification.new do |s|
s.name = "ruby-lapack"
s.version = version
s.summary = "A Ruby wrapper of Lapack"
s.description = <<EOL
Ruby-LAPACK is a Ruby wrapper of Lapack, which is a linear algebra package (http://www.netlib.org/lapack/).
EOL
s.author = "Seiya Nishizawa"
s.email = "seiya@gfd-dennou.org"
s.homepage = "http://ruby.gfd-dennou.org/products/ruby-lapack/"
s.has_rdoc = false
s.files = PKG_FILES
s.test_files = TEST_FILES
s.add_dependency('narray')
s.extensions = %w(ext/extconf.rb)
end
Gem::PackageTask.new(spec) do |pkg|
pkg.need_tar_gz = true
pkg.need_tar_bz2 = true
end
binary_pkg = "pkg/#{spec.name}-#{spec.version}-#{RbConfig::CONFIG["arch"]}.gem"
gem_pkg = "pkg/#{spec.name}-#{spec.version}.gem"
desc "Build binary package"
task :binary_package => binary_pkg
file binary_pkg => gem_pkg do
system "gem compile --fat 1.8:ruby1.8,1.9:ruby1.9 #{gem_pkg}"
end
|