ruby/template/configure-ext.mk.tmpl

45 строки
1.0 KiB
Cheetah

V = 0
Q1 = $(V:1=)
Q = $(Q1:0=@)
ECHO1 = $(V:1=@:)
ECHO = $(ECHO1:0=@echo)
<%
srcdir = miniruby = script_args = nil
opt = OptionParser.new do |o|
o.on('--srcdir=SRCDIR') {|v| srcdir = v}
o.on('--miniruby=MINIRUBY') {|v| miniruby = v}
o.on('--script-args=MINIRUBY') {|v| script_args = v}
o.order!(ARGV)
end
srcdir ||= File.dirname(File.dirname(__FILE__))
exts = {}
[
["exts", "ext", "--extstatic $(EXTSTATIC)"],
["gems", "gems", "--no-extstatic"],
].each do |t, dir, opt|
exts[t] = [opt, Dir.glob("#{srcdir}/#{dir}/*/").map {|n| n[(srcdir.size+1)..-2]}]
end
%>
MINIRUBY = <%=miniruby%>
SCRIPT_ARGS = <%=script_args%>
EXTMK_ARGS = $(SCRIPT_ARGS) --gnumake=$(gnumake) --extflags="$(EXTLDFLAGS)" \
--make-flags='MINIRUBY=$(MINIRUBY)'
all: exts gems
exts:
gems:
% exts.each do |t, (opt, dirs)|
% dirs.each do |dir|
<%=t%>: <%=dir%>/exts.mk
<%=dir%>/exts.mk: FORCE
$(Q)$(MINIRUBY) $(srcdir)/ext/extmk.rb --make='$(MAKE)' \
--command-output=$@ $(EXTMK_ARGS) <%=opt%> \
-- configure $(@D)
% end
% end
.PHONY: FORCE all exts gems
FORCE: