From 3fa3f9abb9a187a12089c2c5a650a62dbd82a3dd Mon Sep 17 00:00:00 2001 From: yugui Date: Wed, 16 May 2012 05:39:06 +0000 Subject: Supports static linking of extensions and encodings again. Fixes --with-static-linked-ext. Patch by Google Inc. [ruby-core:45073]. * Makefile.in (ENCOBJS, EXTOBJS): New variables to specify static linked libraries. Also reintroduces extinit.o, introduces encinit.o introduces encinit.o * common.mk: Builds static libraries rather than shared objects if specified. * configure.in (LD): new substitution. Avoids PIE if s * enc/depend: Supports static linked libraries (libencs, libenc, libtrans): New target. * enc/encinit.c.erb: new template to generate the initialization of statically linked encodings. * enc/make_encmake.rb (--module): new flag to specify whether static or dynamic. * transcode_data.h (TRANS_INIT): New macro to get rid of the name collision of encoding initializers and transcoder initializers. * ext/extmk.rb: Fixes the behavior on $extstatic is true. * lib/mkmf.rb (clean-static): new target to clean up static linked libraries. * ruby.c (process_options): New initializes statically linked encodings here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- enc/encinit.c.erb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 enc/encinit.c.erb (limited to 'enc/encinit.c.erb') diff --git a/enc/encinit.c.erb b/enc/encinit.c.erb new file mode 100644 index 0000000000..17b94027d0 --- /dev/null +++ b/enc/encinit.c.erb @@ -0,0 +1,26 @@ +<%# -*- encoding: UTF-8 -*-%> +/* Copyright 2012 Google Inc. Some Rights Reserved. + * Author: yugui@google.com (Yugui Sonoda) + */ +#include + +#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_enc() +{ + <% ENCS.each do |enc| -%> + init(Init_<%= enc %>, "enc/<%= enc %>.so"); + <% end -%> + + init(Init_transdb, "enc/trans/transdb.so"); + <% TRANS.each do |trans| -%> + <% next if trans == 'trans/transdb' -%> + init(Init_trans_<%= File.basename trans %>, "enc/<%= trans %>.so"); + <% end -%> +} +<%# vim: set fenc=utf-8 ft=eruby sw=2 : -%> -- cgit v1.2.3