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-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-05 14:15:52 -04:00
|
|
|
% atrans = []
|
|
|
|
% trans = Dir.open($srcdir+"/trans") {|d|
|
|
|
|
% d.select {|e|
|
|
|
|
% if e.chomp!('.c')
|
|
|
|
% atrans << e if e.chomp!(".erb")
|
|
|
|
% true
|
|
|
|
% end
|
|
|
|
% }
|
|
|
|
% }
|
|
|
|
% trans.uniq!
|
|
|
|
% atrans = atrans.sort_by(&alphanumeric_order)
|
2007-12-23 22:49:56 -05:00
|
|
|
% trans = trans.sort_by(&alphanumeric_order)
|
|
|
|
% trans.map! {|e| "trans/#{e}"}
|
|
|
|
% dependencies = encs + trans
|
|
|
|
|
|
|
|
VPATH = <%=%w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(srcdir) $(encsrcdir)].join(CONFIG["PATH_SEPARATOR"])%>
|
2007-12-22 13:35:53 -05:00
|
|
|
LIBPATH = <%=libpathflag($DEFLIBPATH)%>
|
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%>
|
|
|
|
ENCDEFS = <%=encs.map {|e|"enc/#{e}.def"}.join(" \\\n\t ") if deffile%><%="\n" if encs.size>1%>
|
2007-12-22 13:35:53 -05:00
|
|
|
ENCSOS = <%=encs.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")%>
|
2007-12-17 11:15:46 -05:00
|
|
|
|
2008-08-06 01:40:13 -04:00
|
|
|
TRANSCSRCS = <%=atrans.map {|e|"enc/trans/#{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%>
|
|
|
|
TRANSDEFS = <%=trans.map {|e|"enc/#{e}.def"}.join(" \\\n\t ") if deffile%><%="\n" if trans.size>1%>
|
|
|
|
TRANSSOS = <%=trans.map {|e|"$(ENCSODIR)/#{e}.$(DLEXT)"}.join(" \\\n\t ")%>
|
|
|
|
|
2008-08-06 01:40:13 -04:00
|
|
|
all: srcs $(ENCSOS) $(TRANSSOS)
|
|
|
|
|
|
|
|
srcs: $(TRANSCSRCS)
|
2007-12-17 03:19:29 -05:00
|
|
|
|
2007-12-22 13:35:53 -05:00
|
|
|
% COMPILE_RULES.each do |rule|
|
|
|
|
<%= rule % %w[c $(OBJEXT)] %>
|
|
|
|
<%=COMPILE_C%>
|
2007-12-20 03:07:56 -05:00
|
|
|
|
2007-12-22 13:35:53 -05:00
|
|
|
% end
|
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|
|
|
|
|
% src = "#{e}.erb.c"
|
2008-08-06 01:40:13 -04:00
|
|
|
% src = [src, *IO.read(File.join($srcdir, "trans", src)).scan(/^\s*require\s+[\'\"]([^\'\"]*)/).flatten.map{|c|c+".rb"}]
|
2008-08-05 14:15:52 -04:00
|
|
|
|
|
|
|
$(srcdir)/enc/trans/<%=e%>.c: <%= src.map {|e| "$(srcdir)/enc/trans/#{e}"}.join(" ")%>
|
2008-08-06 00:55:39 -04:00
|
|
|
$(BASERUBY) "$(srcdir)/tool/transcode-tblgen.rb" -vo "$@" <%= src.map {|e| %'"$(srcdir)/enc/trans/#{e}"'}.join(" ")%>
|
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)
|
|
|
|
$(ENCSODIR)/<%=e%>.$(DLEXT): <%=obj%>
|
|
|
|
% if df
|
|
|
|
echo EXPORTS > <%=df%>
|
|
|
|
echo <%=EXPORT_PREFIX%>Init_<%=File.basename(e)%> >> <%=df%>
|
2007-12-22 13:35:53 -05:00
|
|
|
% end
|
2008-02-13 02:26:52 -05:00
|
|
|
<%=link_so.sub(/\$\(OBJS\)/) {obj}.sub(/\$\(DEFFILE\)/) {df}.gsub(/-(?:implib|pdb):/) {|s|"#{s}enc/#{e.sub(/[^\/]+\z/, '')}"}%>
|
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|
|
|
|
|
enc/<%=e%>.$(OBJEXT): $(srcdir)/enc/<%=e%>.c
|
2008-08-06 01:04:36 -04:00
|
|
|
<%=COMPILE_C.sub(/\$(?:<|\(<(?:.*)\))/) {"$(srcdir)/enc/#{e}.c"}%>
|
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-08-06 01:40:13 -04:00
|
|
|
@$(RM) $(ENCSOS) $(ENCDEFS) $(ENCOBJS) $(TRANSSOS) $(TRANSDEFS) $(TRANSOBJS) $(TRANSCSRCS)
|
2008-06-09 08:17:29 -04:00
|
|
|
% %w[$(ENCSODIR)/trans $(ENCSODIR) enc/trans enc].each do|dir|
|
|
|
|
% dir = dir.gsub('/', File::ALT_SEPARATOR) if File::ALT_SEPARATOR
|
|
|
|
@-rmdir <%=dir%>
|
|
|
|
% end
|