1999-01-19 23:59:39 -05:00
|
|
|
# module to create Makefile for extension modules
|
1998-01-16 07:19:09 -05:00
|
|
|
# invoke like: ruby -r mkmf extconf.rb
|
|
|
|
|
|
|
|
require 'rbconfig'
|
1999-01-19 23:59:39 -05:00
|
|
|
require 'find'
|
2002-03-29 02:42:20 -05:00
|
|
|
require 'shellwords'
|
1998-01-16 07:19:09 -05:00
|
|
|
|
1999-12-06 04:04:03 -05:00
|
|
|
CONFIG = Config::MAKEFILE_CONFIG
|
2000-12-21 22:22:25 -05:00
|
|
|
ORIG_LIBPATH = ENV['LIB']
|
1998-01-16 07:19:09 -05:00
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"]
|
|
|
|
|
2002-03-29 02:42:20 -05:00
|
|
|
unless defined? $configure_args
|
|
|
|
$configure_args = {}
|
2002-09-03 04:40:47 -04:00
|
|
|
args = CONFIG["configure_args"]
|
2002-09-15 08:57:21 -04:00
|
|
|
if ENV["CONFIGURE_ARGS"]
|
2002-09-03 04:40:47 -04:00
|
|
|
args << " " << ENV["CONFIGURE_ARGS"]
|
|
|
|
end
|
|
|
|
for arg in Shellwords::shellwords(args)
|
2002-03-29 02:42:20 -05:00
|
|
|
arg, val = arg.split('=', 2)
|
|
|
|
if arg.sub!(/^(?!--)/, '--')
|
|
|
|
val or next
|
|
|
|
arg.downcase!
|
|
|
|
end
|
|
|
|
next if /^--(?:top|topsrc|src|cur)dir$/ =~ arg
|
|
|
|
$configure_args[arg] = val || true
|
|
|
|
end
|
|
|
|
for arg in ARGV
|
|
|
|
arg, val = arg.split('=', 2)
|
|
|
|
if arg.sub!(/^(?!--)/, '--')
|
|
|
|
val or next
|
|
|
|
arg.downcase!
|
|
|
|
end
|
|
|
|
$configure_args[arg] = val || true
|
|
|
|
end
|
|
|
|
end
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
|
|
$srcdir = CONFIG["srcdir"]
|
2001-05-07 05:26:29 -04:00
|
|
|
$libdir = CONFIG["libdir"]
|
|
|
|
$rubylibdir = CONFIG["rubylibdir"]
|
|
|
|
$archdir = CONFIG["archdir"]
|
2001-05-11 01:24:59 -04:00
|
|
|
$sitedir = CONFIG["sitedir"]
|
2001-05-07 05:26:29 -04:00
|
|
|
$sitelibdir = CONFIG["sitelibdir"]
|
|
|
|
$sitearchdir = CONFIG["sitearchdir"]
|
1998-01-16 07:19:09 -05:00
|
|
|
|
2002-09-10 05:53:04 -04:00
|
|
|
$extmk = /extmk\.rb/ =~ $0
|
2002-09-23 07:01:49 -04:00
|
|
|
$mswin = /mswin/ =~ RUBY_PLATFORM
|
|
|
|
$bccwin = /bccwin/ =~ RUBY_PLATFORM
|
|
|
|
$mingw = /mingw/ =~ RUBY_PLATFORM
|
|
|
|
$cygwin = /cygwin/ =~ RUBY_PLATFORM
|
|
|
|
$human = /human/ =~ RUBY_PLATFORM
|
|
|
|
$netbsd = /netbsd/ =~ RUBY_PLATFORM
|
2002-09-10 05:53:04 -04:00
|
|
|
|
2002-04-01 10:01:56 -05:00
|
|
|
def dir_re(dir)
|
|
|
|
Regexp.new('\$(?:\('+dir+'\)|\{'+dir+'\})(?:\$\(target_prefix\)|\{target_prefix\})?')
|
|
|
|
end
|
|
|
|
commondir = dir_re('commondir')
|
|
|
|
|
|
|
|
INSTALL_DIRS = [
|
|
|
|
[commondir, "$(rubylibdir)"],
|
|
|
|
[dir_re('sitelibdir'), "$(rubylibdir)$(target_prefix)"],
|
|
|
|
[dir_re('sitearchdir'), "$(archdir)$(target_prefix)"]
|
|
|
|
]
|
|
|
|
|
|
|
|
SITEINSTALL_DIRS = [
|
|
|
|
[commondir, "$(sitedir)$(target_prefix)"],
|
|
|
|
[dir_re('rubylibdir'), "$(sitelibdir)$(target_prefix)"],
|
|
|
|
[dir_re('archdir'), "$(sitearchdir)$(target_prefix)"]
|
|
|
|
]
|
|
|
|
|
2002-09-10 05:53:04 -04:00
|
|
|
if not $extmk and File.exist? Config::CONFIG["archdir"] + "/ruby.h"
|
1998-01-16 07:19:09 -05:00
|
|
|
$hdrdir = $archdir
|
|
|
|
elsif File.exist? $srcdir + "/ruby.h"
|
|
|
|
$hdrdir = $srcdir
|
|
|
|
else
|
|
|
|
STDERR.print "can't find header files for ruby.\n"
|
|
|
|
exit 1
|
|
|
|
end
|
2002-09-10 05:30:50 -04:00
|
|
|
$topdir = $hdrdir
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
|
|
CFLAGS = CONFIG["CFLAGS"]
|
2002-09-23 07:01:49 -04:00
|
|
|
if $human
|
1998-01-16 07:19:09 -05:00
|
|
|
CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '')
|
2000-08-28 05:53:42 -04:00
|
|
|
elsif RUBY_PLATFORM =~ /-nextstep|-rhapsody|-darwin/
|
1999-08-13 01:45:20 -04:00
|
|
|
CFLAGS.gsub!( /-arch\s\w*/, '' )
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
2000-07-03 05:37:17 -04:00
|
|
|
|
2002-09-15 08:57:21 -04:00
|
|
|
OUTFLAG = CONFIG['OUTFLAG']
|
|
|
|
CPPOUTFILE = CONFIG['CPPOUTFILE']
|
2002-09-08 05:08:15 -04:00
|
|
|
|
2002-09-23 07:01:49 -04:00
|
|
|
LIBPATHFLAG = $mswin ? ' -libpath:' : ' -L'
|
|
|
|
CONFTEST_C = "conftest.c"
|
1999-01-19 23:59:39 -05:00
|
|
|
|
2002-09-23 07:01:49 -04:00
|
|
|
$INSTALLFILES ||= nil
|
2002-09-13 00:30:27 -04: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 04:10:26 -04:00
|
|
|
File::chmod(0777, *targets)
|
|
|
|
File::unlink(*targets)
|
2000-05-28 22:10:22 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2002-09-03 04:40:47 -04:00
|
|
|
def older(file1, file2)
|
|
|
|
if !File.exist?(file1) then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
if !File.exist?(file2) then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
if File.mtime(file1) < File.mtime(file2)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2002-09-08 05:08:15 -04:00
|
|
|
module Logging
|
|
|
|
@log = nil
|
|
|
|
@logfile = 'mkmf.log'
|
|
|
|
@orgerr = $stderr.dup
|
|
|
|
@orgout = $stdout.dup
|
2002-06-19 01:54:24 -04:00
|
|
|
|
2002-09-08 05:08:15 -04:00
|
|
|
def self::open
|
|
|
|
@log ||= File::open(@logfile, 'w')
|
|
|
|
$stderr.reopen(@log)
|
|
|
|
$stdout.reopen(@log)
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
$stderr.reopen(@orgerr)
|
|
|
|
$stdout.reopen(@orgout)
|
|
|
|
end
|
|
|
|
|
2002-09-15 08:57:21 -04:00
|
|
|
def self::message(*s)
|
|
|
|
@log ||= File::open(@logfile, 'w')
|
|
|
|
@log.printf(*s)
|
|
|
|
end
|
|
|
|
|
2002-09-08 05:08:15 -04:00
|
|
|
def self::logfile file
|
|
|
|
@logfile = file
|
|
|
|
if @log and not @log.closed?
|
|
|
|
@log.close
|
|
|
|
@log = nil
|
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
|
2002-09-06 07:23:14 -04:00
|
|
|
def xsystem command
|
|
|
|
Config.expand(command)
|
2002-09-08 05:08:15 -04:00
|
|
|
Logging::open do
|
2002-09-06 07:23:14 -04:00
|
|
|
puts command
|
|
|
|
system(command)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def xpopen command, *mode, &block
|
|
|
|
Config.expand(command)
|
2002-09-08 05:08:15 -04:00
|
|
|
Logging::open do
|
2002-09-06 07:23:14 -04:00
|
|
|
case mode[0]
|
|
|
|
when nil, /^r/
|
|
|
|
puts "#{command} |"
|
|
|
|
else
|
|
|
|
puts "| #{command}"
|
|
|
|
end
|
|
|
|
IO.popen(command, *mode, &block)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2002-09-23 07:01:49 -04:00
|
|
|
def log_src(src)
|
|
|
|
Logging::message <<"EOM"
|
2002-09-15 08:57:21 -04:00
|
|
|
checked program was:
|
2002-09-23 07:01:49 -04:00
|
|
|
/* begin */
|
|
|
|
#{src}/* end */
|
|
|
|
|
2002-09-15 08:57:21 -04:00
|
|
|
EOM
|
2002-09-23 07:01:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def create_tmpsrc(src)
|
|
|
|
open(CONFTEST_C, "w") do |cfile|
|
|
|
|
cfile.print src
|
2000-12-21 22:22:25 -05:00
|
|
|
end
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
|
2002-09-23 07:01:49 -04:00
|
|
|
def try_do(src, command)
|
|
|
|
src += "\n" unless /\n\z/ =~ src
|
|
|
|
create_tmpsrc(src)
|
|
|
|
xsystem(command)
|
|
|
|
ensure
|
|
|
|
log_src(src)
|
|
|
|
end
|
|
|
|
|
|
|
|
def link_command(ldflags, opt="")
|
|
|
|
# ldflags = "-link " + ldflags if $mswin
|
|
|
|
"$(CC) #{OUTFLAG}conftest #$INCFLAGS -I#{$hdrdir} " \
|
|
|
|
"#$CPPFLAGS $(CFLAGS) #$CFLAGS #{CONFTEST_C} #{opt} " \
|
|
|
|
"#$LOCAL_LIBS $(LIBS) #{ldflags} $(LDFLAGS) #$LDFLAGS"
|
|
|
|
end
|
|
|
|
|
|
|
|
def cc_command(opt="")
|
|
|
|
"$(CC) -c $(CPPFLAGS) #$INCFLAGS -I#{$hdrdir} " \
|
|
|
|
"#$CPPFLAGS $(CFLAGS) #$CFLAGS #{opt} #{CONFTEST_C}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def cpp_command(outfile, opt="")
|
|
|
|
"$(CPP) $(CPPFLAGS) #$INCFLAGS -I#{$hdrdir} " \
|
|
|
|
"#$CPPFLAGS $(CFLAGS) #$CFLAGS #{outfile} #{opt} #{CONFTEST_C}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def libpathflag
|
|
|
|
if $mswin
|
|
|
|
ENV['LIB'] = ($LIBPATH + [ORIG_LIBPATH]).join(';')
|
2002-09-25 04:49:17 -04:00
|
|
|
begin
|
|
|
|
yield ""
|
|
|
|
ensure
|
|
|
|
ENV['LIB'] = ORIG_LIBPATH
|
|
|
|
end
|
2002-09-23 07:01:49 -04:00
|
|
|
else
|
|
|
|
yield $LIBPATH.map{|x| %Q[#{LIBPATHFLAG}"#{x}"]}.join
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
|
|
|
|
2002-09-23 07:01:49 -04:00
|
|
|
def try_link0(src, opt="")
|
|
|
|
libpathflag do |flag|
|
|
|
|
try_do(src, link_command(flag, opt))
|
2002-09-06 07:23:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2002-09-23 07:01:49 -04:00
|
|
|
def try_link(src, opt="")
|
|
|
|
try_link0(src, opt)
|
|
|
|
ensure
|
|
|
|
rm_f "conftest*", "c0x32*"
|
|
|
|
end
|
|
|
|
|
|
|
|
def try_compile(src, opt="")
|
|
|
|
try_do(src, cc_command(opt))
|
|
|
|
ensure
|
|
|
|
rm_f "conftest*"
|
|
|
|
end
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
def try_cpp(src, opt="")
|
2002-09-23 07:01:49 -04:00
|
|
|
try_do(src, cpp_command(CPPOUTFILE, opt))
|
|
|
|
ensure
|
|
|
|
rm_f "conftest*"
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def egrep_cpp(pat, src, opt="")
|
2002-09-23 07:01:49 -04:00
|
|
|
src += "\n" unless /\n\z/ =~ src
|
|
|
|
create_tmpsrc(src)
|
|
|
|
xpopen(cpp_command('', opt)) do |f|
|
|
|
|
if Regexp === pat
|
|
|
|
puts(" ruby -ne 'print if /#{pat.source}/'")
|
|
|
|
f.grep(pat) {|l|
|
|
|
|
puts "#{f.lineno}: #{l}"
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
false
|
|
|
|
else
|
|
|
|
puts(" egrep '#{pat}'")
|
|
|
|
begin
|
|
|
|
stdin = $stdin.dup
|
|
|
|
$stdin.reopen(f)
|
|
|
|
system("egrep", pat)
|
|
|
|
ensure
|
|
|
|
$stdin.reopen(stdin)
|
2002-09-06 07:23:14 -04:00
|
|
|
end
|
|
|
|
end
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
2002-09-23 07:01:49 -04:00
|
|
|
ensure
|
|
|
|
rm_f "conftest*"
|
|
|
|
log_src(src)
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
|
2002-09-08 06:00:43 -04:00
|
|
|
def macro_defined?(macro, src, opt="")
|
2002-09-23 07:01:49 -04:00
|
|
|
try_cpp(src + <<"SRC", opt)
|
2002-09-08 06:00:43 -04:00
|
|
|
#ifndef #{macro}
|
|
|
|
# error
|
|
|
|
#endif
|
2002-09-15 08:57:21 -04:00
|
|
|
SRC
|
2002-09-08 06:00:43 -04:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
def try_run(src, opt="")
|
2002-09-23 07:01:49 -04:00
|
|
|
if try_link0(src, opt)
|
|
|
|
xsystem("./conftest")
|
|
|
|
else
|
|
|
|
nil
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
2002-09-23 07:01:49 -04:00
|
|
|
ensure
|
|
|
|
rm_f "conftest*"
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
|
2002-04-01 10:01:56 -05:00
|
|
|
def install_files(mfile, ifiles, map = INSTALL_DIRS, srcprefix = nil)
|
|
|
|
ifiles or return
|
|
|
|
srcprefix ||= '$(srcdir)'
|
|
|
|
Config::expand(srcdir = srcprefix.dup)
|
|
|
|
dirs = []
|
|
|
|
path = Hash.new {|h, i| h[i] = dirs.push([i])[-1]}
|
|
|
|
ifiles.each do |files, dir, prefix|
|
|
|
|
dir = map.inject(dir) {|dir, (orig, new)| dir.gsub(orig, new)} if map
|
2002-04-24 00:54:16 -04:00
|
|
|
prefix = %r"\A#{Regexp.quote(prefix)}/?" if prefix
|
2002-04-01 12:42:32 -05:00
|
|
|
if( files[0,2] == "./" )
|
2002-04-01 10:01:56 -05:00
|
|
|
# install files which are in current working directory.
|
|
|
|
Dir.glob(files) do |f|
|
|
|
|
d = File.dirname(f)
|
|
|
|
d.sub!(prefix, "") if prefix
|
|
|
|
d = (d.empty? || d == ".") ? dir : File.join(dir,d)
|
|
|
|
path[d] << f
|
|
|
|
end
|
2001-07-24 06:29:17 -04:00
|
|
|
else
|
2002-04-01 10:01:56 -05:00
|
|
|
# install files which are under the $(srcdir).
|
|
|
|
Dir.glob(File.join(srcdir,files)) do |f|
|
|
|
|
f[0..srcdir.size] = ""
|
|
|
|
d = File.dirname(f)
|
|
|
|
d.sub!(prefix, "") if prefix
|
|
|
|
d = (d.empty? || d == ".") ? dir : File.join(dir, d)
|
|
|
|
path[d] << (srcprefix ? File.join(srcprefix, f) : f)
|
|
|
|
end
|
2001-07-24 06:29:17 -04:00
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
2002-04-01 10:01:56 -05:00
|
|
|
|
|
|
|
dirs.each do |dir, *files|
|
|
|
|
mfile.printf("\t@$(MAKEDIRS) %s\n", dir)
|
|
|
|
files.each do |f|
|
|
|
|
mfile.printf("\t@$(INSTALL_DATA) %s %s\n", f, dir)
|
|
|
|
end
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2002-04-01 10:01:56 -05:00
|
|
|
def install_rb(mfile, dest, srcdir = nil)
|
2002-06-24 03:34:30 -04:00
|
|
|
install_files(mfile, [["lib/**/*.rb", dest, "lib"]], nil, srcdir)
|
2002-04-01 10:01:56 -05:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
def append_library(libs, lib)
|
2002-06-10 21:27:48 -04:00
|
|
|
if /mswin32|bccwin32/ =~ RUBY_PLATFORM
|
1999-08-13 01:45:20 -04:00
|
|
|
lib + ".lib " + libs
|
|
|
|
else
|
|
|
|
"-l" + lib + " " + libs
|
1999-01-19 23:59:39 -05:00
|
|
|
end
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
|
2002-09-03 04:40:47 -04:00
|
|
|
def message(*s)
|
2002-09-10 05:53:04 -04:00
|
|
|
unless $extmk and not $VERBOSE
|
2002-09-15 08:57:21 -04:00
|
|
|
printf(*s)
|
|
|
|
$stdout.flush
|
2002-09-04 12:52:53 -04:00
|
|
|
end
|
2002-09-03 04:40:47 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def have_library(lib, func="main")
|
|
|
|
message "checking for #{func}() in -l#{lib}... "
|
2002-09-23 07:01:49 -04:00
|
|
|
Logging::message"have_library: checking for #{func}() in -l#{lib}\n"
|
1998-01-16 07:19:09 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
if func && func != ""
|
1999-08-13 01:45:20 -04:00
|
|
|
libs = append_library($libs, lib)
|
2002-06-10 21:27:48 -04:00
|
|
|
if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM
|
2001-12-29 11:34:01 -05:00
|
|
|
if lib == 'm'
|
2002-09-03 04:40:47 -04:00
|
|
|
message "yes\n"
|
2001-12-29 11:34:01 -05:00
|
|
|
return true
|
|
|
|
end
|
1999-08-13 01:45:20 -04:00
|
|
|
r = try_link(<<"SRC", libs)
|
2002-09-10 05:30:50 -04:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
1999-08-13 01:45:20 -04:00
|
|
|
#include <windows.h>
|
|
|
|
#include <winsock.h>
|
1998-01-16 07:19:09 -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)
|
2002-09-10 05:30:50 -04:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2000-06-05 04:46:59 -04:00
|
|
|
#include <windows.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
int main() { return 0; }
|
1999-08-13 01:45:20 -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:19:09 -05:00
|
|
|
else
|
1999-08-13 01:45:20 -04:00
|
|
|
r = try_link(<<"SRC", libs)
|
|
|
|
int main() { return 0; }
|
|
|
|
int t() { #{func}(); return 0; }
|
|
|
|
SRC
|
|
|
|
end
|
|
|
|
unless r
|
2002-09-03 04:40:47 -04:00
|
|
|
message "no\n"
|
1999-08-13 01:45:20 -04:00
|
|
|
return false
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
1999-08-13 01:45:20 -04:00
|
|
|
else
|
|
|
|
libs = append_library($libs, lib)
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
$libs = libs
|
2002-09-03 04:40:47 -04:00
|
|
|
message "yes\n"
|
1999-08-13 01:45:20 -04:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_library(lib, func, *paths)
|
2002-09-03 04:40:47 -04:00
|
|
|
message "checking for #{func}() in -l#{lib}... "
|
2002-09-23 07:01:49 -04:00
|
|
|
Logging::message"find_library: checking for #{func}() in -l#{lib}\n"
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2000-12-21 22:22:25 -05:00
|
|
|
libpath = $LIBPATH
|
1999-08-13 01:45:20 -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
|
2002-09-03 04:40:47 -04:00
|
|
|
message "no\n"
|
1999-08-13 01:45:20 -04:00
|
|
|
return false
|
|
|
|
end
|
2000-12-21 22:22:25 -05:00
|
|
|
$LIBPATH = libpath | [paths.shift]
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
$libs = libs
|
2002-09-03 04:40:47 -04:00
|
|
|
message "yes\n"
|
1999-08-13 01:45:20 -04:00
|
|
|
return true
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
|
2000-06-22 04:29:58 -04:00
|
|
|
def have_func(func, header=nil)
|
2002-09-03 04:40:47 -04:00
|
|
|
message "checking for #{func}()... "
|
2002-09-23 07:01:49 -04:00
|
|
|
Logging::message"have_func: checking for #{func}()\n"
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
|
|
libs = $libs
|
2000-06-22 04:29:58 -04:00
|
|
|
src =
|
2002-06-10 21:27:48 -04:00
|
|
|
if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM
|
2000-06-22 04:29:58 -04:00
|
|
|
r = <<"SRC"
|
2002-09-10 05:30:50 -04:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
1999-08-13 01:45:20 -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:45:20 -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; }
|
2002-09-06 07:23:14 -04:00
|
|
|
int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; }
|
1999-08-13 01:45:20 -04:00
|
|
|
SRC
|
|
|
|
end
|
|
|
|
unless r
|
2002-09-03 04:40:47 -04:00
|
|
|
message "no\n"
|
1999-08-13 01:45:20 -04:00
|
|
|
return false
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
$defs.push(format("-DHAVE_%s", func.upcase))
|
2002-09-03 04:40:47 -04:00
|
|
|
message "yes\n"
|
1999-08-13 01:45:20 -04:00
|
|
|
return true
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def have_header(header)
|
2002-09-03 04:40:47 -04:00
|
|
|
message "checking for #{header}... "
|
2002-09-23 07:01:49 -04:00
|
|
|
Logging::message"have_header: checking for #{header}\n"
|
1998-01-16 07:19:09 -05:00
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
unless try_cpp(<<"SRC")
|
|
|
|
#include <#{header}>
|
|
|
|
SRC
|
2002-09-03 04:40:47 -04:00
|
|
|
message "no\n"
|
1999-08-13 01:45:20 -04:00
|
|
|
return false
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
2001-05-30 05:10:30 -04:00
|
|
|
$defs.push(format("-DHAVE_%s", header.tr("a-z./\055", "A-Z___")))
|
2002-09-03 04:40:47 -04:00
|
|
|
message "yes\n"
|
1999-08-13 01:45:20 -04:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2002-09-08 06:00:43 -04:00
|
|
|
def have_struct_member(type, member, header=nil)
|
|
|
|
message "checking for #{type}.#{member}... "
|
2002-09-23 07:01:49 -04:00
|
|
|
Logging::message "have_struct_member: checking for #{type}.#{member}\n"
|
2002-09-08 06:00:43 -04:00
|
|
|
|
|
|
|
src =
|
|
|
|
if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM
|
|
|
|
r = <<"SRC"
|
2002-09-10 05:30:50 -04:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2002-09-08 06:00:43 -04:00
|
|
|
#include <windows.h>
|
|
|
|
#include <winsock.h>
|
|
|
|
SRC
|
|
|
|
else
|
|
|
|
""
|
|
|
|
end
|
|
|
|
unless header.nil?
|
|
|
|
header = [header] unless header.kind_of? Array
|
|
|
|
header.each {|h|
|
|
|
|
src << <<"SRC"
|
|
|
|
#include <#{h}>
|
|
|
|
SRC
|
|
|
|
}
|
|
|
|
end
|
|
|
|
src << <<"SRC"
|
|
|
|
int main() { return 0; }
|
|
|
|
int s = (char *)&((#{type}*)0)->#{member} - (char *)0;
|
|
|
|
SRC
|
|
|
|
r = try_compile(src)
|
|
|
|
unless r
|
|
|
|
message "no\n"
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
$defs.push(format("-DHAVE_ST_%s", member.upcase))
|
|
|
|
message "yes\n"
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2002-08-21 04:30:09 -04:00
|
|
|
def find_executable(bin, path = nil)
|
2002-09-03 04:40:47 -04:00
|
|
|
message "checking for #{bin}... "
|
2002-09-23 07:01:49 -04:00
|
|
|
Logging::message "find_executable: checking for #{bin}\n"
|
2002-08-21 04:30:09 -04:00
|
|
|
|
|
|
|
if path.nil?
|
|
|
|
path = ENV['PATH'].split(Config::CONFIG['PATH_SEPARATOR'])
|
|
|
|
else
|
|
|
|
path = path.split(Config::CONFIG['PATH_SEPARATOR'])
|
|
|
|
end
|
|
|
|
|
|
|
|
bin += Config::CONFIG['EXEEXT']
|
|
|
|
for dir in path
|
|
|
|
file = File.join(dir, bin)
|
|
|
|
if FileTest.executable?(file)
|
2002-09-03 04:40:47 -04:00
|
|
|
message "yes\n"
|
2002-08-21 04:30:09 -04:00
|
|
|
return file
|
|
|
|
else
|
|
|
|
next
|
|
|
|
end
|
|
|
|
end
|
2002-09-03 04:40:47 -04:00
|
|
|
message "no\n"
|
2002-08-21 04:30:09 -04:00
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
def arg_config(config, default=nil)
|
|
|
|
$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)
|
2002-03-29 02:42:20 -05:00
|
|
|
if arg_config("--enable-"+config)
|
1999-08-13 01:45:20 -04:00
|
|
|
true
|
2002-03-29 02:42:20 -05:00
|
|
|
elsif arg_config("--disable-"+config)
|
1999-08-13 01:45:20 -04:00
|
|
|
false
|
|
|
|
else
|
|
|
|
default
|
|
|
|
end
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def create_header()
|
2002-09-03 04:40:47 -04:00
|
|
|
message "creating extconf.h\n"
|
1998-01-16 07:19:09 -05:00
|
|
|
if $defs.length > 0
|
2002-09-03 04:40:47 -04:00
|
|
|
open("extconf.h", "w") do |hfile|
|
|
|
|
for line in $defs
|
|
|
|
line =~ /^-D(.*)/
|
|
|
|
hfile.printf "#define %s 1\n", $1
|
|
|
|
end
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2000-08-24 02:21:43 -04:00
|
|
|
def dir_config(target, idefault=nil, ldefault=nil)
|
2002-01-31 07:03:08 -05:00
|
|
|
if dir = with_config(target + "-dir", (idefault unless ldefault))
|
|
|
|
idefault = dir + "/include"
|
|
|
|
ldefault = dir + "/lib"
|
2000-08-24 02:21:43 -04:00
|
|
|
end
|
2001-04-24 02:21:58 -04:00
|
|
|
|
2002-01-31 07:03:08 -05:00
|
|
|
idir = with_config(target + "-include", idefault)
|
|
|
|
ldir = with_config(target + "-lib", ldefault)
|
2001-04-24 02:21:58 -04:00
|
|
|
|
|
|
|
if idir
|
|
|
|
idircflag = "-I" + idir
|
|
|
|
$CPPFLAGS += " " + idircflag unless $CPPFLAGS.split.include?(idircflag)
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
2001-04-24 02:21:58 -04:00
|
|
|
|
|
|
|
if ldir
|
|
|
|
$LIBPATH << ldir unless $LIBPATH.include?(ldir)
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
|
2001-04-24 02:21:58 -04:00
|
|
|
[idir, ldir]
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
|
2001-12-20 11:23:27 -05:00
|
|
|
def with_destdir(dir)
|
|
|
|
/^\$[\(\{]/ =~ dir ? dir : "$(DESTDIR)"+dir
|
|
|
|
end
|
|
|
|
|
2002-06-10 21:27:48 -04:00
|
|
|
def winsep(s)
|
|
|
|
s.tr('/', '\\')
|
|
|
|
end
|
|
|
|
|
2002-04-01 10:01:56 -05:00
|
|
|
def create_makefile(target, srcprefix = nil)
|
2001-03-12 05:20:01 -05:00
|
|
|
save_libs = $libs.dup
|
|
|
|
save_libpath = $LIBPATH.dup
|
2002-09-03 04:40:47 -04:00
|
|
|
message "creating Makefile\n"
|
2000-05-28 22:10:22 -04:00
|
|
|
rm_f "conftest*"
|
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
|
1999-08-13 01:45:20 -04:00
|
|
|
if CONFIG["DLEXT"] == $OBJEXT
|
1998-01-16 07:19:09 -05:00
|
|
|
libs = $libs.split
|
|
|
|
for lib in libs
|
|
|
|
lib.sub!(/-l(.*)/, '"lib\1.a"')
|
|
|
|
end
|
|
|
|
$defs.push(format("-DEXTLIB='%s'", libs.join(",")))
|
|
|
|
end
|
1999-01-19 23:59:39 -05:00
|
|
|
$DLDFLAGS = CONFIG["DLDFLAGS"]
|
|
|
|
|
2002-09-08 05:08:15 -04:00
|
|
|
$libs = CONFIG["LIBRUBYARG"] + " " + $libs + " " + CONFIG["LIBS"]
|
2001-03-13 00:45:13 -05:00
|
|
|
$configure_args['--enable-shared'] or $LIBPATH |= [$topdir]
|
2001-01-15 02:01:00 -05:00
|
|
|
$LIBPATH |= [CONFIG["libdir"]]
|
2000-05-09 00:53:16 -04:00
|
|
|
|
2002-04-01 10:01:56 -05:00
|
|
|
srcprefix ||= '$(srcdir)'
|
|
|
|
Config::expand(srcdir = srcprefix.dup)
|
1999-08-13 01:45:20 -04:00
|
|
|
defflag = ''
|
2002-06-10 21:27:48 -04:00
|
|
|
if RUBY_PLATFORM =~ /bccwin32/
|
|
|
|
deffile = target + '.def'
|
|
|
|
if not File.exist? deffile
|
|
|
|
open(deffile, 'wb') do |f|
|
|
|
|
f.print "EXPORTS\n", "_Init_", target, "\n"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
elsif RUBY_PLATFORM =~ /cygwin|mingw/
|
2002-01-02 09:42:01 -05:00
|
|
|
deffile = target + '.def'
|
|
|
|
if not File.exist? deffile
|
2002-06-28 10:42:46 -04:00
|
|
|
if File.exist? File.join(srcdir, deffile)
|
2002-01-02 09:42:01 -05:00
|
|
|
deffile = File.join srcdir, deffile
|
|
|
|
else
|
|
|
|
open(deffile, 'wb') do |f|
|
|
|
|
f.print "EXPORTS\n", "Init_", target, "\n"
|
|
|
|
end
|
2001-04-02 21:16:14 -04:00
|
|
|
end
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
2002-04-19 03:39:40 -04:00
|
|
|
defflag = deffile
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
|
2002-06-10 21:27:48 -04:00
|
|
|
if RUBY_PLATFORM =~ /mswin32|bccwin32/
|
2000-12-21 22:22:25 -05:00
|
|
|
libpath = $LIBPATH.join(';')
|
|
|
|
else
|
|
|
|
$LIBPATH.each {|d| $DLDFLAGS << " -L" << d}
|
2001-12-06 04:55:31 -05:00
|
|
|
if /netbsdelf/ =~ RUBY_PLATFORM
|
|
|
|
$LIBPATH.each {|d| $DLDFLAGS << " -Wl,-R" + d}
|
|
|
|
end
|
2000-12-21 22:22:25 -05:00
|
|
|
end
|
|
|
|
drive = File::PATH_SEPARATOR == ';' ? /\A\w:/ : /\A/
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
unless $objs then
|
1999-08-13 01:45:20 -04:00
|
|
|
$objs = []
|
2002-03-29 02:42:20 -05:00
|
|
|
for f in Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
|
1999-08-13 01:45:20 -04:00
|
|
|
f = File.basename(f)
|
|
|
|
f.sub!(/(#{SRC_EXT.join(%q{|})})$/, $OBJEXT)
|
|
|
|
$objs.push f
|
1998-01-16 07:19:09 -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:19:09 -05:00
|
|
|
end
|
|
|
|
$objs = $objs.join(" ")
|
|
|
|
|
|
|
|
mfile = open("Makefile", "w")
|
2000-05-14 05:36:29 -04:00
|
|
|
mfile.binmode if /mingw/ =~ RUBY_PLATFORM
|
1998-01-16 07:19:09 -05:00
|
|
|
mfile.print <<EOMF
|
|
|
|
SHELL = /bin/sh
|
|
|
|
|
|
|
|
#### Start of system configuration section. ####
|
|
|
|
|
2002-03-29 02:42:20 -05:00
|
|
|
srcdir = #{srcdir}
|
1999-08-13 01:45:20 -04:00
|
|
|
topdir = #{$topdir}
|
1998-01-16 07:19:09 -05:00
|
|
|
hdrdir = #{$hdrdir}
|
2000-12-21 22:22:25 -05:00
|
|
|
VPATH = $(srcdir)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
CC = #{CONFIG["CC"]}
|
1998-01-16 07:19:09 -05:00
|
|
|
|
2000-08-03 05:50:41 -04:00
|
|
|
CFLAGS = #{CONFIG["CCDLFLAGS"]} #{CFLAGS} #{$CFLAGS}
|
2002-04-02 01:48:45 -05:00
|
|
|
CPPFLAGS = -I. -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{CONFIG["CPPFLAGS"]} #{$CPPFLAGS}
|
1999-01-19 23:59:39 -05:00
|
|
|
CXXFLAGS = $(CFLAGS)
|
2002-06-10 21:27:48 -04:00
|
|
|
#{
|
|
|
|
if /bccwin32/ =~ RUBY_PLATFORM
|
2002-09-08 01:46:29 -04:00
|
|
|
"DLDFLAGS = #$LDFLAGS -L\"$(libdir:/=\\);$(topdir:/=\\)\"\n" +
|
2002-06-24 03:20:42 -04:00
|
|
|
"LDSHARED = #{CONFIG['LDSHARED']}\n"
|
2002-06-10 21:27:48 -04:00
|
|
|
else
|
|
|
|
"DLDFLAGS = #{$DLDFLAGS} #{$LDFLAGS}\n" +
|
2002-06-24 03:20:42 -04:00
|
|
|
"LDSHARED = #{CONFIG['LDSHARED']} #{defflag}\n"
|
2002-06-10 21:27:48 -04:00
|
|
|
end
|
|
|
|
}
|
2000-12-21 22:22:25 -05:00
|
|
|
LIBPATH = #{libpath}
|
1998-01-16 07:19:09 -05:00
|
|
|
|
2000-01-04 23:41:21 -05:00
|
|
|
RUBY_INSTALL_NAME = #{CONFIG["RUBY_INSTALL_NAME"]}
|
2000-08-03 05:50:41 -04:00
|
|
|
RUBY_SO_NAME = #{CONFIG["RUBY_SO_NAME"]}
|
2001-05-07 05:26:29 -04:00
|
|
|
arch = #{CONFIG["arch"]}
|
2002-08-23 04:18:19 -04:00
|
|
|
sitearch = #{CONFIG["sitearch"]}
|
2001-05-07 05:26:29 -04:00
|
|
|
ruby_version = #{Config::CONFIG["ruby_version"]}
|
2002-04-01 10:01:56 -05:00
|
|
|
EOMF
|
|
|
|
if destdir = CONFIG["prefix"].scan(drive)[0] and !destdir.empty?
|
|
|
|
mfile.print "\nDESTDIR = ", destdir, "\n"
|
|
|
|
end
|
2002-05-04 17:57:32 -04:00
|
|
|
CONFIG.each do |key, var|
|
|
|
|
next unless /prefix$/ =~ key
|
2002-04-01 10:01:56 -05:00
|
|
|
mfile.print key, " = ", with_destdir(var.sub(drive, '')), "\n"
|
|
|
|
end
|
2002-05-04 17:57:32 -04:00
|
|
|
CONFIG.each do |key, var|
|
|
|
|
next unless /^(?:src|top|(.*))dir$/ =~ key and $1
|
2002-04-01 10:01:56 -05:00
|
|
|
mfile.print key, " = ", with_destdir(var.sub(drive, '')), "\n"
|
|
|
|
end
|
|
|
|
mfile.print <<EOMF
|
2001-06-12 01:25:04 -04:00
|
|
|
target_prefix = #{target_prefix}
|
1998-01-16 07:19:09 -05:00
|
|
|
|
|
|
|
#### End of system configuration section. ####
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
LOCAL_LIBS = #{$LOCAL_LIBS} #{$local_flags}
|
1998-01-16 07:19:09 -05:00
|
|
|
LIBS = #{$libs}
|
|
|
|
OBJS = #{$objs}
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
TARGET = #{target}
|
|
|
|
DLLIB = $(TARGET).#{CONFIG["DLEXT"]}
|
1998-01-16 07:19:09 -05:00
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
RUBY = #{CONFIG["ruby_install_name"]}
|
2002-05-02 05:31:29 -04:00
|
|
|
RM = $(RUBY) -rftools -e "File::rm_f(*ARGV.map do|x|Dir[x]end.flatten.uniq)"
|
2002-04-01 10:01:56 -05:00
|
|
|
MAKEDIRS = $(RUBY) -r ftools -e 'File::makedirs(*ARGV)'
|
|
|
|
INSTALL_PROG = $(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)'
|
|
|
|
INSTALL_DATA = $(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0644, true)'
|
1998-01-16 07:19:09 -05:00
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
EXEEXT = #{CONFIG["EXEEXT"]}
|
1998-01-16 07:19:09 -05:00
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
all: $(DLLIB)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
2002-06-10 21:27:48 -04:00
|
|
|
clean:
|
|
|
|
@$(RM) *.#{$OBJEXT} *.so *.sl *.a $(DLLIB)
|
|
|
|
#{
|
|
|
|
if /bccwin32/ =~ RUBY_PLATFORM
|
|
|
|
" @$(RM) $(TARGET).lib $(TARGET).def $(TARGET).ilc $(TARGET).ild $(TARGET).ilf $(TARGET).ils $(TARGET).tds $(TARGET).map $(CLEANFILES)\n"+
|
|
|
|
" @if exist $(target).def.org ren $(target).def.org $(target).def"
|
|
|
|
else
|
|
|
|
" @$(RM) $(TARGET).lib $(TARGET).exp $(TARGET).ilk *.pdb $(CLEANFILES)"
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2000-06-12 03:48:31 -04:00
|
|
|
distclean: clean
|
2001-07-03 11:02:20 -04:00
|
|
|
@$(RM) Makefile extconf.h conftest.* mkmf.log
|
2001-07-22 08:24:12 -04:00
|
|
|
@$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
2000-06-12 03:48:31 -04:00
|
|
|
realclean: distclean
|
1998-01-16 07:19:09 -05:00
|
|
|
|
2001-06-12 01:25:04 -04:00
|
|
|
install: $(archdir)$(target_prefix)/$(DLLIB)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
2001-06-12 01:25:04 -04:00
|
|
|
site-install: $(sitearchdir)$(target_prefix)/$(DLLIB)
|
2000-04-12 01:06:23 -04:00
|
|
|
|
2001-06-12 01:25:04 -04:00
|
|
|
$(archdir)$(target_prefix)/$(DLLIB): $(DLLIB)
|
2002-04-01 10:01:56 -05:00
|
|
|
@$(MAKEDIRS) $(rubylibdir) $(archdir)$(target_prefix)
|
|
|
|
@$(INSTALL_PROG) $(DLLIB) $(archdir)$(target_prefix)/$(DLLIB)
|
2000-04-12 01:06:23 -04:00
|
|
|
|
2001-06-12 01:25:04 -04:00
|
|
|
$(sitearchdir)$(target_prefix)/$(DLLIB): $(DLLIB)
|
2002-04-01 10:01:56 -05:00
|
|
|
@$(MAKEDIRS) $(sitearchdir)$(target_prefix)
|
|
|
|
@$(INSTALL_PROG) $(DLLIB) $(sitearchdir)$(target_prefix)/$(DLLIB)
|
|
|
|
|
2000-04-12 01:06:23 -04:00
|
|
|
EOMF
|
2002-04-01 10:01:56 -05:00
|
|
|
mfile.print "install:\n"
|
|
|
|
install_rb(mfile, "$(rubylibdir)$(target_prefix)", srcprefix)
|
|
|
|
install_files(mfile, $INSTALLFILES, INSTALL_DIRS, srcprefix)
|
|
|
|
mfile.print "\n"
|
|
|
|
mfile.print "site-install:\n"
|
|
|
|
install_rb(mfile, "$(sitelibdir)$(target_prefix)", srcprefix)
|
|
|
|
install_files(mfile, $INSTALLFILES, SITEINSTALL_DIRS, srcprefix)
|
1998-01-16 07:19:09 -05:00
|
|
|
|
2001-06-09 03:41:44 -04:00
|
|
|
unless /mswin32/ =~ RUBY_PLATFORM
|
2002-06-12 22:21:53 -04:00
|
|
|
if /bccwin32/ =~ RUBY_PLATFORM
|
2002-06-10 21:27:48 -04:00
|
|
|
src = '$(<:\\=/)'
|
|
|
|
else
|
|
|
|
src = '$<'
|
|
|
|
end
|
2001-06-09 03:41:44 -04:00
|
|
|
copt = cxxopt = ''
|
|
|
|
else
|
|
|
|
if /nmake/i =~ $make
|
|
|
|
src = '$(<:\\=/)'
|
|
|
|
else
|
|
|
|
src = '$(subst /,\\\\,$<)'
|
|
|
|
end
|
|
|
|
copt = '-Tc'
|
|
|
|
cxxopt = '-Tp'
|
|
|
|
end
|
2002-09-06 07:23:14 -04:00
|
|
|
|
|
|
|
mfile.print ".SUFFIXES: .#{SRC_EXT.join(' .')} .#{$OBJEXT}\n"
|
2001-06-09 03:41:44 -04:00
|
|
|
unless /nmake/i =~ $make
|
2002-06-10 21:27:48 -04:00
|
|
|
if /bccwin32/ =~ RUBY_PLATFORM
|
|
|
|
mfile.print "
|
|
|
|
{$(srcdir)}.cc{}.@OBJEXT@:
|
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
|
|
|
{$(srcdir)}.cpp{}.@OBJEXT@:
|
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
|
|
|
{$(srcdir)}.cxx{}.@OBJEXT@:
|
|
|
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src}
|
|
|
|
{$(srcdir)}.c{}.@OBJEXT@:
|
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src}
|
|
|
|
"
|
|
|
|
end
|
2001-06-09 03:41:44 -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}
|
|
|
|
.c.#{$OBJEXT}:
|
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src}
|
2000-12-21 22:22:25 -05:00
|
|
|
"
|
2001-06-09 03:41:44 -04:00
|
|
|
else
|
2000-12-21 22:22:25 -05:00
|
|
|
mfile.print "
|
2001-06-09 03:41:44 -04:00
|
|
|
{$(srcdir)}.c{}.#{$OBJEXT}:
|
|
|
|
$(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-08-13 01:45:20 -04:00
|
|
|
if CONFIG["DLEXT"] != $OBJEXT
|
2000-08-03 05:50:41 -04:00
|
|
|
mfile.print "$(DLLIB): $(OBJS)\n"
|
2002-06-10 21:27:48 -04:00
|
|
|
if /bccwin32/ =~ RUBY_PLATFORM
|
|
|
|
mfile.print "\t$(LDSHARED) $(DLDFLAGS) C0D32.OBJ $(OBJS), $@,, CW32.LIB IMPORT32.LIB WS2_32.LIB $(LIBS), #{deffile}\n"
|
|
|
|
else
|
|
|
|
if /mswin32|bccwin32/ =~ RUBY_PLATFORM
|
|
|
|
if /nmake/i =~ $make
|
|
|
|
mfile.print "\tset LIB=$(LIBPATH:/=\\);$(LIB)\n"
|
|
|
|
else
|
|
|
|
mfile.print "\tenv LIB='$(subst /,\\\\,$(LIBPATH));$(LIB)' \\\n"
|
|
|
|
end
|
2000-12-21 22:22:25 -05:00
|
|
|
end
|
2002-06-10 21:27:48 -04:00
|
|
|
mfile.print "\t$(LDSHARED) $(DLDFLAGS) #{OUTFLAG}$(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n"
|
2000-08-03 05:50:41 -04:00
|
|
|
end
|
1999-08-13 01:45:20 -04:00
|
|
|
elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc")
|
|
|
|
mfile.print "$(DLLIB): $(OBJS)\n"
|
|
|
|
case RUBY_PLATFORM
|
1998-01-16 07:19:09 -05:00
|
|
|
when "m68k-human"
|
1999-08-13 01:45:20 -04:00
|
|
|
mfile.printf "ar cru $(DLLIB) $(OBJS)\n"
|
1998-01-16 07:19:09 -05:00
|
|
|
else
|
1999-08-13 01:45:20 -04:00
|
|
|
mfile.printf "ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS)\n"
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2002-01-02 09:42:01 -05:00
|
|
|
depend = File.join(srcdir, "depend")
|
|
|
|
if File.exist?(depend)
|
|
|
|
dfile = open(depend, "r")
|
1998-01-16 07:19:09 -05:00
|
|
|
mfile.printf "###\n"
|
|
|
|
while line = dfile.gets()
|
2002-04-23 11:43:26 -04:00
|
|
|
line.gsub!(/\.o\b/, ".#{$OBJEXT}")
|
2002-04-23 12:22:25 -04:00
|
|
|
line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') if /nmake/i =~ $make
|
|
|
|
mfile.printf "%s", line
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
dfile.close
|
|
|
|
end
|
|
|
|
mfile.close
|
2001-03-12 05:20:01 -05:00
|
|
|
$libs = save_libs
|
|
|
|
$LIBPATH = save_libpath
|
1998-01-16 07:19:09 -05:00
|
|
|
end
|
|
|
|
|
1999-08-13 01:45:20 -04:00
|
|
|
$OBJEXT = CONFIG["OBJEXT"]
|
1998-01-16 07:19:09 -05:00
|
|
|
$objs = nil
|
2000-05-09 00:53:16 -04:00
|
|
|
$libs = CONFIG["DLDLIBS"]
|
1999-08-13 01:45:20 -04:00
|
|
|
$local_flags = ""
|
|
|
|
case RUBY_PLATFORM
|
|
|
|
when /mswin32/
|
2000-12-21 22:22:25 -05:00
|
|
|
$local_flags = "-link /INCREMENTAL:no /EXPORT:Init_$(TARGET)"
|
1999-08-13 01:45:20 -04:00
|
|
|
end
|
|
|
|
$LOCAL_LIBS = ""
|
1998-01-16 07:19:09 -05:00
|
|
|
$defs = []
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2000-12-21 22:22:25 -05:00
|
|
|
$make = with_config("make-prog", ENV["MAKE"] || "make")
|
1999-08-13 01:45:20 -04:00
|
|
|
|
2002-03-29 06:25:01 -05:00
|
|
|
$CFLAGS = with_config("cflags", arg_config("CFLAGS", ""))
|
|
|
|
$CPPFLAGS = with_config("cppflags", arg_config("CPPFLAGS", ""))
|
|
|
|
$LDFLAGS = with_config("ldflags", arg_config("LDFLAGS", ""))
|
2001-04-24 02:21:58 -04:00
|
|
|
$LIBPATH = []
|
2002-09-10 05:30:50 -04:00
|
|
|
$INCFLAGS = ""
|
2001-04-24 02:21:58 -04:00
|
|
|
|
|
|
|
dir_config("opt")
|
2002-03-29 02:42:20 -05:00
|
|
|
|
2002-04-01 10:01:56 -05:00
|
|
|
Config::CONFIG["srcdir"] = CONFIG["srcdir"] =
|
|
|
|
$srcdir = arg_config("--srcdir", File.dirname($0))
|
2002-03-29 02:42:20 -05:00
|
|
|
$configure_args["--topsrcdir"] ||= $srcdir
|
2002-04-01 10:01:56 -05:00
|
|
|
Config::CONFIG["topdir"] = CONFIG["topdir"] =
|
|
|
|
$curdir = arg_config("--curdir", Dir.pwd)
|
2002-03-29 02:42:20 -05:00
|
|
|
$configure_args["--topdir"] ||= $curdir
|