summaryrefslogtreecommitdiff
path: root/ext/extmk.rb.nt
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-05-10 08:22:50 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-05-10 08:22:50 +0000
commit27e948fd458b06c3a018d46f04599a874f43fd92 (patch)
treee369ed2a78f4d5393074804b71f136c84e9dfca5 /ext/extmk.rb.nt
parent192463c7a5525008a7bf95065261877eff79cf74 (diff)
regexp,range,squeeze
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/extmk.rb.nt')
-rw-r--r--ext/extmk.rb.nt403
1 files changed, 212 insertions, 191 deletions
diff --git a/ext/extmk.rb.nt b/ext/extmk.rb.nt
index 81bbb3e4dd..b5aa4592c2 100644
--- a/ext/extmk.rb.nt
+++ b/ext/extmk.rb.nt
@@ -3,39 +3,39 @@
$".push 'mkmf.rb'
if ARGV[0] == 'static'
- $force_static = TRUE
+ $force_static = true
ARGV.shift
elsif ARGV[0] == 'install'
- $install = TRUE
+ $install = true
$destdir = ARGV[1] || ''
ARGV.shift
elsif ARGV[0] == 'clean'
- $clean = TRUE
+ $clean = true
ARGV.shift
end
$extlist = []
-$cache_mod = FALSE;
+$cache_mod = false;
$lib_cache = {}
$func_cache = {}
$hdr_cache = {}
-$top_srcdir = ".."
-if $top_srcdir !~ "^/"
- # get absolute path
- $top_srcdir = File.expand_path($top_srcdir)
-end
+
+$top_srcdir = File.expand_path("..")
$topdir = File.expand_path("..")
$topdir = File.expand_path($topdir)
$ruby_inc = $top_srcdir
load "#{$top_srcdir}/lib/find.rb"
+#$dllopt = '-MD'
+$dllopt = ''
+
if File.exist?("config.cache") then
f = open("config.cache", "r")
while f.gets
case $_
- when /^lib: (.+) (yes|no)/
+ when /^lib: ([\w_]+) (yes|no)/
$lib_cache[$1] = $2
when /^func: ([\w_]+) (yes|no)/
$func_cache[$1] = $2
@@ -59,11 +59,11 @@ def older(file1, file2)
return false
end
-CFLAGS = "-g -O2"
-LINK = "gcc -o conftest -I#$topdir -I#$top_srcdir -I${prefix}/include #{CFLAGS} %s %s conftest.c -ldl -lcrypt -lm %s"
-CPP = "gcc -E -I#$topdir -I#$top_srcdir -I${prefix}/include #{CFLAGS} %s conftest.c"
-
+#LINK = "cl -o conftest.exe -I../.. -Zi -O -I. %s conftest.c %s > nul"
+LINK = "cl -o conftest.exe -Zi -O %s conftest.c %s > nul"
+CPP = "cl -E -I../.. -I../../missing -I../../win32 -I. -Zi -O %s conftest.c > nul"
$null = open("nul", "w")
+
$orgerr = $stderr.dup
$orgout = $stdout.dup
def xsystem command
@@ -78,12 +78,18 @@ def xsystem command
return r
end
-def try_link(src, opt="")
+def try_link0(src, opt="")
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
+ xsystem(format(LINK, $CFLAGS, $LDFLAGS, opt))
+end
+
+def try_link(src, opt="")
begin
- xsystem(format(LINK, $CFLAGS, $LDFLAGS, opt))
+ try_link0(src, opt)
+ ensure
+ system "rm -f conftest*"
end
end
@@ -91,19 +97,27 @@ def try_cpp(src, opt=$CFLAGS)
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
- xsystem(format(CPP, opt))
+ begin
+ xsystem(format(CPP, opt))
+ ensure
+ system "rm -f conftest*"
+ end
end
def egrep_cpp(pat, src, opt=$CFLAGS)
cfile = open("conftest.c", "w")
cfile.print src
cfile.close
- xsystem(format(CPP+"|egrep #{pat}", opt))
+ begin
+ xsystem(format(CPP+"|egrep #{pat}", opt))
+ ensure
+ system "rm -f conftest*"
+ end
end
def try_run(src, opt="")
begin
- if try_link(src, opt)
+ if try_link0(src, opt)
if xsystem("./conftest")
true
else
@@ -112,6 +126,8 @@ def try_run(src, opt="")
else
nil
end
+ ensure
+ system "rm -f conftest*"
end
end
@@ -134,73 +150,84 @@ def install_rb(mfile)
end
def have_library(lib, func="main")
+ #print format("have_library(%s, %s)\n", lib, func)
if $lib_cache[lib]
if $lib_cache[lib] == "yes"
if $libs
- $libs = "-l" + lib + " " + $libs
+ $libs = lib + ".lib " + $libs
else
- $libs = "-l" + lib
+ $libs = lib + ".lib "
end
- return TRUE
+ return true
else
- return FALSE
+ return false
end
end
if func && func != ""
if $libs
- libs = "-l" + lib + " " + $libs
+ libs = lib + ".lib " + $libs
else
- libs = "-l" + lib
+ libs = lib + ".lib"
end
+ #print "libs=#{libs}\n"
unless try_link(<<"SRC", libs)
+#include <windows.h>
+#include <winsock.h>
+//char #{func}();
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
+ #print "fail : #{libs}\n"
$lib_cache[lib] = 'no'
- $cache_mod = TRUE
- return FALSE
- end
- else
- if $libs
- libs = "-l" + lib + " " + $libs
- else
- libs = "-l" + lib
+ $cache_mod = true
+ return false
end
end
$libs = libs
$lib_cache[lib] = 'yes'
- $cache_mod = TRUE
- return TRUE
+ $cache_mod = true
+ return true
end
def have_func(func)
if $func_cache[func]
if $func_cache[func] == "yes"
$defs.push(format("-DHAVE_%s", func.upcase))
- return TRUE
+ return true
else
- return FALSE
+ return false
end
end
+ cfile = open("conftest.c", "w")
+ cfile.printf "\
+#include <windows.h>
+#include <winsock.h>
+//char %s();
+int main() { return 0; }
+int t() { %s(); return 0; }
+", func, func
+ cfile.close
+
libs = $libs
libs = "" if libs == nil
- unless try_link(<<"SRC", libs)
-char #{func}();
-int main() { return 0; }
-int t() { #{func}(); return 0; }
-SRC
- $func_cache[func] = 'no'
- $cache_mod = TRUE
- return FALSE
+ begin
+ #print "libs=#{libs}\n"
+ unless try_link(libs)
+ $func_cache[func] = 'no'
+ $cache_mod = true
+ return false
+ end
+ ensure
+ system "rm -f conftest*"
end
$defs.push(format("-DHAVE_%s", func.upcase))
$func_cache[func] = 'yes'
- $cache_mod = TRUE
- return TRUE
+ $cache_mod = true
+ return true
end
def have_header(header)
@@ -208,9 +235,9 @@ def have_header(header)
if $hdr_cache[header] == "yes"
header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header))
- return TRUE
+ return true
else
- return FALSE
+ return false
end
end
@@ -218,25 +245,25 @@ def have_header(header)
#include <#{header}>
SRC
$hdr_cache[header] = 'no'
- $cache_mod = TRUE
- return FALSE
+ $cache_mod = true
+ return false
end
$hdr_cache[header] = 'yes'
header.tr!("a-z./\055", "A-Z___")
$defs.push(format("-DHAVE_%s", header))
- $cache_mod = TRUE
- return TRUE
+ $cache_mod = true
+ return true
end
def arg_config(config, default=nil)
unless defined? $configure_args
$configure_args = {}
- for arg in " --prefix=/usr --with-dbm-include=/usr/include/db1".split
+ for arg in ENV["CONFIGURE_ARGS"].split
next unless /^--/ =~ arg
if /=/ =~ arg
$configure_args[$`] = $'
else
- $configure_args[arg] = default
+ $configure_args[arg] = true
end
end
end
@@ -273,121 +300,96 @@ end
def create_makefile(target)
- if $libs and "so" == "o"
+ if $libs
libs = $libs.split
for lib in libs
- lib.sub!(/-l(.*)/, '"lib\1.a"')
+ lib.sub!(/(.*)/, '"\1.lib"') if /.lib$/ !~ lib
end
$defs.push(format("-DEXTLIB='%s'", libs.join(",")))
end
+ $libs = "" unless $libs
- $DLDFLAGS = ''
-
- if PLATFORM =~ /beos/
- if $libs
- $libs = $libs + " -lruby"
- else
- $libs = "-lruby"
- end
- $DLDFLAGS = $DLDFLAGS + " -L" + $topdir
- end
-
- $srcdir = $top_srcdir + "/ext/" + $mdir
mfile = open("Makefile", "w")
mfile.printf "\
-SHELL = /bin/sh
+SHELL = $(COMPSEC)
#### Start of system configuration section. ####
-srcdir = #{$srcdir}
+srcdir = .
+VPATH = .
-hdrdir = #{$topdir}
+CC = cl
-CC = gcc
+CFLAGS = %s -I../.. -I../../missing -I../../win32 -I. -O -DNT %s #{CFLAGS} #$CFLAGS %s
-prefix = /usr
-CFLAGS = %s -I#{$topdir} -I#{$top_srcdir} -I${prefix}/include #{CFLAGS} #$CFLAGS %s
-DLDFLAGS = #$DLDFLAGS #$LDFLAGS
-LDSHARED = gcc -shared
-", if $static then "" else "-fPIC" end, $defs.join(" ")
+RUBYLIB = ../../ruby.lib
+DLDFLAGS = /DLL
+LDSHARED =
+", if $static then "" else "-fpic" end, $dllopt, $defs.join(" ")
- mfile.printf "\
+ if $force_static
+ print "static\n"
+ else
+ print "non static\n"
+ end
-RUBY_INSTALL_NAME = ruby
+ mfile.printf "\
-prefix = /usr
-exec_prefix = ${prefix}
-libdir = ${exec_prefix}/lib
-pkglibdir = $(libdir)/ruby/1.3
-archdir = $(pkglibdir)/i586-linux
-ruby_inc = #{$ruby_inc}
+libdir = /usr/local/lib/ruby/i386-mswin32
#### End of system configuration section. ####
-
"
- mfile.printf "LOCAL_LIBS = %s\n", $local_libs unless $local_libs == ""
+ mfile.printf "LOCAL_LIBS = %s\n", $LOCAL_LIBS unless $LOCAL_LIBS == ""
mfile.printf "LIBS = %s\n", $libs
mfile.printf "OBJS = "
if !$objs then
- $objs = []
- for f in Dir["#{$top_srcdir}/ext/#{$mdir}/*.{c,cc}"]
- f = File.basename(f)
- f.sub!(/\.(c|cc)$/, ".o")
- $objs.push f
+ $objs = Dir["*.{c,cc}"]
+ for f in $objs
+ f.sub!(/\.(c|cc)$/, ".obj")
end
end
mfile.printf $objs.join(" ")
mfile.printf "\n"
- mfile.printf <<EOS
-TARGET = #{target}
-DLLIB = $(TARGET).#{$static ? "a" : "so"}
-
-INSTALL = /usr/bin/install -c
-INSTALL_DATA = ${INSTALL} -m 644
-
-binsuffix =
+ mfile.printf "\
+TARGET = %s
+DLLIB = $(TARGET).%s
+INSTALL = ginstall -c
+DEFFILE = %s.def
-all: $(DLLIB)
+all: $(DLLIB)
-clean:; @rm -f *.o *.a *.so *.sl *.a
+clean:; @rm -f *.obj *.lib *.exp vc*.pdb *.bak *.def
@rm -f Makefile extconf.h conftest.*
- @rm -f core ruby$(binsuffix) *~
-realclean: clean
-EOS
-
- mfile.printf <<EOS
+realclean: clean
install:
@test -d $(DESTDIR)$(libdir) || mkdir $(DESTDIR)$(libdir)
@test -d $(DESTDIR)$(pkglibdir) || mkdir $(DESTDIR)$(pkglibdir)
@test -d $(DESTDIR)$(archdir) || mkdir $(DESTDIR)$(archdir)
-EOS
+", target,
+ if $force_static then "lib" else "dll" end, target
+
if !$static
mfile.printf "\
- $(INSTALL) $(DLLIB) $(DESTDIR)$(archdir)/$(DLLIB)
+ $(INSTALL) $(DLLIB) $(libdir)/$(DLLIB)
"
end
- install_rb(mfile)
- mfile.printf "\n"
- if $static
- mfile.printf "\
-$(DLLIB): $(OBJS)
- ar cru $(DLLIB) $(OBJS)
- @-ranlib $(DLLIB) 2> /dev/null || true
-"
- else
+ if $force_static
mfile.printf "\
$(DLLIB): $(OBJS)
- $(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)
+ lib /OUT:$(DLLIB) $(OBJS)
"
- elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc")
+ else
mfile.printf "\
-$(DLLIB): $(OBJS)
- ld $(DLDFLAGS) -r -o $(DLLIB) $(OBJS)
+$(DEFFILE):
+ echo $(DEFFILE)
+
+$(DLLIB): $(OBJS) $(DEFFILE)
+ cl -DLL -o$(DLLIB) $(OBJS) $(RUBYLIB) -link /DEF:$(DEFFILE)
"
end
@@ -400,99 +402,120 @@ $(DLLIB): $(OBJS)
dfile.close
end
mfile.close
-
+ if $static
+ #printf format("push %s,%s\n", $static, target); ##debug print##
+ $extlist.push [$static,target]
+ end
+end
+
+#template of .def file.
+def create_def(basename)
+ defname = sprintf("%s.def", basename)
+ f = open(defname, "w")
+ f.printf "\
+LIBRARY %s.dll
+CODE LOADONCALL
+DATA LOADONCALL
+DESCRIPTION 'win32 %s.dll'
+EXPORTS
+
+ Init_%s
+", basename, basename, basename
+ f.close
+
end
def extmake(target)
if $force_static or $static_ext[target]
$static = target
else
- $static = FALSE
+ $static = false
end
return if $nodynamic and not $static
- $objs = nil
- $libs = "-lc"
- $local_libs = "" # to be assigned in extconf.rb
+ $CFLAGS = nil
+ $LDFLAGS = nil
+ $LOCAL_LIBS = "" # to be assigned in extconf.rb
$CFLAGS = ""
$LDFLAGS = ""
begin
- system "mkdir", target unless File.directory?(target)
Dir.chdir target
- $mdir = target
if $static_ext.size > 0 ||
!File.exist?("./Makefile") ||
- older("./Makefile", "#{$top_srcdir}/ext/Setup") ||
+ older("./Makefile", "../Setup") ||
older("./Makefile", "../extmk.rb") ||
- older("./Makefile", "#{$top_srcdir}/ext/#{target}/extconf.rb")
+ older("./Makefile", "./extconf.rb")
then
$defs = []
- if File.exist?("#{$top_srcdir}/ext/#{target}/extconf.rb")
- load "#{$top_srcdir}/ext/#{target}/extconf.rb"
+ if File.exist?("extconf.rb")
+ load "extconf.rb"
else
create_makefile(target);
end
end
+
+ if !File.exist?("#{target}.def")
+ create_def(target)
+ end
+
if File.exist?("./Makefile")
- if $static
- $extlist.push [$static,target]
- end
if $install
- system "make install DESTDIR=#{$destdir}"
+ system "nmake install DESTDIR=#{$destdir}"
+ if File.directory? "./lib"
+ for i in Dir["./lib/*.rb"]
+ system "ginstall -c #{i} /usr/local/lib/ruby/i386-mswin32"
+ end
+ end
elsif $clean
- system "make clean"
+ system "nmake clean"
else
- system "make all" or exit
+ #print "!!!make!!!\n"
+ system "nmake all"
end
end
if $static
- $extlibs ||= ""
+ $extlibs = " "
$extlibs += " " + $LDFLAGS unless $LDFLAGS == ""
$extlibs += " " + $libs if $libs
- $extlibs += " " + $local_libs unless $local_libs == ""
+ $extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == ""
end
ensure
- system "rm -f conftest*"
Dir.chdir ".."
end
end
# get static-link modules
$static_ext = {}
-for setup in ["Setup", "#{$top_srcdir}/ext/Setup"]
- if File.file? setup
- f = open(setup)
- while f.gets()
- $_.chomp!
- sub!(/#.*$/, '')
- next if /^\s*$/
- if /^option +nodynamic/
- $nodynamic = TRUE
- next
- end
- $static_ext[$_.split[0]] = TRUE
+if File.file? "./Setup"
+ f = open("./Setup")
+ while f.gets()
+ $_.chop!
+ sub!(/#.*$/, '')
+ next if /^\s*$/
+ #print $_, "\n"
+
+ if /^option +nodynamic/
+ $nodynamic = true
+ next
end
- f.close
- break
+ $static_ext[$_.split[0]] = true
end
+ f.close
end
-for d in Dir["#{$top_srcdir}/ext/*"]
+for d in Dir["*"]
File.directory?(d) || next
File.file?(d + "/MANIFEST") || next
- d = File.basename(d)
+ d = $1 if d =~ /\/([\/]*)$/
if $install
print "installing ", d, "\n"
elsif $clean
print "cleaning ", d, "\n"
else
print "compiling ", d, "\n"
- if PLATFORM =~ /-aix/ and older("../ruby.imp", "../miniruby")
- load "#{$top_srcdir}/ext/aix_mksym.rb"
- end
end
extmake(d)
end
@@ -512,64 +535,62 @@ if $cache_mod
end
exit if $install or $clean
-$extinit = "" unless $extinit
-
-ruby = "ruby"
-miniruby = "miniruby"
-
+$extinit = " " unless $extinit
+$extobjs = ""
if $extlist.size > 0
for s,t in $extlist
- f = format("%s/%s.a", s, t)
- if File.exist?(f)
+ #for s,t in $static_ext
+ #f = format("%s/%s.obj", s, t)
+ #f = format("%s/%s.obj", s, s)
+ l = format("%s/%s.lib", s, s)
+ if File.exist?(l)
$extinit += format("\
\tInit_%s();\n\
\trb_provide(\"%s.so\");\n\
-", t, t)
- $extobjs = "" unless $extobjs
+", s, s)
$extobjs += "ext/"
- $extobjs += f
+ #$extobjs += f # *.obj
+ $extobjs += l # *.lib
$extobjs += " "
else
- FALSE
+ false
end
end
- if older("extinit.c", "#{$top_srcdir}/ext/Setup")
+ if older("extinit.c", "Setup")
f = open("extinit.c", "w")
f.printf "void Init_ext() {\n"
f.printf $extinit
f.printf "}\n"
f.close
end
- if older("extinit.o", "extinit.c")
- cmd = "gcc " + CFLAGS + " -c extinit.c"
+ if older("extinit.obj", "extinit.c")
+ cmd = "cl -Zi -O -I. -c extinit.c"
print cmd, "\n"
system cmd or exit 1
end
Dir.chdir ".."
- if older(ruby, "#{$top_srcdir}/ext/Setup") or older(ruby, miniruby)
- system("rm -f #{ruby}")
+ if older("ruby.exe", "ext/Setup") or older("ruby.exe", "miniruby.exe")
+ `rm -f ruby.exe`
end
- if $extobjs
- $extobjs = "ext/extinit.o " + $extobjs
- else
- $extobjs = "ext/extinit.o "
- end
- if PLATFORM =~ /m68k-human|beos/
- $extlibs.gsub!("-L/usr/local/lib", "") if $extlibs
- end
- system format(%[make #{ruby} EXTOBJS="%s" EXTLIBS="%s"], $extobjs, $extlibs)
+ $extobjs = "ext/extinit.obj " + $extobjs
+ #$extlibs = ""
+ #print "EXTLIBS=#{$extlibs}\n"
+ $extlibs.gsub!("-L/usr/local/lib", "") if $extlibs
+ $extlibs.gsub!(" +", " ") if $extlibs
+ #print "EXTLIBS=#{$extlibs}\n"
+
+ system format('nmake ruby.exe EXTOBJS="%s" EXTLIBS="%s"', $extobjs, $extlibs)
else
Dir.chdir ".."
- if older(ruby, miniruby)
- system("rm -f #{ruby}")
- system("make #{ruby}")
+ if older("ruby.exe", "miniruby.exe")
+ `rm -f ruby.exe`
+ `cp miniruby.exe ruby.exe`
end
end
-
#Local variables:
# mode: ruby
#end: