[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby1.9 CVS Makefile issue?

ggarramuno

10/22/2004 9:08:00 PM

I just downloaded both ruby1.9 CVS and 1.8.2 CVS and I found out that, when
compiling on windows, zlib seems like it is not being compiled/installed
anymore. A directory under win32/ext/zlib is created but the Makefile created
is basically empty.
Is there any reason for this?

9 Answers

Joao Pedrosa

10/22/2004 9:17:00 PM

0

Hi,

On Sat, 23 Oct 2004 06:09:12 +0900, GGarramuno <ggarramuno@aol.com> wrote:
> I just downloaded both ruby1.9 CVS and 1.8.2 CVS and I found out that, when
> compiling on windows, zlib seems like it is not being compiled/installed
> anymore. A directory under win32/ext/zlib is created but the Makefile created
> is basically empty.
> Is there any reason for this?

You need the libraries and headers to compile de C Ruby libraries. On
Windows it is a little bit more difficult to setup everything
correctly to compile a complete Ruby. Are you sure you have everything
needed?

Cheers,
Joao


ggarramuno

10/22/2004 10:23:00 PM

0

>Windows it is a little bit more difficult to setup everything
>correctly to compile a complete Ruby. Are you sure you have everything
>needed?

Obviously not, as zlib didn't get compiled.
I do have the zlib library on my drive and a full cygwin installation for the
basic make tools, but the instructions did not mention anything on any switches
to set the appropiate include/libs directories for zlib.
I had expected that in case of failure or a missing library compilation would
not have worked at all, stopping with some include or similar error (I'm pretty
sure that's what happened with 1.8.0).
I do recall having compiled 1.8.0 with no issues, but the Makefile has changed
quite a lot with 1.8.2 and 1.9.
I guess the proper question then is: what do I need, besides the microsoft
compiler libs and the standard cygwin tools now?

ggarramuno

10/22/2004 10:41:00 PM

0


Never mind.

It seems the extconf.rb for zlib silently avoids creating a Makefile if it
cannot find zlib.h in the INCLUDE path.

May I suggest this be changed to at least spit out a warning or, better yet in
my opinion, abort compilation completely with a clear message? And that the
compile README win32 instructions be updated to mention the need for zlib, too?


nobu.nokada

10/23/2004 12:25:00 AM

0

Hi,

At Sat, 23 Oct 2004 07:44:12 +0900,
GGarramuno wrote in [ruby-talk:117416]:
> May I suggest this be changed to at least spit out a warning or, better yet in
> my opinion, abort compilation completely with a clear message? And that the
> compile README win32 instructions be updated to mention the need for zlib, too?

All platforms can't always compile all libraries. extmk.rb
doesn't know if you failed to compile it or just don't want.

--
Nobu Nakada


ggarramuno

10/23/2004 8:45:00 PM

0

nobu.nokada@softhome.net wrote in message news:<200410230024.i9N0OYCf032575@sharui.nakada.niregi.kanuma.tochigi.jp>...
>
>
> All platforms can't always compile all libraries. extmk.rb
> doesn't know if you failed to compile it or just don't want.

But then surely the makefile for that platform should not include the
lib in the compilation at all.

Either way, as/if the computer cannot tell, to me that's more a reason
to at least warn the user about it, instead of silently not doing
anything and let him find the problem after everything is installed.

This is not a problem with extmk.rb, btw, but with the extconf.rb of
the lib. In case of zlib, a simple change like:

if %w'z libz zlib'.find {|z| have_library(z, 'deflateReset')} and
have_header('zlib.h') then
.....
else
puts "Warning: zlib will not be compiled. "
puts " zlib1.7 or later not found in LIB path"
puts " and/or zlib.h not in INCLUDE path."
end

would do the trick. Albeit I would argue that something like not
compiling zlib should really result in aborting the compilation all
together.
I'd just use this approach for things such as libs that are "optional"
in the ruby distribution. "optional" being a relatively subjective
matter (it could be argued that once a lib becomes part of the
standard library, it should not be considered optional anymore...
unless until a better lib supercedes it).
zlib to me does not qualify as optional as many other important
modules depend on it (rubygems, etc).

nobu.nokada

10/24/2004 2:23:00 PM

0

Hi,

At Sun, 24 Oct 2004 05:49:11 +0900,
GGarramuno wrote in [ruby-talk:117447]:
> This is not a problem with extmk.rb, btw, but with the extconf.rb of
> the lib. In case of zlib, a simple change like:
>
> if %w'z libz zlib'.find {|z| have_library(z, 'deflateReset')} and
> have_header('zlib.h') then
> .....
> else
> puts "Warning: zlib will not be compiled. "
> puts " zlib1.7 or later not found in LIB path"
> puts " and/or zlib.h not in INCLUDE path."
> end
>
> would do the trick. Albeit I would argue that something like not
> compiling zlib should really result in aborting the compilation all
> together.

But it would be buried in lots of other messages. Instead, what
about an option that direct which libraries should be compiled?

E.g.:

$ make EXTS=+zlib

will stop if zlib can't get compiled.


Index: ext/extmk.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/extmk.rb,v
retrieving revision 1.65
diff -U2 -p -d -r1.65 extmk.rb
--- ext/extmk.rb 2 Sep 2004 16:54:35 -0000 1.65
+++ ext/extmk.rb 24 Oct 2004 06:10:10 -0000
@@ -75,8 +75,10 @@ def extmake(target)
$preload = nil
makefile = "./Makefile"
+ ok = false
unless $ignore
if !(t = modified?(makefile, MTIMES)) ||
%W<#{$srcdir}/makefile.rb #{$srcdir}/extconf.rb
- #{$srcdir}/depend #{$srcdir}/MANIFEST>.any? {|f| modified?(f, [t])}
+ #{$srcdir}/depend #{$srcdir}/MANIFEST>.any? {|f| modified?(f, [t])} ||
+ $necessary[target] && /^all\b.*:\s*Makefile$/ =~ File.read(makefile)
then
$defs = []
@@ -93,9 +95,10 @@ def extmake(target)
end
$extupdate = true
- File.exist?(makefile)
+ ok = File.exist?(makefile)
rescue SystemExit
# ignore
ensure
rm_f "conftest*"
+ config = $0
$0 = $PROGRAM_NAME
Config::CONFIG["srcdir"] = $top_srcdir
@@ -121,11 +124,17 @@ def extmake(target)
%w[$(libdir) $(topdir)]
end
- true
+ ok = true
end
else
- File.exist?(makefile)
- end or open(makefile, "w") do |f|
- f.print dummy_makefile($srcdir)
- return true
+ ok = File.exist?(makefile)
+ end
+ unless ok
+ if $necessary[target]
+ mkmf_failed(config)
+ end
+ open(makefile, "w") do |f|
+ f.print dummy_makefile($srcdir)
+ return true
+ end
end
args = sysquote($mflags)
@@ -168,8 +177,21 @@ def parse_args()

opts = nil
- ARGV.options do |opts|
+ $optparser ||= OptionParser.new do |opts|
opts.on('-n') {$dryrun = true}
opts.on('--[no-]extension [EXTS]', Array) do |v|
- $extension = (v == false ? [] : v)
+ if v
+ $extension = v.compact.collect {|v|
+ (m = /\A[-+]?/.match(v)) ? [m.post_match, m[0][0]] : [v, nil]
+ }
+ if $extension.empty? or
+ $extension.all? {|t, n| t != '*' and n != ?-} &&
+ $extension.any? {|t, n| n != ?+}
+ $extension << ["*", ?-]
+ end
+ elsif v == false
+ $extension = [["*", ?-]]
+ else
+ $extension = nil
+ end
end
opts.on('--[no-]extstatic [STATIC]', Array) do |v|
@@ -200,11 +222,12 @@ def parse_args()
$message = v
end
- begin
- opts.parse!
- rescue OptionParser::InvalidOption => e
- retry if /^--/ =~ e.args[0]
- raise
- end
- end or abort opts.to_s
+ end
+ begin
+ $optparser.parse!(ARGV)
+ rescue OptionParser::InvalidOption => e
+ retry if /^--/ =~ e.args[0]
+ $optparser.warn(e)
+ abort opts.to_s
+ end

$destdir ||= ''
@@ -311,13 +334,26 @@ for dir in ["ext", File::join($top_srcdi
end unless $extstatic

+$necessary = {}
ext_prefix = "#{$top_srcdir}/ext"
exts = $static_ext.sort_by {|t, i| i}.collect {|t, i| t}
-exts |= $extension if $extension
exts.delete_if {|t| !File.exist?("#{ext_prefix}/#{t}/MANIFEST")}
-exts |= Dir.glob("#{ext_prefix}/*/**/MANIFEST").collect {|d|
+exts |= Dir.glob("#{ext_prefix}/*/**/MANIFEST")
+exts.collect! {|d|
d = File.dirname(d)
d.slice!(0, ext_prefix.length + 1)
+ $extension.each {|pat, opt|
+ if File.fnmatch?(pat, d)
+ case opt
+ when ?+
+ $necessary[d] = true
+ when ?-
+ d = nil
+ end
+ break
+ end
+ } if $extension
d
-} unless $extension
+}
+exts.compact!

if $extout
Index: lib/mkmf.rb
===================================================================
RCS file: /cvs/ruby/src/ruby/lib/mkmf.rb,v
retrieving revision 1.197
diff -U2 -p -d -r1.197 mkmf.rb
--- lib/mkmf.rb 16 Oct 2004 01:56:44 -0000 1.197
+++ lib/mkmf.rb 24 Oct 2004 06:17:16 -0000
@@ -626,4 +626,5 @@ end

def arg_config(config, default=nil)
+ $arg_config << [config, default]
$configure_args.fetch(config.tr('_', '-'), default)
end
@@ -672,5 +673,7 @@ def dir_config(target, idefault=nil, lde

idir = with_config(target + "-include", idefault)
+ $arg_config.last[1] ||= "${#{target}-dir}/include"
ldir = with_config(target + "-lib", ldefault)
+ $arg_config.last[1] ||= "${#{target}-dir}/lib"

# idirs = idir ? idir.split(File::PATH_SEPARATOR) : []
@@ -1005,4 +1008,6 @@ site-install-rb: install-rb
mfile.print "$(OBJS): #{vpath}ruby.h #{vpath}defines.h #{$config_h}\n"
end
+
+ $makefile_created = true
ensure
mfile.close if mfile
@@ -1010,4 +1015,6 @@ end

def init_mkmf(config = CONFIG)
+ $makefile_created = false
+ $arg_config = []
$enable_shared = config['ENABLE_SHARED'] == 'yes'
$defs = []
@@ -1041,7 +1048,23 @@ def init_mkmf(config = CONFIG)
$extout_prefix ||= nil

+ $arg_config.clear
dir_config("opt")
end

+FailedMassage = <<MESSAGE
+Could not create Makefile due to some reason, probably lack of
+necessary libraries and/or headers. Check the mkmf.log file for more
+details. You may need configuration options.
+
+Provided configuration options:
+MESSAGE
+
+def mkmf_failed(path)
+ unless $makefile_created
+ opts = $arg_config.collect {|t, n| "\t#{t}#{"=#{n}" if n}\n"}
+ abort "*** #{path} failed ***\n" + FailedMassage + opts.join
+ end
+end
+
init_mkmf

@@ -1108,2 +1131,6 @@ distclean: clean
realclean: distclean
"
+
+if not $extmk and /\A(extconf|makefile).rb\z/ =~ File.basename($0)
+ END {mkmf_failed($0)}
+end


--
Nobu Nakada


ggarramuno

10/25/2004 1:04:00 AM

0

nobu.nokada@softhome.net wrote in message news:<200410241422.i9OEMeCf009398@sharui.nakada.niregi.kanuma.tochigi.jp>...
>
> But it would be buried in lots of other messages. Instead, what
> about an option that direct which libraries should be compiled?
>
> E.g.:
>
> $ make EXTS=+zlib
>
> will stop if zlib can't get compiled.

Haven't tried the patch, but it sounds good to me.

Also, is there any way to compile ruby and its libs in debug mode?
Something along the lines of:

> make debug (or nmake debug on windows)

I'm trying 1.9 CVS and Zlib::GzipWriter's closing of files is crashing
right and left and want to track why.

nobu.nokada

10/25/2004 1:46:00 AM

0

Hi,

At Mon, 25 Oct 2004 10:04:08 +0900,
GGarramuno wrote in [ruby-talk:117547]:
> Also, is there any way to compile ruby and its libs in debug mode?
> Something along the lines of:
>
> > make debug (or nmake debug on windows)

It needs to compile all objects with debug options, so I don't
feel "debug" target so useful. I would run configure with
CFLAGS='-ggdb -g3 -O0' in another directory for such purpose.

--
Nobu Nakada


ggarramuno

10/25/2004 7:54:00 PM

0

>It needs to compile all objects with debug options, so I don't
>feel "debug" target so useful. I would run configure with
>CFLAGS='-ggdb -g3 -O0' in another directory for such purpose

It is useful. When you deal with several platforms, switches change subtly
between them and their compilers.
For my line of work, it is often needed to test or debug things in linux,
windows, osx and sometimes even irix (albeit I am currently just doing work on
windows at home; evaluating all of the ruby issues before I deploy ruby fully
at a future job).
The above CFLAGS would result in nothing of use for windows and would likely
choke irix, too.
No sane person remembers them or even wants to learn them. That's what
makefiles are for, imo (write the flags once, then quickly forget about them).

PS. I've tracked the bug in latest zlib. There's a simple NULL pointer being
indexed on gzipwriter's flush due to an incorrect len check in a previous
function.