Rakefile.local
author Mahlon E. Smith <mahlon@martini.nu>
Tue, 14 Oct 2008 16:11:19 +0000
branchmahlon-misc
changeset 9 4c51ebe6e9b6
parent 0 92d00ff32c56
child 3 7f6da371e2ce
permissions -rw-r--r--
* Add a mkrf monkeypatch so BSD build flags are generated correctly. * Fix typos!

#!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'


#####################################################################
###	T A S K S
#####################################################################

# task :local => [ :build, :build_specs ]
task :local => [ :build ]
task :spec => [ :build ]

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
	
	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
	end
end
CLOBBER.include( EXTDIR + 'mkrf.log' )


desc "Build the C extension"
task :build => EXT_RAKEFILE.to_s do
	Dir.chdir( EXTDIR ) do
		sh 'rake'
	end
end


task :clean do
	if EXT_RAKEFILE.exist?
		Dir.chdir( EXTDIR ) do
			sh 'rake', 'clean'
		end
	end
end	

task :clobber do
	if EXT_RAKEFILE.exist?
		Dir.chdir( EXTDIR ) do
			sh 'rake', 'clobber'
		end
	end
end	
CLOBBER.include( EXT_RAKEFILE )