summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-07-28 09:26:53 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-07-28 09:26:53 +0000
commit16adedaa6d6ceb8e3f21e33dc6653aed3ffa6932 (patch)
treed1c104d8b5e197b22830a2c37f84327de76586b3 /ext
parent7dcd244615f172994ca4af37108af7ff744d0998 (diff)
990728
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/curses/extconf.rb15
-rw-r--r--ext/dbm/dbm.c2
-rw-r--r--ext/dbm/extconf.rb5
-rw-r--r--ext/extmk.rb.in146
-rw-r--r--ext/extmk.rb.nt252
-rw-r--r--ext/gdbm/extconf.rb6
-rw-r--r--ext/readline/extconf.rb17
-rw-r--r--ext/socket/extconf.rb10
-rw-r--r--ext/tcltklib/extconf.rb96
9 files changed, 288 insertions, 261 deletions
diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb
index 8356241f95..e1bf24c435 100644
--- a/ext/curses/extconf.rb
+++ b/ext/curses/extconf.rb
@@ -1,24 +1,21 @@
require 'mkmf'
-$CFLAGS="-I/usr/include/ncurses -I/usr/local/include/ncurses"
-$LDFLAGS="-L/usr/local/lib"
-make=FALSE
+make=false
have_library("mytinfo", "tgetent") if /bow/ =~ PLATFORM
if have_header("ncurses.h") and have_library("ncurses", "initscr")
- make=TRUE
+ make=true
elsif have_header("ncurses/curses.h") and have_library("ncurses", "initscr")
- make=TRUE
+ make=true
elsif have_header("curses_colr/curses.h") and have_library("cur_colr", "initscr")
- make=TRUE
+ make=true
else
- $CFLAGS=nil
have_library("termcap", "tgetent")
if have_library("curses", "initscr")
- make=TRUE
+ make=true
end
end
-if make then
+if make
for f in %w(isendwin ungetch beep doupdate flash deleteln wdeleteln)
have_func(f)
end
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index f873781d28..4d83cec1b1 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -332,7 +332,7 @@ fdbm_store(obj, keystr, valstr)
dbmp->di_size = -1;
dbm = dbmp->di_dbm;
if (dbm_store(dbm, key, val, DBM_REPLACE)) {
-#ifdef HAVE_DBM_CLAERERR
+#ifdef HAVE_DBM_CLEARERR
dbm_clearerr(dbm);
#endif
if (errno == EPERM) rb_sys_fail(0);
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index c75412e680..22198910cc 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -1,8 +1,5 @@
require 'mkmf'
-$LDFLAGS = "-L/usr/local/lib"
-if dir = with_config("dbm-include")
- $CFLAGS = "-I#{dir}"
-end
+dir_config("dbm")
have_library("gdbm", "dbm_open") or
have_library("db", "dbm_open") or
have_library("dbm", "dbm_open")
diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in
index 30cff493a8..3514ab2503 100644
--- a/ext/extmk.rb.in
+++ b/ext/extmk.rb.in
@@ -14,7 +14,7 @@ elsif ARGV[0] == 'clean'
ARGV.shift
end
-SRC_EXT = ["c", "cc", "cxx", "C"]
+SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"]
$extlist = []
$cache_mod = false
@@ -60,9 +60,9 @@ def older(file1, file2)
end
if RUBY_PLATFORM == "m68k-human"
-CFLAGS = "@CFLAGS@".gsub(/-c..-stack=[0-9]+ */, '')
+ CFLAGS = "@CFLAGS@".gsub(/-c..-stack=[0-9]+ */, '')
else
-CFLAGS = "@CFLAGS@"
+ CFLAGS = "@CFLAGS@"
end
LINK = "@CC@ -o conftest -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} @LDFLAGS@ %s %s conftest.c %s %s @LIBS@"
CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir -I@includedir@ #{CFLAGS} %s %s conftest.c"
@@ -160,10 +160,18 @@ def install_rb(mfile, srcdir = nil)
end
end
+def append_library(libs, lib)
+ if /mswin32/ =~ RUBY_PLATFORM
+ lib + ".lib " + libs
+ else
+ "-l" + lib + " " + libs
+ end
+end
+
def have_library(lib, func="main")
if $lib_cache[lib]
if $lib_cache[lib] == "yes"
- $libs = "-l" + lib + " " + $libs
+ $libs = append_library($libs, lib)
return true
else
return false
@@ -171,7 +179,7 @@ def have_library(lib, func="main")
end
if func && func != ""
- libs = "-l" + lib + " " + $libs
+ libs = append_library($libs, lib)
unless try_link(<<"SRC", libs)
int main() { return 0; }
int t() { #{func}(); return 0; }
@@ -181,7 +189,7 @@ SRC
return false
end
else
- libs = "-l" + lib + " " + $libs
+ libs = append_library($libs, lib)
end
$libs = libs
@@ -190,6 +198,23 @@ SRC
return true
end
+def find_library(lib, func, *paths)
+ ldflags = $LDFLAGS
+ libs = "-l" + lib + " " + $libs
+ until try_link(<<"SRC", libs)
+int main() { return 0; }
+int t() { #{func}(); return 0; }
+SRC
+ if paths.size == 0
+ $LDFLAGS = ldflags
+ return false
+ end
+ $LDFLAGS = ldflags + " -L"+paths.shift
+ end
+ $libs = libs
+ return true
+end
+
def have_func(func)
if $func_cache[func]
if $func_cache[func] == "yes"
@@ -285,9 +310,28 @@ def create_header()
end
end
+def dir_config(target)
+ dir = with_config("%s-dir"%target)
+ if dir
+ idir = " -I"+dir+"/include"
+ ldir = " -L"+dir+"/lib"
+ end
+ unless idir
+ dir = with_config("%s-include"%target)
+ idir = " -I"+dir if dir
+ end
+ unless ldir
+ dir = with_config("%s-lib"%target)
+ ldir = " -L"+dir if dir
+ end
+
+ $CFLAGS += idir if idir
+ $LDFLAGS += ldir if ldir
+end
+
def create_makefile(target)
system "rm -f conftest*"
- if "@DLEXT@" == "o"
+ if "@DLEXT@" == $OBJEXT
libs = $libs.split
for lib in libs
lib.sub!(/-l(.*)/, '"lib\1.a"')
@@ -347,14 +391,14 @@ archdir = $(pkglibdir)/@arch@
#### End of system configuration section. ####
"
- mfile.printf "LOCAL_LIBS = %s\n", $LOCAL_LIBS unless $LOCAL_LIBS == ""
+ mfile.printf "LOCAL_LIBS = %s %s\n", $LOCAL_LIBS, $local_flags
mfile.printf "LIBS = %s\n", $libs
mfile.printf "OBJS = "
if !$objs then
$objs = []
for f in Dir["#{$top_srcdir}/ext/#{$mdir}/*.{#{SRC_EXT.join(%q{,})}}"]
f = File.basename(f)
- f.sub!(/(#{SRC_EXT.join(%q{|})})$/, "o")
+ f.sub!(/(#{SRC_EXT.join(%q{|})})$/, $OBJEXT)
$objs.push f
end
end
@@ -365,15 +409,15 @@ archdir = $(pkglibdir)/@arch@
TARGET = #{target}
DLLIB = $(TARGET).#{$static ? "a" : "@DLEXT@"}
-RUBY = ../../miniruby@binsuffix@
+RUBY = ../../miniruby@EXEEXT@
-binsuffix = @binsuffix@
+EXEEXT = @EXEEXT@
all: $(DLLIB)
-clean:; @rm -f *.o *.so *.sl *.a $(DLLIB)
+clean:; @rm -f *.#{$OBJEXT} *.so *.sl *.a $(DLLIB)
@rm -f Makefile extconf.h conftest.*
- @rm -f core ruby$(binsuffix) *~
+ @rm -f core ruby$(EXEEXT) *~
realclean: clean
EOS
@@ -397,7 +441,7 @@ $(DLLIB): $(OBJS)
@AR@ cru $(DLLIB) $(OBJS)
@-@RANLIB@ $(DLLIB) 2> /dev/null || true
"
- elsif "@DLEXT@" != "o"
+ elsif "@DLEXT@" != $OBJEXT
mfile.printf "\
$(DLLIB): $(OBJS)
$(LDSHARED) $(DLDFLAGS) -o $(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)
@@ -445,29 +489,57 @@ def extmake(target)
$static = false
end
- return if $nodynamic and not $static
+ unless $install or $clean
+ return if $nodynamic and not $static
+ end
+ $OBJEXT = "@OBJEXT@"
$objs = nil
- $libs = RUBY_PLATFORM =~ /cygwin|beos|openstep|nextstep|rhapsody/ ? "" : "-lc"
+ $local_flags = ""
+ case RUBY_PLATFORM
+ when /cygwin|beos|openstep|nextstep|rhapsody/
+ $libs = ""
+ when /mswin32/
+ $libs = ""
+ $local_flags = "rubymw.lib -link /LIBPATH:$(topdir) /EXPORT:Init_$(TARGET)"
+ else
+ $libs = "-lc"
+ end
$LOCAL_LIBS = "" # to be assigned in extconf.rb
- $CFLAGS = ""
- $LDFLAGS = ""
+ dir = with_config("opt-dir")
+ if dir
+ idir = "-I"+dir+"/include"
+ ldir = "-L"+dir+"/lib"
+ end
+ unless idir
+ dir = with_config("opt-include")
+ idir = "-I"+dir if dir
+ end
+ unless ldir
+ dir = with_config("opt-lib")
+ ldir = "-L"+dir if dir
+ end
+
+ $CFLAGS = idir || ""
+ $LDFLAGS = ldir || ""
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", "../extmk.rb") ||
- older("./Makefile", "#{$top_srcdir}/ext/#{target}/extconf.rb")
- then
- $defs = []
- if File.exist?("#{$top_srcdir}/ext/#{target}/extconf.rb")
- load "#{$top_srcdir}/ext/#{target}/extconf.rb"
- else
- create_makefile(target)
+ unless $install or $clean
+ if $static_ext.size > 0 ||
+ !File.exist?("./Makefile") ||
+ older("./Makefile", "#{$top_srcdir}/ext/@setup@") ||
+ older("./Makefile", "../extmk.rb") ||
+ older("./Makefile", "#{$top_srcdir}/ext/#{target}/extconf.rb")
+ then
+ $defs = []
+ if File.exist?("#{$top_srcdir}/ext/#{target}/extconf.rb")
+ load "#{$top_srcdir}/ext/#{target}/extconf.rb"
+ else
+ create_makefile(target)
+ end
end
end
if File.exist?("./Makefile")
@@ -552,9 +624,10 @@ end
exit if $install or $clean
$extinit = "" unless $extinit
-ruby = "@RUBY_INSTALL_NAME@@binsuffix@"
-miniruby = "miniruby@binsuffix@"
+ruby = "@RUBY_INSTALL_NAME@@EXEEXT@"
+miniruby = "miniruby@EXEEXT@"
+$extobjs = "" unless $extobjs
if $extlist.size > 0
for s,t in $extlist
f = format("%s/%s.a", s, t)
@@ -563,7 +636,6 @@ if $extlist.size > 0
\tInit_%s();\n\
\trb_provide(\"%s.so\");\n\
", t, t)
- $extobjs = "" unless $extobjs
$extobjs += "ext/"
$extobjs += f
$extobjs += " "
@@ -579,7 +651,7 @@ if $extlist.size > 0
f.printf "}\n"
f.close
end
- if older("extinit.o", "extinit.c")
+ if older("extinit.#{$OBJEXT}", "extinit.c")
cmd = "@CC@ " + CFLAGS + " -c extinit.c"
print cmd, "\n"
system cmd or exit 1
@@ -591,11 +663,7 @@ if $extlist.size > 0
system("rm -f #{ruby}")
end
- if $extobjs
- $extobjs = "ext/extinit.o " + $extobjs
- else
- $extobjs = "ext/extinit.o "
- end
+ $extobjs = "ext/extinit.#{$OBJEXT} " + $extobjs
if RUBY_PLATFORM =~ /m68k-human|beos/
$extlibs.gsub!("-L/usr/local/lib", "") if $extlibs
end
@@ -604,7 +672,7 @@ else
Dir.chdir ".."
if older(ruby, miniruby)
system("rm -f #{ruby}")
- system("make #{ruby}")
+ system("#{$make} #{ruby}")
end
end
diff --git a/ext/extmk.rb.nt b/ext/extmk.rb.nt
index 531abf7b29..1416548649 100644
--- a/ext/extmk.rb.nt
+++ b/ext/extmk.rb.nt
@@ -14,16 +14,16 @@ elsif ARGV[0] == 'clean'
ARGV.shift
end
+SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"]
$extlist = []
-$cache_mod = false;
+$cache_mod = false
$lib_cache = {}
$func_cache = {}
$hdr_cache = {}
$top_srcdir = File.expand_path("..")
$topdir = File.expand_path("..")
-$topdir = File.expand_path($topdir)
$ruby_inc = $top_srcdir
load "#{$top_srcdir}/lib/find.rb"
@@ -60,9 +60,8 @@ def older(file1, file2)
end
CFLAGS = ""
-#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 %s > nul"
-CPP = "cl -E -I#{$ruby_inc} -I#{$ruby_inc}/missing -I#{$ruby_inc}/win32 -I. -Zi -O %s conftest.c > nul"
+LINK = "cl -o conftest.exe %s conftest.c %s %s"
+CPP = "cl -E -I#{$ruby_inc} -I#{$ruby_inc}/missing -I#{$ruby_inc}/win32 -I. %s conftest.c"
$null = open("nul", "w")
$orgerr = $stderr.dup
@@ -132,21 +131,31 @@ def try_run(src, opt="")
end
end
-def install_rb(mfile)
+def install_rb(mfile, srcdir = nil)
+ libdir = "lib"
+ libdir = srcdir + "/" + libdir if srcdir
path = []
dir = []
- Find.find("lib") do |f|
+ Find.find(libdir) do |f|
next unless /\.rb$/ =~ f
- f = f[4..-1]
+ f = f[libdir.length+1..-1]
path.push f
dir |= File.dirname(f)
end
for f in dir
next if f == "."
- mfile.printf "\t@test -d $(DESTDIR)$(pkglibdir)/%s || mkdir $(DESTDIR)$(pkglibdir)/%s\n", f, f
+ mfile.printf "\t@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(DESTDIR)$(pkglibdir)/%s\n", f
end
for f in path
- mfile.printf "\t$(INSTALL_DATA) lib/%s $(DESTDIR)$(pkglibdir)/%s\n", f, f
+ mfile.printf "\t@$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0644, true)' $(srcdir)/lib/%s $(DESTDIR)$(pkglibdir)/%s\n", f, f
+ end
+end
+
+def append_library(libs, lib)
+ if /mswin32/ =~ RUBY_PLATFORM
+ lib + ".lib " + libs
+ else
+ "-l" + lib + " " + libs
end
end
@@ -154,11 +163,7 @@ 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 = lib + ".lib " + $libs
- else
- $libs = lib + ".lib "
- end
+ $libs = append_library($libs, lib)
return true
else
return false
@@ -166,19 +171,23 @@ def have_library(lib, func="main")
end
if func && func != ""
- if $libs
- libs = lib + ".lib " + $libs
- else
- libs = lib + ".lib"
- end
+ libs = append_library($libs, lib)
#print "libs=#{libs}\n"
- unless try_link(<<"SRC", libs)
+ r = try_link(<<"SRC", libs)
#include <windows.h>
#include <winsock.h>
-//char #{func}();
int main() { return 0; }
int t() { #{func}(); return 0; }
SRC
+ unless r
+ r = try_link(<<"SRC", libs)
+#include <windows.h>
+#include <winsock.h>
+int main() { return 0; }
+int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; }
+SRC
+ end
+ unless r
#print "fail : #{libs}\n"
$lib_cache[lib] = 'no'
$cache_mod = true
@@ -202,28 +211,27 @@ def have_func(func)
end
end
- cfile = open("conftest.c", "w")
- cfile.printf "\
+ libs = $libs
+
+ #print "libs=#{libs}\n"
+ r = try_link(<<"SRC", libs)
#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
-
- begin
- #print "libs=#{libs}\n"
- unless try_link(libs)
- $func_cache[func] = 'no'
- $cache_mod = true
- return false
- end
- ensure
- system "rm -f conftest*"
+int t() { #{func}(); return 0; }
+SRC
+ unless r
+ try_link(<<"SRC", libs)
+#include <windows.h>
+#include <winsock.h>
+int main() { return 0; }
+int t() { void ((*p)()); p = (void ((*)()))#{func}; return 0; }
+SRC
+ end
+ unless r
+ $func_cache[func] = 'no'
+ $cache_mod = true
+ return false
end
$defs.push(format("-DHAVE_%s", func.upcase))
$func_cache[func] = 'yes'
@@ -280,7 +288,7 @@ def with_config(config, default=nil)
end
def enable_config(config, default=nil)
- if arg_config("--enable-"+config, true)
+ if arg_config("--enable-"+config, default)
true
elsif arg_config("--disable-"+config, false)
false
@@ -301,15 +309,15 @@ def create_header()
end
def create_makefile(target)
+ $target = target
- if $libs
+ if $libs != ""
libs = $libs.split
for lib in libs
lib.sub!(/(.*)/, '"\1.lib"') if /.lib$/ !~ lib
end
$defs.push(format("-DEXTLIB='%s'", libs.join(",")))
end
- $libs = "" unless $libs
mfile = open("Makefile", "w")
mfile.printf "\
@@ -320,25 +328,28 @@ SHELL = $(COMPSEC)
srcdir = .
VPATH = .
-CC = cl
+topdir = #{$topdir}
+hdrdir = #{$top_srcdir}
-CFLAGS = %s -I#{$ruby_inc} -I#{$ruby_inc}/missing -I#{$ruby_inc}/win32 -I. -O -DNT %s #{CFLAGS} #{$CFLAGS} %s
+CC = cl
+CFLAGS = %s -I#{$ruby_inc} -I#{$ruby_inc}/missing -I. -O -DNT %s #{CFLAGS} #{$CFLAGS} %s
+DLDFLAGS =
+LDSHARED = cl -LD
RUBYLIB = ../../ruby.lib
-DLDFLAGS = /DLL
-LDSHARED =
", if $static then "" else "-fpic" end, $dllopt, $defs.join(" ")
if $force_static
- print "static\n"
+ print "static\n"
else
- print "non static\n"
+ print "non static\n"
end
mfile.printf "\
-libdir = /usr/local/lib/ruby/i386-mswin32
-
+libdir = /usr/local/lib
+pkglibdir = $(libdir)/ruby/1.3
+archdir = $(pkglibdir)/i386-mswin32
#### End of system configuration section. ####
"
@@ -346,9 +357,11 @@ libdir = /usr/local/lib/ruby/i386-mswin32
mfile.printf "LIBS = %s\n", $libs
mfile.printf "OBJS = "
if !$objs then
- $objs = Dir["*.{c,cc}"]
- for f in $objs
- f.sub!(/\.(c|cc)$/, ".obj")
+ $objs = []
+ for f in Dir["*.{#{SRC_EXT.join(%q{,})}}"]
+ f = File.basename(f)
+ f.sub!(/(#{SRC_EXT.join(%q{|})})$/, $OBJEXT)
+ $objs.push f
end
end
mfile.printf $objs.join(" ")
@@ -357,28 +370,28 @@ libdir = /usr/local/lib/ruby/i386-mswin32
mfile.printf "\
TARGET = %s
DLLIB = $(TARGET).%s
-INSTALL = ginstall -c
-DEFFILE = %s.def
+DEFFILE = $(TARGET).def
+
+RUBY = ..\\..\\miniruby.exe
all: $(DLLIB)
-clean:; @rm -f *.obj *.lib *.exp vc*.pdb *.bak *.def
+clean:; @rm -f *.#{$OBJEXT} *.lib *.exp vc*.pdb *.bak *.def
@rm -f Makefile extconf.h conftest.*
realclean: clean
install:
- @test -d $(DESTDIR)$(libdir) || mkdir $(DESTDIR)$(libdir)
- @test -d $(DESTDIR)$(pkglibdir) || mkdir $(DESTDIR)$(pkglibdir)
- @test -d $(DESTDIR)$(archdir) || mkdir $(DESTDIR)$(archdir)
+ @$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(DESTDIR)$(libdir) $(DESTDIR)$(pkglibdir) $(DESTDIR)$(archdir)
", target,
- if $force_static then "lib" else "dll" end, target
+ if $force_static then "lib" else "dll" end
- if !$static
+ unless $static
mfile.printf "\
- $(INSTALL) $(DLLIB) $(libdir)/$(DLLIB)
+ @$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0555, true)' $(DLLIB) $(DESTDIR)$(archdir)/$(DLLIB)
"
end
+ install_rb(mfile, $srcdir)
if $force_static
mfile.printf "\
@@ -387,11 +400,11 @@ $(DLLIB): $(OBJS)
"
else
mfile.printf "\
-$(DEFFILE):
+$(DEFFILE):
echo $(DEFFILE)
-$(DLLIB): $(OBJS) $(DEFFILE)
- cl -DLL -o$(DLLIB) $(OBJS) $(RUBYLIB) -link /DEF:$(DEFFILE)
+$(DLLIB): $(OBJS) $(DEFFILE)
+ $(LDSHARED) -o $(DLLIB) $(OBJS) $(RUBYLIB) -link /DEF:$(DEFFILE)
"
end
@@ -399,14 +412,15 @@ $(DLLIB): $(OBJS) $(DEFFILE)
dfile = open("depend", "r")
mfile.printf "###\n"
while line = dfile.gets()
- mfile.printf "%s", line
+ mfile.printf "%s", line.gsub(/\.o/, ".#{$OBJEXT}")
end
dfile.close
end
mfile.close
- if $static
- #printf format("push %s,%s\n", $static, target); ##debug print##
- $extlist.push [$static,target]
+ unless $static
+ if !File.exist?("#{target}.def")
+ create_def(target)
+ end
end
end
@@ -434,59 +448,63 @@ def extmake(target)
$static = false
end
- return if $nodynamic and not $static
+ unless $install or $clean
+ return if $nodynamic and not $static
+ end
+ $OBJEXT = 'obj'
$objs = nil
+ $local_flags = ""
+ $libs = ""
$LOCAL_LIBS = "" # to be assigned in extconf.rb
$CFLAGS = ""
$LDFLAGS = ""
begin
Dir.chdir target
- if $static_ext.size > 0 ||
- !File.exist?("./Makefile") ||
- older("./Makefile", "../Setup") ||
- older("./Makefile", "../extmk.rb") ||
- older("./Makefile", "./extconf.rb")
- then
- $defs = []
- if File.exist?("extconf.rb")
- load "extconf.rb"
- else
- create_makefile(target);
+ $target = target
+ unless $install or $clean
+ if $static_ext.size > 0 ||
+ !File.exist?("./Makefile") ||
+ older("./Makefile", "../Setup") ||
+ older("./Makefile", "../extmk.rb") ||
+ older("./Makefile", "./extconf.rb")
+ then
+ $defs = []
+ if File.exist?("extconf.rb")
+ load "extconf.rb"
+ else
+ create_makefile(target)
+ end
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 "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
+ system "#{$make} install DESTDIR=#{$destdir}"
elsif $clean
- system "nmake clean"
+ system "#{$make} clean"
else
- #print "!!!make!!!\n"
- system "nmake all"
+ system "#{$make} all" or exit
end
end
if $static
- $extlibs = " "
+ $extlibs ||= ""
$extlibs += " " + $LDFLAGS unless $LDFLAGS == ""
- $extlibs += " " + $libs if $libs
+ $extlibs += " " + $libs unless $libs == ""
$extlibs += " " + $LOCAL_LIBS unless $LOCAL_LIBS == ""
end
ensure
+ system "rm -f conftest*"
Dir.chdir ".."
end
end
+$make = ENV["MAKE"]
+$make ||= with_config("make-prog", "nmake -nologo")
+
# get static-link modules
$static_ext = {}
if File.file? "./Setup"
@@ -536,22 +554,22 @@ if $cache_mod
end
exit if $install or $clean
-$extinit = " " unless $extinit
-$extobjs = ""
+$extinit = "" unless $extinit
+
+ruby = "ruby.exe"
+miniruby = "miniruby.exe"
+
+$extobjs = "" unless $extobjs
if $extlist.size > 0
for s,t in $extlist
- #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)
+ f = format("%s/%s.lib", s, t)
+ if File.exist?(f)
$extinit += format("\
\tInit_%s();\n\
\trb_provide(\"%s.so\");\n\
-", s, s)
+", t, t)
$extobjs += "ext/"
- #$extobjs += f # *.obj
- $extobjs += l # *.lib
+ $extobjs += f
$extobjs += " "
else
false
@@ -565,7 +583,7 @@ if $extlist.size > 0
f.printf "}\n"
f.close
end
- if older("extinit.obj", "extinit.c")
+ if older("extinit.#{$OBJEXT}", "extinit.c")
cmd = "cl -Zi -O -I. -c extinit.c"
print cmd, "\n"
system cmd or exit 1
@@ -573,23 +591,23 @@ if $extlist.size > 0
Dir.chdir ".."
- if older("ruby.exe", "ext/Setup") or older("ruby.exe", "miniruby.exe")
- `rm -f ruby.exe`
+ if older(ruby, "ext/Setup") or older(ruby, miniruby)
+ system("rm -f #{ruby}")
end
- $extobjs = "ext/extinit.obj " + $extobjs
+ $extobjs = "ext/extinit.#{$OBJEXT} " + $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)
+ system format(%[#{$make} #{ruby} EXTOBJS="%s" EXTLIBS="%s"], $extobjs, $extlibs)
else
Dir.chdir ".."
- if older("ruby.exe", "miniruby.exe")
- `rm -f ruby.exe`
- `cp miniruby.exe ruby.exe`
+ if older(ruby, miniruby)
+ system("rm -f #{ruby}")
+ system("#{$make} #{ruby}")
end
end
#Local variables:
diff --git a/ext/gdbm/extconf.rb b/ext/gdbm/extconf.rb
index bb51ac8971..5a09492e5e 100644
--- a/ext/gdbm/extconf.rb
+++ b/ext/gdbm/extconf.rb
@@ -1,7 +1,7 @@
require 'mkmf'
-$LDFLAGS = "-L/usr/local/lib"
+
+dir_config("gdbm")
if have_library("gdbm", "gdbm_open") and
- have_header("gdbm.h") and
- have_func("gdbm_open") then
+ have_header("gdbm.h")
create_makefile("gdbm")
end
diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb
index f532f8a21d..3dd9c0fc1e 100644
--- a/ext/readline/extconf.rb
+++ b/ext/readline/extconf.rb
@@ -1,21 +1,6 @@
require "mkmf"
-readline_dir = with_config("readline-dir")
-if readline_dir
- $CFLAGS = "-I#{readline_dir}/include"
- $LDFLAGS = "-L#{readline_dir}/lib"
-end
-
-readline_dir = with_config("readline-include-dir")
-if readline_dir
- $CFLAGS = "-I#{readline_dir}"
-end
-
-readline_dir = with_config("readline-lib-dir")
-if readline_dir
- $LDFLAGS = "-L#{readline_dir}"
-end
-
+dir_config("readline")
have_library("user32", nil) if /cygwin/ === PLATFORM
have_library("termcap", "tgetnum")
have_library("curses", "tgetnum")
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 1e41c02261..362679389f 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -1,6 +1,6 @@
require 'mkmf'
-$LDFLAGS = "-L/usr/local/lib" if File.directory?("/usr/local/lib")
-$CFLAGS = "-Dss_family=__ss_family -Dss_len=__ss_len"
+$LDFLAGS += " -L/usr/local/lib" if File.directory?("/usr/local/lib")
+$CFLAGS += " -Dss_family=__ss_family -Dss_len=__ss_len"
case PLATFORM
when /mswin32/
@@ -245,7 +245,7 @@ EOS
end
-$objs = ["socket.o"]
+$objs = ["socket.#{$OBJEXT}"]
if $getaddr_info_ok and have_func("getaddrinfo") and have_func("getnameinfo")
have_getaddrinfo = true
@@ -255,8 +255,8 @@ if have_getaddrinfo
$CFLAGS="-DHAVE_GETADDRINFO "+$CFLAGS
else
$CFLAGS="-I. "+$CFLAGS
- $objs += ["getaddrinfo.o"]
- $objs += ["getnameinfo.o"]
+ $objs += ["getaddrinfo.#{$OBJEXT}"]
+ $objs += ["getnameinfo.#{$OBJEXT}"]
have_func("inet_ntop") or have_func("inet_ntoa")
have_func("inet_pton") or have_func("inet_aton")
end
diff --git a/ext/tcltklib/extconf.rb b/ext/tcltklib/extconf.rb
index 7a568edd10..ec06f8b245 100644
--- a/ext/tcltklib/extconf.rb
+++ b/ext/tcltklib/extconf.rb
@@ -7,79 +7,41 @@ have_library("socket", "socket")
have_library("dl", "dlopen")
have_library("m", "log")
-$includes = []
-def search_header(include, *path)
- pwd = Dir.getwd
- begin
- for i in path.sort!.reverse!
- dir = Dir[i]
- for path in dir.sort!.reverse!
- next unless File.directory? path
- Dir.chdir path
- files = Dir[include]
- if files.size > 0
- unless $includes.include? path
- $includes << path
- end
- return
- end
- end
- end
- ensure
- Dir.chdir pwd
- end
-end
+dir_config("tk")
+dir_config("tcl")
+dir_config("X11")
-search_header("tcl.h",
- "/usr/include/tcl{,8*,7*}",
- "/usr/include",
- "/usr/local/include/tcl{,8*,7*}",
- "/usr/local/include")
-search_header("tk.h",
- "/usr/include/tk{,8*,4*}",
- "/usr/include",
- "/usr/local/include/tk{,8*,4*}",
- "/usr/local/include")
-search_header("X11/Xlib.h",
- "/usr/include/X11*",
- "/usr/include",
- "/usr/openwin/include",
- "/usr/X11*/include")
+tklib = with_config("tklib")
+tcllib = with_config("tcllib")
-$CFLAGS = $includes.collect{|path| "-I" + path}.join(" ")
+def find_tcl(tcllib)
+ paths = ["/usr/local/lib", "/usr/pkg"]
+ func = "Tcl_FindExecutable"
+ if tcllib
+ find_library(tcllib, func, *paths)
+ else
+ find_library("tcl", func, *paths) or
+ find_library("tcl8.0", func, *paths) or
+ find_library("tcl7.6", func, *paths)
+ end
+end
-$libraries = []
-def search_lib(file, func, *path)
- for i in path.reverse!
- dir = Dir[i]
- for path in dir.sort!.reverse!
- $LDFLAGS = $libraries.collect{|p| "-L" + p}.join(" ") + " -L" + path
- files = Dir[path+"/"+file]
- if files.size > 0
- for lib in files.sort!.reverse!
- lib = File::basename(lib)
- lib.sub!(/^lib/, '')
- lib.sub!(/\.(a|so(.[0-9.]+)?)$/, '')
- if have_library(lib, func)
- unless $libraries.include? path
- $libraries << path
- end
- return true
- end
- end
- end
- end
+def find_tk(tklib)
+ paths = ["/usr/local/lib", "/usr/pkg"]
+ func = "Tk_Init"
+ if tklib
+ find_library(tklib, func, *paths)
+ else
+ find_library("tk", func, *paths) or
+ find_library("tk8.0", func, *paths) or
+ find_library("tk4.2", func, *paths)
end
- return false;
end
if have_header("tcl.h") && have_header("tk.h") &&
- search_lib("libX11.{so*,a}", "XOpenDisplay",
- "/usr/lib", "/usr/openwin/lib", "/usr/X11*/lib") &&
- search_lib("libtcl{8*,7*,}.{so,a}", "Tcl_FindExecutable",
- "/usr/lib", "/usr/local/lib") &&
- search_lib("libtk{8*,4*,}.{so,a}", "Tk_Init",
- "/usr/lib", "/usr/local/lib")
- $LDFLAGS = $libraries.collect{|path| "-L" + path}.join(" ")
+ find_library("X11", "XOpenDisplay",
+ "/usr/X11/lib", "/usr/X11R6/lib", "/usr/openwin/lib") &&
+ find_tcl(tcllib) &&
+ find_tk(tklib)
create_makefile("tcltklib")
end