about summary refs log tree commit homepage
diff options
authorEric Wong <normalperson@yhbt.net>2009-09-07 16:24:41 -0700
committerEric Wong <normalperson@yhbt.net>2009-09-07 16:35:58 -0700
commit732325a67ba68060fe18dc66c21134c35f8006ea (patch)
parentcee939b527e82237f89eb8eece62610854ac888a (diff)
It was too much confusion to have multiple gems in the mix
and I mainly use the C extension anyways.

If we're not on a compatible version of Ruby, the extension will
just be disabled by generating a dummy no-op Makefile to work
around it.
4 files changed, 40 insertions, 16 deletions
diff --git a/GNUmakefile b/GNUmakefile
index b690ca9..1d88a9f 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -82,8 +82,6 @@ release: package $(release_notes) $(release_changes)
           clogger clogger $(VERSION) pkg/clogger-$(VERSION).gem
         rubyforge add_file \
           clogger clogger $(VERSION) pkg/clogger-$(VERSION).tgz
-        rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
-          clogger clogger_ext $(VERSION) pkg/clogger_ext-$(VERSION).gem
 doc: .document History
diff --git a/README b/README
index 707b851..a4fc4ec 100644
--- a/README
+++ b/README
@@ -110,15 +110,17 @@ For all Rubygems users:
   gem install clogger
-If you're using MRI 1.8/1.9 and have a build environment, you can also try:
-  gem install clogger_ext
 If you do not use Rubygems, you may also use setup.rb from tarballs from
 the Rubyforge project page:
 * http://rubyforge.org/frs/?group_id=8896
+There is an optional C extension that should be compatible with MRI
+1.8/1.9.  The extensions should automatically be disabled for users of
+other Ruby implementations, but be sure to let us know if that's not the
+case.  No pre-built currently distributed, let us know if you're
+interested in helping with the release/support effort.
 Copyright (C) 2009 Eric Wong <normalperson@yhbt.net> and contributors.
diff --git a/clogger.gemspec b/clogger.gemspec
index 0876b0a..442c482 100644
--- a/clogger.gemspec
+++ b/clogger.gemspec
@@ -27,4 +27,6 @@ is customizable so you can specify exactly which fields to log.
   # HeaderHash wasn't case-insensitive in old versions
   s.add_dependency(%q<rack>, ["> 0.9"])
+  s.extensions = %w(ext/clogger_ext/extconf.rb)
diff --git a/ext/clogger_ext/extconf.rb b/ext/clogger_ext/extconf.rb
index 8cc8b5e..b327ada 100644
--- a/ext/clogger_ext/extconf.rb
+++ b/ext/clogger_ext/extconf.rb
@@ -1,12 +1,34 @@
-require 'mkmf'
+  require 'mkmf'
-if have_header('fcntl.h')
-  have_macro('F_GETFL', %w(fcntl.h))
-  have_macro('O_NONBLOCK', %w(unistd.h fcntl.h))
+  # XXX let me know if this works for you...
+  if ! defined?(RUBY_VERSION) || RUBY_VERSION !~ /\A1\.[89]\./
+    raise "Invalid RUBY_VERSION for C extension"
+  end
+  have_header('ruby.h') or raise "ruby.h header not found!"
+  if have_header('fcntl.h')
+    have_macro('F_GETFL', %w(fcntl.h))
+    have_macro('O_NONBLOCK', %w(unistd.h fcntl.h))
+  end
-have_func('localtime_r', 'time.h') or abort "localtime_r needed"
-have_func('gmtime_r', 'time.h') or abort "gmtime_r needed"
-have_func('rb_str_set_len', 'ruby.h')
+  have_func('localtime_r', 'time.h') or raise "localtime_r needed"
+  have_func('gmtime_r', 'time.h') or raise "gmtime_r needed"
+  have_func('rb_str_set_len', 'ruby.h')
+  dir_config('clogger_ext')
+  create_makefile('clogger_ext')
+rescue Object => err
+  warn "E: #{err.inspect}"
+  warn "Skipping C extension, pure Ruby version will be used instead"
+  # generate a dummy Makefile to fool rubygems installer
+  targets = %w(all static clean distclean realclean
+               install install-so install-rb install-rb-default
+               pre-install-rb pre-install-rb-default
+               site-install site-install-so site-install-rb)
+  File.open(File.dirname(__FILE__) << "/Makefile", "wb") do |fp|
+    fp.puts targets.join(' ') << ":"
+    fp.puts "\techo >&2 extension disabled"
+  end