Hello,

As I was tracking down problems with making shared libraries for Ruby on
Solaris, I discovered a minor problem with Makefile.in.  Seems when one
tries to do a "make distclean" Makefiles remain in the ext tree.

This is due to "distclean" not calling miniruby with extmk.rb distclean.
Further, when one adds this to the distclean, it fails since distclean
depends on "clean" which removes miniruby before it gets back to do the
extmk.rb distclean.

I've created a patch for the Makefile.in which adds two additional
targets, clean-ext and distclean-ext which handle cleaning up the ext
tree correctly and I've also straightened out the dependencies to put
everything in the correct order.

This is for Ruby 1.6.5 (probably earlier as well) and the development
version too.  The line numbers may be different since I made this diff
on the development version.

I've also included the shared library fix as well.  This is required for
both the Solaris /usr/ccs/bin/ld as well as GNU ld.  It has to do with
GCC constructing the command line passed to the linker.  Without the
"-shared" it links in the startup C library as well as setting a few
different command line switches.  This behaviour is defined in the GCC
specs file.

The GCC patch has been tested with all combinations of linkers on both
Solaris 7 and Solaris 8 using GCC 2.95.3.  I'm probably sure this is the
case for others as well.

I may have the diffs backwards, but have included the diff command used.

Here's the the context diff for the Makefile:

------------------------- BEGIN INCLUDED FILE -------------------------
diff -c Makefile.in Makefile.in.orig
*** Makefile.in   Wed Nov  7 19:34:07 2001
--- Makefile.in.orig Wed Nov  7 19:29:50 2001
***************
*** 107,123 ****
  install:  rbconfig.rb
      @MINIRUBY@ $(srcdir)/instruby.rb $(DESTDIR)

! clean-ext:
!     @-@MINIRUBY@ -Cext extmk.rb clean 2> /dev/null || true
!
! clean:
!     @rm -f $(OBJS) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY_ALIASES)
!     @rm -f $(MAINOBJ) rbconfig.rb
      @rm -f ext/extinit.c ext/extinit.@OBJEXT@ dmyext.@OBJEXT@
      @rm -f $(PROGRAM) miniruby$(EXEEXT)
-
- distclean-ext:
-     @-@MINIRUBY@ -Cext extmk.rb distclean 2> /dev/null || true

  distclean:   clean
      @rm -f Makefile ext/extmk.rb config.h
--- 107,116 ----
  install:  rbconfig.rb
      @MINIRUBY@ $(srcdir)/instruby.rb $(DESTDIR)

! clean:;      @rm -f $(OBJS) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY_ALIASES) $(MAINOBJ) rbconfig.rb
      @rm -f ext/extinit.c ext/extinit.@OBJEXT@ dmyext.@OBJEXT@
+     @-@MINIRUBY@ -Cext extmk.rb clean 2> /dev/null || true
      @rm -f $(PROGRAM) miniruby$(EXEEXT)

  distclean:   clean
      @rm -f Makefile ext/extmk.rb config.h

-------------------------- END INCLUDED FILE --------------------------


Here's the context diff for configure:

------------------------- BEGIN INCLUDED FILE -------------------------
diff -c configure configure.orig 
*** configure	Wed Nov  7 00:26:08 2001
--- configure.orig	Wed Nov  7 00:26:02 2001
***************
*** 4679,4685 ****
  			LDFLAGS="-Wl,-E"
  			rb_cv_dlopen=yes;;
  	solaris*) 	if test "$GCC" = yes; then
! 			   LDSHARED='$(CC) -Wl,-G -shared'
  			   `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null && LDFLAGS="-Wl,-E"
  			else
  			   LDSHARED='ld -G'
--- 4679,4685 ----
  			LDFLAGS="-Wl,-E"
  			rb_cv_dlopen=yes;;
  	solaris*) 	if test "$GCC" = yes; then
! 			   LDSHARED='$(CC) -Wl,-G'
  			   `$CC --print-prog-name=ld` -v 2>&1 | grep "GNU ld" > /dev/null && LDFLAGS="-Wl,-E"
  			else
  			   LDSHARED='ld -G'

-------------------------- END INCLUDED FILE --------------------------

-- 
Michael P. Sullivan                                  
Distributed Computing Systems, LLC                         Cell: 516-429-2080 
E-Mail: mps / discomsys.com                           http://www.discomsys.com/ 
    * UNIX Systems and Database Consulting, Architecture and Management *
"Failing to plan, is planning to fail... plan for the worst, hope for the best"