1998-01-16 07:13:05 -05:00
|
|
|
#! /usr/local/bin/ruby
|
2000-12-21 22:22:25 -05:00
|
|
|
# -*- ruby -*-
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
$".push 'mkmf.rb'
|
2000-12-21 22:22:25 -05:00
|
|
|
ORIG_LIBPATH = ENV['LIB']
|
1998-01-16 07:19:22 -05:00
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
if ARGV[0] == 'static'
|
1999-08-13 01:37:52 -04:00
|
|
|
$force_static = true
|
1998-01-16 07:13:05 -05:00
|
|
|
ARGV.shift
|
|
|
|
elsif ARGV[0] == 'install'
|
1999-08-13 01:37:52 -04:00
|
|
|
$install = true
|
1999-01-19 23:59:39 -05:00
|
|
|
$destdir = ARGV[1] || ''
|
1998-01-16 07:13:05 -05:00
|
|
|
ARGV.shift
|
|
|
|
elsif ARGV[0] == 'clean'
|
2001-01-09 02:26:21 -05:00
|
|
|
$clean = "clean"
|
|
|
|
ARGV.shift
|
|
|
|
elsif ARGV[0] == 'distclean'
|
|
|
|
$clean = "distclean"
|
|
|
|
ARGV.shift
|
|
|
|
elsif ARGV[0] == 'realclean'
|
|
|
|
$clean = "realclean"
|
1998-01-16 07:13:05 -05:00
|
|
|
ARGV.shift
|
|
|
|
end
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"]
|
1998-01-16 07:13:05 -05:00
|
|
|
$extlist = []
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
$includedir = "@includedir@".gsub(/\$\{prefix\}|\$\(prefix\)/,'@prefix@')
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
$top_srcdir = "@top_srcdir@"
|
|
|
|
if $top_srcdir !~ "^/"
|
|
|
|
# get absolute path
|
1999-08-13 01:37:52 -04:00
|
|
|
$top_srcdir = File.expand_path($top_srcdir)
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
1999-08-13 01:37:52 -04:00
|
|
|
# get absolute path
|
|
|
|
$topdir = File.expand_path("..")
|
|
|
|
|
2000-09-22 01:00:23 -04:00
|
|
|
$:.replace [$top_srcdir, $top_srcdir+"/lib", "."]
|
1999-08-13 01:37:52 -04:00
|
|
|
|
|
|
|
require 'find'
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2000-05-28 22:10:22 -04:00
|
|
|
def rm_f(*files)
|
|
|
|
targets = []
|
|
|
|
for file in files
|
|
|
|
targets.concat Dir[file]
|
|
|
|
end
|
|
|
|
if not targets.empty?
|
2001-07-09 03:54:49 -04:00
|
|
|
File::chmod(0777, *targets)
|
|
|
|
File::unlink(*targets)
|
2000-05-28 22:10:22 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
def older(file1, file2)
|
|
|
|
if !File.exist?(file1) then
|
1999-08-13 01:37:52 -04:00
|
|
|
return true
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
if !File.exist?(file2) then
|
1999-08-13 01:37:52 -04:00
|
|
|
return false
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
if File.mtime(file1) < File.mtime(file2)
|
1999-08-13 01:37:52 -04:00
|
|
|
return true
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
1999-08-13 01:37:52 -04:00
|
|
|
return false
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
if RUBY_PLATFORM == "m68k-human"
|
|
|
|
CFLAGS = "@CFLAGS@".gsub(/-c..-stack=[0-9]+ */, '')
|
1998-01-16 07:13:05 -05:00
|
|
|
else
|
1999-08-13 01:37:52 -04:00
|
|
|
CFLAGS = "@CFLAGS@"
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
2001-06-09 03:41:44 -04:00
|
|
|
if /mswin32/ =~ RUBY_PLATFORM
|
|
|
|
OUTFLAG = '-Fe'
|
|
|
|
else
|
|
|
|
OUTFLAG = '-o '
|
|
|
|
end
|
|
|
|
LINK = "@CC@ #{OUTFLAG}conftest -I#$topdir -I#$top_srcdir #{CFLAGS} -I#$includedir @LDFLAGS@ %s %s %s conftest.c %s %s @LIBS@"
|
2000-08-09 00:32:24 -04:00
|
|
|
CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir #{CFLAGS} -I#$includedir %s %s %s conftest.c"
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2001-06-05 00:54:52 -04:00
|
|
|
$log = open('extmk.log', 'w')
|
1999-01-19 23:59:39 -05:00
|
|
|
|
|
|
|
$orgerr = $stderr.dup
|
|
|
|
$orgout = $stdout.dup
|
|
|
|
def xsystem command
|
|
|
|
if $DEBUG
|
1999-08-13 01:37:52 -04:00
|
|
|
puts command
|
1999-01-19 23:59:39 -05:00
|
|
|
return system(command)
|
|
|
|
end
|
2001-06-05 00:54:52 -04:00
|
|
|
$stderr.reopen($log)
|
|
|
|
$stdout.reopen($log)
|
|
|
|
puts command
|
1999-01-19 23:59:39 -05:00
|
|
|
r = system(command)
|
|
|
|
$stderr.reopen($orgerr)
|
|
|
|
$stdout.reopen($orgout)
|
|
|
|
return r
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
def try_link0(src, opt="")
|
|
|
|
cfile = open("conftest.c", "w")
|
|
|
|
cfile.print src
|
|
|
|
cfile.close
|
2000-12-21 22:22:25 -05:00
|
|
|
ldflags = $LDFLAGS
|
|
|
|
if /mswin32/ =~ RUBY_PLATFORM and !$LIBPATH.empty?
|
|
|
|
ENV['LIB'] = ($LIBPATH + [ORIG_LIBPATH]).compact.join(';')
|
|
|
|
else
|
|
|
|
$LDFLAGS = ldflags.dup
|
|
|
|
$LIBPATH.each {|d| $LDFLAGS << " -L" + d}
|
|
|
|
end
|
|
|
|
begin
|
|
|
|
xsystem(format(LINK, $CFLAGS, $CPPFLAGS, $LDFLAGS, opt, $LOCAL_LIBS))
|
|
|
|
ensure
|
|
|
|
$LDFLAGS = ldflags
|
|
|
|
ENV['LIB'] = ORIG_LIBPATH if /mswin32/ =~ RUBY_PLATFORM
|
|
|
|
end
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def try_link(src, opt="")
|
|
|
|
begin
|
|
|
|
try_link0(src, opt)
|
|
|
|
ensure
|
2000-05-28 22:10:22 -04:00
|
|
|
rm_f "conftest*"
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def try_cpp(src, opt="")
|
|
|
|
cfile = open("conftest.c", "w")
|
|
|
|
cfile.print src
|
|
|
|
cfile.close
|
|
|
|
begin
|
2000-08-09 00:32:24 -04:00
|
|
|
xsystem(format(CPP, $CFLAGS, $CPPFLAGS, opt))
|
1999-08-13 01:37:52 -04:00
|
|
|
ensure
|
2000-05-28 22:10:22 -04:00
|
|
|
rm_f "conftest*"
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
def egrep_cpp(pat, src, opt="")
|
|
|
|
cfile = open("conftest.c", "w")
|
|
|
|
cfile.print src
|
|
|
|
cfile.close
|
|
|
|
begin
|
2000-08-09 00:32:24 -04:00
|
|
|
xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, $CPPFLAGS, opt))
|
1999-08-13 01:37:52 -04:00
|
|
|
ensure
|
2000-05-28 22:10:22 -04:00
|
|
|
rm_f "conftest*"
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
def try_run(src, opt="")
|
|
|
|
begin
|
|
|
|
if try_link0(src, opt)
|
|
|
|
if xsystem("./conftest")
|
|
|
|
true
|
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
ensure
|
2000-05-28 22:10:22 -04:00
|
|
|
rm_f "conftest*"
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def install_rb(mfile, srcdir = nil)
|
|
|
|
libdir = "lib"
|
|
|
|
libdir = srcdir + "/" + libdir if srcdir
|
1999-01-19 23:59:39 -05:00
|
|
|
path = []
|
|
|
|
dir = []
|
2000-09-21 06:08:57 -04:00
|
|
|
if File.directory? libdir
|
|
|
|
Find.find(libdir) do |f|
|
|
|
|
next unless /\.rb$/ =~ f
|
|
|
|
f = f[libdir.length+1..-1]
|
|
|
|
path.push f
|
2000-12-05 06:07:49 -05:00
|
|
|
dir |= [File.dirname(f)]
|
2000-09-21 06:08:57 -04:00
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
|
|
|
for f in dir
|
2001-07-24 06:29:17 -04:00
|
|
|
if f == "."
|
|
|
|
mfile.print "\t@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(DESTDIR)$(pkglibdir)$(target_prefix)\n"
|
|
|
|
else
|
|
|
|
mfile.printf "\t@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(DESTDIR)$(pkglibdir)$(target_prefix)/%s\n", f
|
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
|
|
|
for f in path
|
2001-07-13 14:02:10 -04:00
|
|
|
mfile.printf "\t@$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0644, true)' $(srcdir)/lib/%s $(DESTDIR)$(pkglibdir)$(target_prefix)/%s\n", f, f
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def append_library(libs, lib)
|
|
|
|
if /mswin32/ =~ RUBY_PLATFORM
|
|
|
|
lib + ".lib " + libs
|
|
|
|
else
|
|
|
|
"-l" + lib + " " + libs
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
def have_library(lib, func="main")
|
|
|
|
if func && func != ""
|
1999-08-13 01:37:52 -04:00
|
|
|
libs = append_library($libs, lib)
|
2000-05-13 12:13:31 -04:00
|
|
|
if /mswin32|mingw/ =~ RUBY_PLATFORM
|
1999-08-13 01:37:52 -04:00
|
|
|
r = try_link(<<"SRC", libs)
|
|
|
|
#include <windows.h>
|
|
|
|
#include <winsock.h>
|
1998-01-16 07:13:05 -05:00
|
|
|
int main() { return 0; }
|
2000-06-05 04:46:59 -04:00
|
|
|
int t() { #{func}(); return 0; }
|
|
|
|
SRC
|
|
|
|
unless r
|
|
|
|
r = try_link(<<"SRC", libs)
|
|
|
|
#include <windows.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
int main() { return 0; }
|
1999-08-13 01:37:52 -04:00
|
|
|
int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; }
|
|
|
|
SRC
|
2000-06-05 04:46:59 -04:00
|
|
|
end
|
1998-01-16 07:13:05 -05:00
|
|
|
else
|
1999-08-13 01:37:52 -04:00
|
|
|
r = try_link(<<"SRC", libs)
|
|
|
|
int main() { return 0; }
|
|
|
|
int t() { #{func}(); return 0; }
|
|
|
|
SRC
|
|
|
|
end
|
|
|
|
unless r
|
|
|
|
return false
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
1999-08-13 01:37:52 -04:00
|
|
|
else
|
|
|
|
libs = append_library($libs, lib)
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
$libs = libs
|
1999-08-13 01:37:52 -04:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_library(lib, func, *paths)
|
2000-12-21 22:22:25 -05:00
|
|
|
libpath = $LIBPATH
|
1999-08-13 01:37:52 -04:00
|
|
|
libs = append_library($libs, lib)
|
|
|
|
until try_link(<<"SRC", libs)
|
|
|
|
int main() { return 0; }
|
|
|
|
int t() { #{func}(); return 0; }
|
|
|
|
SRC
|
|
|
|
if paths.size == 0
|
2000-12-21 22:22:25 -05:00
|
|
|
$LIBPATH = libpath
|
1999-08-13 01:37:52 -04:00
|
|
|
return false
|
|
|
|
end
|
2000-12-21 22:22:25 -05:00
|
|
|
$LIBPATH = libpath | [paths.shift]
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
|
|
|
$libs = libs
|
|
|
|
return true
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
|
2000-06-22 04:29:58 -04:00
|
|
|
def have_func(func, header=nil)
|
1998-01-16 07:13:05 -05:00
|
|
|
libs = $libs
|
2000-06-22 04:29:58 -04:00
|
|
|
src =
|
|
|
|
if /mswin32|mingw/ =~ RUBY_PLATFORM
|
|
|
|
r = <<"SRC"
|
1999-08-13 01:37:52 -04:00
|
|
|
#include <windows.h>
|
|
|
|
#include <winsock.h>
|
2000-06-22 04:29:58 -04:00
|
|
|
SRC
|
|
|
|
else
|
|
|
|
""
|
|
|
|
end
|
|
|
|
unless header.nil?
|
|
|
|
src << <<"SRC"
|
|
|
|
#include <#{header}>
|
|
|
|
SRC
|
|
|
|
end
|
|
|
|
r = try_link(src + <<"SRC", libs)
|
1999-08-13 01:37:52 -04:00
|
|
|
int main() { return 0; }
|
2000-06-05 04:46:59 -04:00
|
|
|
int t() { #{func}(); return 0; }
|
|
|
|
SRC
|
2000-06-22 04:29:58 -04:00
|
|
|
unless r
|
|
|
|
r = try_link(src + <<"SRC", libs)
|
2000-06-05 04:46:59 -04:00
|
|
|
int main() { return 0; }
|
1999-08-13 01:37:52 -04:00
|
|
|
int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; }
|
|
|
|
SRC
|
|
|
|
end
|
|
|
|
unless r
|
|
|
|
return false
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
$defs.push(format("-DHAVE_%s", func.upcase))
|
1999-08-13 01:37:52 -04:00
|
|
|
return true
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def have_header(header)
|
1999-08-13 01:37:52 -04:00
|
|
|
unless try_cpp(<<"SRC")
|
|
|
|
#include <#{header}>
|
|
|
|
SRC
|
|
|
|
return false
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
2001-05-24 02:10:36 -04:00
|
|
|
$defs.push(format("-DHAVE_%s", header.tr("a-z./\055", "A-Z___")))
|
1999-08-13 01:37:52 -04:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
def arg_config(config, default=nil)
|
|
|
|
unless defined? $configure_args
|
|
|
|
$configure_args = {}
|
|
|
|
args = "@configure_args@"
|
2000-05-13 12:13:31 -04:00
|
|
|
if /mswin32|mingw/ =~ RUBY_PLATFORM and ENV["CONFIGURE_ARGS"]
|
2000-12-21 22:22:25 -05:00
|
|
|
args << " " << ENV["CONFIGURE_ARGS"]
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
|
|
|
for arg in args.split
|
|
|
|
next unless /^--/ =~ arg
|
|
|
|
if /=/ =~ arg
|
|
|
|
$configure_args[$`] = $'
|
|
|
|
else
|
|
|
|
$configure_args[arg] = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
$configure_args.fetch(config, default)
|
|
|
|
end
|
|
|
|
|
|
|
|
def with_config(config, default=nil)
|
|
|
|
unless /^--with-/ =~ config
|
|
|
|
config = '--with-' + config
|
|
|
|
end
|
|
|
|
arg_config(config, default)
|
|
|
|
end
|
|
|
|
|
|
|
|
def enable_config(config, default=nil)
|
|
|
|
if arg_config("--enable-"+config, default)
|
|
|
|
true
|
|
|
|
elsif arg_config("--disable-"+config, false)
|
|
|
|
false
|
|
|
|
else
|
|
|
|
default
|
|
|
|
end
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def create_header()
|
|
|
|
if $defs.length > 0
|
|
|
|
hfile = open("extconf.h", "w")
|
|
|
|
for line in $defs
|
|
|
|
line =~ /^-D(.*)/
|
|
|
|
hfile.printf "#define %s 1\n", $1
|
|
|
|
end
|
|
|
|
hfile.close
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2000-08-24 02:21:43 -04:00
|
|
|
def dir_config(target, idefault=nil, ldefault=nil)
|
|
|
|
if idefault && ldefault == nil
|
|
|
|
default = idefault
|
|
|
|
idefault = default + "/include"
|
|
|
|
ldefault = default + "/lib"
|
|
|
|
end
|
2001-04-24 02:21:58 -04:00
|
|
|
|
|
|
|
dir = with_config(target + "-dir", default)
|
|
|
|
|
|
|
|
idir, ldir = if dir then [
|
|
|
|
dir + "/include",
|
|
|
|
dir + "/lib"
|
|
|
|
] else [
|
|
|
|
with_config(target + "-include", idefault),
|
|
|
|
with_config(target + "-lib", ldefault)
|
|
|
|
] end
|
|
|
|
|
|
|
|
if idir
|
|
|
|
idircflag = "-I" + idir
|
|
|
|
$CPPFLAGS += " " + idircflag unless $CPPFLAGS.split.include?(idircflag)
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
2001-04-24 02:21:58 -04:00
|
|
|
|
|
|
|
if ldir
|
|
|
|
$LIBPATH << ldir unless $LIBPATH.include?(ldir)
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
|
|
|
|
2001-04-24 02:21:58 -04:00
|
|
|
[idir, ldir]
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
def create_makefile(target)
|
1999-08-13 01:37:52 -04:00
|
|
|
$target = target
|
2001-07-13 10:19:28 -04:00
|
|
|
if target.include?('/')
|
|
|
|
target_prefix, target = File.split(target)
|
|
|
|
target_prefix[0,0] = '/'
|
2000-08-28 22:52:41 -04:00
|
|
|
else
|
|
|
|
target_prefix = ""
|
|
|
|
end
|
2000-05-28 22:10:22 -04:00
|
|
|
rm_f "conftest*"
|
1999-08-13 01:37:52 -04:00
|
|
|
if "@DLEXT@" == $OBJEXT
|
1998-01-16 07:13:05 -05:00
|
|
|
libs = $libs.split
|
|
|
|
for lib in libs
|
1999-08-13 01:37:52 -04:00
|
|
|
lib.sub!(/-l(.*)/, %%"lib\\1.#{$LIBEXT}"%)
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
$defs.push(format("-DEXTLIB='%s'", libs.join(",")))
|
|
|
|
end
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
$DLDFLAGS = '@DLDFLAGS@'
|
|
|
|
|
2000-12-21 22:22:25 -05:00
|
|
|
if $configure_args['--enable-shared'] or "@LIBRUBY@" != "@LIBRUBY_A@"
|
2000-05-09 00:53:16 -04:00
|
|
|
$libs = "@LIBRUBYARG@ " + $libs
|
2000-12-27 00:59:03 -05:00
|
|
|
$LIBPATH.unshift $topdir
|
2000-05-09 00:53:16 -04:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
defflag = ''
|
2000-05-13 12:13:31 -04:00
|
|
|
if RUBY_PLATFORM =~ /cygwin|mingw/ and not $static
|
2001-04-02 21:16:14 -04:00
|
|
|
if not File.exist? target + '.def'
|
|
|
|
open(target + '.def', 'wb') do |f|
|
|
|
|
f.print "EXPORTS\n", "Init_", target, "\n"
|
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
2000-07-05 10:12:27 -04:00
|
|
|
defflag = "--def=" + target + ".def"
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
|
|
|
|
2000-12-21 22:22:25 -05:00
|
|
|
if RUBY_PLATFORM =~ /mswin32/
|
|
|
|
libpath = $LIBPATH.join(';')
|
|
|
|
else
|
|
|
|
$LIBPATH.each {|d| $DLDFLAGS << " -L" << d}
|
2001-12-06 04:55:31 -05:00
|
|
|
if /netbsdelf/ =~ RUBY_PLATFORM
|
2001-12-07 01:52:31 -05:00
|
|
|
$LIBPATH.each {|d| $DLDFLAGS << " -Wl,-R" + d unless d == $topdir}
|
2001-12-06 04:55:31 -05:00
|
|
|
end
|
2000-12-21 22:22:25 -05:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
$srcdir = $top_srcdir + "/ext/" + $mdir
|
1998-01-16 07:13:05 -05:00
|
|
|
mfile = open("Makefile", "w")
|
2000-05-14 05:36:29 -04:00
|
|
|
mfile.binmode if /mingw/ =~ RUBY_PLATFORM
|
1998-01-16 07:13:05 -05:00
|
|
|
mfile.printf "\
|
|
|
|
SHELL = /bin/sh
|
|
|
|
|
|
|
|
#### Start of system configuration section. ####
|
|
|
|
|
|
|
|
srcdir = #{$srcdir}
|
|
|
|
VPATH = #{$srcdir}
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
topdir = #{$topdir}
|
|
|
|
hdrdir = #{$top_srcdir}
|
1998-01-16 07:19:22 -05:00
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
CC = @CC@
|
|
|
|
|
2000-08-03 05:50:41 -04:00
|
|
|
CFLAGS = %s #{CFLAGS} #$CFLAGS
|
2000-08-09 00:32:24 -04:00
|
|
|
CPPFLAGS = -I$(topdir) -I$(hdrdir) -I@includedir@ %s #$CPPFLAGS
|
1999-08-13 01:37:52 -04:00
|
|
|
DLDFLAGS = #$DLDFLAGS #$LDFLAGS
|
|
|
|
LDSHARED = @LDSHARED@ #{defflag}
|
1999-01-19 23:59:39 -05:00
|
|
|
", if $static then "" else "@CCDLFLAGS@" end, $defs.join(" ")
|
2000-12-21 22:22:25 -05:00
|
|
|
mfile.puts "LIBPATH = #{libpath}" if libpath
|
|
|
|
|
|
|
|
mfile.puts ".SUFFIXES: .@OBJEXT@" unless "@OBJEXT@" == "o"
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
mfile.printf "\
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
RUBY_INSTALL_NAME = @RUBY_INSTALL_NAME@
|
2000-08-03 05:50:41 -04:00
|
|
|
RUBY_SO_NAME = @RUBY_SO_NAME@
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
prefix = @prefix@
|
|
|
|
exec_prefix = @exec_prefix@
|
1999-01-19 23:59:39 -05:00
|
|
|
libdir = @libdir@
|
1999-08-13 01:37:52 -04:00
|
|
|
#pkglibdir = $(libdir)/$(RUBY_INSTALL_NAME)/@MAJOR@.@MINOR@
|
|
|
|
pkglibdir = $(libdir)/ruby/@MAJOR@.@MINOR@
|
1999-01-19 23:59:39 -05:00
|
|
|
archdir = $(pkglibdir)/@arch@
|
2001-07-13 14:02:10 -04:00
|
|
|
target_prefix = #{target_prefix}
|
1998-01-16 07:13:05 -05:00
|
|
|
@SET_MAKE@
|
|
|
|
|
|
|
|
#### End of system configuration section. ####
|
1998-01-16 07:19:22 -05:00
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
"
|
1999-08-13 01:37:52 -04:00
|
|
|
mfile.printf "LOCAL_LIBS = %s %s\n", $LOCAL_LIBS, $local_flags
|
1998-01-16 07:13:05 -05:00
|
|
|
mfile.printf "LIBS = %s\n", $libs
|
|
|
|
mfile.printf "OBJS = "
|
|
|
|
if !$objs then
|
1998-01-16 07:19:22 -05:00
|
|
|
$objs = []
|
1999-08-13 01:37:52 -04:00
|
|
|
for f in Dir["#{$top_srcdir}/ext/#{$mdir}/*.{#{SRC_EXT.join(%q{,})}}"]
|
1998-01-16 07:19:22 -05:00
|
|
|
f = File.basename(f)
|
1999-08-13 01:37:52 -04:00
|
|
|
f.sub!(/(#{SRC_EXT.join(%q{|})})$/, $OBJEXT)
|
1998-01-16 07:19:22 -05:00
|
|
|
$objs.push f
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
2000-07-17 05:38:10 -04:00
|
|
|
else
|
|
|
|
for i in $objs
|
|
|
|
i.sub!(/\.o\z/, ".#{$OBJEXT}")
|
|
|
|
end
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
mfile.printf $objs.join(" ")
|
|
|
|
mfile.printf "\n"
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
ruby_interpreter = "$(topdir)/miniruby@EXEEXT@"
|
2000-12-21 22:22:25 -05:00
|
|
|
if /nmake/i =~ $make
|
|
|
|
ruby_interpreter = '$(topdir:/=\)\miniruby@EXEEXT@'
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
2000-05-21 05:25:58 -04:00
|
|
|
if defined? CROSS_COMPILING
|
|
|
|
ruby_interpreter = "@MINIRUBY@"
|
|
|
|
end
|
1999-08-13 01:37:52 -04:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
mfile.printf <<EOS
|
1999-08-13 01:37:52 -04:00
|
|
|
TARGET = #{target}
|
|
|
|
DLLIB = $(TARGET).#{$static ? $LIBEXT : "@DLEXT@"}
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
RUBY = #{ruby_interpreter} -I$(topdir) -I$(hdrdir)/lib
|
2001-07-16 22:13:13 -04:00
|
|
|
RM = $(RUBY) -rftools -e "File::rm_f(*ARGV.map{|x|Dir[x]}.flatten.uniq)"
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
EXEEXT = @EXEEXT@
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
all: $(DLLIB)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2000-05-28 22:10:22 -04:00
|
|
|
clean:; @$(RM) *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB)
|
2001-07-22 08:24:12 -04:00
|
|
|
@$(RM) *.ilk *.exp *.pdb *.bak $(CLEANFILES)
|
2000-06-12 03:48:31 -04:00
|
|
|
|
|
|
|
distclean: clean
|
2000-05-28 22:10:22 -04:00
|
|
|
@$(RM) Makefile extconf.h conftest.*
|
2001-07-22 08:24:12 -04:00
|
|
|
@$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2000-06-12 03:48:31 -04:00
|
|
|
realclean: distclean
|
1999-01-19 23:59:39 -05:00
|
|
|
EOS
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
mfile.printf <<EOS
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
install:
|
2001-07-13 14:02:10 -04:00
|
|
|
@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(DESTDIR)$(libdir) $(DESTDIR)$(pkglibdir) $(DESTDIR)$(archdir)$(target_prefix)
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
EOS
|
1999-08-13 01:37:52 -04:00
|
|
|
unless $static
|
1999-01-19 23:59:39 -05:00
|
|
|
mfile.printf "\
|
2001-07-13 14:02:10 -04:00
|
|
|
@$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)' $(DLLIB) $(DESTDIR)$(archdir)$(target_prefix)/$(DLLIB)
|
1998-01-16 07:13:05 -05:00
|
|
|
"
|
|
|
|
end
|
1999-08-13 01:37:52 -04:00
|
|
|
install_rb(mfile, $srcdir)
|
1998-01-16 07:19:22 -05:00
|
|
|
mfile.printf "\n"
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2001-06-09 03:41:44 -04:00
|
|
|
unless /mswin32/ =~ RUBY_PLATFORM
|
|
|
|
src = '$<'
|
|
|
|
copt = cxxopt = ''
|
|
|
|
else
|
|
|
|
if /nmake/i =~ $make
|
|
|
|
src = '$(<:\\=/)'
|
2001-05-28 09:25:34 -04:00
|
|
|
else
|
|
|
|
src = '$(subst /,\\\\,$<)'
|
|
|
|
end
|
2001-06-09 03:41:44 -04:00
|
|
|
copt = '-Tc'
|
|
|
|
cxxopt = '-Tp'
|
|
|
|
end
|
|
|
|
unless /nmake/i =~ $make
|
2000-08-03 05:50:41 -04:00
|
|
|
mfile.puts "
|
2001-03-28 05:35:40 -05:00
|
|
|
.cc.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
2001-03-28 05:35:40 -05:00
|
|
|
.cpp.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
2001-03-28 05:35:40 -05:00
|
|
|
.cxx.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
2001-03-28 05:35:40 -05:00
|
|
|
.C.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
2001-05-28 09:25:34 -04:00
|
|
|
.c.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src}
|
2000-12-21 22:22:25 -05:00
|
|
|
"
|
2001-05-28 09:25:34 -04:00
|
|
|
else
|
2000-12-21 22:22:25 -05:00
|
|
|
mfile.print "
|
|
|
|
{$(srcdir)}.c{}.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CC) -I. -I$(<D) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src}
|
2000-12-21 22:22:25 -05:00
|
|
|
.c.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src}
|
2001-03-28 09:47:44 -05:00
|
|
|
{$(srcdir)}.cc{}.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
2001-03-28 09:47:44 -05:00
|
|
|
.cc.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
2001-03-28 09:47:44 -05:00
|
|
|
{$(srcdir)}.cpp{}.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
2001-03-28 09:47:44 -05:00
|
|
|
.cpp.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
2001-03-28 09:47:44 -05:00
|
|
|
{$(srcdir)}.cxx{}.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CXX) -I. -I$(<D) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
2001-03-28 09:47:44 -05:00
|
|
|
.cxx.@OBJEXT@:
|
2001-06-09 03:41:44 -04:00
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
2000-08-03 05:50:41 -04:00
|
|
|
"
|
|
|
|
end
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
if $static
|
1999-08-13 01:37:52 -04:00
|
|
|
if "@AR@" =~ /^lib\b/i
|
1999-01-19 23:59:39 -05:00
|
|
|
mfile.printf "\
|
1999-08-13 01:37:52 -04:00
|
|
|
$(DLLIB): $(OBJS)
|
|
|
|
@AR@ /OUT:$(DLLIB) $(OBJS)
|
1998-01-16 07:13:05 -05:00
|
|
|
"
|
|
|
|
else
|
|
|
|
mfile.printf "\
|
1999-08-13 01:37:52 -04:00
|
|
|
$(DLLIB): $(OBJS)
|
|
|
|
@AR@ cru $(DLLIB) $(OBJS)
|
|
|
|
@-@RANLIB@ $(DLLIB) 2> /dev/null || true
|
1998-01-16 07:13:05 -05:00
|
|
|
"
|
|
|
|
end
|
1999-08-13 01:37:52 -04:00
|
|
|
elsif "@DLEXT@" != $OBJEXT
|
2000-12-21 22:22:25 -05:00
|
|
|
mfile.print "$(DLLIB): $(OBJS)\n"
|
|
|
|
if /mswin32/ =~ RUBY_PLATFORM
|
|
|
|
if /nmake/i =~ $make
|
|
|
|
mfile.print "\tset LIB=$(LIBPATH:/=\\);$(LIB)\n"
|
|
|
|
else
|
|
|
|
mfile.print "\tenv LIB='$(subst /,\\\\,$(LIBPATH));$(LIB)' \\\n"
|
|
|
|
end
|
|
|
|
end
|
2001-06-09 03:41:44 -04:00
|
|
|
mfile.print "\t$(LDSHARED) $(DLDFLAGS) #{OUTFLAG}$(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n"
|
1999-08-13 01:37:52 -04:00
|
|
|
elsif RUBY_PLATFORM == "m68k-human"
|
|
|
|
mfile.printf "\
|
|
|
|
$(DLLIB): $(OBJS)
|
|
|
|
ar cru $(DLLIB) $(OBJS)
|
|
|
|
"
|
|
|
|
else
|
|
|
|
mfile.printf "\
|
|
|
|
$(DLLIB): $(OBJS)
|
|
|
|
ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS)
|
|
|
|
"
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
if File.exist?("#{$srcdir}/depend")
|
|
|
|
dfile = open("#{$srcdir}/depend", "r")
|
1998-01-16 07:13:05 -05:00
|
|
|
mfile.printf "###\n"
|
|
|
|
while line = dfile.gets()
|
2000-07-17 05:38:10 -04:00
|
|
|
line.gsub!(/\.o\b/, ".#{$OBJEXT}")
|
2000-12-21 22:22:25 -05:00
|
|
|
line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1$(srcdir)/\2') if /nmake/i =~ $make
|
1999-08-13 01:37:52 -04:00
|
|
|
mfile.printf "%s", line.gsub('\$\(hdrdir\)/config.h', '$(topdir)/config.h')
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
dfile.close
|
|
|
|
end
|
|
|
|
mfile.close
|
|
|
|
end
|
|
|
|
|
|
|
|
def extmake(target)
|
|
|
|
if $force_static or $static_ext[target]
|
|
|
|
$static = target
|
|
|
|
else
|
1999-08-13 01:37:52 -04:00
|
|
|
$static = false
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
unless $install or $clean
|
|
|
|
return if $nodynamic and not $static
|
|
|
|
end
|
1998-01-16 07:13:05 -05:00
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
$OBJEXT = "@OBJEXT@"
|
|
|
|
$LIBEXT = "a"
|
1998-01-16 07:13:05 -05:00
|
|
|
$objs = nil
|
2000-05-09 00:53:16 -04:00
|
|
|
$libs = "@DLDLIBS@"
|
1999-08-13 01:37:52 -04:00
|
|
|
$local_flags = ""
|
2000-05-09 00:53:16 -04:00
|
|
|
if /mswin32/ =~ RUBY_PLATFORM
|
1999-08-13 01:37:52 -04:00
|
|
|
$LIBEXT = "lib"
|
2000-12-21 22:22:25 -05:00
|
|
|
$local_flags = "-link /INCREMENTAL:no /EXPORT:Init_$(TARGET)"
|
1999-08-13 01:37:52 -04:00
|
|
|
end
|
|
|
|
$LOCAL_LIBS = "" # to be assigned in extconf.rb
|
2000-08-09 17:27:10 -04:00
|
|
|
$CFLAGS = ""
|
2001-04-24 02:21:58 -04:00
|
|
|
$CPPFLAGS = ""
|
2000-12-21 22:22:25 -05:00
|
|
|
$LDFLAGS = ""
|
2001-04-24 02:21:58 -04:00
|
|
|
$LIBPATH = []
|
|
|
|
|
|
|
|
dir_config("opt")
|
1998-01-16 07:13:05 -05:00
|
|
|
|
|
|
|
begin
|
2001-07-13 14:02:10 -04:00
|
|
|
dir = Dir.pwd
|
2000-08-03 05:50:41 -04:00
|
|
|
Dir.mkdir target unless File.directory?(target)
|
1998-01-16 07:13:05 -05:00
|
|
|
Dir.chdir target
|
1999-08-13 01:37:52 -04:00
|
|
|
$target = target
|
1999-01-19 23:59:39 -05:00
|
|
|
$mdir = target
|
1999-08-13 01:37:52 -04:00
|
|
|
unless $install or $clean
|
|
|
|
if $static_ext.size > 0 ||
|
|
|
|
!File.exist?("./Makefile") ||
|
|
|
|
older("./Makefile", "#{$top_srcdir}/ext/@setup@") ||
|
2001-11-19 00:03:03 -05:00
|
|
|
older("./Makefile", "#{$topdir}/ext/extmk.rb") ||
|
1999-08-13 01:37:52 -04:00
|
|
|
older("./Makefile", "#{$top_srcdir}/ext/#{target}/makefile.rb") ||
|
|
|
|
older("./Makefile", "#{$top_srcdir}/ext/#{target}/extconf.rb")
|
|
|
|
then
|
|
|
|
$defs = []
|
|
|
|
if File.exist?("#{$top_srcdir}/ext/#{target}/makefile.rb")
|
|
|
|
load "#{$top_srcdir}/ext/#{target}/makefile.rb"
|
|
|
|
elsif File.exist?("#{$top_srcdir}/ext/#{target}/extconf.rb")
|
|
|
|
load "#{$top_srcdir}/ext/#{target}/extconf.rb"
|
|
|
|
else
|
|
|
|
create_makefile(target)
|
|
|
|
end
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
if File.exist?("./Makefile")
|
1998-01-16 07:19:22 -05:00
|
|
|
if $static
|
2001-07-13 14:02:10 -04:00
|
|
|
$extlist.push [$static, File.basename($target)]
|
1998-01-16 07:19:22 -05:00
|
|
|
end
|
1998-01-16 07:13:05 -05:00
|
|
|
if $install
|
1999-08-13 01:37:52 -04:00
|
|
|
system "#{$make} install DESTDIR=#{$destdir}"
|
1998-01-16 07:13:05 -05:00
|
|
|
elsif $clean
|
2001-01-09 02:26:21 -05:00
|
|
|
system "#{$make} #{$clean}"
|
1998-01-16 07:13:05 -05:00
|
|
|
else
|
2000-03-05 23:15:42 -05:00
|
|
|
unless system "#{$make} all"
|
|
|
|
if ENV["MAKEFLAGS"] != "k" and ENV["MFLAGS"] != "-k"
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
end
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
if $static
|
1999-01-19 23:59:39 -05:00
|
|
|
$extlibs ||= ""
|
|
|
|
$extlibs += " " + $LDFLAGS unless $LDFLAGS == ""
|
1999-08-13 01:37:52 -04:00
|
|
|
$extlibs += " " + $libs unless $libs == ""
|
|
|
|
$extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == ""
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
ensure
|
2000-05-28 22:10:22 -04:00
|
|
|
rm_f "conftest*"
|
2001-07-13 14:02:10 -04:00
|
|
|
Dir.chdir dir
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
$make = ENV["MAKE"]
|
|
|
|
$make ||= with_config("make-prog", "make")
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
# get static-link modules
|
|
|
|
$static_ext = {}
|
1999-01-19 23:59:39 -05:00
|
|
|
for setup in ["@setup@", "#{$top_srcdir}/ext/@setup@"]
|
1998-01-16 07:19:22 -05:00
|
|
|
if File.file? setup
|
|
|
|
f = open(setup)
|
2000-12-28 00:00:47 -05:00
|
|
|
while line = f.gets()
|
|
|
|
line.chomp!
|
|
|
|
line.sub!(/#.*$/, '')
|
|
|
|
next if /^\s*$/ =~ line
|
|
|
|
if /^option +nodynamic/ =~ line
|
1999-08-13 01:37:52 -04:00
|
|
|
$nodynamic = true
|
1998-01-16 07:19:22 -05:00
|
|
|
next
|
|
|
|
end
|
2000-12-28 00:00:47 -05:00
|
|
|
target = line.split[0]
|
1999-08-13 01:37:52 -04:00
|
|
|
target = target.downcase if /mswin32/ =~ RUBY_PLATFORM
|
|
|
|
$static_ext[target] = true
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
1998-01-16 07:19:22 -05:00
|
|
|
f.close
|
|
|
|
break
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2001-07-13 14:02:10 -04:00
|
|
|
ext_prefix = "#{$top_srcdir}/ext"
|
|
|
|
for d in Dir["#{ext_prefix}/**/*"]
|
1998-01-16 07:13:05 -05:00
|
|
|
File.directory?(d) || next
|
|
|
|
File.file?(d + "/MANIFEST") || next
|
|
|
|
|
2001-07-13 14:02:10 -04:00
|
|
|
d.slice!(0, ext_prefix.length + 1)
|
1998-01-16 07:13:05 -05:00
|
|
|
if $install
|
|
|
|
print "installing ", d, "\n"
|
|
|
|
elsif $clean
|
|
|
|
print "cleaning ", d, "\n"
|
|
|
|
else
|
|
|
|
print "compiling ", d, "\n"
|
1999-08-13 01:37:52 -04:00
|
|
|
if RUBY_PLATFORM =~ /-aix/ and older("../ruby.imp", "../miniruby")
|
|
|
|
load "#{$top_srcdir}/ext/aix_mksym.rb"
|
|
|
|
end
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
extmake(d)
|
|
|
|
end
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
if $install or $clean
|
|
|
|
Dir.chdir ".."
|
|
|
|
exit
|
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
$extinit = "" unless $extinit
|
1999-08-13 01:37:52 -04:00
|
|
|
|
|
|
|
ruby = "@RUBY_INSTALL_NAME@@EXEEXT@"
|
|
|
|
miniruby = "miniruby@EXEEXT@"
|
|
|
|
|
|
|
|
$extobjs = "" unless $extobjs
|
1998-01-16 07:13:05 -05:00
|
|
|
if $extlist.size > 0
|
|
|
|
for s,t in $extlist
|
1999-08-13 01:37:52 -04:00
|
|
|
f = format("%s/%s.%s", s, t, $LIBEXT)
|
1998-01-16 07:13:05 -05:00
|
|
|
if File.exist?(f)
|
|
|
|
$extinit += format("\
|
|
|
|
\tInit_%s();\n\
|
2001-08-29 02:28:51 -04:00
|
|
|
\trb_provide(\"%s\");\n\
|
2001-07-13 14:02:10 -04:00
|
|
|
", t, s)
|
1998-01-16 07:13:05 -05:00
|
|
|
$extobjs += "ext/"
|
|
|
|
$extobjs += f
|
|
|
|
$extobjs += " "
|
|
|
|
else
|
1999-08-13 01:37:52 -04:00
|
|
|
false
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
if older("extinit.c", "#{$top_srcdir}/ext/@setup@")
|
1998-01-16 07:13:05 -05:00
|
|
|
f = open("extinit.c", "w")
|
|
|
|
f.printf "void Init_ext() {\n"
|
|
|
|
f.printf $extinit
|
|
|
|
f.printf "}\n"
|
|
|
|
f.close
|
|
|
|
end
|
1999-08-13 01:37:52 -04:00
|
|
|
if older("extinit.#{$OBJEXT}", "extinit.c")
|
1998-01-16 07:13:05 -05:00
|
|
|
cmd = "@CC@ " + CFLAGS + " -c extinit.c"
|
|
|
|
print cmd, "\n"
|
|
|
|
system cmd or exit 1
|
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir ".."
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
if older(ruby, "#{$top_srcdir}/ext/@setup@") or older(ruby, miniruby)
|
2000-05-28 22:10:22 -04:00
|
|
|
rm_f ruby
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:37:52 -04:00
|
|
|
$extobjs = "ext/extinit.#{$OBJEXT} " + $extobjs
|
|
|
|
if RUBY_PLATFORM =~ /m68k-human|beos/
|
1999-01-19 23:59:39 -05:00
|
|
|
$extlibs.gsub!("-L/usr/local/lib", "") if $extlibs
|
|
|
|
end
|
2000-07-04 00:22:02 -04:00
|
|
|
system format(%[#{$make} #{ruby} EXTOBJS='%s' EXTLIBS='%s'], $extobjs, $extlibs)
|
1998-01-16 07:13:05 -05:00
|
|
|
else
|
|
|
|
Dir.chdir ".."
|
1999-08-13 01:37:52 -04:00
|
|
|
if older(ruby, miniruby)
|
2000-05-28 22:10:22 -04:00
|
|
|
rm_f ruby
|
1999-08-13 01:37:52 -04:00
|
|
|
system("#{$make} #{ruby}")
|
1998-01-16 07:13:05 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
#Local variables:
|
|
|
|
# mode: ruby
|
|
|
|
#end:
|