diff options
-rw-r--r-- | ChangeLog | 36 | ||||
-rw-r--r-- | Makefile.in | 15 | ||||
-rw-r--r-- | common.mk | 26 | ||||
-rw-r--r-- | configure.in | 39 | ||||
-rw-r--r-- | dmyext.c | 5 | ||||
-rw-r--r-- | enc/Makefile.in | 3 | ||||
-rw-r--r-- | enc/depend | 71 | ||||
-rw-r--r-- | enc/encinit.c.erb | 26 | ||||
-rwxr-xr-x | enc/make_encmake.rb | 62 | ||||
-rw-r--r-- | enc/trans/big5.trans | 3 | ||||
-rw-r--r-- | enc/trans/chinese.trans | 3 | ||||
-rw-r--r-- | enc/trans/emoji.trans | 3 | ||||
-rw-r--r-- | enc/trans/emoji_iso2022_kddi.trans | 3 | ||||
-rw-r--r-- | enc/trans/emoji_sjis_docomo.trans | 3 | ||||
-rw-r--r-- | enc/trans/emoji_sjis_kddi.trans | 3 | ||||
-rw-r--r-- | enc/trans/emoji_sjis_softbank.trans | 3 | ||||
-rw-r--r-- | enc/trans/escape.trans | 3 | ||||
-rw-r--r-- | enc/trans/gb18030.trans | 3 | ||||
-rw-r--r-- | enc/trans/gbk.trans | 3 | ||||
-rw-r--r-- | enc/trans/iso2022.trans | 3 | ||||
-rw-r--r-- | enc/trans/japanese.trans | 3 | ||||
-rw-r--r-- | enc/trans/japanese_euc.trans | 3 | ||||
-rw-r--r-- | enc/trans/japanese_sjis.trans | 3 | ||||
-rw-r--r-- | enc/trans/korean.trans | 3 | ||||
-rw-r--r-- | enc/trans/single_byte.trans | 3 | ||||
-rw-r--r-- | enc/trans/utf8_mac.trans | 3 | ||||
-rw-r--r-- | enc/trans/utf_16_32.trans | 3 | ||||
-rwxr-xr-x | ext/extmk.rb | 73 | ||||
-rw-r--r-- | lib/mkmf.rb | 11 | ||||
-rw-r--r-- | ruby.c | 4 | ||||
-rw-r--r-- | transcode_data.h | 10 |
31 files changed, 306 insertions, 129 deletions
@@ -1,3 +1,39 @@ +Wed May 16 14:19:51 2012 Yuki Yugui Sonoda <yugui@google.com> + + 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. + + * 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. + Wed May 16 14:30:43 2012 NAKAMURA Usaku <usa@ruby-lang.org> * io.c: fixed a merge mistake of r33878, reported by nobu via IRC. diff --git a/Makefile.in b/Makefile.in index bae0ce103c..721dc2ae03 100644 --- a/Makefile.in +++ b/Makefile.in @@ -16,6 +16,7 @@ PLATFORM_DIR = @PLATFORM_DIR@ CC = @CC@ CPP = @CPP@ +LD = @LD@ YACC = bison PURIFY = AUTOCONF = autoconf @@ -70,6 +71,8 @@ DLDFLAGS = @LIBRUBY_DLDFLAGS@ $(XLDFLAGS) $(ARCH_FLAG) SOLIBS = @SOLIBS@ MAINLIBS = @MAINLIBS@ ARCHMINIOBJS = @MINIOBJS@ +ENCOBJS = @ENCOBJS@ +EXTOBJS = @EXTOBJS@ BUILTIN_ENCOBJS = @BUILTIN_ENCOBJS@ BUILTIN_TRANSSRCS = @BUILTIN_TRANSSRCS@ BUILTIN_TRANSOBJS = @BUILTIN_TRANSOBJS@ @@ -175,7 +178,7 @@ miniruby$(EXEEXT): $(PROGRAM): @$(RM) $@ $(ECHO) linking $@ - $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) $(OUTFLAG)$@ + $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(EXTOBJS) $(ENCOBJS) $(LIBRUBYARG) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@ $(Q) $(POSTLINK) # We must `rm' the library each time this rule is invoked because "updating" a @@ -186,8 +189,9 @@ $(LIBRUBY_A): $(ECHO) linking static-library $@ $(Q) $(AR) $(ARFLAGS) $@ $(OBJS) $(DMYEXT) @-$(RANLIB) $@ 2> /dev/null || true + $(ECHO) verifying static-library $@ @$(PURIFY) $(CC) $(XLDFLAGS) $(MAINOBJ) $(LIBRUBY_A) $(MAINLIBS) $(EXTLIBS) $(LIBS) $(OUTFLAG)conftest$(EXEEXT) $(LDFLAGS) - @$(RM) conftest$(EXEEXT) + @$(RM) conftset$(EXEEXT) conftest.c $(LIBRUBY_SO): @-$(PRE_LIBRUBY_UPDATE) @@ -311,7 +315,8 @@ enc/unicode/name2ctype.h: enc/unicode/name2ctype.kwd $(Q) $(CPP) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -E $< > $@ clean-local:: - $(Q)$(RM) ext/extinit.c ext/extinit.$(OBJEXT) ext/ripper/y.output + $(Q)$(RM) ext/extinit.c ext/extinit.$(OBJEXT) ext/ripper/y.output \ + enc/encinit.c enc/encinit.$(OBJEXT) -$(Q)$(RM) $(pkgconfig_DATA) distclean-local:: @@ -335,8 +340,10 @@ clean-ext distclean-ext realclean-ext:: $(RMDIRS) "ext/$$dir" 2> /dev/null || true;; \ esac; \ done + -$(Q)$(RM) ext/extinit.$(OBJEXT) distclean-ext realclean-ext:: + -$(Q)$(RM) ext/extinit.c -$(Q)$(RMDIR) ext 2> /dev/null || true clean-extout: @@ -362,6 +369,8 @@ ext/extinit.$(OBJEXT): ext/extinit.c $(SETUP) $(ECHO) compiling $@ $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c ext/extinit.c +enc/encinit.$(OBJEXT): enc/encinit.c $(SETUP) + up:: @$(CHDIR) "$(srcdir)" && LC_TIME=C exec $(VCSUP) @@ -32,7 +32,6 @@ ID_H_TARGET = -id.h- DMYEXT = dmyext.$(OBJEXT) NORMALMAINOBJ = main.$(OBJEXT) MAINOBJ = $(NORMALMAINOBJ) -EXTOBJS = DLDOBJS = $(DMYEXT) MINIOBJS = $(ARCHMINIOBJS) dmyencoding.$(OBJEXT) dmyversion.$(OBJEXT) miniprelude.$(OBJEXT) ENC_MK = enc.mk @@ -141,7 +140,7 @@ COMPILE_PRELUDE = $(MINIRUBY) -I$(srcdir) $(srcdir)/tool/compile_prelude.rb all: showflags main docs -main: showflags encs exts +main: showflags $(EXTSTATIC:static=lib)encs exts @$(NULLCMD) .PHONY: showflags @@ -168,12 +167,13 @@ exts: build-ext EXTS_MK = exts.mk $(EXTS_MK): $(MKFILES) incs $(PREP) $(RBCONFIG) $(LIBRUBY) + $(ECHO) generating makefile $@ $(Q)$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --command-output=$(EXTS_MK) $(EXTMK_ARGS) configure configure-ext: $(EXTS_MK) build-ext: $(EXTS_MK) - $(Q)$(MAKE) -f $(EXTS_MK) $(MFLAGS) + $(Q)$(MAKE) -f $(EXTS_MK) $(MFLAGS) $(EXTSTATIC) $(MKMAIN_CMD): $(MKFILES) incs $(PREP) $(RBCONFIG) $(LIBRUBY) $(Q)$(MINIRUBY) $(srcdir)/ext/extmk.rb --make="$(MAKE)" --command-output=$@ $(EXTMK_ARGS) @@ -206,7 +206,7 @@ Doxyfile: $(srcdir)/template/Doxyfile.tmpl $(PREP) $(srcdir)/tool/generic_erb.rb program: showflags $(PROGRAM) wprogram: showflags $(WPROGRAM) -$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(SETUP) $(PREP) +$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(ENCOBJS) $(SETUP) $(PREP) $(LIBRUBY_A): $(OBJS) $(MAINOBJ) $(DMYEXT) $(ARCHFILE) @@ -519,17 +519,21 @@ test-rubyspec: test-rubyspec-precheck $(RUNRUBY) $(srcdir)/spec/mspec/bin/mspec run -B $(srcdir)/spec/default.mspec $(MSPECOPT) encs: enc trans -encs enc trans: showflags $(ENC_MK) $(LIBRUBY) $(PREP) +libencs: libenc libtrans +encs enc trans libencs libenc libtrans: showflags $(ENC_MK) $(LIBRUBY) $(PREP) $(ECHO) making $@ - $(Q) $(MAKE) -f $(ENC_MK) RUBY="$(MINIRUBY)" MINIRUBY="$(MINIRUBY)" $(MFLAGS) $@ + $(Q) $(MAKE) -f $(ENC_MK) V="$(V)" \ + RUBY="$(MINIRUBY)" MINIRUBY="$(MINIRUBY)" \ + $(MFLAGS) $@ -enc: {$(VPATH)}encdb.h -trans: {$(VPATH)}transdb.h + +libenc enc: {$(VPATH)}encdb.h +libtrans trans: {$(VPATH)}transdb.h $(ENC_MK): $(srcdir)/enc/make_encmake.rb $(srcdir)/enc/Makefile.in $(srcdir)/enc/depend \ - $(srcdir)/lib/mkmf.rb $(RBCONFIG) + $(srcdir)/enc/encinit.c.erb $(srcdir)/lib/mkmf.rb $(RBCONFIG) $(ECHO) generating $@ - $(Q) $(MINIRUBY) $(srcdir)/enc/make_encmake.rb --builtin-encs="$(BUILTIN_ENCOBJS)" --builtin-transes="$(BUILTIN_TRANSOBJS)" $@ $(ENCS) + $(Q) $(MINIRUBY) $(srcdir)/enc/make_encmake.rb --builtin-encs="$(BUILTIN_ENCOBJS)" --builtin-transes="$(BUILTIN_TRANSOBJS)" --module$(EXTSTATIC) $@ $(ENCS) .PRECIOUS: $(MKFILES) @@ -833,6 +837,8 @@ transdb.h: $(PREP) srcs-enc $(srcdir)/tool/generic_erb.rb $(srcdir)/template/tra $(ECHO) generating $@ $(Q) $(MINIRUBY) $(srcdir)/tool/generic_erb.rb -c -o $@ $(srcdir)/template/transdb.h.tmpl $(srcdir)/enc/trans enc/trans +enc/encinit.c: $(ENC_MK) $(srcdir)/enc/encinit.c.erb + known_errors.inc: $(srcdir)/template/known_errors.inc.tmpl $(srcdir)/defs/known_errors.def $(ECHO) generating $@ $(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb -c -o $@ $(srcdir)/template/known_errors.inc.tmpl $(srcdir)/defs/known_errors.def diff --git a/configure.in b/configure.in index d0043b824e..ee7bb05e1d 100644 --- a/configure.in +++ b/configure.in @@ -291,6 +291,8 @@ AC_PROG_CC AC_PROG_CXX AC_PROG_GCC_TRADITIONAL AC_SUBST(GCC) +AC_CHECK_TOOL([LD], [ld], [ld]) +AC_SUBST(LD) if test "$GCC" = yes; then linker_flag=-Wl, : ${optflags=-O3} @@ -2095,7 +2097,7 @@ if test "$with_dln_a_out" != yes; then AS_CASE(["$target_os"], [hpux*], [ DLDFLAGS="$DLDFLAGS -E" - : ${LDSHARED='ld -b'} + : ${LDSHARED="$(LD) -b"} XLDFLAGS="$XLDFLAGS -Wl,-E" : ${LIBPATHENV=SHLIB_PATH} if test "$rb_cv_prog_gnu_ld" = no; then @@ -2114,17 +2116,17 @@ if test "$with_dln_a_out" != yes; then : ${LIBPATHENV=LD_LIBRARY_PATH_64} fi rb_cv_dlopen=yes], - [sunos*], [ : ${LDSHARED='ld -assert nodefinitions'} + [sunos*], [ : ${LDSHARED="$(LD) -assert nodefinitions"} rb_cv_dlopen=yes], - [irix*], [ : ${LDSHARED='ld -shared'} + [irix*], [ : ${LDSHARED="$(LD) -shared"} rb_cv_dlopen=yes], - [sysv4*], [ : ${LDSHARED='ld -G'} + [sysv4*], [ : ${LDSHARED="$(LD) -G"} rb_cv_dlopen=yes], [nto-qnx*], [ : ${LDSHARED='$(CC) -shared'} rb_cv_dlopen=yes], - [esix*|uxpds*], [ : ${LDSHARED="ld -G"} + [esix*|uxpds*], [ : ${LDSHARED="$(LD) -G"} rb_cv_dlopen=yes], - [osf*], [ : ${LDSHARED="ld -shared -expect_unresolved \"*\""} + [osf*], [ : ${LDSHARED="$(LD) -shared -expect_unresolved \"*\""} rb_cv_dlopen=yes], [bsdi3*], [ AS_CASE(["$CC"], [*shlicc*], [ : ${LDSHARED='$(CC) -r'} @@ -2145,7 +2147,7 @@ if test "$with_dln_a_out" != yes; then LDFLAGS="$LDFLAGS -rdynamic" DLDFLAGS="$DLDFLAGS "'-Wl,-soname,$(.TARGET)' else - test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED="ld -Bshareable" + test "$GCC" = yes && test "$rb_cv_prog_gnu_ld" = yes || LDSHARED="$(LD) -Bshareable" fi rb_cv_dlopen=yes], [openbsd*], [ : ${LDSHARED='$(CC) -shared ${CCDLFLAGS}'} @@ -2179,12 +2181,12 @@ if test "$with_dln_a_out" != yes; then rb_cv_dlopen=yes], [beos*], [ AS_CASE(["$target_cpu"], [powerpc*], [ - : ${LDSHARED="ld -xms"} + : ${LDSHARED="$(LD) -xms"} DLDFLAGS="$DLDFLAGS "'-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o' LDFLAGS="$LDFLAGS -L/boot/home/config/lib -lbe -lroot" ], [i586*], [ - : ${LDSHARED="ld -shared"} + : ${LDSHARED="$(LD) -shared"} DLDFLAGS="$DLDFLAGS -L/boot/develop/lib/x86 -L/boot/home/config/lib \$(topdir)/_APP_ -lbe -lroot" LDFLAGS="$LDFLAGS -L/boot/develop/lib/x86 -L/boot/home/config/lib -lbe -lroot" ]) @@ -2192,17 +2194,17 @@ if test "$with_dln_a_out" != yes; then rb_cv_dlopen=yes], [haiku*], [ AS_CASE(["$target_cpu"], [powerpc*], [ - : ${LDSHARED="ld -xms"} + : ${LDSHARED="$(LD) -xms"} DLDFLAGS="$DLDFLAGS "'-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o' ], [i586*], [ - : ${LDSHARED="ld -shared"} + : ${LDSHARED="$(LD) -shared"} DLDFLAGS="$DLDFLAGS -L/boot/develop/lib/x86 -lbe -lroot" ]) : ${LIBPATHENV=LIBRARY_PATH} rb_cv_dlopen=yes ], [nto-qnx*], [ DLDFLAGS="$DLDFLAGS -L/lib -L/usr/lib -L/usr/local/lib" - : ${LDSHARED='ld -Bshareable -x'} + : ${LDSHARED="$(LD) -Bshareable -x"} LDFLAGS="$LDFLAGS -L/lib -L/usr/lib -L/usr/local/lib" rb_cv_dlopen=yes], [cygwin*|mingw*], [ @@ -2211,12 +2213,12 @@ if test "$with_dln_a_out" != yes; then DLDFLAGS="${DLDFLAGS} -Wl,--enable-auto-image-base,--enable-auto-import" : ${LIBPATHENV=""} rb_cv_dlopen=yes], - [hiuxmpp], [ : ${LDSHARED='ld -r'}], + [hiuxmpp], [ : ${LDSHARED="$(LD) -r"}], [atheos*], [ : ${LDSHARED='$(CC) -shared'} rb_cv_dlopen=yes], [os2-emx*], [ LDFLAGS="$LDFLAGS -Zomf" ], - [ : ${LDSHARED='ld'}]) + [ : ${LDSHARED="$(LD)"}]) AC_MSG_RESULT($rb_cv_dlopen) fi if test "${LDSHAREDXX}" = ""; then @@ -2324,6 +2326,13 @@ AC_SUBST(EXTSTATIC)dnl AC_ARG_WITH(static-linked-ext, AS_HELP_STRING([--with-static-linked-ext], [link external modules statically]), [AS_CASE([$withval],[yes],[STATIC=;EXTSTATIC=static])]) +if test x"$EXTSTATIC" = xstatic; then + ENCOBJS='enc/encinit.$(OBJEXT) enc/libenc.a enc/libtrans.a' + EXTOBJS='ext/extinit.$(OBJEXT) ext/libext.a' + AC_DEFINE_UNQUOTED(EXTSTATIC, 1) +fi +AC_SUBST(ENCOBJS) +AC_SUBST(EXTOBJS) AS_CASE(["$target_os"], dnl OS/2 environment w/ Autoconf 2.1x for EMX @@ -2507,7 +2516,7 @@ AS_CASE("$enable_shared", [yes], [ LIBRUBYARG_SHARED= # enable PIE if possible - if test "$GCC" = yes; then + if test "$GCC" = yes and -z "$EXTSTATIC"; then RUBY_TRY_CFLAGS(-fPIE, [pie=yes], [pie=no]) if test "$pie" = yes; then RUBY_APPEND_OPTION(XCFLAGS, -fPIE) @@ -2,3 +2,8 @@ void Init_ext(void) { } + +void +Init_enc() +{ +} diff --git a/enc/Makefile.in b/enc/Makefile.in index 203a83dbfd..44e714a440 100644 --- a/enc/Makefile.in +++ b/enc/Makefile.in @@ -20,6 +20,7 @@ ENCSODIR = $(EXTOUT)/$(arch)/enc TRANSSODIR = $(ENCSODIR)/trans DLEXT = @DLEXT@ OBJEXT = @OBJEXT@ +LIBEXT = @LIBEXT@ BUILTIN_ENCS = ascii.c us_ascii.c\ unicode.c utf_8.c @@ -32,7 +33,9 @@ LIBRUBYARG_SHARED = @LIBRUBYARG_SHARED@ LIBRUBYARG_STATIC = $(LIBRUBYARG_SHARED) empty = +AR = @AR@ CC = @CC@ +RANLIB = @RANLIB@ OUTFLAG = @OUTFLAG@$(empty) COUTFLAG = @COUTFLAG@$(empty) CFLAGS = $(CCDLFLAGS) @CFLAGS@ @ARCH_FLAG@ diff --git a/enc/depend b/enc/depend index ca6085dad9..d600616734 100644 --- a/enc/depend +++ b/enc/depend @@ -5,34 +5,7 @@ % dldflags = $2 % enable_shared = CONFIG['ENABLE_SHARED'] == 'yes' % deffile = (true if /\$\(DEFFILE\)/ =~ CONFIG["LINK_SO"]) -% encs = Dir.open($srcdir) {|d| d.grep(/.+\.c\z/)} - BUILTIN_ENCS - ["mktable.c"] -% encs.each {|e| e.chomp!(".c")} -% encs.reject! {|e| !ENC_PATTERNS.any? {|p| File.fnmatch?(p, e)}} if !ENC_PATTERNS.empty? -% encs.reject! {|e| NOENC_PATTERNS.any? {|p| File.fnmatch?(p, e)}} -% alphanumeric_order = proc {|e| e.scan(/(\d+)|(\D+)/).map {|n,a| a||[n.size,n.to_i]}.flatten} -% encs = encs.sort_by(&alphanumeric_order) -% encs.unshift(encs.delete("encdb")) -% atrans = [] -% trans = Dir.open($srcdir+"/trans") {|d| -% d.select {|e| -% if e.chomp!('.trans') -% atrans << e -% true -% elsif e.chomp!('.c') -% true -% end -% } -% } -% trans -= BUILTIN_TRANSES -% atrans -= BUILTIN_TRANSES -% trans.uniq! -% atrans = atrans.sort_by(&alphanumeric_order) -% trans = trans.sort_by(&alphanumeric_order) -% trans.unshift(trans.delete("transdb")) -% trans.compact! -% trans |= atrans -% trans.map! {|e| "trans/#{e}"} -% dependencies = encs + trans +% dependencies = ENCS + TRANS % cleanlibs = Shellwords.shellwords(CONFIG["cleanlibs"] || "") % cleanobjs = Shellwords.shellwords(CONFIG["cleanobjs"] || "") % cleanobjs << "$*.def" if deffile @@ -54,31 +27,51 @@ 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%> +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%> +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) <%=CONFIG['ARFLAGS'] || 'rcu' %> $@ $(ENCOBJS) + @-$(RANLIB) $@ 2> /dev/null || true +$(LIBTRANS): $(TRANSOBJS) + @$(RM) $@ + $(ECHO) linking statically-linked transcoder library $@ + $(Q) $(AR) <%=CONFIG['ARFLAGS'] || 'rcu' %> $@ $(TRANSOBJS) + @-$(RANLIB) $@ 2> /dev/null || true srcs: $(TRANSCSRCS) @@ -86,15 +79,15 @@ srcs: $(TRANSCSRCS) $(ECHO) generating table from $@ $(Q)$(MINIRUBY) "$(srcdir)/tool/transcode-tblgen.rb" -vo "$@" "$<" -% unless encs.empty? or trans.empty? +% unless ENCS.empty? or TRANS.empty? -% unless encs.empty? +% unless ENCS.empty? $(ENCOBJS): regenc.h oniguruma.h config.h defines.h % end -% unless trans.empty? +% unless TRANS.empty? $(TRANSOBJS): ruby.h intern.h config.h defines.h missing.h encoding.h oniguruma.h st.h transcode_data.h % end -% atrans.each do |e| +% ATRANS.each do |e| % src = "#{e}.trans" <%=transvpath % "#{e}.c"%>: <%= transvpath % "#{e}.trans"%> @@ -142,7 +135,7 @@ enc/encdb.$(OBJEXT): encdb.h enc/trans/transdb.$(OBJEXT): transdb.h clean: -% %w[$(ENCSOS) $(ENCOBJS) $(ENCCLEANOBJS) $(ENCCLEANLIBS) $(TRANSSOS) $(TRANSOBJS) $(TRANSCLEANOBJS) $(TRANSCLEANLIBS)].each do |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' @@ -160,3 +153,5 @@ clean-srcs: $(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 : -%> 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 <stdio.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_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 : -%> diff --git a/enc/make_encmake.rb b/enc/make_encmake.rb index ed3680313f..291774e60c 100755 --- a/enc/make_encmake.rb +++ b/enc/make_encmake.rb @@ -15,6 +15,7 @@ BUILTIN_ENCS = [] BUILTIN_TRANSES = [] ENC_PATTERNS = [] NOENC_PATTERNS = [] +module_type = :dynamic until ARGV.empty? case ARGV[0] @@ -30,11 +31,57 @@ until ARGV.empty? when /\A--no-encs=/ NOENC_PATTERNS.concat $'.split ARGV.shift + when /\A--module$/ + ARGV.shift + when /\A--modulestatic$/ + module_type = :static + ARGV.shift else break end end +ALPHANUMERIC_ORDER = proc {|e| e.scan(/(\d+)|(\D+)/).map {|n,a| a||[n.size,n.to_i]}.flatten} +def target_encodings + encs = Dir.open($srcdir) {|d| d.grep(/.+\.c\z/)} - BUILTIN_ENCS - ["mktable.c"] + encs.each {|e| e.chomp!(".c")} + encs.reject! {|e| !ENC_PATTERNS.any? {|p| File.fnmatch?(p, e)}} if !ENC_PATTERNS.empty? + encs.reject! {|e| NOENC_PATTERNS.any? {|p| File.fnmatch?(p, e)}} + encs = encs.sort_by(&ALPHANUMERIC_ORDER) + encs.unshift(encs.delete("encdb")) + return encs +end + +def target_transcoders + atrans = [] + trans = Dir.open($srcdir+"/trans") {|d| + d.select {|e| + if e.chomp!('.trans') + atrans << e + true + elsif e.chomp!('.c') + true + end + } + } + trans -= BUILTIN_TRANSES + atrans -= BUILTIN_TRANSES + trans.uniq! + atrans = atrans.sort_by(&ALPHANUMERIC_ORDER) + trans = trans.sort_by(&ALPHANUMERIC_ORDER) + trans.unshift(trans.delete("transdb")) + trans.compact! + trans |= atrans + trans.map! {|e| "trans/#{e}"} + + return atrans, trans +end + +# Constants that "depend" needs. +MODULE_TYPE = module_type +ENCS = target_encodings +ATRANS, TRANS = target_transcoders + if File.exist?(depend = File.join($srcdir, "depend")) erb = ERB.new(File.read(depend), nil, '%') erb.filename = depend @@ -48,3 +95,18 @@ mkin.gsub!(/@(#{CONFIG.keys.join('|')})@/) {CONFIG[$1]} open(ARGV[0], 'wb') {|f| f.puts mkin, dep } +if MODULE_TYPE == :static + erb = ERB.new(File.read(File.join($srcdir, "encinit.c.erb")), nil, '%-') + erb.filename = "enc/encinit.c.cerb" + tmp = erb.result(binding) + begin + Dir.mkdir 'enc' + rescue Errno::EEXIST + end + File.open("enc/encinit.c", "w") {|f| + f.puts "/* Automatically generated from enc/encinit.c.erb" + f.puts " * Do not edit." + f.puts " */" + f.puts tmp + } +end diff --git a/enc/trans/big5.trans b/enc/trans/big5.trans index 9dacfd1f7e..c85ada3731 100644 --- a/enc/trans/big5.trans +++ b/enc/trans/big5.trans @@ -26,8 +26,7 @@ <%= transcode_generated_code %> -void -Init_big5(void) +TRANS_INIT(big5) { <%= transcode_register_code %> } diff --git a/enc/trans/chinese.trans b/enc/trans/chinese.trans index 0662a3bebc..282c91aba7 100644 --- a/enc/trans/chinese.trans +++ b/enc/trans/chinese.trans @@ -25,8 +25,7 @@ <%= transcode_generated_code %> -void -Init_chinese(void) +TRANS_INIT(chinese) { <%= transcode_register_code %> } diff --git a/enc/trans/emoji.trans b/enc/trans/emoji.trans index 1cf13743a2..25d9fdd4d8 100644 --- a/enc/trans/emoji.trans +++ b/enc/trans/emoji.trans @@ -30,8 +30,7 @@ <%= transcode_generated_code %> -void -Init_emoji(void) +TRANS_INIT(emoji) { <%= transcode_register_code %> } diff --git a/enc/trans/emoji_iso2022_kddi.trans b/enc/trans/emoji_iso2022_kddi.trans index ccf3139d3c..ea180c1e42 100644 --- a/enc/trans/emoji_iso2022_kddi.trans +++ b/enc/trans/emoji_iso2022_kddi.trans @@ -208,8 +208,7 @@ rb_iso2022jp_kddi_encoder = { iso2022jp_kddi_encoder_reset_sequence_size, finish_iso2022jp_kddi_encoder }; -void -Init_emoji_iso2022_kddi(void) +TRANS_INIT(emoji_iso2022_kddi) { rb_register_transcoder(&rb_iso2022jp_kddi_decoder); rb_register_transcoder(&rb_iso2022jp_kddi_encoder); diff --git a/enc/trans/emoji_sjis_docomo.trans b/enc/trans/emoji_sjis_docomo.trans index 36e6e20339..5dd9c7a1e3 100644 --- a/enc/trans/emoji_sjis_docomo.trans +++ b/enc/trans/emoji_sjis_docomo.trans @@ -26,8 +26,7 @@ <%= transcode_generated_code %> -void -Init_emoji_sjis_docomo(void) +TRANS_INIT(emoji_sjis_docomo) { <%= transcode_register_code %> } diff --git a/enc/trans/emoji_sjis_kddi.trans b/enc/trans/emoji_sjis_kddi.trans index 654bed134e..6df62f14d1 100644 --- a/enc/trans/emoji_sjis_kddi.trans +++ b/enc/trans/emoji_sjis_kddi.trans @@ -27,8 +27,7 @@ <%= transcode_generated_code %> -void -Init_emoji_sjis_kddi(void) +TRANS_INIT(emoji_sjis_kddi) { <%= transcode_register_code %> } diff --git a/enc/trans/emoji_sjis_softbank.trans b/enc/trans/emoji_sjis_softbank.trans index c152d99c76..c520035347 100644 --- a/enc/trans/emoji_sjis_softbank.trans +++ b/enc/trans/emoji_sjis_softbank.trans @@ -26,8 +26,7 @@ <%= transcode_generated_code %> -void -Init_emoji_sjis_softbank(void) +TRANS_INIT(emoji_sjis_softbank) { <%= transcode_register_code %> } diff --git a/enc/trans/escape.trans b/enc/trans/escape.trans index a2fbebac33..550e4ac767 100644 --- a/enc/trans/escape.trans +++ b/enc/trans/escape.trans @@ -85,8 +85,7 @@ rb_escape_xml_attr_quote = { escape_xml_attr_quote_finish }; -void -Init_escape(void) +TRANS_INIT(escape) { <%= transcode_register_code %> rb_register_transcoder(&rb_escape_xml_attr_quote); diff --git a/enc/trans/gb18030.trans b/enc/trans/gb18030.trans index c7da4c64b4..94c866eb39 100644 --- a/enc/trans/gb18030.trans +++ b/enc/trans/gb18030.trans @@ -176,8 +176,7 @@ rb_to_GB18030 = { }; -void -Init_gb18030(void) +TRANS_INIT(gb18030) { rb_register_transcoder(&rb_from_GB18030); rb_register_transcoder(&rb_to_GB18030); diff --git a/enc/trans/gbk.trans b/enc/trans/gbk.trans index 0df148198e..3c2cf0c1af 100644 --- a/enc/trans/gbk.trans +++ b/enc/trans/gbk.trans @@ -9,8 +9,7 @@ <%= transcode_generated_code %> -void -Init_gbk(void) +TRANS_INIT(gbk) { <%= transcode_register_code %> } diff --git a/enc/trans/iso2022.trans b/enc/trans/iso2022.trans index 3f40cce3c8..a441f1596d 100644 --- a/enc/trans/iso2022.trans +++ b/enc/trans/iso2022.trans @@ -553,8 +553,7 @@ rb_cp50220_encoder = { iso2022jp_encoder_reset_sequence_size, finish_cp50220_encoder }; -void -Init_iso2022(void) +TRANS_INIT(iso2022) { rb_register_transcoder(&rb_iso2022jp_decoder); rb_register_transcoder(&rb_iso2022jp_encoder); diff --git a/enc/trans/japanese.trans b/enc/trans/japanese.trans index ce5d0bb70f..7ff024fa8d 100644 --- a/enc/trans/japanese.trans +++ b/enc/trans/japanese.trans @@ -90,8 +90,7 @@ rb_sjis2eucjp = { NULL, NULL, NULL, fun_so_sjis2eucjp }; -void -Init_japanese(void) +TRANS_INIT(japanese) { rb_register_transcoder(&rb_eucjp2sjis); rb_register_transcoder(&rb_sjis2eucjp); diff --git a/enc/trans/japanese_euc.trans b/enc/trans/japanese_euc.trans index ff976e4dd0..0f63272321 100644 --- a/enc/trans/japanese_euc.trans +++ b/enc/trans/japanese_euc.trans @@ -51,8 +51,7 @@ <%= transcode_generated_code %> -void -Init_japanese_euc(void) +TRANS_INIT(japanese_euc) { <%= transcode_register_code %> } diff --git a/enc/trans/japanese_sjis.trans b/enc/trans/japanese_sjis.trans index 00eace27a3..8e1e13056d 100644 --- a/enc/trans/japanese_sjis.trans +++ b/enc/trans/japanese_sjis.trans @@ -27,8 +27,7 @@ <%= transcode_generated_code %> -void -Init_japanese_sjis(void) +TRANS_INIT(japanese_sjis) { <%= transcode_register_code %> } diff --git a/enc/trans/korean.trans b/enc/trans/korean.trans index ef1cdfcb8e..fda1a3eeda 100644 --- a/enc/trans/korean.trans +++ b/enc/trans/korean.trans @@ -12,8 +12,7 @@ <%= transcode_generated_code %> -void -Init_korean(void) +TRANS_INIT(korean) { <%= transcode_register_code %> } diff --git a/enc/trans/single_byte.trans b/enc/trans/single_byte.trans index 2293bf6faf..50f568cb94 100644 --- a/enc/trans/single_byte.trans +++ b/enc/trans/single_byte.trans @@ -84,8 +84,7 @@ <%= transcode_generated_code %> -void -Init_single_byte(void) +TRANS_INIT(single_byte) { <%= transcode_register_code %> } diff --git a/enc/trans/utf8_mac.trans b/enc/trans/utf8_mac.trans index 8ea0afd73f..11ce35e212 100644 --- a/enc/trans/utf8_mac.trans +++ b/enc/trans/utf8_mac.trans @@ -233,8 +233,7 @@ rb_from_UTF8_MAC = { from_utf8_mac_finish }; -void -Init_utf8_mac(void) +TRANS_INIT(utf8_mac) { <%= transcode_register_code %> rb_register_transcoder(&rb_from_UTF8_MAC); diff --git a/enc/trans/utf_16_32.trans b/enc/trans/utf_16_32.trans index c841df035f..632c8808ef 100644 --- a/enc/trans/utf_16_32.trans +++ b/enc/trans/utf_16_32.trans @@ -539,8 +539,7 @@ rb_to_UTF_32 = { NULL, NULL, NULL, fun_so_to_utf_32 }; -void -Init_utf_16_32(void) +TRANS_INIT(utf_16_32) { rb_register_transcoder(&rb_from_UTF_16BE); rb_register_transcoder(&rb_to_UTF_16BE); diff --git a/ext/extmk.rb b/ext/extmk.rb index 3b2c0c65fa..c8ff664b33 100755 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -10,7 +10,7 @@ $dryrun = false $clean = nil $nodynamic = nil $extinit = nil -$extobjs = nil +$extobjs = [] $extflags = "" $extlibs = nil $extpath = nil @@ -26,6 +26,8 @@ alias $0 $progname $extlist = [] $compiled = {} +DUMMY_SIGNATURE = "***DUMMY MAKEFILE***" + srcdir = File.dirname(File.dirname(__FILE__)) unless defined?(CROSS_COMPILING) and CROSS_COMPILING $:.replace([File.expand_path("lib", srcdir), Dir.pwd]) @@ -46,7 +48,18 @@ def sysquote(x) end def verbose? - $mflags.defined?("Q") != "@" + $mflags.defined?("V") == "1" +end + +def system(*args) + if verbose? + if args.size == 1 + puts args + else + puts args.map{|arg| Shellwords.escape(arg)}.join(' ') + end + end + super end def extract_makefile(makefile, keep = true) @@ -100,7 +113,7 @@ def extract_makefile(makefile, keep = true) end def extmake(target) - unless $configure_only + unless $configure_only || verbose? print "#{$message} #{target}\n" $stdout.flush end @@ -163,7 +176,11 @@ def extmake(target) then ok = false if $configure_only - print "#{$message} #{target}\n" + if verbose? + print "#{conf}\n" if conf + else + print "#{$message} #{target}\n" + end $stdout.flush end init_mkmf @@ -193,9 +210,11 @@ def extmake(target) $0 = $PROGRAM_NAME end end + ok &&= File.open(makefile){|f| !f.gets[DUMMY_SIGNATURE]} ok = yield(ok) if block_given? unless ok open(makefile, "w") do |f| + f.puts "# " + DUMMY_SIGNATURE f.print(*dummy_makefile(CONFIG["srcdir"])) end print "Failed to configure #{target}. It will not be installed.\n" @@ -205,9 +224,9 @@ def extmake(target) unless $destdir.to_s.empty? or $mflags.defined?("DESTDIR") args += [sysquote("DESTDIR=" + relative_from($destdir, "../"+prefix))] end - if $static + if $static and %r(\A-test-) !~ target and target != 'json' and ok args += ["static"] unless $clean - $extlist.push [$static, $target, File.basename($target), $preload] + $extlist.push [$static, target, $target, $preload] end FileUtils.rm_f(old_cleanfiles - $distcleanfiles) FileUtils.rm_f(old_objs - $objs) @@ -466,7 +485,7 @@ Dir::chdir('ext') hdrdir = $hdrdir $hdrdir = ($top_srcdir = relative_from(srcdir, $topdir = "..")) + "/include" exts.each do |d| - $static = $force_static ? $static_ext[target] : nil + $static = $force_static ? true : $static_ext[target] if $ignore or !$nodynamic or $static extmake(d) or abort @@ -502,7 +521,7 @@ if $ignore end $extinit ||= "" -$extobjs ||= "" +$extobjs ||= [] $extpath ||= [] $extflags ||= "" $extlibs ||= [] @@ -519,31 +538,27 @@ unless $extlist.empty? end next end - f = format("%s/%s.%s", t, i, $LIBEXT) - if File.exist?(f) - $extinit << " init(Init_#{i}, \"#{t}.so\");\n" - $extobjs << "ext/#{f} " - built << t - end + $extinit << " init(Init_#{File.basename i}, \"#{i}.so\");\n" + $extobjs << format("ext/%s/%s.%s", t, File.basename(i), $LIBEXT) + built << t end src = %{\ -#include "ruby.h" +#include "ruby/ruby.h" #define init(func, name) { \\ - extern void func _((void)); \\ + extern void func(void); \\ ruby_init_ext(name, func); \\ } -void ruby_init_ext _((const char *name, void (*init)(void))); +void ruby_init_ext(const char *name, void (*init)(void)); -void Init_ext _((void))\n{\n#$extinit} +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 - $extobjs = "ext/#{extinit.o} #{$extobjs}" if RUBY_PLATFORM =~ /beos/ $extflags.delete("-L/usr/local/lib") end @@ -552,7 +567,6 @@ void Init_ext _((void))\n{\n#$extinit} conf = [ ['LIBRUBY_SO_UPDATE', '$(LIBRUBY_EXTS)'], ['SETUP', $setup], - [enable_config("shared", $enable_shared) ? 'DLDOBJS' : 'EXTOBJS', $extobjs], ['EXTLIBS', $extlibs.join(' ')], ['EXTLDFLAGS', $extflags] ].map {|n, v| "#{n}=#{v}" if v and !(v = v.strip).empty? @@ -615,21 +629,34 @@ if $configure_only and $command_output w += d.size + 1 end mf.puts + if !$extlist.empty? + mf.puts "EXTOBJS = ext/extinit.#{$OBJEXT} #{$extobjs.join(' ')}" + mf.puts "EXTLIBS = #{$extlibs.join(' ')}" + else + mf.puts "EXTOBJS = " + mf.puts "EXTLIBS = " + end + mf.puts targets = %w[all install static install-so install-rb clean distclean realclean] targets.each do |tgt| mf.puts "#{tgt}: $(extensions:/.=/#{tgt})" end mf.puts mf.puts "all: #{rubies.join(' ')}" - mf.puts "#{rubies.join(' ')}: $(extensions:/.=/all)" + mf.puts "static: ext/extinit.#{$OBJEXT} #{rubies.join(' ')}" + mf.puts "clean:\n\t-$(Q)$(RM) ext/extinit.#{$OBJEXT}" + mf.puts "distclean:\n\t-$(Q)$(RM) ext/extinit.c" + mf.puts + mf.puts "#{rubies.join(' ')}: $(extensions:/.=/#{$force_static ? 'static' : 'all'})" rubies.each do |tgt| - mf.puts "#{tgt}:\n\t$(Q)$(MAKE) $(MFLAGS) $@" + mf.puts "#{tgt}:\n\t$(Q)$(MAKE) $(MFLAGS) EXTOBJS='$(EXTOBJS)' EXTLIBS='$(EXTLIBS)' $@" end + mf.puts "ext/extinit.#{$OBJEXT}:\n\t$(Q)$(MAKE) $(MFLAGS) V=$(V) $@" mf.puts exec = config_string("exec") {|str| str + " "} targets.each do |tgt| exts.each do |d| - mf.puts "#{d[0..-2]}#{tgt}:\n\t$(Q)cd $(@D) && #{exec}$(MAKE) $(MFLAGS) $(@F)" + mf.puts "#{d[0..-2]}#{tgt}:\n\t$(Q)cd $(@D) && #{exec}$(MAKE) $(MFLAGS) V=$(V) $(@F)" end end end diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 78841e2bf3..05c3bd8972 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -1835,7 +1835,7 @@ DISTCLEANFILES = #{$distcleanfiles.join(' ')} all install static install-so install-rb: Makefile .PHONY: all install static install-so install-rb -.PHONY: clean clean-so clean-rb +.PHONY: clean clean-so clean-static clean-rb RULES end @@ -2064,7 +2064,7 @@ CLEANOBJS = *.#{$OBJEXT} #{config_string('cleanobjs') {|t| t.gsub(/\$\*/, "$ all: #{$extout ? "install" : target ? "$(DLLIB)" : "Makefile"} static: $(STATIC_LIB)#{$extout ? " install-rb" : ""} .PHONY: all install static install-so install-rb -.PHONY: clean clean-so clean-rb +.PHONY: clean clean-so clean-static clean-rb " mfile.print CLEANINGS fsep = config_string('BUILD_FILE_SEPARATOR') {|s| s unless s == "/"} @@ -2100,6 +2100,8 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""} mfile.print "\t@echo #{dir}/#{File.basename(f)}>>$(INSTALLED_LIST)\n" end end + mfile.print "clean-static::\n" + mfile.print "\t-$(Q)$(RM) $(STATIC_LIB)\n" else mfile.puts "Makefile" end @@ -2372,13 +2374,14 @@ MESSAGE clean-rb-default:: clean-rb:: clean-so:: -clean: clean-so clean-rb-default clean-rb +clean: clean-so clean-static clean-rb-default clean-rb \t\t-$(Q)$(RM) $(CLEANLIBS#{sep}) $(CLEANOBJS#{sep}) $(CLEANFILES#{sep}) distclean-rb-default:: distclean-rb:: distclean-so:: -distclean: clean distclean-so distclean-rb-default distclean-rb +distclean-static:: +distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb \t\t-$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log \t\t-$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES#{sep}) \t\t-$(Q)$(RMDIRS) $(DISTCLEANDIRS#{sep})#{$ignore_error} @@ -1225,6 +1225,9 @@ rb_f_chomp(argc, argv) return str; } +/* blank function in dmyencoding.c or generated by enc/make_encmake.rb */ +extern void Init_enc(void); + static VALUE process_options(int argc, char **argv, struct cmdline_options *opt) { @@ -1311,6 +1314,7 @@ process_options(int argc, char **argv, struct cmdline_options *opt) #endif ruby_init_loadpath_safe(opt->safe_level); + Init_enc(); rb_enc_find_index("encdb"); lenc = rb_locale_encoding(); rb_enc_associate(rb_progname, lenc); diff --git a/transcode_data.h b/transcode_data.h index 8e85ce6db4..dcaee61033 100644 --- a/transcode_data.h +++ b/transcode_data.h @@ -110,6 +110,16 @@ struct rb_transcoder { void rb_declare_transcoder(const char *enc1, const char *enc2, const char *lib); void rb_register_transcoder(const rb_transcoder *); +/* + * To get rid of collision of initializer symbols in statically-linked encodings + * and transcoders + */ +#if defined(EXTSTATIC) && EXTSTATIC +# define TRANS_INIT(name) void Init_trans_ ## name(void) +#else +# define TRANS_INIT(name) void Init_ ## name(void) +#endif + #if defined __GNUC__ && __GNUC__ >= 4 #pragma GCC visibility pop #endif |