なかだです。

At Tue, 1 Oct 2002 08:40:44 +0900,
Nobuyoshi-Nakada wrote:
> >   gcc -o conftest -I/package/prog/ruby/lib/ruby/1.6/i686-linux -g -O2  
> > -rdynamic  -L/package/prog/ruby/lib
> > -L/package/prog/ruby/lib/ruby/1.6/i686-linux conftest.c -lc libruby.a 
> > -ldl -lcrypt -lm
> >   gcc: libruby.a: No such file or directory
> >   conftest.c: In function `t':
> >   conftest.c:3: too few arguments to function `memchr'
> > 
> >  あ、それ以前に何か libruby.a が見付からないとか言ってますね。
> 
> 二三日前に気づいたのですが、--enable-sharedをつけないと
> $(LIBRUBYARG)が$(LIBRUBY_A)になってしまって、カレントディレクト
> リにライブラリがある場合(つまりruby自身をリンクするとき)以外は
> 意味がありません。これは要修正ですが、既に出ちゃってる1.6にはど
> うしようもないので、extconf.rbでなんとかしないといけませんね。

Windows以外でもRUBY_SO_NAMEをセットするようにして、デフォルトの
LIBRUBYARGは-l$(RUBY_INSTALL_NAME)、--enable-sharedなら
-l$(RUBY_SO_NAME)にするということでどうでしょうか。

あと$(prefix)/lib以外にすることもできるので、-rpathなどはlibdir
を使うようにしないとまずいのでは。


Index: configure.in =================================================================== RCS file: /cvs/ruby/src/ruby/configure.in,v retrieving revision 1.68.2.37 diff -u -2 -p -r1.68.2.37 configure.in --- configure.in 25 Sep 2002 07:07:36 -0000 1.68.2.37 +++ configure.in 1 Oct 2002 01:44:03 -0000 @@ -591,5 +591,5 @@ if test "$with_dln_a_out" != yes; then esac ;; bsdi*) LDSHARED="ld -shared" - LDFLAGS='-rdynamic -Wl,-rpath,$(prefix)/lib/ruby/$(MAJOR).$(MINOR)/i386-bsdi4.0' + LDFLAGS='-rdynamic -Wl,-rpath,$(libdir)/ruby/$(MAJOR).$(MINOR)/i386-bsdi4.0' rb_cv_dlopen=yes ;; nextstep*) LDSHARED='cc -r -nostdlib' @@ -804,5 +804,5 @@ FIRSTMAKEFILE="" LIBRUBY_A='lib$(RUBY_INSTALL_NAME).a' LIBRUBY='$(LIBRUBY_A)' -LIBRUBYARG='$(LIBRUBY_A)' +LIBRUBYARG='-l$(RUBY_INSTALL_NAME)' SOLIBS= @@ -816,8 +816,9 @@ case "$target_os" in esac +RUBY_SO_NAME='$(RUBY_INSTALL_NAME)' LIBRUBY_LDSHARED=$LDSHARED LIBRUBY_DLDFLAGS=$DLDFLAGS -LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR).$(TEENY)' -LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so' +LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR).$(TEENY)' +LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so' ENABLE_SHARED=no @@ -827,5 +828,5 @@ AC_ARG_ENABLE(enable-shared, if test "$enable_shared" = 'yes'; then LIBRUBY='$(LIBRUBY_SO)' - LIBRUBYARG='-L. -l$(RUBY_INSTALL_NAME)' + LIBRUBYARG='-l$(RUBY_SO_NAME)' CFLAGS="$CFLAGS $CCDLFLAGS" ENABLE_SHARED=yes @@ -835,13 +836,13 @@ if test "$enable_shared" = 'yes'; then case "$target_os" in sunos4*) - LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so' + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' ;; linux*) - LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR)' - LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).so' + LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)' + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' ;; freebsd*) SOLIBS='$(LIBS)' - LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR)' + LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR)' if test "$rb_cv_binary_elf" != "yes" ; then LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)" @@ -851,9 +852,9 @@ if test "$enable_shared" = 'yes'; then netbsd*) SOLIBS='$(LIBS)' - LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR).$(TEENY)' - LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR)' - LIBRUBYARG='-Wl,-R -Wl,${prefix}/lib -L${prefix}/lib -L. -l$(RUBY_INSTALL_NAME)' + LIBRUBY_SO='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR).$(TEENY)' + LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR)' + LIBRUBYARG='-Wl,-R -Wl,${libdir} -L${libdir} -l$(RUBY_SO_NAME)' if test "$rb_cv_binary_elf" = yes; then # ELF platforms - LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).so.$(MAJOR)$(MINOR) lib$(RUBY_INSTALL_NAME).so' + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR)$(MINOR) lib$(RUBY_SO_NAME).so' else # a.out platforms LIBRUBY_ALIASES="" @@ -864,10 +865,10 @@ if test "$enable_shared" = 'yes'; then ;; solaris*) - XLDFLAGS='-R${prefix}/lib' + XLDFLAGS='-R${libdir}' ;; hpux*) - XLDFLAGS='-Wl,+s,+b,$(prefix)/lib' - LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)' - LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_INSTALL_NAME).sl' + XLDFLAGS='-Wl,+s,+b,$(libdir)' + LIBRUBY_SO='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR).$(TEENY)' + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).sl.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).sl' ;; aix*) @@ -879,5 +880,5 @@ if test "$enable_shared" = 'yes'; then LIBRUBY_DLDFLAGS='-bE:ruby.imp -bM:SRE -bnoentry' fi - LIBRUBYARG='-L${prefix}/lib -Wl,lib$(RUBY_INSTALL_NAME).so' + LIBRUBYARG='-L${libdir} -Wl,lib$(RUBY_SO_NAME).so' SOLIBS='-lm -lc' ;; @@ -890,8 +891,8 @@ if test "$enable_shared" = 'yes'; then ;; darwin*) - LIBRUBY_SO='lib$(RUBY_INSTALL_NAME).$(MAJOR).$(MINOR).$(TEENY).dylib' + LIBRUBY_SO='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).$(TEENY).dylib' LIBRUBY_LDSHARED='cc -dynamiclib -undefined suppress -flat_namespace' - LIBRUBY_DLDFLAGS='-install_name $(prefix)/lib/lib$(RUBY_INSTALL_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)' - LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_INSTALL_NAME).dylib' + LIBRUBY_DLDFLAGS='-install_name $(libdir)/lib$(RUBY_SO_NAME).dylib -current_version $(MAJOR).$(MINOR).$(TEENY) -compatibility_version $(MAJOR).$(MINOR)' + LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).$(MAJOR).$(MINOR).dylib lib$(RUBY_SO_NAME).dylib' ;; *) @@ -899,4 +900,5 @@ if test "$enable_shared" = 'yes'; then esac fi +XLDFLAGS="$XLDFLAGS -L." case "$target_os" in @@ -954,5 +956,4 @@ case "$target_os" in LIBRUBY_A='lib$(RUBY_INSTALL_NAME)s.a' LIBRUBY='lib$(RUBY_SO_NAME).a' - LIBRUBYARG='-L. -l$(RUBY_SO_NAME)' FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in SOLIBS='$(LIBS)' Index: lib/mkmf.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/mkmf.rb,v retrieving revision 1.37.2.43 diff -u -2 -p -r1.37.2.43 mkmf.rb --- lib/mkmf.rb 22 Sep 2002 15:33:28 -0000 1.37.2.43 +++ lib/mkmf.rb 1 Oct 2002 14:40:58 -0000 @@ -63,5 +63,6 @@ else OUTFLAG = '-o ' end -LINK = "#{CONFIG['CC']} #{OUTFLAG}conftest -I#{$hdrdir} #{CFLAGS} %s %s #{CONFIG['LDFLAGS']} %s conftest.c %s %s #{CONFIG['LIBS']}" +LINK = "#{CONFIG['CC']} #{OUTFLAG}conftest -I#{$hdrdir} #{CFLAGS} %s %s "\ + "#{CONFIG['LDFLAGS']} %s conftest.c #{CONFIG['LIBRUBYARG']} %s %s #{CONFIG['LIBS']}" CC = "#{CONFIG['CC']} -c #{CONFIG['CPPFLAGS']} %s -I#{$hdrdir} #{CFLAGS} %s %s conftest.c" CPP = "#{CONFIG['CPP']} -E %s -I#{$hdrdir} #{CFLAGS} %s %s conftest.c"
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦