1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/extmk.rb (extmake): pass LIBPATH to make ruby. [ruby-dev:21137]

* ext/extmk.rb (extmake): set library name as source file name in
  Init_ext().  [ruby-dev:21137]

* lib/mkmf.rb (Logging::postpone): postpone logging messages after
  heading message as the result of the block.

* lib/mkmf.rb (macro_defined?): append newline to src unless ended
  with it.

* lib/mkmf.rb (have_library): allow nil function name to just
  append a library.  (ruby-bugs:PR#1083)

* lib/mkmf.rb (pkg_config): should append additional libraries to
  $libs but not $LIBS.  [ruby-dev:21137]

* ext/io/wait/extconf.rb: check DOSISH macro instead of platform.

* ext/digest/sha1/extconf.rb: have_library already appends library
  name.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2003-08-06 03:11:14 +00:00
parent 6fa004b2e8
commit 94d17c1f1f
5 changed files with 78 additions and 23 deletions

View file

@ -1,3 +1,27 @@
Wed Aug 6 12:11:10 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb (extmake): pass LIBPATH to make ruby. [ruby-dev:21137]
* ext/extmk.rb (extmake): set library name as source file name in
Init_ext(). [ruby-dev:21137]
* lib/mkmf.rb (Logging::postpone): postpone logging messages after
heading message as the result of the block.
* lib/mkmf.rb (macro_defined?): append newline to src unless ended
with it.
* lib/mkmf.rb (have_library): allow nil function name to just
append a library. (ruby-bugs:PR#1083)
* lib/mkmf.rb (pkg_config): should append additional libraries to
$libs but not $LIBS. [ruby-dev:21137]
* ext/io/wait/extconf.rb: check DOSISH macro instead of platform.
* ext/digest/sha1/extconf.rb: have_library already appends library
name.
Wed Aug 6 04:58:32 2003 NAKAMURA Usaku <usa@ruby-lang.org> Wed Aug 6 04:58:32 2003 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/Setup*: add io/wait and openssl. * ext/Setup*: add io/wait and openssl.

View file

@ -12,7 +12,6 @@ dir_config("openssl")
if !with_config("bundled-sha1") && if !with_config("bundled-sha1") &&
have_library("crypto") && have_header("openssl/sha.h") have_library("crypto") && have_header("openssl/sha.h")
$objs << "sha1ossl.#{$OBJEXT}" $objs << "sha1ossl.#{$OBJEXT}"
$libs << " -lcrypto"
else else
$objs << "sha1.#{$OBJEXT}" << "sha1hl.#{$OBJEXT}" $objs << "sha1.#{$OBJEXT}" << "sha1hl.#{$OBJEXT}"
end end

View file

@ -101,10 +101,12 @@ def extmake(target)
if $static if $static
$extflags ||= "" $extflags ||= ""
$extlibs ||= "" $extlibs ||= ""
$extflags += " " + $DLDFLAGS if $DLDFLAGS $extpath ||= []
$extflags += " " + $LDFLAGS unless $LDFLAGS == "" $extflags += " " + $DLDFLAGS unless $DLDFLAGS.empty?
$extlibs += " " + $libs unless $libs == "" $extflags += " " + $LDFLAGS unless $LDFLAGS.empty?
$extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == "" libs = ($libs.split+$LOCAL_LIBS.split).uniq
$extlibs = [$extlibs, *libs].join(" ") unless libs.empty?
$extpath |= $LIBPATH
end end
ensure ensure
Dir.chdir dir Dir.chdir dir
@ -212,7 +214,7 @@ File::makedirs('ext')
Dir::chdir('ext') Dir::chdir('ext')
ext_prefix = "#{$top_srcdir}/ext" ext_prefix = "#{$top_srcdir}/ext"
Dir.glob("#{ext_prefix}/**/MANIFEST") do |d| Dir.glob("#{ext_prefix}/*/**/MANIFEST") do |d|
d = File.dirname(d) d = File.dirname(d)
d.slice!(0, ext_prefix.length + 1) d.slice!(0, ext_prefix.length + 1)
extmake(d) or exit(1) extmake(d) or exit(1)
@ -229,12 +231,16 @@ if $extlist.size > 0
for s,t,i in $extlist for s,t,i in $extlist
f = format("%s/%s.%s", s, i, $LIBEXT) f = format("%s/%s.%s", s, i, $LIBEXT)
if File.exist?(f) if File.exist?(f)
$extinit += "\tInit_#{i}();\n\trb_provide(\"#{t}.so\");\n" $extinit += "\tinit(Init_#{i}, \"#{t}.so\");\n"
$extobjs += "ext/#{f} " $extobjs += "ext/#{f} "
end end
end end
src = "void Init_ext() {\n#$extinit}\n" src = <<SRC
extern char *ruby_sourcefile, *rb_source_filename();
#define init(func, name) (ruby_sourcefile = src = rb_source_filename(name), func(), rb_provide(src))
void Init_ext() {\n\tchar* src;\n#$extinit}
SRC
if !modified?("extinit.c", MTIMES) || IO.read("extinit.c") != src if !modified?("extinit.c", MTIMES) || IO.read("extinit.c") != src
open("extinit.c", "w") {|f| f.print src} open("extinit.c", "w") {|f| f.print src}
end end
@ -243,6 +249,8 @@ if $extlist.size > 0
if RUBY_PLATFORM =~ /m68k-human|beos/ if RUBY_PLATFORM =~ /m68k-human|beos/
$extlibs.gsub!("-L/usr/local/lib", "") if $extlibs $extlibs.gsub!("-L/usr/local/lib", "") if $extlibs
end end
$extpath.delete("$(topdir)")
$extflags = libpathflag($extpath) << " " << $extflags.strip
conf = [ conf = [
['SETUP', $setup], ['EXTOBJS', $extobjs], ['SETUP', $setup], ['EXTOBJS', $extobjs],
['EXTLIBS', $extlibs], ['EXTLDFLAGS', $extflags] ['EXTLIBS', $extlibs], ['EXTLDFLAGS', $extflags]

View file

@ -1,7 +1,7 @@
require 'mkmf' require 'mkmf'
target = "io/wait" target = "io/wait"
unless /djgpp|mswin|mingw|human/ =~ RUBY_PLATFORM unless macro_defined?("DOSISH", "#include <ruby.h>")
fionread = %w[sys/ioctl.h sys/filio.h].find do |h| fionread = %w[sys/ioctl.h sys/filio.h].find do |h|
checking_for("FIONREAD") {macro_defined?("FIONREAD", "#include <#{h}>\n")} checking_for("FIONREAD") {macro_defined?("FIONREAD", "#include <#{h}>\n")}
end end

View file

@ -144,6 +144,22 @@ module Logging
@log = nil @log = nil
end end
end end
def self::postpone
tmplog = "mkmftmp.log"
open do
log, *save = @log, @logfile, @orgout, @orgerr
@log, @logfile, @orgout, @orgerr = nil, tmplog, log, log
begin
log.print(open {yield})
@log.close
File::open(tmplog) {|t| FileUtils.copy_stream(t, log)}
ensure
@log, @logfile, @orgout, @orgerr = log, *save
rm_f tmplog
end
end
end
end end
def xsystem command def xsystem command
@ -184,7 +200,7 @@ def create_tmpsrc(src)
end end
def try_do(src, command) def try_do(src, command)
src += "\n" unless /\n\z/ =~ src src = src.sub(/[^\n]\z/, "\\&\n")
create_tmpsrc(src) create_tmpsrc(src)
xsystem(command) xsystem(command)
ensure ensure
@ -318,7 +334,7 @@ SRC
end end
def egrep_cpp(pat, src, opt="") def egrep_cpp(pat, src, opt="")
src += "\n" unless /\n\z/ =~ src src = src.sub(/[^\n]\z/, "\\&\n")
create_tmpsrc(src) create_tmpsrc(src)
xpopen(cpp_command('', opt)) do |f| xpopen(cpp_command('', opt)) do |f|
if Regexp === pat if Regexp === pat
@ -345,6 +361,7 @@ ensure
end end
def macro_defined?(macro, src, opt="") def macro_defined?(macro, src, opt="")
src = src.sub(/[^\n]\z/, "\\&\n")
try_cpp(src + <<"SRC", opt) try_cpp(src + <<"SRC", opt)
#ifndef #{macro} #ifndef #{macro}
# error # error
@ -418,19 +435,25 @@ def checking_for(m)
f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim f = caller[0][/in `(.*)'$/, 1] and f << ": " #` for vim
m = "checking for #{m}... " m = "checking for #{m}... "
message "%s", m message "%s", m
Logging::message "%s%s--------------------\n", f, m a = r = nil
Logging::postpone do
r = yield r = yield
message(a = r ? "yes\n" : "no\n") a = r ? "yes\n" : "no\n"
Logging::message "-------------------- %s\n", a "#{f}#{m}-------------------- #{a}\n"
end
message(a)
Logging::message "--------------------\n\n"
r r
end end
def have_library(lib, func="main") def have_library(lib, func="main")
checking_for "#{func}() in -l#{lib}" do func &&= ((m = "#{func}() in "; func) unless func.empty?)
libs = append_library($libs, lib) checking_for "#{m}-l#{lib}" do
if func && func != "" && COMMON_LIBS.include?(lib) if COMMON_LIBS.include?(lib)
true true
elsif try_func(func, libs) else
libs = append_library($libs, lib)
if !func || try_func(func, libs)
$libs = libs $libs = libs
true true
else else
@ -438,6 +461,7 @@ def have_library(lib, func="main")
end end
end end
end end
end
def find_library(lib, func, *paths) def find_library(lib, func, *paths)
checking_for "#{func}() in -l#{lib}" do checking_for "#{func}() in -l#{lib}" do
@ -630,7 +654,7 @@ def pkg_config(pkg)
libs = `#{$PKGCONFIG} --libs-only-l #{pkg}`.chomp libs = `#{$PKGCONFIG} --libs-only-l #{pkg}`.chomp
$CFLAGS += " " << cflags $CFLAGS += " " << cflags
$LDFLAGS += " " << ldflags $LDFLAGS += " " << ldflags
$LIBS += " " << libs $libs += " " << libs
Logging::message "package configuration for %s\n", pkg Logging::message "package configuration for %s\n", pkg
Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n", Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n",
cflags, ldflags, libs cflags, ldflags, libs