Made git generate ChangeLog.
[ruby-eet.git] / Rakefile
index 650d158a6502fd3e78391ecae1e23b97cf5b7ec6..f49c8367e18be29fb27e01bde63b82c31bac3ee9 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -1,82 +1,91 @@
-# $Id: Rakefile 4 2005-03-27 01:14:48Z tilman $
-
 require "rbconfig"
 require "rake/clean"
 require "rake/testtask"
 require "rake/rdoctask"
 require "rake/packagetask"
+require "rake/contrib/compositepublisher"
 require "rake/contrib/sshpublisher"
 
 # make sure we run at least Rake 0.5.0
 if (RAKEVERSION.split(".").map { |p| p.to_i } <=> [0, 5, 0]) < 0
-       fail("Rake 0.5.0 or greater required")
+       raise("Rake 0.5.0 or greater required")
 end
 
 PKG_NAME = "ruby-eet"
-PKG_VERSION = `grep VERSION lib/eet.rb`.match(/VERSION = \"(.*)\"/).
-              captures.first
+PKG_VERSION = File.read("lib/eet.rb").
+              match(/^\s*VERSION = \"(.*)\"\s$/).captures.first
 
+cc = ENV["CC"] || "cc"
 ext_obj = "ext/ext.o"
 ext_lib = "ext/eet_ext.so"
 
-CLOBBER.include(ext_obj)
-CLOBBER.include(ext_lib)
-CLOBBER.include(FileList["test/*.eet"])
-
-archdir = Config::CONFIG["archdir"]
-sitearchdir = Config::CONFIG["sitearchdir"]
-libdir = Config::CONFIG["libdir"]
-sitelibdir = Config::CONFIG["sitelibdir"]
-rubylib = Config::CONFIG["LIBRUBYARG_SHARED"]
-destdir = "#{ENV["DESTDIR"]}"
-eet_cflags = `eet-config --cflags`.strip
-eet_libs = `eet-config --libs`.strip
-cflags = "#{ENV["CFLAGS"]} #{eet_cflags}"
-ldflags = "#{ENV["LDFLAGS"]} #{eet_libs}"
+CLOBBER.include(ext_obj, ext_lib, "test/*.eet")
 
 task :default => [ext_lib]
 
 rule ".o" => [".c"] do |t|
-       sh "cc #{cflags} -fPIC -I #{archdir} #{t.source} -c -o #{t.name}"
+       archdir = Config::CONFIG["archdir"]
+       cflags = "#{ENV["CFLAGS"]} #{`eet-config --cflags`.strip} " +
+                "-I#{archdir}"
+
+       sh "#{cc} #{cflags} -fPIC #{t.source} -c -o #{t.name}"
 end
 
 file ext_lib => ext_obj do |t|
-       sh "cc #{ldflags} -shared -Wl -L #{libdir} #{rubylib} " +
-          "#{t.prerequisites.join(" ")} -o #{t.name}"
+       libdir = Config::CONFIG["libdir"]
+       rubylib = Config::CONFIG["LIBRUBYARG_SHARED"]
+       ldflags = "#{ENV["LDFLAGS"]} #{`eet-config --libs`.strip} " +
+                 "-L#{libdir} #{rubylib}"
+
+       sh "#{cc} #{ldflags} -shared -Wl #{t.prerequisites.join(" ")} " +
+          "-o #{t.name}"
 end
 
 task :install => [ext_lib] do |t|
-       d = destdir + sitearchdir
+       destdir = ENV["DESTDIR"] || ""
+
+       ddir = destdir + Config::CONFIG["sitearchdir"]
+       FileUtils::Verbose.mkdir_p(ddir) unless File.directory?(ddir)
+       FileUtils::Verbose.install(ext_lib, ddir, :mode => 0755)
 
-       FileUtils::Verbose.install(ext_lib, d, :mode => 0755)
-       FileUtils::Verbose.install("lib/eet.rb", d, :mode => 0644)
+       ddir = destdir + Config::CONFIG["sitelibdir"]
+       FileUtils::Verbose.mkdir_p(ddir) unless File.directory?(ddir)
+       FileUtils::Verbose.install("lib/eet.rb", ddir, :mode => 0644)
 end
 
 task :test => [ext_lib]
 
 Rake::TestTask.new do |t|
-       t.libs << "ext"
+       t.libs = ["lib", "ext", "test"]
        t.test_files = FileList["test/test_*.rb"]
        t.verbose = true
 end
 
 Rake::RDocTask.new do |t|
        t.rdoc_dir = "doc"
-       t.title = "ruby-eet - EET bindings for Ruby"
+       t.title = "Ruby-EET - EET bindings for Ruby"
        t.options = ["--line-numbers", "--inline-source", "--main", "README"]
-       t.rdoc_files.include("README", "COPYING", "AUTHORS", "ChangeLog",
-                            "ext/ext.c", "lib/eet.rb")
+       t.rdoc_files.include("README", "COPYING", "AUTHORS",
+                            "NEWS", "ext/ext.c", "lib/eet.rb")
+end
+
+CLOBBER.include("ChangeLog")
+
+file "ChangeLog" do
+       `git log > ChangeLog`
 end
 
 Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |t|
        t.need_tar_gz = true
-       t.package_files.include("[A-Z]*", "ext/*.c", "lib/*.rb", "test/*.rb")
+       t.package_files.include("AUTHORS", "ChangeLog", "COPYING", "NEWS",
+                               "README", "Rakefile",
+                               "ext/*.c", "lib/*.rb", "test/*.rb")
 end
 
 task :publish => [:rdoc, :package] do
        p = Rake::CompositePublisher.new
        p.add(Rake::SshFreshDirPublisher.new("code-monkey.de",
-                                            "public_html/docs/" +
+                                            "public_docs/" +
                                             PKG_NAME, "doc"))
        p.add(Rake::SshFilePublisher.new("code-monkey.de",
                                         ".", "pkg",