Rakefile.local
branchmahlon-misc
changeset 10 b1426511fb64
parent 0 92d00ff32c56
equal deleted inserted replaced
9:4c51ebe6e9b6 10:b1426511fb64
     1 #!rake
     1 #!rake
     2 
     2 
     3 begin
     3 #!rake
     4 	require 'mkrf'
       
     5 rescue LoadError => err
       
     6 	unless Object.const_defined?( :Gem )
       
     7 		require 'rubygems'
       
     8 		retry
       
     9 	end
       
    10 	
       
    11 	fail "You need to have the mkrf library installed to build this."
       
    12 end
       
    13 
       
    14 
     4 
    15 # C extension constants
     5 # C extension constants
    16 EXT_RAKEFILE  = EXTDIR + 'Rakefile'
     6 EXT_MAKEFILE  = EXTDIR + 'Makefile'
    17 EXT_SO        = EXTDIR + "redleaf_ext.#{CONFIG['DLEXT']}"
     7 EXT_SOURCES   = FileList[ EXTDIR + '*.c' ]
    18 
     8 EXT_SO        = EXTDIR + "bsdjail.#{CONFIG['DLEXT']}"
    19 ADDITIONAL_INCLUDE_DIRS = %w[
       
    20 	/usr/local/include
       
    21 	/opt/include
       
    22 	/opt/local/include
       
    23 ]
       
    24 
       
    25 # Additional (auto-generated) spec constants
       
    26 SPEC_RAKEFILE = SPECDIR + 'Rakefile'
       
    27 
     9 
    28 
    10 
    29 #####################################################################
    11 #####################################################################
    30 ###	T A S K S
    12 ###	T A S K S
    31 #####################################################################
    13 #####################################################################
    32 
    14 
    33 # task :local => [ :build, :build_specs ]
    15 # Make both the default task and the spec task depend on building the extension
    34 task :local => [ :build ]
    16 task :local => :build
    35 task :spec => [ :build ]
    17 task :spec => :build
       
    18 namespace :spec do
       
    19 	task :doc   => [ :build ]
       
    20 	task :quiet => [ :build ]
       
    21 	task :html  => [ :build ]
       
    22 	task :text  => [ :build ]
       
    23 end
    36 
    24 
    37 desc "Make the Rakefile for the C extension"
    25 desc "Make the Makefile for the C extension"
    38 file EXT_RAKEFILE.to_s => FileList[ 'Rakefile', EXTDIR + '*.c' ] do
    26 file EXT_MAKEFILE.to_s => EXT_SOURCES do
    39 	require 'misc/monkeypatches' # Fix Mkrf's output
       
    40 	
       
    41 	log "Configuring bsdjail C extension"
    27 	log "Configuring bsdjail C extension"
    42 	Dir.chdir( EXTDIR ) do
    28 	in_subdirectory( EXTDIR ) do
    43 		Mkrf::Generator.new( 'bsdjail', FileList['*.c'] ) do |gen|
    29 		ruby 'extconf.rb'
    44 			trace "Setting CFLAGS"
       
    45 			gen.cflags << ' -Wall'
       
    46 			gen.cflags << ' -DDEBUG'
       
    47 
       
    48 			# Make sure we have the ODE library and header available
       
    49 			trace "checking for sys/param.h"
       
    50 			gen.include_header( "sys/param.h" ) or
       
    51 				fail "Can't find the sys/param.h header."
       
    52 
       
    53 			trace "checking for sys/jail.h"
       
    54 			gen.include_header( "sys/jail.h" ) or
       
    55 				fail "Can't find the sys/jail.h header."
       
    56 
       
    57 			gen.include_library( "c", "jail_attach" ) or
       
    58 				fail "Can't find jail_attach in the stdlib."
       
    59 		end
       
    60 	end
    30 	end
    61 end
    31 end
    62 CLOBBER.include( EXTDIR + 'mkrf.log' )
    32 CLOBBER.include( EXTDIR + 'mkmf.log', EXT_SO )
    63 
       
    64 
    33 
    65 desc "Build the C extension"
    34 desc "Build the C extension"
    66 task :build => EXT_RAKEFILE.to_s do
    35 task :build => [ EXT_MAKEFILE.to_s, *EXT_SOURCES ] do
    67 	Dir.chdir( EXTDIR ) do
    36 	in_subdirectory( EXTDIR ) do
    68 		sh 'rake'
    37 		sh 'make'
    69 	end
    38 	end
    70 end
    39 end
    71 
    40 
    72 
    41 
       
    42 desc "Rebuild the C extension"
       
    43 task :rebuild => [ :clean, :build ]
       
    44 
       
    45 
    73 task :clean do
    46 task :clean do
    74 	if EXT_RAKEFILE.exist?
    47 	if EXT_MAKEFILE.exist?
    75 		Dir.chdir( EXTDIR ) do
    48 		in_subdirectory( EXTDIR ) do
    76 			sh 'rake', 'clean'
    49 			sh 'make clean'
    77 		end
    50 		end
    78 	end
    51 	end
    79 end	
    52 end	
    80 
    53 
    81 task :clobber do
    54 task :clobber do
    82 	if EXT_RAKEFILE.exist?
    55 	if EXT_MAKEFILE.exist?
    83 		Dir.chdir( EXTDIR ) do
    56 		in_subdirectory( EXTDIR ) do
    84 			sh 'rake', 'clobber'
    57 			sh 'make distclean'
    85 		end
    58 		end
    86 	end
    59 	end
    87 end	
    60 end	
    88 CLOBBER.include( EXT_RAKEFILE )
    61 CLOBBER.include( EXT_MAKEFILE )
    89 
    62