0
|
1 |
#!rake
|
|
2 |
|
|
3 |
begin
|
|
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 |
|
|
15 |
# C extension constants
|
|
16 |
EXT_RAKEFILE = EXTDIR + 'Rakefile'
|
|
17 |
EXT_SO = EXTDIR + "redleaf_ext.#{CONFIG['DLEXT']}"
|
|
18 |
|
|
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 |
|
|
28 |
|
|
29 |
#####################################################################
|
|
30 |
### T A S K S
|
|
31 |
#####################################################################
|
|
32 |
|
|
33 |
# task :local => [ :build, :build_specs ]
|
|
34 |
task :local => [ :build ]
|
|
35 |
task :spec => [ :build ]
|
|
36 |
|
|
37 |
desc "Make the Rakefile for the C extension"
|
|
38 |
file EXT_RAKEFILE.to_s => FileList[ 'Rakefile', EXTDIR + '*.c' ] do
|
|
39 |
require 'misc/monkeypatches' # Fix Mkrf's output
|
|
40 |
|
|
41 |
log "Configuring bsdjail C extension"
|
|
42 |
Dir.chdir( EXTDIR ) do
|
|
43 |
Mkrf::Generator.new( 'bsdjail', FileList['*.c'] ) do |gen|
|
|
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
|
|
61 |
end
|
|
62 |
CLOBBER.include( EXTDIR + 'mkrf.log' )
|
|
63 |
|
|
64 |
|
|
65 |
desc "Build the C extension"
|
|
66 |
task :build => EXT_RAKEFILE.to_s do
|
|
67 |
Dir.chdir( EXTDIR ) do
|
|
68 |
sh 'rake'
|
|
69 |
end
|
|
70 |
end
|
|
71 |
|
|
72 |
|
|
73 |
task :clean do
|
|
74 |
if EXT_RAKEFILE.exist?
|
|
75 |
Dir.chdir( EXTDIR ) do
|
|
76 |
sh 'rake', 'clean'
|
|
77 |
end
|
|
78 |
end
|
|
79 |
end
|
|
80 |
|
|
81 |
task :clobber do
|
|
82 |
if EXT_RAKEFILE.exist?
|
|
83 |
Dir.chdir( EXTDIR ) do
|
|
84 |
sh 'rake', 'clobber'
|
|
85 |
end
|
|
86 |
end
|
|
87 |
end
|
|
88 |
CLOBBER.include( EXT_RAKEFILE )
|
|
89 |
|