mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
template/extinit.c.tmpl
* template/extinit.c.tmpl: separate from ext/extmk.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
709a60f92d
commit
78b95b49f8
3 changed files with 24 additions and 21 deletions
|
@ -220,6 +220,10 @@ build-ext: $(EXTS_MK)
|
||||||
$(Q)$(MAKE) -f $(EXTS_MK) $(MFLAGS) libdir="$(libdir)" LIBRUBY_EXTS=$(LIBRUBY_EXTS) \
|
$(Q)$(MAKE) -f $(EXTS_MK) $(MFLAGS) libdir="$(libdir)" LIBRUBY_EXTS=$(LIBRUBY_EXTS) \
|
||||||
EXTENCS="$(ENCOBJS)" UPDATE_LIBRARIES=no $(EXTSTATIC)
|
EXTENCS="$(ENCOBJS)" UPDATE_LIBRARIES=no $(EXTSTATIC)
|
||||||
|
|
||||||
|
ext/extinit.c: $(srcdir)/template/extinit.c.tmpl
|
||||||
|
$(Q)$(MINIRUBY) $(srcdir)/tool/generic_erb.rb -o $@ -c \
|
||||||
|
$(srcdir)/template/extinit.c.tmpl $(EXTINITS)
|
||||||
|
|
||||||
prog: program wprogram
|
prog: program wprogram
|
||||||
|
|
||||||
$(PREP): $(MKFILES)
|
$(PREP): $(MKFILES)
|
||||||
|
|
25
ext/extmk.rb
25
ext/extmk.rb
|
@ -11,7 +11,6 @@ $destdir = nil
|
||||||
$dryrun = false
|
$dryrun = false
|
||||||
$clean = nil
|
$clean = nil
|
||||||
$nodynamic = nil
|
$nodynamic = nil
|
||||||
$extinit = nil
|
|
||||||
$extobjs = []
|
$extobjs = []
|
||||||
$extflags = ""
|
$extflags = ""
|
||||||
$extlibs = nil
|
$extlibs = nil
|
||||||
|
@ -642,13 +641,12 @@ if $ignore
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
$extinit ||= ""
|
|
||||||
$extobjs ||= []
|
$extobjs ||= []
|
||||||
$extpath ||= []
|
$extpath ||= []
|
||||||
$extflags ||= ""
|
$extflags ||= ""
|
||||||
$extlibs ||= []
|
$extlibs ||= []
|
||||||
|
extinits = {}
|
||||||
unless $extlist.empty?
|
unless $extlist.empty?
|
||||||
$extinit << "\n" unless $extinit.empty?
|
|
||||||
list = $extlist.dup
|
list = $extlist.dup
|
||||||
built = []
|
built = []
|
||||||
while e = list.shift
|
while e = list.shift
|
||||||
|
@ -662,27 +660,11 @@ unless $extlist.empty?
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
base = File.basename(feature)
|
base = File.basename(feature)
|
||||||
$extinit << " init(Init_#{base}, \"#{feature}.so\");\n"
|
extinits[base] = feature
|
||||||
$extobjs << format("ext/%s/%s.%s", target, base, $LIBEXT)
|
$extobjs << format("ext/%s/%s.%s", target, base, $LIBEXT)
|
||||||
built << target
|
built << target
|
||||||
end
|
end
|
||||||
|
|
||||||
src = %{\
|
|
||||||
#include "ruby/ruby.h"
|
|
||||||
|
|
||||||
#define init(func, name) { \\
|
|
||||||
extern void func(void); \\
|
|
||||||
ruby_init_ext(name, func); \\
|
|
||||||
}
|
|
||||||
|
|
||||||
void ruby_init_ext(const char *name, void (*init)(void));
|
|
||||||
|
|
||||||
void Init_ext(void)\n{\n#$extinit}
|
|
||||||
}
|
|
||||||
if !modified?(extinit.c, MTIMES) || IO.read(extinit.c) != src
|
|
||||||
open(extinit.c, "w") {|fe| fe.print src}
|
|
||||||
end
|
|
||||||
|
|
||||||
$extpath.delete("$(topdir)")
|
$extpath.delete("$(topdir)")
|
||||||
$extflags = libpathflag($extpath) << " " << $extflags.strip
|
$extflags = libpathflag($extpath) << " " << $extflags.strip
|
||||||
conf = [
|
conf = [
|
||||||
|
@ -749,6 +731,7 @@ if $configure_only and $command_output
|
||||||
mf.macro "EXTLIBS", $extlibs
|
mf.macro "EXTLIBS", $extlibs
|
||||||
mf.macro "EXTSO", extso
|
mf.macro "EXTSO", extso
|
||||||
mf.macro "EXTLDFLAGS", $extflags.split
|
mf.macro "EXTLDFLAGS", $extflags.split
|
||||||
|
mf.macro "EXTINITS", extinits.map {|k, v| "#{k},#{v}"}
|
||||||
submakeopts = []
|
submakeopts = []
|
||||||
if enable_config("shared", $enable_shared)
|
if enable_config("shared", $enable_shared)
|
||||||
submakeopts << 'DLDOBJS="$(EXTOBJS) $(EXTENCS)"'
|
submakeopts << 'DLDOBJS="$(EXTOBJS) $(EXTENCS)"'
|
||||||
|
@ -785,7 +768,7 @@ if $configure_only and $command_output
|
||||||
mf.puts "#{tgt}:\n\t#{submake} $@"
|
mf.puts "#{tgt}:\n\t#{submake} $@"
|
||||||
end
|
end
|
||||||
mf.puts "libencs:\n\t$(Q)$(MAKE) -f enc.mk V=$(V) $@"
|
mf.puts "libencs:\n\t$(Q)$(MAKE) -f enc.mk V=$(V) $@"
|
||||||
mf.puts "ext/extinit.#{$OBJEXT}:\n\t$(Q)$(MAKE) $(MFLAGS) V=$(V) $@" if $static
|
mf.puts "ext/extinit.#{$OBJEXT}:\n\t$(Q)$(MAKE) $(MFLAGS) V=$(V) EXTINITS=\"$(EXTINITS)\" $@" if $static
|
||||||
mf.puts
|
mf.puts
|
||||||
if $gnumake == "yes"
|
if $gnumake == "yes"
|
||||||
submake = "$(MAKE) -C $(@D)"
|
submake = "$(MAKE) -C $(@D)"
|
||||||
|
|
16
template/extinit.c.tmpl
Normal file
16
template/extinit.c.tmpl
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
%# -*- C -*-
|
||||||
|
#include "ruby/ruby.h"
|
||||||
|
|
||||||
|
#define init(func, name) { \
|
||||||
|
extern void func(void); \
|
||||||
|
ruby_init_ext(name, func); \
|
||||||
|
}
|
||||||
|
|
||||||
|
void ruby_init_ext(const char *name, void (*init)(void));
|
||||||
|
|
||||||
|
void Init_ext(void)
|
||||||
|
{
|
||||||
|
% ARGV.each do |n|
|
||||||
|
init(Init_<%=n.sub(/,(.*)/, ', "\1.so"')%>);
|
||||||
|
% end
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue