1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
% inplace = File.identical?($top_srcdir, ".")
% workdirs = %w"$(ENCSODIR) $(TRANSSODIR) enc enc/trans"
% CONFIG["WORKDIRS"] = workdirs.join(' ')
% enable_shared = CONFIG['ENABLE_SHARED'] == 'yes'
% deffile = (true if /\$\(DEFFILE\)/ =~ CONFIG["LINK_SO"])
% dependencies = ENCS + TRANS
% cleanlibs = Shellwords.shellwords(CONFIG["cleanlibs"] || "")
% cleanobjs = Shellwords.shellwords(CONFIG["cleanobjs"] || "")
% cleanobjs << "$*.def" if deffile
% rule_subst = CONFIG["RULE_SUBST"] || "%s"
% transvpath = rule_subst.dup.sub!(/\{[^{}]+\}/, '$(TRANSVPATH)/') || "enc/trans/%s"
% transvpath_prefix = (rule_subst.dup.sub!(/\{[^{}]+\}/, '{$(TRANSVPATH)}') || "%s") % ""
% CONFIG['ARFLAGS'] = 'rcu ' if (CONFIG['ARFLAGS'] || "").empty?
% CONFIG['RANLIB'] = ':' if (CONFIG['RANLIB'] || "").empty?
% CONFIG['CPPFLAGS'] += " -DRUBY_EXPORT=1" if CONFIG["EXTSTATIC"] == "static"
% if File::ALT_SEPARATOR
% pathrep = proc {|path| path.gsub('/', File::ALT_SEPARATOR).gsub(/\$\(([@<?*]\w?|\w+)\)/, "$(\\1:/=\\#{File::ALT_SEPARATOR})")}
% else
% pathrep = proc {|path| path}
% end
VPATH = <%=%w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(srcdir) $(encsrcdir)].join(CONFIG["PATH_SEPARATOR"])%>
LIBPATH = <%=libpathflag($DEFLIBPATH)%>
LIBS = <%=
if enable_shared or RbConfig.expand(CONFIG["LIBRUBY"].dup) != RbConfig.expand(CONFIG["LIBRUBY_A"].dup)
CONFIG['LIBRUBYARG']
else
''
end %> <%=CONFIG['LIBS']%> $(EXTLIBS)
ENCOBJS = <%=ENCS.map {|e|"enc/#{e}.$(OBJEXT)"}.join(" \\\n\t ")%><%="\n" if ENCS.size>1%>
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(" ")%>
LIBENC=enc/libenc.$(LIBEXT)
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|
clean.gsub(/\$\*(\.\w+)?/) {"$(TRANSOBJS#{$1 ? ":.#{CONFIG["OBJEXT"]}=#{$1}" : ""})"}
}.join(" ")%>
TRANSCLEANOBJS = <%=cleanobjs.map {|clean|
clean.gsub(/\$\*(\.\w+)?/) {"$(TRANSOBJS#{$1 ? ":.#{CONFIG["OBJEXT"]}=#{$1}" : ""})"}
}.join(" ")%>
LIBTRANS=enc/libtrans.$(LIBEXT)
encs: all
% if MODULE_TYPE == :static
all: libenc libtrans
% else
all: enc trans
%end
libencs: libenc libtrans
enc: $(ENCSOS)
libenc: $(LIBENC)
trans: $(TRANSSOS)
libtrans: $(LIBTRANS)
$(LIBENC): $(ENCOBJS)
@$(RM) $@
$(ECHO) linking statically-linked encoding library $@
$(Q) $(AR) $(ARFLAGS)$@ $(ENCOBJS)
@-$(RANLIB) $@ 2> /dev/null || true
$(LIBTRANS): $(TRANSOBJS)
@$(RM) $@
$(ECHO) linking statically-linked transcoder library $@
$(Q) $(AR) $(ARFLAGS)$@ $(TRANSOBJS)
@-$(RANLIB) $@ 2> /dev/null || true
srcs: $(TRANSCSRCS)
<%=transvpath_prefix%>.trans<%=transvpath_prefix%>.c:
$(ECHO) generating table from $@
$(Q)$(MINIRUBY) "$(srcdir)/tool/transcode-tblgen.rb" -vo "$@" "$<"
% unless ENCS.empty? or TRANS.empty?
% unless ENCS.empty?
$(ENCOBJS): $(hdrdir)/ruby.h regenc.h oniguruma.h config.h defines.h ruby.h missing.h subst.h intern.h st.h encoding.h
% end
% ENC_DEPS.each do |e, deps|
enc/<%=e%>.$(OBJEXT): <%=deps.map {|n| rule_subst % n}.join(' ')%>
% end
% unless TRANS.empty?
$(TRANSOBJS): $(hdrdir)/ruby.h ruby.h intern.h config.h defines.h missing.h encoding.h oniguruma.h st.h transcode_data.h subst.h encoding.h
% end
% ATRANS.each do |e|
% src = "#{e}.trans"
<%=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 {|s| transvpath % "#{s}"}.join(" ")%> $(srcdir)/tool/transcode-tblgen.rb
% end
% end
% link_so = LINK_SO.gsub(/([^\\])\n/, "\\1\n$(Q) ").gsub(/\n/, "\n\t")
% link_so.gsub!(/(-(?:implib|pdb):\S+)-\$\(arch\)\./, '\1.')
% dependencies.each do |e|
% obj = "enc/#{e}.$(OBJEXT)"
% df = ("enc/#{e}.def" if deffile)
% target = e.dup
% if target.sub!(/\Atrans\//, '$(TRANSSODIR)/')
% mesg = "transcoder"
% else
% target = "$(ENCSODIR)/#{e}"
% mesg = "encoding"
% end
<%=target%>.$(DLEXT): <%=obj%>
$(ECHO) linking <%=mesg%> $(@F)
% cmd = link_so.sub(/\$\(OBJS\)/) {obj}
% base = File.basename(e)
% if df
$(Q)echo> <%=df%> EXPORTS
$(Q)echo>> <%=df%> <%=EXPORT_PREFIX%>Init_<%=base%>
% cmd.sub!(/\$\(DEFFILE\)/) {df}
% cmd.gsub!(/-(?:implib|pdb):/) {|s|"#{s}enc/#{e.sub(/[^\/]+\z/, '')}"}
% end
$(Q)$(MAKEDIRS) "$(@D)"
$(Q)<%=cmd%>
% end
% dependencies.each do |e|
<%="enc/#{e}.$(OBJEXT)"%>: <%="$(encsrcdir)/#{e}.c"%>
-$(Q)$(MAKEDIRS) "$(@D)"
$(ECHO) compiling <%= "$(encsrcdir)/#{e}.c"%>
$(Q)<%=COMPILE_C.gsub(/\$(\()?<(\:[^)]+)?(\))?/){"$(encsrcdir)/#{e}.c"}%>
% end
enc/encdb.$(OBJEXT): encdb.h
enc/trans/transdb.$(OBJEXT): transdb.h
clean:
% %w[$(ENCSOS) $(LIBENC) $(ENCOBJS) $(ENCCLEANOBJS) $(ENCCLEANLIBS) $(TRANSSOS) $(LIBTRANS) $(TRANSOBJS) $(TRANSCLEANOBJS) $(TRANSCLEANLIBS)].each do |clean|
$(Q)$(RM) <%=pathrep[clean]%>
% end
% @ignore_error = $nmake ? '' : ' 2> /dev/null || true'
% unless inplace
$(Q)$(RM) enc/unicode/name2ctype.h
-$(Q)$(RMDIR) enc/unicode<%=@ignore_error%>
% end
% workdirs.reverse_each do|d|
-$(Q)$(RMDIR) <%=pathrep[d]%><%=@ignore_error%>
% end
clean-srcs:
$(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%>
<%# vim: set ft=eruby noexpandtab ts=8 sw=2 : -%>
|