forked from ranguba/rroonga
-
Notifications
You must be signed in to change notification settings - Fork 1
/
extconf.rb
executable file
·66 lines (61 loc) · 1.93 KB
/
extconf.rb
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
#!/usr/bin/env ruby
#
# Copyright (C) 2009-2010 Kouhei Sutou <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
require 'English'
require 'pathname'
require 'fileutils'
require 'mkmf'
base_dir = Pathname(__FILE__).dirname.realpath
source_ext_dir = Pathname("ext") + "groonga"
FileUtils.mkdir_p(source_ext_dir.to_s)
require 'rbconfig'
ext_dir = base_dir + "ext" + "groonga"
definitions = ""
Dir.chdir(source_ext_dir.to_s) do
config = Proc.new do |key|
RbConfig::CONFIG[key]
end
ruby = "#{config['bindir']}/#{config['ruby_install_name']}#{config['EXEEXT']}"
message("checking in #{ext_dir}...\n")
ENV["INSTALL_RB"] = "yes"
system(ruby, (ext_dir + 'extconf.rb').to_s, *ARGV) or exit 1
message("checking in #{ext_dir}: done.\n")
File.open("Makefile") do |file|
file.each_line do |line|
case line
when /\A\w+\s*=/
definitions << line
end
end
end
end
message("creating top-level Makefile\n")
File.open("Makefile", "w") do |makefile|
makefile.puts(definitions)
makefile.puts
targets = ["all", "clean", "install"]
targets.each do |target|
# overriding RUBYARCHDIR and RUBYLIBDIR for RubyGems.
makefile.puts <<-EOM
#{target}:
cd #{source_ext_dir}; \\
$(MAKE) $(MAKE_ARGS) \\
RUBYARCHDIR=$(RUBYARCHDIR) \\
RUBYLIBDIR=$(RUBYLIBDIR) \\
#{target}
EOM
end
end