diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-05-16 05:39:06 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-05-16 05:39:06 +0000 |
commit | 3fa3f9abb9a187a12089c2c5a650a62dbd82a3dd (patch) | |
tree | 5a7f6c9f348469863b60010b02375c06b6704951 /enc/make_encmake.rb | |
parent | 0923ae5ed1711d699ef2923c2223163646634a66 (diff) |
Supports static linking of extensions and encodings again.
Fixes --with-static-linked-ext.
Patch by Google Inc. [ruby-core:45073].
* Makefile.in (ENCOBJS, EXTOBJS): New variables to specify static
linked libraries. Also reintroduces extinit.o, introduces encinit.o
introduces encinit.o
* common.mk: Builds static libraries rather than shared objects if
specified.
* configure.in (LD): new substitution.
Avoids PIE if s
* enc/depend: Supports static linked libraries
(libencs, libenc, libtrans): New target.
* enc/encinit.c.erb: new template to generate the initialization of
statically linked encodings.
* enc/make_encmake.rb (--module): new flag to specify whether static
or dynamic.
* transcode_data.h (TRANS_INIT): New macro to get rid of the name
collision of encoding initializers and transcoder initializers.
* ext/extmk.rb: Fixes the behavior on $extstatic is true.
* lib/mkmf.rb (clean-static): new target to clean up static linked
libraries.
* ruby.c (process_options): New initializes statically linked
encodings here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/make_encmake.rb')
-rwxr-xr-x | enc/make_encmake.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/enc/make_encmake.rb b/enc/make_encmake.rb index ed3680313f..291774e60c 100755 --- a/enc/make_encmake.rb +++ b/enc/make_encmake.rb @@ -15,6 +15,7 @@ BUILTIN_ENCS = [] BUILTIN_TRANSES = [] ENC_PATTERNS = [] NOENC_PATTERNS = [] +module_type = :dynamic until ARGV.empty? case ARGV[0] @@ -30,11 +31,57 @@ until ARGV.empty? when /\A--no-encs=/ NOENC_PATTERNS.concat $'.split ARGV.shift + when /\A--module$/ + ARGV.shift + when /\A--modulestatic$/ + module_type = :static + ARGV.shift else break end end +ALPHANUMERIC_ORDER = proc {|e| e.scan(/(\d+)|(\D+)/).map {|n,a| a||[n.size,n.to_i]}.flatten} +def target_encodings + encs = Dir.open($srcdir) {|d| d.grep(/.+\.c\z/)} - BUILTIN_ENCS - ["mktable.c"] + encs.each {|e| e.chomp!(".c")} + encs.reject! {|e| !ENC_PATTERNS.any? {|p| File.fnmatch?(p, e)}} if !ENC_PATTERNS.empty? + encs.reject! {|e| NOENC_PATTERNS.any? {|p| File.fnmatch?(p, e)}} + encs = encs.sort_by(&ALPHANUMERIC_ORDER) + encs.unshift(encs.delete("encdb")) + return encs +end + +def target_transcoders + atrans = [] + trans = Dir.open($srcdir+"/trans") {|d| + d.select {|e| + if e.chomp!('.trans') + atrans << e + true + elsif e.chomp!('.c') + true + end + } + } + trans -= BUILTIN_TRANSES + atrans -= BUILTIN_TRANSES + trans.uniq! + atrans = atrans.sort_by(&ALPHANUMERIC_ORDER) + trans = trans.sort_by(&ALPHANUMERIC_ORDER) + trans.unshift(trans.delete("transdb")) + trans.compact! + trans |= atrans + trans.map! {|e| "trans/#{e}"} + + return atrans, trans +end + +# Constants that "depend" needs. +MODULE_TYPE = module_type +ENCS = target_encodings +ATRANS, TRANS = target_transcoders + if File.exist?(depend = File.join($srcdir, "depend")) erb = ERB.new(File.read(depend), nil, '%') erb.filename = depend @@ -48,3 +95,18 @@ mkin.gsub!(/@(#{CONFIG.keys.join('|')})@/) {CONFIG[$1]} open(ARGV[0], 'wb') {|f| f.puts mkin, dep } +if MODULE_TYPE == :static + erb = ERB.new(File.read(File.join($srcdir, "encinit.c.erb")), nil, '%-') + erb.filename = "enc/encinit.c.cerb" + tmp = erb.result(binding) + begin + Dir.mkdir 'enc' + rescue Errno::EEXIST + end + File.open("enc/encinit.c", "w") {|f| + f.puts "/* Automatically generated from enc/encinit.c.erb" + f.puts " * Do not edit." + f.puts " */" + f.puts tmp + } +end |