2007-12-17 03:47:28 -05:00
|
|
|
#! ./miniruby
|
|
|
|
|
|
|
|
dir = File.expand_path("../..", __FILE__)
|
|
|
|
$:.unshift(dir)
|
|
|
|
$:.unshift(".")
|
2008-08-12 01:25:14 -04:00
|
|
|
if $".grep(/mkmf/).empty?
|
|
|
|
$" << "mkmf.rb"
|
|
|
|
load File.expand_path("lib/mkmf.rb", dir)
|
|
|
|
end
|
2007-12-22 13:35:53 -05:00
|
|
|
require 'erb'
|
2007-12-17 03:47:28 -05:00
|
|
|
|
2010-11-17 04:38:38 -05:00
|
|
|
CONFIG["MAKEDIRS"] ||= '$(MINIRUBY) -run -e mkdir -- -p'
|
2008-08-12 01:25:14 -04:00
|
|
|
|
|
|
|
BUILTIN_ENCS = []
|
2008-08-24 11:58:43 -04:00
|
|
|
BUILTIN_TRANSES = []
|
2008-08-12 01:25:14 -04:00
|
|
|
ENC_PATTERNS = []
|
|
|
|
NOENC_PATTERNS = []
|
|
|
|
|
|
|
|
until ARGV.empty?
|
|
|
|
case ARGV[0]
|
|
|
|
when /\A--builtin-encs=/
|
|
|
|
BUILTIN_ENCS.concat $'.split.map {|e| File.basename(e, '.*') << '.c'}
|
|
|
|
ARGV.shift
|
2008-08-24 11:58:43 -04:00
|
|
|
when /\A--builtin-transes=/
|
|
|
|
BUILTIN_TRANSES.concat $'.split.map {|e| File.basename(e, '.*') }
|
|
|
|
ARGV.shift
|
2008-08-12 01:25:14 -04:00
|
|
|
when /\A--encs=/
|
|
|
|
ENC_PATTERNS.concat $'.split
|
|
|
|
ARGV.shift
|
|
|
|
when /\A--no-encs=/
|
|
|
|
NOENC_PATTERNS.concat $'.split
|
|
|
|
ARGV.shift
|
|
|
|
else
|
|
|
|
break
|
|
|
|
end
|
2007-12-17 12:30:57 -05:00
|
|
|
end
|
|
|
|
|
2007-12-17 11:15:46 -05:00
|
|
|
if File.exist?(depend = File.join($srcdir, "depend"))
|
2007-12-22 13:35:53 -05:00
|
|
|
erb = ERB.new(File.read(depend), nil, '%')
|
|
|
|
erb.filename = depend
|
|
|
|
tmp = erb.result(binding)
|
2007-12-23 22:49:56 -05:00
|
|
|
dep = "\n#### depend ####\n\n" << depend_rules(tmp).join
|
|
|
|
else
|
|
|
|
dep = ""
|
2007-12-17 11:15:46 -05:00
|
|
|
end
|
2007-12-23 22:49:56 -05:00
|
|
|
mkin = File.read(File.join($srcdir, "Makefile.in"))
|
|
|
|
mkin.gsub!(/@(#{CONFIG.keys.join('|')})@/) {CONFIG[$1]}
|
2007-12-17 12:30:57 -05:00
|
|
|
open(ARGV[0], 'wb') {|f|
|
2007-12-23 22:49:56 -05:00
|
|
|
f.puts mkin, dep
|
2007-12-17 03:47:28 -05:00
|
|
|
}
|