Don't use Array#pack when the result is constant.
[ruby-eet.git] / Rakefile
1 # $Id: Rakefile 32 2005-04-19 09:07:57Z 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 ext_obj = "ext/ext.o"
21 ext_lib = "ext/eet_ext.so"
22
23 CLOBBER.include(ext_obj, ext_lib, "test/*.eet")
24
25 archdir = Config::CONFIG["archdir"]
26 sitearchdir = Config::CONFIG["sitearchdir"]
27 libdir = Config::CONFIG["libdir"]
28 sitelibdir = Config::CONFIG["sitelibdir"]
29 rubylib = Config::CONFIG["LIBRUBYARG_SHARED"]
30 destdir = "#{ENV["DESTDIR"]}"
31 eet_cflags = `eet-config --cflags`.strip
32 eet_libs = `eet-config --libs`.strip
33 cflags = "#{ENV["CFLAGS"]} #{eet_cflags}"
34 ldflags = "#{ENV["LDFLAGS"]} #{eet_libs}"
35
36 task :default => [ext_lib]
37
38 rule ".o" => [".c"] do |t|
39         sh "cc #{cflags} -fPIC -I #{archdir} #{t.source} -c -o #{t.name}"
40 end
41
42 file ext_lib => ext_obj do |t|
43         sh "cc #{ldflags} -shared -Wl -L #{libdir} #{rubylib} " +
44            "#{t.prerequisites.join(" ")} -o #{t.name}"
45 end
46
47 task :install => [ext_lib] do |t|
48         FileUtils::Verbose.install(ext_lib, destdir + sitearchdir,
49                                    :mode => 0755)
50         FileUtils::Verbose.install("lib/eet.rb", destdir + sitelibdir,
51                                    :mode => 0644)
52 end
53
54 task :test => [ext_lib]
55
56 Rake::TestTask.new do |t|
57         t.libs = ["lib", "ext", "test"]
58         t.test_files = FileList["test/test_*.rb"]
59         t.verbose = true
60 end
61
62 Rake::RDocTask.new do |t|
63         t.rdoc_dir = "doc"
64         t.title = "Ruby-EET - EET bindings for Ruby"
65         t.options = ["--line-numbers", "--inline-source", "--main", "README"]
66         t.rdoc_files.include("README", "COPYING", "AUTHORS", "ChangeLog",
67                              "NEWS", "ext/ext.c", "lib/eet.rb")
68 end
69
70 Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |t|
71         t.need_tar_gz = true
72         t.package_files.include("[A-Z]*", "ext/*.c", "lib/*.rb", "test/*.rb")
73 end
74
75 task :publish => [:rdoc, :package] do
76         p = Rake::CompositePublisher.new
77         p.add(Rake::SshFreshDirPublisher.new("code-monkey.de",
78                                              "public_html/docs/" +
79                                              PKG_NAME, "doc"))
80         p.add(Rake::SshFilePublisher.new("code-monkey.de",
81                                          ".", "pkg",
82                                          "#{PKG_NAME}-#{PKG_VERSION}.tar.gz"))
83         p.upload
84 end