--- a/Rakefile.local Thu Oct 16 02:43:08 2008 +0000
+++ b/Rakefile.local Thu Nov 20 16:43:02 2008 +0000
@@ -1,89 +1,62 @@
+#!rake
+
#!rake
-begin
- require 'mkrf'
-rescue LoadError => err
- unless Object.const_defined?( :Gem )
- require 'rubygems'
- retry
- end
-
- fail "You need to have the mkrf library installed to build this."
-end
-
-
# C extension constants
-EXT_RAKEFILE = EXTDIR + 'Rakefile'
-EXT_SO = EXTDIR + "redleaf_ext.#{CONFIG['DLEXT']}"
-
-ADDITIONAL_INCLUDE_DIRS = %w[
- /usr/local/include
- /opt/include
- /opt/local/include
-]
-
-# Additional (auto-generated) spec constants
-SPEC_RAKEFILE = SPECDIR + 'Rakefile'
+EXT_MAKEFILE = EXTDIR + 'Makefile'
+EXT_SOURCES = FileList[ EXTDIR + '*.c' ]
+EXT_SO = EXTDIR + "bsdjail.#{CONFIG['DLEXT']}"
#####################################################################
### T A S K S
#####################################################################
-# task :local => [ :build, :build_specs ]
-task :local => [ :build ]
-task :spec => [ :build ]
+# Make both the default task and the spec task depend on building the extension
+task :local => :build
+task :spec => :build
+namespace :spec do
+ task :doc => [ :build ]
+ task :quiet => [ :build ]
+ task :html => [ :build ]
+ task :text => [ :build ]
+end
-desc "Make the Rakefile for the C extension"
-file EXT_RAKEFILE.to_s => FileList[ 'Rakefile', EXTDIR + '*.c' ] do
- require 'misc/monkeypatches' # Fix Mkrf's output
-
+desc "Make the Makefile for the C extension"
+file EXT_MAKEFILE.to_s => EXT_SOURCES do
log "Configuring bsdjail C extension"
- Dir.chdir( EXTDIR ) do
- Mkrf::Generator.new( 'bsdjail', FileList['*.c'] ) do |gen|
- trace "Setting CFLAGS"
- gen.cflags << ' -Wall'
- gen.cflags << ' -DDEBUG'
-
- # Make sure we have the ODE library and header available
- trace "checking for sys/param.h"
- gen.include_header( "sys/param.h" ) or
- fail "Can't find the sys/param.h header."
-
- trace "checking for sys/jail.h"
- gen.include_header( "sys/jail.h" ) or
- fail "Can't find the sys/jail.h header."
-
- gen.include_library( "c", "jail_attach" ) or
- fail "Can't find jail_attach in the stdlib."
- end
+ in_subdirectory( EXTDIR ) do
+ ruby 'extconf.rb'
end
end
-CLOBBER.include( EXTDIR + 'mkrf.log' )
-
+CLOBBER.include( EXTDIR + 'mkmf.log', EXT_SO )
desc "Build the C extension"
-task :build => EXT_RAKEFILE.to_s do
- Dir.chdir( EXTDIR ) do
- sh 'rake'
+task :build => [ EXT_MAKEFILE.to_s, *EXT_SOURCES ] do
+ in_subdirectory( EXTDIR ) do
+ sh 'make'
end
end
+desc "Rebuild the C extension"
+task :rebuild => [ :clean, :build ]
+
+
task :clean do
- if EXT_RAKEFILE.exist?
- Dir.chdir( EXTDIR ) do
- sh 'rake', 'clean'
+ if EXT_MAKEFILE.exist?
+ in_subdirectory( EXTDIR ) do
+ sh 'make clean'
end
end
end
task :clobber do
- if EXT_RAKEFILE.exist?
- Dir.chdir( EXTDIR ) do
- sh 'rake', 'clobber'
+ if EXT_MAKEFILE.exist?
+ in_subdirectory( EXTDIR ) do
+ sh 'make distclean'
end
end
end
-CLOBBER.include( EXT_RAKEFILE )
+CLOBBER.include( EXT_MAKEFILE )