Object#to_eet: don't put the final chunk in a stream again.
[ruby-eet.git] / Rakefile
1 # $Id: Rakefile 55 2005-06-02 20:16:44Z tilman $
2
3 require "rbconfig"
4 require "rake/clean"
5 require "rake/testtask"
6 require "rake/rdoctask"
7 require "rake/packagetask"
8 require "rake/contrib/compositepublisher"
9 require "rake/contrib/sshpublisher"
10
11 # make sure we run at least Rake 0.5.0
12 if (RAKEVERSION.split(".").map { |p| p.to_i } <=> [0, 5, 0]) < 0
13         raise("Rake 0.5.0 or greater required")
14 end
15
16 PKG_NAME = "ruby-eet"
17 PKG_VERSION = File.read("lib/eet.rb").
18               match(/^\s*VERSION = \"(.*)\"\s$/).captures.first
19
20 cc = ENV["CC"] || "cc"
21 ext_obj = "ext/ext.o"
22 ext_lib = "ext/eet_ext.so"
23
24 CLOBBER.include(ext_obj, ext_lib, "test/*.eet")
25
26 task :default => [ext_lib]
27
28 rule ".o" => [".c"] do |t|
29         archdir = Config::CONFIG["archdir"]
30         cflags = "#{ENV["CFLAGS"]} #{`eet-config --cflags`.strip} " +
31                  "-I#{archdir}"
32
33         sh "#{cc} #{cflags} -fPIC #{t.source} -c -o #{t.name}"
34 end
35
36 file ext_lib => ext_obj do |t|
37         libdir = Config::CONFIG["libdir"]
38         rubylib = Config::CONFIG["LIBRUBYARG_SHARED"]
39         ldflags = "#{ENV["LDFLAGS"]} #{`eet-config --libs`.strip} " +
40                   "-L#{libdir} #{rubylib}"
41
42         sh "#{cc} #{ldflags} -shared -Wl #{t.prerequisites.join(" ")} " +
43            "-o #{t.name}"
44 end
45
46 task :install => [ext_lib] do |t|
47         destdir = ENV["DESTDIR"] || ""
48
49         ddir = destdir + Config::CONFIG["sitearchdir"]
50         FileUtils::Verbose.mkdir_p(ddir) unless File.directory?(ddir)
51         FileUtils::Verbose.install(ext_lib, ddir, :mode => 0755)
52
53         ddir = destdir + Config::CONFIG["sitelibdir"]
54         FileUtils::Verbose.mkdir_p(ddir) unless File.directory?(ddir)
55         FileUtils::Verbose.install("lib/eet.rb", ddir, :mode => 0644)
56 end
57
58 task :test => [ext_lib]
59
60 Rake::TestTask.new do |t|
61         t.libs = ["lib", "ext", "test"]
62         t.test_files = FileList["test/test_*.rb"]
63         t.verbose = true
64 end
65
66 Rake::RDocTask.new do |t|
67         t.rdoc_dir = "doc"
68         t.title = "Ruby-EET - EET bindings for Ruby"
69         t.options = ["--line-numbers", "--inline-source", "--main", "README"]
70         t.rdoc_files.include("README", "COPYING", "AUTHORS", "ChangeLog",
71                              "NEWS", "ext/ext.c", "lib/eet.rb")
72 end
73
74 Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |t|
75         t.need_tar_gz = true
76         t.package_files.include("[A-Z]*", "ext/*.c", "lib/*.rb", "test/*.rb")
77 end
78
79 task :publish => [:rdoc, :package] do
80         p = Rake::CompositePublisher.new
81         p.add(Rake::SshFreshDirPublisher.new("code-monkey.de",
82                                              "public_html/docs/" +
83                                              PKG_NAME, "doc"))
84         p.add(Rake::SshFilePublisher.new("code-monkey.de",
85                                          ".", "pkg",
86                                          "#{PKG_NAME}-#{PKG_VERSION}.tar.gz"))
87         p.upload
88 end