2012-08-18 04:57:48 +04:00
|
|
|
% inplace = File.identical?($top_srcdir, ".")
|
2010-12-21 06:45:21 +03:00
|
|
|
% workdirs = %w"$(ENCSODIR) $(TRANSSODIR) enc enc/trans"
|
|
|
|
% CONFIG["WORKDIRS"] = workdirs.join(' ')
|
2008-11-17 12:05:19 +03:00
|
|
|
% enable_shared = CONFIG['ENABLE_SHARED'] == 'yes'
|
2007-12-24 06:49:56 +03:00
|
|
|
% deffile = (true if /\$\(DEFFILE\)/ =~ CONFIG["LINK_SO"])
|
2012-05-16 09:39:06 +04:00
|
|
|
% dependencies = ENCS + TRANS
|
2008-08-07 09:17:34 +04:00
|
|
|
% cleanlibs = Shellwords.shellwords(CONFIG["cleanlibs"] || "")
|
|
|
|
% cleanobjs = Shellwords.shellwords(CONFIG["cleanobjs"] || "")
|
2009-01-27 05:03:54 +03:00
|
|
|
% cleanobjs << "$*.def" if deffile
|
2008-08-07 09:17:34 +04:00
|
|
|
% rule_subst = CONFIG["RULE_SUBST"] || "%s"
|
2008-08-12 09:25:14 +04:00
|
|
|
% transvpath = rule_subst.dup.sub!(/\{[^{}]+\}/, '$(TRANSVPATH)/') || "enc/trans/%s"
|
2012-09-10 05:20:16 +04:00
|
|
|
% transvpath_prefix = (rule_subst.dup.sub!(/\{[^{}]+\}/, '{$(TRANSVPATH)}') || "%s") % ""
|
2013-02-25 10:59:10 +04:00
|
|
|
% CONFIG['ARFLAGS'] = 'rcu ' if (CONFIG['ARFLAGS'] || "").empty?
|
|
|
|
% CONFIG['RANLIB'] = ':' if (CONFIG['RANLIB'] || "").empty?
|
2013-03-02 19:04:23 +04:00
|
|
|
% CONFIG['CPPFLAGS'] += " -DRUBY_EXPORT=1" if CONFIG["EXTSTATIC"] == "static"
|
2008-08-07 09:17:34 +04:00
|
|
|
% if File::ALT_SEPARATOR
|
2008-08-10 06:45:18 +04:00
|
|
|
% pathrep = proc {|path| path.gsub('/', File::ALT_SEPARATOR).gsub(/\$\(([@<?*]\w?|\w+)\)/, "$(\\1:/=\\#{File::ALT_SEPARATOR})")}
|
2008-08-07 09:17:34 +04:00
|
|
|
% else
|
|
|
|
% pathrep = proc {|path| path}
|
|
|
|
% end
|
2007-12-24 06:49:56 +03:00
|
|
|
|
|
|
|
VPATH = <%=%w[$(arch_hdrdir)/ruby $(hdrdir)/ruby $(srcdir) $(encsrcdir)].join(CONFIG["PATH_SEPARATOR"])%>
|
2007-12-22 21:35:53 +03:00
|
|
|
LIBPATH = <%=libpathflag($DEFLIBPATH)%>
|
2008-11-17 12:05:19 +03: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 19:15:46 +03:00
|
|
|
|
2012-05-16 09:39:06 +04:00
|
|
|
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%>
|
2008-08-07 09:17:34 +04:00
|
|
|
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(" ")%>
|
2012-05-16 09:39:06 +04:00
|
|
|
LIBENC=enc/libenc.$(LIBEXT)
|
2007-12-17 19:15:46 +03:00
|
|
|
|
2008-08-12 09:25:14 +04:00
|
|
|
TRANSVPATH = $(srcdir)/enc/trans
|
|
|
|
|
2012-05-16 09:39:06 +04:00
|
|
|
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%>
|
2008-08-07 09:17:34 +04:00
|
|
|
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(" ")%>
|
2012-05-16 09:39:06 +04:00
|
|
|
LIBTRANS=enc/libtrans.$(LIBEXT)
|
2007-12-24 06:49:56 +03:00
|
|
|
|
2008-10-16 09:34:25 +04:00
|
|
|
encs: all
|
2012-05-16 09:39:06 +04:00
|
|
|
% if MODULE_TYPE == :static
|
|
|
|
all: libenc libtrans
|
|
|
|
% else
|
2008-10-16 09:34:25 +04:00
|
|
|
all: enc trans
|
2012-05-16 09:39:06 +04:00
|
|
|
%end
|
|
|
|
libencs: libenc libtrans
|
2008-10-16 09:34:25 +04:00
|
|
|
enc: $(ENCSOS)
|
2012-05-16 09:39:06 +04:00
|
|
|
libenc: $(LIBENC)
|
2008-10-16 09:34:25 +04:00
|
|
|
trans: $(TRANSSOS)
|
2012-05-16 09:39:06 +04:00
|
|
|
libtrans: $(LIBTRANS)
|
|
|
|
|
|
|
|
$(LIBENC): $(ENCOBJS)
|
|
|
|
@$(RM) $@
|
|
|
|
$(ECHO) linking statically-linked encoding library $@
|
2013-02-25 10:47:23 +04:00
|
|
|
$(Q) $(AR) $(ARFLAGS)$@ $(ENCOBJS)
|
2012-05-16 09:39:06 +04:00
|
|
|
@-$(RANLIB) $@ 2> /dev/null || true
|
|
|
|
$(LIBTRANS): $(TRANSOBJS)
|
|
|
|
@$(RM) $@
|
|
|
|
$(ECHO) linking statically-linked transcoder library $@
|
2013-02-25 10:47:23 +04:00
|
|
|
$(Q) $(AR) $(ARFLAGS)$@ $(TRANSOBJS)
|
2012-05-16 09:39:06 +04:00
|
|
|
@-$(RANLIB) $@ 2> /dev/null || true
|
2008-08-06 09:40:13 +04:00
|
|
|
|
|
|
|
srcs: $(TRANSCSRCS)
|
2007-12-17 11:19:29 +03:00
|
|
|
|
2008-08-12 09:25:14 +04:00
|
|
|
<%=transvpath_prefix%>.trans<%=transvpath_prefix%>.c:
|
2010-11-11 15:46:23 +03:00
|
|
|
$(ECHO) generating table from $@
|
2010-12-29 14:27:36 +03:00
|
|
|
$(Q)$(MINIRUBY) "$(srcdir)/tool/transcode-tblgen.rb" -vo "$@" "$<"
|
2008-08-12 09:25:14 +04:00
|
|
|
|
2012-05-16 09:39:06 +04:00
|
|
|
% unless ENCS.empty? or TRANS.empty?
|
2007-12-17 19:15:46 +03:00
|
|
|
|
2012-05-16 09:39:06 +04:00
|
|
|
% unless ENCS.empty?
|
2013-04-08 18:56:01 +04:00
|
|
|
$(ENCOBJS): $(hdrdir)/ruby.h regenc.h oniguruma.h config.h defines.h ruby.h missing.h subst.h intern.h st.h encoding.h
|
2007-12-24 06:49:56 +03:00
|
|
|
% end
|
2012-05-21 07:11:28 +04:00
|
|
|
% ENC_DEPS.each do |e, deps|
|
|
|
|
enc/<%=e%>.$(OBJEXT): <%=deps.map {|n| rule_subst % n}.join(' ')%>
|
|
|
|
% end
|
2012-05-16 09:39:06 +04:00
|
|
|
% unless TRANS.empty?
|
2013-04-08 18:56:01 +04:00
|
|
|
$(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
|
2007-12-24 06:49:56 +03:00
|
|
|
% end
|
2012-05-16 09:39:06 +04:00
|
|
|
% ATRANS.each do |e|
|
2008-08-11 11:39:52 +04:00
|
|
|
% src = "#{e}.trans"
|
2008-08-05 22:15:52 +04:00
|
|
|
|
2008-08-12 09: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"}]
|
2012-02-25 11:08:47 +04:00
|
|
|
<%=transvpath % "#{e}.c"%>: <%= src.map {|s| transvpath % "#{s}"}.join(" ")%> $(srcdir)/tool/transcode-tblgen.rb
|
2008-08-05 22:15:52 +04:00
|
|
|
% end
|
2007-12-22 21:35:53 +03:00
|
|
|
|
|
|
|
% end
|
2012-12-10 08:32:11 +04:00
|
|
|
% link_so = LINK_SO.gsub(/([^\\])\n/, "\\1\n$(Q) ").gsub(/\n/, "\n\t")
|
2007-12-24 06:49:56 +03: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 15:46:23 +03: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-23 00:51:18 +03:00
|
|
|
% cmd = link_so.sub(/\$\(OBJS\)/) {obj}
|
|
|
|
% base = File.basename(e)
|
2007-12-24 06:49:56 +03:00
|
|
|
% if df
|
2010-12-29 14:27:36 +03:00
|
|
|
$(Q)echo> <%=df%> EXPORTS
|
|
|
|
$(Q)echo>> <%=df%> <%=EXPORT_PREFIX%>Init_<%=base%>
|
2009-03-23 00:51:18 +03:00
|
|
|
% cmd.sub!(/\$\(DEFFILE\)/) {df}
|
|
|
|
% cmd.gsub!(/-(?:implib|pdb):/) {|s|"#{s}enc/#{e.sub(/[^\/]+\z/, '')}"}
|
2007-12-22 21:35:53 +03:00
|
|
|
% end
|
2010-12-29 14:27:36 +03:00
|
|
|
$(Q)$(MAKEDIRS) "$(@D)"
|
|
|
|
$(Q)<%=cmd%>
|
2007-12-24 06:49:56 +03:00
|
|
|
|
2007-12-22 21:35:53 +03:00
|
|
|
% end
|
2007-12-24 06:49:56 +03:00
|
|
|
% dependencies.each do |e|
|
2009-01-30 08:13:22 +03:00
|
|
|
<%="enc/#{e}.$(OBJEXT)"%>: <%="$(encsrcdir)/#{e}.c"%>
|
2010-12-29 14:27:36 +03:00
|
|
|
-$(Q)$(MAKEDIRS) "$(@D)"
|
2011-06-16 04:10:10 +04:00
|
|
|
$(ECHO) compiling <%= "$(encsrcdir)/#{e}.c"%>
|
2010-12-29 14:27:36 +03:00
|
|
|
$(Q)<%=COMPILE_C.gsub(/\$(\()?<(\:[^)]+)?(\))?/){"$(encsrcdir)/#{e}.c"}%>
|
2009-01-30 08:13:22 +03:00
|
|
|
|
2007-12-22 21:35:53 +03:00
|
|
|
% end
|
2007-12-19 20:23:24 +03:00
|
|
|
|
2008-04-07 10:51:33 +04:00
|
|
|
enc/encdb.$(OBJEXT): encdb.h
|
|
|
|
enc/trans/transdb.$(OBJEXT): transdb.h
|
|
|
|
|
2007-12-19 20:23:24 +03:00
|
|
|
clean:
|
2012-05-16 09:39:06 +04:00
|
|
|
% %w[$(ENCSOS) $(LIBENC) $(ENCOBJS) $(ENCCLEANOBJS) $(ENCCLEANLIBS) $(TRANSSOS) $(LIBTRANS) $(TRANSOBJS) $(TRANSCLEANOBJS) $(TRANSCLEANLIBS)].each do |clean|
|
2010-12-29 14:27:36 +03:00
|
|
|
$(Q)$(RM) <%=pathrep[clean]%>
|
2008-08-07 09:17:34 +04:00
|
|
|
% end
|
2010-08-06 12:44:33 +04:00
|
|
|
% @ignore_error = $nmake ? '' : ' 2> /dev/null || true'
|
2010-12-29 14:31:23 +03:00
|
|
|
% unless inplace
|
|
|
|
$(Q)$(RM) enc/unicode/name2ctype.h
|
|
|
|
-$(Q)$(RMDIR) enc/unicode<%=@ignore_error%>
|
|
|
|
% end
|
2012-02-25 11:08:47 +04:00
|
|
|
% workdirs.reverse_each do|d|
|
|
|
|
-$(Q)$(RMDIR) <%=pathrep[d]%><%=@ignore_error%>
|
2008-12-08 18:17:52 +03:00
|
|
|
% end
|
|
|
|
|
|
|
|
clean-srcs:
|
2010-12-29 14:27:36 +03: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%>
|
2012-05-16 09:39:06 +04:00
|
|
|
|
|
|
|
<%# vim: set ft=eruby noexpandtab ts=8 sw=2 : -%>
|