2010-12-29 06:31:23 -05:00
|
|
|
% inplace = File.identical?($srcdir, ".")
|
2010-12-20 22:45:21 -05:00
|
|
|
% workdirs = %w"$(ENCSODIR) $(TRANSSODIR) enc enc/trans"
|
|
|
|
% CONFIG["WORKDIRS"] = workdirs.join(' ')
|
2009-03-22 17:51:18 -04:00
|
|
|
% CONFIG["DLDFLAGS"].sub!(/(\A|\s)(-\S+(?:\s*\w*)?\$\(TARGET\)\S*)/, '\1')
|
|
|
|
% dldflags = $2
|
2008-11-17 04:05:19 -05:00
|
|
|
% enable_shared = CONFIG['ENABLE_SHARED'] == 'yes'
|
2007-12-23 22:49:56 -05:00
|
|
|
% deffile = (true if /\$\(DEFFILE\)/ =~ CONFIG["LINK_SO"])
|
2007-12-22 13:35:53 -05:00
|
|
|
% encs = Dir.open($srcdir) {|d| d.grep(/.+\.c\z/)} - BUILTIN_ENCS
|
|
|
|
% encs.each {|e| e.chomp!(".c")}
|
2008-08-12 01:25:14 -04:00
|
|
|
% 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)}}
|
2008-02-21 19:07:23 -05:00
|
|
|
% alphanumeric_order = proc {|e| e.scan(/(\d+)|(\D+)/).map {|n,a| a||[n.size,n.to_i]}.flatten}
|
2007-12-23 22:49:56 -05:00
|
|
|
% encs = encs.sort_by(&alphanumeric_order)
|
2008-08-07 04:47:58 -04:00
|
|
|
% encs.unshift(encs.delete("encdb"))
|
2008-08-05 14:15:52 -04:00
|
|
|
% atrans = []
|
|
|
|
% trans = Dir.open($srcdir+"/trans") {|d|
|
|
|
|
% d.select {|e|
|
2008-08-11 03:39:52 -04:00
|
|
|
% if e.chomp!('.trans')
|
|
|
|
% atrans << e
|
|
|
|
% true
|
|
|
|
% elsif e.chomp!('.c')
|
2008-08-05 14:15:52 -04:00
|
|
|
% true
|
|
|
|
% end
|
|
|
|
% }
|
|
|
|
% }
|
2008-08-24 11:58:43 -04:00
|
|
|
% trans -= BUILTIN_TRANSES
|
|
|
|
% atrans -= BUILTIN_TRANSES
|
2008-08-05 14:15:52 -04:00
|
|
|
% trans.uniq!
|
|
|
|
% atrans = atrans.sort_by(&alphanumeric_order)
|
2007-12-23 22:49:56 -05:00
|
|
|
% trans = trans.sort_by(&alphanumeric_order)
|
2008-08-07 04:47:58 -04:00
|
|
|
% trans.unshift(trans.delete("transdb"))
|
2008-09-01 01:37:04 -04:00
|
|
|
% trans.compact!
|
2008-08-12 01:25:14 -04:00
|
|
|
% trans |= atrans
|
2007-12-23 22:49:56 -05:00
|
|
|
% trans.map! {|e| "trans/#{e}"}
|
|
|
|
% dependencies = encs + trans
|
2008-08-07 01:17:34 -04:00
|
|
|
% cleanlibs = Shellwords.shellwords(CONFIG["cleanlibs"] || "")
|
|
|
|
% cleanobjs = Shellwords.shellwords(CONFIG["cleanobjs"] || "")
|
2009-01-26 21:03:54 -05:00
|
|
|
% cleanobjs << "$*.def" if deffile
|
2008-08-07 01:17:34 -04:00
|
|
|
% rule_subst = CONFIG["RULE_SUBST"] || "%s"
|
2008-08-12 01:25:14 -04:00
|
|
|
% transvpath = rule_subst.dup.sub!(/\{[^{}]+\}/, '$(TRANSVPATH)/') || "enc/trans/%s"
|
2008-08-12 02:19:00 -04:00
|
|
|
% transvpath_prefix = (rule_subst.dup.sub!(/\{[^{}]+\}/, '{$(TRANSVPATH)}') || "") % ""
|
2008-08-07 01:17:34 -04:00
|
|
|
% if File::ALT_SEPARATOR
|
2008-08-09 22:45:18 -04:00
|
|
|
% pathrep = proc {|path| path.gsub('/', File::ALT_SEPARATOR).gsub(/\$\(([@<?*]\w?|\w+)\)/, "$(\\1:/=\\#{File::ALT_SEPARATOR})")}
|
2008-08-07 01:17:34 -04:00
|
|
|
% else
|
|
|
|
% pathrep = proc {|path| path}
|
|
|
|
% end
|
2007-12-23 22:49:56 -05:00
|
|
|
|
|
|
|
VPATH = <%=%w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(srcdir) $(encsrcdir)].join(CONFIG["PATH_SEPARATOR"])%>
|
2007-12-22 13:35:53 -05:00
|
|
|
LIBPATH = <%=libpathflag($DEFLIBPATH)%>
|
2008-11-17 04:05:19 -05:00
|
|
|
LIBS = <%=
|
|
|
|
if enable_shared or RbConfig.expand(CONFIG["LIBRUBY"].dup) != RbConfig.expand(CONFIG["LIBRUBY_A"].dup)
|
|
|
|
CONFIG['LIBRUBYARG']
|
|
|
|
else
|
|
|
|
''
|
|
|
|
end %> <%=CONFIG['LIBS']%> $(EXTLIBS)
|
2007-12-17 11:15:46 -05:00
|
|
|
|
2007-12-23 22:49:56 -05:00
|
|
|
ENCOBJS = <%=encs.map {|e|"enc/#{e}.$(OBJEXT)"}.join(" \\\n\t ")%><%="\n" if encs.size>1%>
|
2008-08-07 01:17:34 -04:00
|
|
|
ENCSOS = <%=encs.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")%><%="\n" if encs.size>1%>
|
|
|
|
ENCCLEANLIBS = <%=cleanlibs.map {|clean|
|
|
|
|
clean.gsub(/\$\*(\.\w+)?/) {"$(ENCOBJS#{$1 ? ":.#{CONFIG["OBJEXT"]}=#{$1}" : ""})"}
|
|
|
|
}.join(" ")%>
|
|
|
|
ENCCLEANOBJS = <%=cleanobjs.map {|clean|
|
|
|
|
clean.gsub(/\$\*(\.\w+)?/) {"$(ENCOBJS#{$1 ? ":.#{CONFIG["OBJEXT"]}=#{$1}" : ""})"}
|
|
|
|
}.join(" ")%>
|
2007-12-17 11:15:46 -05:00
|
|
|
|
2008-08-12 01:25:14 -04:00
|
|
|
TRANSVPATH = $(srcdir)/enc/trans
|
|
|
|
|
|
|
|
TRANSCSRCS = <%=atrans.map {|e| transvpath % "#{e}.c"}.join(" \\\n\t ")%><%="\n" if trans.size>1%>
|
2007-12-23 22:49:56 -05:00
|
|
|
TRANSOBJS = <%=trans.map {|e|"enc/#{e}.$(OBJEXT)"}.join(" \\\n\t ")%><%="\n" if trans.size>1%>
|
2008-08-07 01:17:34 -04:00
|
|
|
TRANSSOS = <%=trans.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")%><%="\n" if trans.size>1%>
|
|
|
|
TRANSCLEANLIBS = <%=cleanlibs.map {|clean|
|
|
|
|
clean.gsub(/\$\*(\.\w+)?/) {"$(TRANSOBJS#{$1 ? ":.#{CONFIG["OBJEXT"]}=#{$1}" : ""})"}
|
|
|
|
}.join(" ")%>
|
|
|
|
TRANSCLEANOBJS = <%=cleanobjs.map {|clean|
|
|
|
|
clean.gsub(/\$\*(\.\w+)?/) {"$(TRANSOBJS#{$1 ? ":.#{CONFIG["OBJEXT"]}=#{$1}" : ""})"}
|
|
|
|
}.join(" ")%>
|
2007-12-23 22:49:56 -05:00
|
|
|
|
2008-10-16 01:34:25 -04:00
|
|
|
encs: all
|
|
|
|
all: enc trans
|
|
|
|
enc: $(ENCSOS)
|
|
|
|
trans: $(TRANSSOS)
|
2008-08-06 01:40:13 -04:00
|
|
|
|
|
|
|
srcs: $(TRANSCSRCS)
|
2007-12-17 03:19:29 -05:00
|
|
|
|
2008-08-12 01:25:14 -04:00
|
|
|
<%=transvpath_prefix%>.trans<%=transvpath_prefix%>.c:
|
2010-11-11 07:46:23 -05:00
|
|
|
$(ECHO) generating table from $@
|
2010-12-29 06:27:36 -05:00
|
|
|
$(Q)$(MINIRUBY) "$(srcdir)/tool/transcode-tblgen.rb" -vo "$@" "$<"
|
2008-08-12 01:25:14 -04:00
|
|
|
|
2007-12-23 22:49:56 -05:00
|
|
|
% unless encs.empty? or trans.empty?
|
2007-12-17 11:15:46 -05:00
|
|
|
|
2007-12-23 22:49:56 -05:00
|
|
|
% unless encs.empty?
|
2007-12-17 03:19:29 -05:00
|
|
|
$(ENCOBJS): regenc.h oniguruma.h config.h defines.h
|
2007-12-23 22:49:56 -05:00
|
|
|
% end
|
|
|
|
% unless trans.empty?
|
2008-01-01 11:20:56 -05:00
|
|
|
$(TRANSOBJS): ruby.h intern.h config.h defines.h missing.h encoding.h oniguruma.h st.h transcode_data.h
|
2007-12-23 22:49:56 -05:00
|
|
|
% end
|
2008-08-05 14:15:52 -04:00
|
|
|
% atrans.each do |e|
|
2008-08-11 03:39:52 -04:00
|
|
|
% src = "#{e}.trans"
|
2008-08-05 14:15:52 -04:00
|
|
|
|
2008-08-12 01:25:14 -04:00
|
|
|
<%=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
|
2008-08-05 14:15:52 -04:00
|
|
|
% end
|
2007-12-22 13:35:53 -05:00
|
|
|
|
|
|
|
% end
|
|
|
|
% link_so = LINK_SO.gsub(/\n/, "\n\t")
|
2007-12-23 22:49:56 -05:00
|
|
|
% link_so.gsub!(/(-(?:implib|pdb):\S+)-\$\(arch\)\./, '\1.')
|
|
|
|
% dependencies.each do |e|
|
|
|
|
% obj = "enc/#{e}.$(OBJEXT)"
|
|
|
|
% df = ("enc/#{e}.def" if deffile)
|
2010-11-11 07:46:23 -05:00
|
|
|
% target = e.dup
|
|
|
|
% if target.sub!(/\Atrans\//, '$(TRANSSODIR)/')
|
|
|
|
% mesg = "transcoder"
|
|
|
|
% else
|
|
|
|
% target = "$(ENCSODIR)/#{e}"
|
|
|
|
% mesg = "encoding"
|
|
|
|
% end
|
|
|
|
<%=target%>.$(DLEXT): <%=obj%>
|
|
|
|
$(ECHO) linking <%=mesg%> $(@F)
|
2009-03-22 17:51:18 -04:00
|
|
|
% cmd = link_so.sub(/\$\(OBJS\)/) {obj}
|
|
|
|
% base = File.basename(e)
|
|
|
|
% cmd.sub!(/(?=\$\(DLDFLAGS\))/) {dldflags.sub(/\$\(TARGET\)/) {base} + " "} if dldflags
|
2007-12-23 22:49:56 -05:00
|
|
|
% if df
|
2010-12-29 06:27:36 -05:00
|
|
|
$(Q)echo> <%=df%> EXPORTS
|
|
|
|
$(Q)echo>> <%=df%> <%=EXPORT_PREFIX%>Init_<%=base%>
|
2009-03-22 17:51:18 -04:00
|
|
|
% cmd.sub!(/\$\(DEFFILE\)/) {df}
|
|
|
|
% cmd.gsub!(/-(?:implib|pdb):/) {|s|"#{s}enc/#{e.sub(/[^\/]+\z/, '')}"}
|
2007-12-22 13:35:53 -05:00
|
|
|
% end
|
2010-12-29 06:27:36 -05:00
|
|
|
$(Q)$(MAKEDIRS) "$(@D)"
|
|
|
|
$(Q)<%=cmd%>
|
2007-12-23 22:49:56 -05:00
|
|
|
|
2007-12-22 13:35:53 -05:00
|
|
|
% end
|
2007-12-23 22:49:56 -05:00
|
|
|
% dependencies.each do |e|
|
2009-01-30 00:13:22 -05:00
|
|
|
<%="enc/#{e}.$(OBJEXT)"%>: <%="$(encsrcdir)/#{e}.c"%>
|
2010-12-29 06:27:36 -05:00
|
|
|
-$(Q)$(MAKEDIRS) "$(@D)"
|
2011-06-15 20:10:10 -04:00
|
|
|
$(ECHO) compiling <%= "$(encsrcdir)/#{e}.c"%>
|
2010-12-29 06:27:36 -05:00
|
|
|
$(Q)<%=COMPILE_C.gsub(/\$(\()?<(\:[^)]+)?(\))?/){"$(encsrcdir)/#{e}.c"}%>
|
2009-01-30 00:13:22 -05:00
|
|
|
|
2007-12-22 13:35:53 -05:00
|
|
|
% end
|
2007-12-19 12:23:24 -05:00
|
|
|
|
2008-04-07 02:51:33 -04:00
|
|
|
enc/encdb.$(OBJEXT): encdb.h
|
|
|
|
enc/trans/transdb.$(OBJEXT): transdb.h
|
|
|
|
|
2007-12-19 12:23:24 -05:00
|
|
|
clean:
|
2008-12-08 10:17:52 -05:00
|
|
|
% %w[$(ENCSOS) $(ENCOBJS) $(ENCCLEANOBJS) $(ENCCLEANLIBS) $(TRANSSOS) $(TRANSOBJS) $(TRANSCLEANOBJS) $(TRANSCLEANLIBS)].each do |clean|
|
2010-12-29 06:27:36 -05:00
|
|
|
$(Q)$(RM) <%=pathrep[clean]%>
|
2008-08-07 01:17:34 -04:00
|
|
|
% end
|
2010-08-06 04:44:33 -04:00
|
|
|
% @ignore_error = $nmake ? '' : ' 2> /dev/null || true'
|
2010-12-29 06:31:23 -05:00
|
|
|
% unless inplace
|
|
|
|
$(Q)$(RM) enc/unicode/name2ctype.h
|
|
|
|
-$(Q)$(RMDIR) enc/unicode<%=@ignore_error%>
|
|
|
|
% end
|
2010-12-20 22:45:21 -05:00
|
|
|
% workdirs.reverse_each do|dir|
|
2010-12-29 06:27:36 -05:00
|
|
|
-$(Q)$(RMDIR) <%=pathrep[dir]%><%=@ignore_error%>
|
2008-12-08 10:17:52 -05:00
|
|
|
% end
|
|
|
|
|
|
|
|
clean-srcs:
|
2010-12-29 06:27:36 -05:00
|
|
|
$(Q)$(RM) <%=pathrep['$(TRANSCSRCS)']%>
|
|
|
|
-$(Q)$(RMDIR) <%=pathrep['enc/trans']%><%=@ignore_error%>
|
|
|
|
$(Q)$(RM) enc/unicode/name2ctype.h
|
|
|
|
-$(Q)$(RMDIR) <%=pathrep['enc/unicode']%><%=@ignore_error%>
|
|
|
|
-$(Q)$(RMDIR) <%=pathrep['enc']%><%=@ignore_error%>
|