summaryrefslogtreecommitdiff
path: root/enc
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-12 05:25:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-12 05:25:14 +0000
commit13f1418d546c3d498dcd826e82e262befdd1d9c3 (patch)
tree06774f5de5985423eac6edc750b74022b1d56991 /enc
parentae04e36638f6f3ada402b12b9994ec404c26b184 (diff)
downloadruby-13f1418d546c3d498dcd826e82e262befdd1d9c3.tar.gz
* enc/Makefile.in (.SUFFIXES): renamed to .trans.
* enc/make_encmake.rb: added --encs and --no-encs options. * enc/depend (TRANSVPATH): fix for nmake. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc')
-rw-r--r--enc/Makefile.in3
-rw-r--r--enc/depend25
-rw-r--r--enc/make_encmake.rb31
3 files changed, 44 insertions, 15 deletions
diff --git a/enc/Makefile.in b/enc/Makefile.in
index cc3d99d397..460ec320df 100644
--- a/enc/Makefile.in
+++ b/enc/Makefile.in
@@ -42,13 +42,14 @@ ldflags = $(LDFLAGS)
dldflags = @DLDFLAGS@
archflag = @ARCH_FLAG@
DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
+RUBY = $(MINIRUBY)
WORKDIRS = $(ENCSODIR) $(TRANSSODIR) enc enc/trans
RM = @RM@
MAKEDIRS = @MAKEDIRS@
-.SUFFIXES: .erb.c
+.SUFFIXES: .trans
all: make-workdir
diff --git a/enc/depend b/enc/depend
index 2eeb058d91..35cf6939b3 100644
--- a/enc/depend
+++ b/enc/depend
@@ -1,6 +1,8 @@
% deffile = (true if /\$\(DEFFILE\)/ =~ CONFIG["LINK_SO"])
% encs = Dir.open($srcdir) {|d| d.grep(/.+\.c\z/)} - BUILTIN_ENCS
% 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)}}
% alphanumeric_order = proc {|e| e.scan(/(\d+)|(\D+)/).map {|n,a| a||[n.size,n.to_i]}.flatten}
% encs = encs.sort_by(&alphanumeric_order)
% encs.unshift(encs.delete("encdb"))
@@ -19,11 +21,14 @@
% atrans = atrans.sort_by(&alphanumeric_order)
% trans = trans.sort_by(&alphanumeric_order)
% trans.unshift(trans.delete("transdb"))
+% trans |= atrans
% trans.map! {|e| "trans/#{e}"}
% dependencies = encs + trans
% cleanlibs = Shellwords.shellwords(CONFIG["cleanlibs"] || "")
% cleanobjs = Shellwords.shellwords(CONFIG["cleanobjs"] || "")
% rule_subst = CONFIG["RULE_SUBST"] || "%s"
+% transvpath = rule_subst.dup.sub!(/\{[^{}]+\}/, '$(TRANSVPATH)/') || "enc/trans/%s"
+% transvpath_prefix = rule_subst.dup.sub!(/\{[^{}]+\}/, '{$(TRANSVPATH)}') || ""
% if File::ALT_SEPARATOR
% pathrep = proc {|path| path.gsub('/', File::ALT_SEPARATOR).gsub(/\$\(([@<?*]\w?|\w+)\)/, "$(\\1:/=\\#{File::ALT_SEPARATOR})")}
% else
@@ -42,7 +47,9 @@ ENCCLEANOBJS = <%=cleanobjs.map {|clean|
clean.gsub(/\$\*(\.\w+)?/) {"$(ENCOBJS#{$1 ? ":.#{CONFIG["OBJEXT"]}=#{$1}" : ""})"}
}.join(" ")%>
-TRANSCSRCS = <%=atrans.map {|e| rule_subst % "enc/trans/#{e}.c"}.join(" \\\n\t ")%><%="\n" if trans.size>1%>
+TRANSVPATH = $(srcdir)/enc/trans
+
+TRANSCSRCS = <%=atrans.map {|e| transvpath % "#{e}.c"}.join(" \\\n\t ")%><%="\n" if trans.size>1%>
TRANSOBJS = <%=trans.map {|e|"enc/#{e}.$(OBJEXT)"}.join(" \\\n\t ")%><%="\n" if trans.size>1%>
TRANSSOS = <%=trans.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")%><%="\n" if trans.size>1%>
TRANSCLEANLIBS = <%=cleanlibs.map {|clean|
@@ -61,10 +68,14 @@ srcs: $(TRANSCSRCS)
% end
% compile_rules.each do |rule|
<%= rule % %w[c $(OBJEXT)] %>
- @$(MAKEDIRS) "$(@D)"
+ -@$(MAKEDIRS) "$(@D)"
<%=COMPILE_C%>
% end
+
+<%=transvpath_prefix%>.trans<%=transvpath_prefix%>.c:
+ $(MINIRUBY) "$(srcdir)/tool/transcode-tblgen.rb" -vo "$@" "$<"
+
% unless encs.empty? or trans.empty?
% unless encs.empty?
@@ -75,10 +86,10 @@ $(TRANSOBJS): ruby.h intern.h config.h defines.h missing.h encoding.h oniguruma.
% end
% atrans.each do |e|
% src = "#{e}.trans"
-% src = [src, *IO.read(File.join($srcdir, "trans", src)).scan(/^\s*require\s+[\'\"]([^\'\"]*)/).flatten.map{|c|c+".rb"}]
-<%=rule_subst % "enc/trans/#{e}.c"%>: <%= src.map {|e| rule_subst % "enc/trans/#{e}"}.join(" ")%> $(srcdir)/tool/transcode-tblgen.rb
- $(MINIRUBY) "$(srcdir)/tool/transcode-tblgen.rb" -vo "$@" <%= src.map {|e| %'"$(srcdir)/enc/trans/#{e}"'}.join(" ")%>
+<%=transvpath % "#{e}.c"%>: <%= transvpath % "#{e}.trans"%>
+% src = [*IO.read(File.join($srcdir, "trans", src)).scan(/^\s*require\s+[\'\"]([^\'\"]*)/).flatten.map{|c|c+".rb"}]
+<%=transvpath % "#{e}.c"%>: <%= src.map {|e| transvpath % "#{e}"}.join(" ")%> $(srcdir)/tool/transcode-tblgen.rb
% end
% end
@@ -89,8 +100,8 @@ $(TRANSOBJS): ruby.h intern.h config.h defines.h missing.h encoding.h oniguruma.
% df = ("enc/#{e}.def" if deffile)
$(ENCSODIR)/<%=e%>.$(DLEXT): <%=obj%>
% if df
- echo EXPORTS > <%=df%>
- echo <%=EXPORT_PREFIX%>Init_<%=File.basename(e)%> >> <%=df%>
+ echo> <%=df%> EXPORTS
+ echo>> <%=df%> <%=EXPORT_PREFIX%>Init_<%=File.basename(e)%>
% end
@$(MAKEDIRS) "$(@D)"
<%=link_so.sub(/\$\(OBJS\)/) {obj}.sub(/\$\(DEFFILE\)/) {df}.gsub(/-(?:implib|pdb):/) {|s|"#{s}enc/#{e.sub(/[^\/]+\z/, '')}"}%>
diff --git a/enc/make_encmake.rb b/enc/make_encmake.rb
index e36723294d..f8c7735047 100644
--- a/enc/make_encmake.rb
+++ b/enc/make_encmake.rb
@@ -3,15 +3,32 @@
dir = File.expand_path("../..", __FILE__)
$:.unshift(dir)
$:.unshift(".")
-$" << "mkmf.rb"
-load File.expand_path("lib/mkmf.rb", dir)
+if $".grep(/mkmf/).empty?
+ $" << "mkmf.rb"
+ load File.expand_path("lib/mkmf.rb", dir)
+end
require 'erb'
-if /--builtin-encs=/ =~ ARGV[0]
- BUILTIN_ENCS = $'.split.map {|e| File.basename(e, '.*') << '.c'}
- ARGV.shift
-else
- BUILTIN_ENCS = []
+CONFIG["MAKEDIRS"] ||= '@$(MINIRUBY) -run -e mkdir -- -p'
+
+BUILTIN_ENCS = []
+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
+ when /\A--encs=/
+ ENC_PATTERNS.concat $'.split
+ ARGV.shift
+ when /\A--no-encs=/
+ NOENC_PATTERNS.concat $'.split
+ ARGV.shift
+ else
+ break
+ end
end
if File.exist?(depend = File.join($srcdir, "depend"))