summaryrefslogtreecommitdiff
path: root/ext/extmk.rb.in
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-17 14:46:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-17 14:46:44 +0000
commit21d0c3b815b16713b31522c14ebb52e815224ec3 (patch)
treeea3d4ecc483f835084e8a4399700dca2ef976c12 /ext/extmk.rb.in
parent11829a5368447bf4829fc040498457763d52a9b3 (diff)
* mkconfig.rb (Config::expand): expand ${} too.
* ext/extmk.rb.in (try_link0): expand command. * ext/extmk.rb.in (try_cpp): ditto. * ext/extmk.rb.in (extmake): default $LIBPATH to $libdir git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/extmk.rb.in')
-rw-r--r--ext/extmk.rb.in36
1 files changed, 16 insertions, 20 deletions
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index b073a15..5b4d9b9 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -1,7 +1,7 @@
#! /usr/local/bin/ruby
# -*- ruby -*-
-$".push 'mkmf.rb'
+$".push 'mkmf.rb' # "
ORIG_LIBPATH = ENV['LIB']
if ARGV[0] == 'static'
@@ -25,8 +25,8 @@ end
SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"]
$extlist = []
-$includedir = "@includedir@".gsub(/\$\{prefix\}|\$\(prefix\)/,'@prefix@')
-$libdir = "@libdir@".gsub(/\$\{exec_prefix\}|\$\(exec_prefix\)/,'@exec_prefix@')
+$includedir = "@includedir@"
+$libdir = "@libdir@"
$top_srcdir = "@top_srcdir@"
if $top_srcdir !~ "^/"
@@ -36,8 +36,9 @@ end
# get absolute path
$topdir = File.expand_path("..")
-$:.replace [$top_srcdir, $top_srcdir+"/lib", "."]
+$:.replace [$topdir, $top_srcdir, $top_srcdir+"/lib", "."]
+require 'rbconfig.rb'
require 'find'
def rm_f(*files)
@@ -64,17 +65,16 @@ def older(file1, file2)
return false
end
+CFLAGS = "@CFLAGS@"
if RUBY_PLATFORM == "m68k-human"
- CFLAGS = "@CFLAGS@".gsub(/-c..-stack=[0-9]+ */, '')
-else
- CFLAGS = "@CFLAGS@"
+ CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '')
end
if /mswin32/ =~ RUBY_PLATFORM
OUTFLAG = '-Fe'
else
OUTFLAG = '-o '
end
-LINK = "@CC@ #{OUTFLAG}conftest -I#$topdir -I#$top_srcdir #{CFLAGS} -I#$includedir -L#$libdir @LDFLAGS@ %s %s %s conftest.c %s %s @LIBS@"
+LINK = "@CC@ #{OUTFLAG}conftest -I#$topdir -I#$top_srcdir #{CFLAGS} -I#$includedir @LDFLAGS@ %s %s %s conftest.c %s %s @LIBS@"
CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir #{CFLAGS} -I#$includedir %s %s %s conftest.c"
$log = open('extmk.log', 'w')
@@ -103,13 +103,12 @@ def try_link0(src, opt="")
if /mswin32/ =~ RUBY_PLATFORM and !$LIBPATH.empty?
ENV['LIB'] = ($LIBPATH + [ORIG_LIBPATH]).compact.join(';')
else
- $LDFLAGS = ldflags.dup
- $LIBPATH.each {|d| $LDFLAGS << " -L" + d}
+ ldflags = ldflags.dup
+ $LIBPATH.each {|d| ldflags << " -L" + d}
end
begin
- xsystem(format(LINK, $CFLAGS, $CPPFLAGS, $LDFLAGS, opt, $LOCAL_LIBS))
+ xsystem(Config::expand(format(LINK, $CFLAGS, $CPPFLAGS, ldflags, opt, $LOCAL_LIBS)))
ensure
- $LDFLAGS = ldflags
ENV['LIB'] = ORIG_LIBPATH if /mswin32/ =~ RUBY_PLATFORM
end
end
@@ -127,7 +126,7 @@ def try_cpp(src, opt="")
cfile.print src
cfile.close
begin
- xsystem(format(CPP, $CFLAGS, $CPPFLAGS, opt))
+ xsystem(Config::expand(format(CPP, $CFLAGS, $CPPFLAGS, opt)))
ensure
rm_f "conftest*"
end
@@ -138,7 +137,7 @@ def egrep_cpp(pat, src, opt="")
cfile.print src
cfile.close
begin
- xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, $CPPFLAGS, opt))
+ xsystem(Config::expand(format(CPP, $CFLAGS, $CPPFLAGS, opt))+"|egrep #{pat}")
ensure
rm_f "conftest*"
end
@@ -298,11 +297,8 @@ def arg_config(config, default=nil)
end
for arg in args.split
next unless /^--/ =~ arg
- if /=/ =~ arg
- $configure_args[$`] = $'
- else
- $configure_args[arg] = true
- end
+ arg, val = arg.split('=', 2)
+ $configure_args[arg] = val || true
end
end
$configure_args.fetch(config, default)
@@ -629,7 +625,7 @@ def extmake(target)
$CFLAGS = ""
$CPPFLAGS = ""
$LDFLAGS = ""
- $LIBPATH = []
+ $LIBPATH = [$libdir]
dir_config("opt")