1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# -*- coding: UTF-8 -*-
#
require 'rbconfig'
# Setup some constants
WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32
DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
def quiet( &block )
io = [STDOUT.dup, STDERR.dup]
STDOUT.reopen DEV_NULL
STDERR.reopen DEV_NULL
block.call
ensure
STDOUT.reopen io.first
STDERR.reopen io.last
$stdout, $stderr = STDOUT, STDERR
end
BUILD_DIR = "build"
USE_RAKE_COMPILER = ( (RUBY_PLATFORM =~ /java/) ? false : true ) or test ?d, 'ext'
if USE_RAKE_COMPILER# and test ?d, 'ext'
gem 'rake-compiler', '>=0.6.0'
require 'rake/extensiontask'
ENV['RUBY_CC_VERSION'] = '1.8.7:1.9.2'
end
LIBEXT = case Config::CONFIG['host_os'].downcase
when /darwin/
"dylib"
when /mswin|mingw/
"dll"
else
Config::CONFIG['DLEXT']
end
CPU = case Config::CONFIG['host_cpu'].downcase
when /i[3456]86/
# Darwin always reports i686, even when running in 64bit mode
if Config::CONFIG['host_os'] =~ /darwin/ && 0xfee1deadbeef.is_a?(Fixnum)
"x86_64"
else
"i386"
end
when /amd64|x86_64/
"x86_64"
when /ppc64|powerpc64/
"powerpc64"
when /ppc|powerpc/
"powerpc"
else
Config::CONFIG['host_cpu']
end
OS = case Config::CONFIG['host_os'].downcase
when /linux/
"linux"
when /darwin/
"darwin"
when /freebsd/
"freebsd"
when /openbsd/
"openbsd"
when /sunos|solaris/
"solaris"
when /mswin|mingw/
"win32"
else
Config::CONFIG['host_os'].downcase
end
CC=ENV['CC'] || Config::CONFIG['CC'] || "gcc"
GMAKE = Config::CONFIG['host_os'].downcase =~ /bsd|solaris/ ? "gmake" : "make"
DIFF = if WIN32 then 'diff.exe'
else
if quiet {system "gdiff", __FILE__, __FILE__} then 'gdiff'
else 'diff' end
end unless defined? DIFF
SUDO = if WIN32 then ''
else
if quiet {system 'which sudo'} then 'sudo'
else '' end
end
RCOV = WIN32 ? 'rcov.bat' : 'rcov'
RDOC = WIN32 ? 'rdoc.bat' : 'rdoc'
GEM = WIN32 ? 'gem.bat' : 'gem'
%w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
begin
require lib
Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", true}
rescue LoadError
Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", false}
end
end
HAVE_SVN = (Dir.entries(Dir.pwd).include?('.svn') and system("svn --version 2>&1 > #{DEV_NULL}"))
HAVE_GIT = (Dir.entries(Dir.pwd).include?('.git') and system("git --version 2>&1 > #{DEV_NULL}"))
# Add bones as a development dependency
#
if HAVE_BONES
bones_version = defined?(Bones::VERSION) ? Bones::VERSION : Bones.version
PROJ.gem.development_dependencies << ['bones', ">= #{bones_version}"]
end
# EOF
|