Bug in Ruby 1.8.2 'mkmf.rb'?

Hi all!

  I have a file called 'extconf.rb' that used to run fine
under Ruby 1.8.0, but now seems to have problems in Ruby 1.8.2 Windows XP Pro SP2
(2005-12-25 [i386-mswin32] - from the single .EXE installer).
First off, here is the extconf.rb file:

···

--------------------------------------------------------------
require 'mkmf'
create_makefile('RubyBarChart')

# Add on to end of Makefile...
open('Makefile', 'ab') {|mf|
   mf.puts <<EOM

RubyBarChart_wrap.cxx: RubyBarChart.i Makefile extconf.rb Account.h Contract.h Portfolio.h Tick.h EntryExitSystem.h Order.h PositionSizing.h
\tswig -c++ -ruby $(CPPFLAGS) -DDEFI_CPP_ANSI RubyBarChart.i

Tick.obj: Tick.cpp Tick.h

Account.obj: Account.cpp Account.h PositionSizing.h Order.h Contract.h Tick.h

PositionSizing.obj: PositionSizing.cpp PositionSizing.h Order.h Contract.h Tick.h Account.h

EntryExitSystem.obj: EntryExitSystem.cpp EntryExitSystem.h Tick.h

Contract.obj: Contract.cpp EntryExitSystem.h Tick.h Contract.h Portfolio.h PositionSizing.h Account.h

Portfolio.obj: Portfolio.cpp Portfolio.h Contract.h

EOM
}
--------------------------------------------------------------

Now, here are the diffs between the old Makefile and the new Makefile:
7,8c7,8
< topdir = $(rubylibdir)/$(arch)
< hdrdir = $(rubylibdir)/$(arch)
---
> topdir = c:/ruby/lib/ruby/1.8/i386-mswin32
> hdrdir = $(topdir)
24c24
< compile_dir = $(DESTDIR)/tmp/ruby-1.8.0
---
> compile_dir = $(DESTDIR)/Dev/RubyDev/rubyinstaller/cvs-repo/installer-win/stable/download/ruby-1.8.2/win32
39,40c39,40
< CFLAGS = -MD -Zi -O2b2xg- -G6
< CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) -I. -I. -I./missing
---
> CFLAGS = -MD -Zi -O2b2xg- -G6
> CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) -I. -I./.. -I./../missing
42c42
< DLDFLAGS = -link -incremental:no -pdb:none -dll $(LIBPATH) -def:$(DEFFILE)
---
> DLDFLAGS = -link -incremental:no -debug -opt:ref -opt:icf -dll $(LIBPATH) -def:$(DEFFILE)
52c52,53
< RUBY = ruby
---
> ruby = c:/ruby/bin/ruby
> RUBY = $(ruby:/=\)
62c63
< DEFFILE = RubyBarChart.def
---
> DEFFILE = $(srcdir)/$(TARGET).def
70c71
< OBJS = RubyBarChart_wrap.obj Account.obj Contract.obj Portfolio.obj EntryExitSystem.obj PositionSizing.obj
---
> OBJS = Account.obj Contract.obj EntryExitSystem.obj Portfolio.obj PositionSizing.obj Tick.obj
72a74
> STATIC_LIB = $(TARGET).lib
81a84
> static: $(STATIC_LIB)
136a140,142
> $(STATIC_LIB): $(OBJS)
> $(AR) -machine:x86 -out:$@ $(OBJS)
>
139a146,147
>
> Tick.obj: Tick.cpp Tick.h
--------------------------------------------------------------------------

  Notice on the 'OBJS' line, how the old version caught the build
of RubyBarChart_wrap.obj, but the new one doesn't? This appears to be
a bug.

  Any ideas? Am I doing something wrong? Thanks!

-- Glenn

Hi,

···

In message "Re: Bug in Ruby 1.8.2 'mkmf.rb' ?" on Thu, 15 Sep 2005 15:56:34 +0900, "Glenn M. Lewis" <noSpam@noSpam.com> writes:

--------------------------------------------------------------

Now, here are the diffs between the old Makefile and the new Makefile:
7,8c7,8
< topdir = $(rubylibdir)/$(arch)
< hdrdir = $(rubylibdir)/$(arch)

PLEASE send us unified / context diff. Old diff is too hard to read.

              matz.

Hi,

At Thu, 15 Sep 2005 15:56:34 +0900,
Glenn M. Lewis wrote in [ruby-talk:156202]:

RubyBarChart_wrap.cxx: RubyBarChart.i Makefile extconf.rb Account.h Contract.h Portfolio.h Tick.h EntryExitSystem.h Order.h PositionSizing.h
\tswig -c++ -ruby $(CPPFLAGS) -DDEFI_CPP_ANSI RubyBarChart.i

Seems RubyBarChart_wrap.cxx is autogenerated. Was it there
when you run extconf.rb?

···

--
Nobu Nakada

Hi Matz! Awesome language! Sorry about the diff... a context diff is below...
-- Glenn

Yukihiro Matsumoto wrote:

···

Hi,
[...] PLEASE send us unified / context diff. Old diff is too hard to read.

              matz.

==============================================================================
*** Makefile.old Thu Sep 30 17:35:01 2004
--- Makefile Wed Sep 14 23:56:33 2005
***************
*** 4,11 ****
   #### Start of system configuration section. ####

   srcdir = .
! topdir = $(rubylibdir)/$(arch)
! hdrdir = $(rubylibdir)/$(arch)
   VPATH = $(srcdir)

   DESTDIR = c:
--- 4,11 ----
   #### Start of system configuration section. ####

   srcdir = .
! topdir = c:/ruby/lib/ruby/1.8/i386-mswin32
! hdrdir = $(topdir)
   VPATH = $(srcdir)

   DESTDIR = c:
***************
*** 21,27 ****
   infodir = $(prefix)/info
   oldincludedir = $(DESTDIR)/usr/include
   libexecdir = $(exec_prefix)/libexec
! compile_dir = $(DESTDIR)/tmp/ruby-1.8.0
   sbindir = $(exec_prefix)/sbin
   includedir = $(prefix)/include
   sysconfdir = $(prefix)/etc
--- 21,27 ----
   infodir = $(prefix)/info
   oldincludedir = $(DESTDIR)/usr/include
   libexecdir = $(exec_prefix)/libexec
! compile_dir = $(DESTDIR)/Dev/RubyDev/rubyinstaller/cvs-repo/installer-win/stable/download/ruby-1.8.2/win32
   sbindir = $(exec_prefix)/sbin
   includedir = $(prefix)/include
   sysconfdir = $(prefix)/etc
***************
*** 36,45 ****
   LIBRUBYARG_SHARED = $(LIBRUBY)
   LIBRUBYARG_STATIC = $(LIBRUBY_A)

! CFLAGS = -MD -Zi -O2b2xg- -G6
! CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) -I. -I. -I./missing
   CXXFLAGS = $(CFLAGS)
! DLDFLAGS = -link -incremental:no -pdb:none -dll $(LIBPATH) -def:$(DEFFILE)
   LDSHARED = cl -nologo -LD
   AR = lib -nologo
   EXEEXT = .exe
--- 36,45 ----
   LIBRUBYARG_SHARED = $(LIBRUBY)
   LIBRUBYARG_STATIC = $(LIBRUBY_A)

! CFLAGS = -MD -Zi -O2b2xg- -G6
! CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) -I. -I./.. -I./../missing
   CXXFLAGS = $(CFLAGS)
! DLDFLAGS = -link -incremental:no -debug -opt:ref -opt:icf -dll $(LIBPATH) -def:$(DEFFILE)
   LDSHARED = cl -nologo -LD
   AR = lib -nologo
   EXEEXT = .exe
***************
*** 49,55 ****
   arch = i386-mswin32
   sitearch = i386-msvcrt
   ruby_version = 1.8
! RUBY = ruby
   RM = $(RUBY) -run -e rm -- -f
   MAKEDIRS = $(RUBY) -run -e mkdir -- -p
   INSTALL_PROG = $(RUBY) -run -e install -- -vpm 0755
--- 49,56 ----
   arch = i386-mswin32
   sitearch = i386-msvcrt
   ruby_version = 1.8
! ruby = c:/ruby/bin/ruby
! RUBY = $(ruby:/=\)
   RM = $(RUBY) -run -e rm -- -f
   MAKEDIRS = $(RUBY) -run -e mkdir -- -p
   INSTALL_PROG = $(RUBY) -run -e install -- -vpm 0755
***************
*** 59,65 ****

   LIBPATH = -libpath:"$(libdir)"
! DEFFILE = RubyBarChart.def

   CLEANFILES =
   DISTCLEANFILES =
--- 60,66 ----

   LIBPATH = -libpath:"$(libdir)"
! DEFFILE = $(srcdir)/$(TARGET).def

   CLEANFILES =
   DISTCLEANFILES =
***************
*** 67,75 ****
   target_prefix =
   LOCAL_LIBS =
   LIBS = $(LIBRUBYARG_SHARED) oldnames.lib user32.lib advapi32.lib wsock32.lib
! OBJS = RubyBarChart_wrap.obj Account.obj Contract.obj Portfolio.obj EntryExitSystem.obj PositionSizing.obj Tick.obj
   TARGET = RubyBarChart
   DLLIB = $(TARGET).so

   RUBYCOMMONDIR = $(sitedir)$(target_prefix)
   RUBYLIBDIR = $(sitelibdir)$(target_prefix)
--- 68,77 ----
   target_prefix =
   LOCAL_LIBS =
   LIBS = $(LIBRUBYARG_SHARED) oldnames.lib user32.lib advapi32.lib wsock32.lib
! OBJS = Account.obj Contract.obj EntryExitSystem.obj Portfolio.obj PositionSizing.obj Tick.obj
   TARGET = RubyBarChart
   DLLIB = $(TARGET).so
+ STATIC_LIB = $(TARGET).lib

   RUBYCOMMONDIR = $(sitedir)$(target_prefix)
   RUBYLIBDIR = $(sitelibdir)$(target_prefix)
***************
*** 79,84 ****
--- 81,87 ----
   CLEANOBJS = "*.{obj,lib,s[ol],pdb,bak}"

   all: $(DLLIB)
+ static: $(STATIC_LIB)

   clean:
                 @$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
***************
*** 133,138 ****
--- 136,144 ----
         @-$(RM) $@
         @-$(RM) $(TARGET).lib
         $(LDSHARED) -Fe$(@) $(OBJS) $(LIBS) $(LOCAL_LIBS) $(DLDFLAGS)
+
+ $(STATIC_LIB): $(OBJS)
+ $(AR) -machine:x86 -out:$@ $(OBJS)

   RubyBarChart_wrap.cxx: RubyBarChart.i Makefile extconf.rb Account.h Contract.h Portfolio.h Tick.h EntryExitSystem.h Order.h PositionSizing.h

Hi, Nobuyoshi!

  That is an excellent question... It has been so long,
that I don't even remember. I could have sworn that 'extconf.rb'
generated a correct Makefile before from a clean directory, but
maybe I am just remembering wrong.

  So Matz... I'm sorry... I forget the answer to this question,
and maybe there is no bug at all... you can ignore my last message.

  Is there a correct way to handle this situation in the
future? Can I somehow tell 'mkmf' that "RubyBarChart_wrap.cxx" is
supposed to be auto-generated? (So that whether it exists or not
in the directory, the Makefile will end up being correct?)

  Thank you very much!
-- Glenn

nobuyoshi nakada wrote:

···

Hi,

At Thu, 15 Sep 2005 15:56:34 +0900,
Glenn M. Lewis wrote in [ruby-talk:156202]:

RubyBarChart_wrap.cxx: RubyBarChart.i Makefile extconf.rb Account.h Contract.h Portfolio.h Tick.h EntryExitSystem.h Order.h PositionSizing.h
\tswig -c++ -ruby $(CPPFLAGS) -DDEFI_CPP_ANSI RubyBarChart.i

Seems RubyBarChart_wrap.cxx is autogenerated. Was it there
when you run extconf.rb?

Hi,

At Thu, 15 Sep 2005 23:36:34 +0900,
Glenn M. Lewis wrote in [ruby-talk:156253]:

  Is there a correct way to handle this situation in the
future? Can I somehow tell 'mkmf' that "RubyBarChart_wrap.cxx" is
supposed to be auto-generated? (So that whether it exists or not
in the directory, the Makefile will end up being correct?)

Setting $objs to all object files, and separating dependency
rules to "depend" file.

# extconf.rb
$objs = %w[RubyBarChart_wrap.o Account.o Contract.o Portfolio.o EntryExitSystem.o PositionSizing.o]
create_makefile('RubyBarChart')

# depend
RubyBarChart_wrap.cxx: RubyBarChart.i Account.h Contract.h Portfolio.h Tick.h \
           EntryExitSystem.h Order.h PositionSizing.h
  swig -c++ -ruby $(CPPFLAGS) -DDEFI_CPP_ANSI RubyBarChart.i

Tick.o: Tick.cpp Tick.h

Account.o: Account.cpp Account.h PositionSizing.h Order.h Contract.h Tick.h

PositionSizing.o: PositionSizing.cpp PositionSizing.h Order.h Contract.h Tick.h Account.h

EntryExitSystem.o: EntryExitSystem.cpp EntryExitSystem.h Tick.h

Contract.o: Contract.cpp EntryExitSystem.h Tick.h Contract.h Portfolio.h PositionSizing.h Account.h

Portfolio.o: Portfolio.cpp Portfolio.h Contract.h

···

--
Nobu Nakada