From d0b3651906aa943423e430a61437a42f7dd39422 Mon Sep 17 00:00:00 2001 From: H_Konishi Date: Tue, 11 Jun 2002 01:27:48 +0000 Subject: new platform [bccwin32] merged. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/Win32API/Win32API.c | 34 +++++++++++++ ext/digest/defs.h | 2 + ext/dl/depend | 8 ++-- ext/dl/dl.c | 2 +- ext/dl/extconf.rb | 15 ++++++ ext/dl/sym.c | 2 +- ext/extmk.rb.in | 123 ++++++++++++++++++++++++++++++++++++------------ ext/pty/extconf.rb | 2 +- ext/socket/extconf.rb | 4 ++ ext/tcltklib/extconf.rb | 8 ++-- 10 files changed, 160 insertions(+), 40 deletions(-) (limited to 'ext') diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c index 65b6a558c1..b9f16e2519 100644 --- a/ext/Win32API/Win32API.c +++ b/ext/Win32API/Win32API.c @@ -148,6 +148,15 @@ Win32API_initialize(self, dllname, proc, import, export) return Qnil; } +#ifdef __BORLANDC__ +int c_m( FARPROC api, long* p ) +{ + long pp[16]; + memcpy( pp, p, 16*sizeof(long) ); + return api(); +} +#endif + static VALUE Win32API_Call(argc, argv, obj) int argc; @@ -175,6 +184,10 @@ Win32API_Call(argc, argv, obj) int nimport, timport, texport, i; int items; int ret; +#ifdef __BORLANDC__ + long* ptr; + long p[16]; +#endif items = rb_scan_args(argc, argv, "0*", &args); @@ -192,6 +205,9 @@ Win32API_Call(argc, argv, obj) nimport, items); if (0 < nimport) { +#ifdef __BORLANDC__ + ptr = p + ( nimport - 1 ); +#endif for (i = nimport - 1; 0 <= i; i--) { VALUE str; import_type = rb_ary_entry(obj_import, i); @@ -215,6 +231,9 @@ Win32API_Call(argc, argv, obj) #else #error #endif +#elif defined(__BORLANDC__) + *ptr = lParam; + --ptr; #elif defined __GNUC__ asm volatile ("pushl %0" :: "g" (lParam)); #else @@ -247,6 +266,9 @@ Win32API_Call(argc, argv, obj) #else #error #endif +#elif defined(__BORLANDC__) + *ptr = (long)pParam; + --ptr; #elif defined __GNUC__ asm volatile ("pushl %0" :: "g" (pParam)); #else @@ -275,16 +297,28 @@ Win32API_Call(argc, argv, obj) #else switch (texport) { case _T_NUMBER: +#if defined(__BORLANDC__) + Return = INT2NUM((long)c_m(ApiFunction, p)); +#else ApiFunctionNumber = (ApiNumber *) ApiFunction; Return = INT2NUM(ApiFunctionNumber()); +#endif break; case _T_POINTER: +#if defined(__BORLANDC__) + Return = rb_str_new2((char *)c_m(ApiFunction, p)); +#else ApiFunctionPointer = (ApiPointer *) ApiFunction; Return = rb_str_new2((char *)ApiFunctionPointer()); +#endif break; case _T_INTEGER: +#if defined(__BORLANDC__) + Return = INT2NUM((int)c_m(ApiFunction, p)); +#else ApiFunctionInteger = (ApiInteger *) ApiFunction; Return = INT2NUM(ApiFunctionInteger()); +#endif break; case _T_VOID: default: diff --git a/ext/digest/defs.h b/ext/digest/defs.h index df7df377b9..8e44cf6fa2 100644 --- a/ext/digest/defs.h +++ b/ext/digest/defs.h @@ -27,6 +27,8 @@ typedef unsigned long long uint64_t; # elif defined(_MSC_VER) typedef unsigned _int64 uint64_t; +# elif defined(__BORLANDC__) + typedef unsigned __int64 uint64_t; # else # define NO_UINT64_T # endif diff --git a/ext/dl/depend b/ext/dl/depend index 552c67d0f5..313fac43a7 100644 --- a/ext/dl/depend +++ b/ext/dl/depend @@ -6,19 +6,19 @@ LDSHARED_TEST = $(LDSHARED) $(LDFLAGS) test/test.o -o test/libtest.so $(LOCAL_LI libtest.so: test/libtest.so test/libtest.so: test/test.o test/libtest.def - $(RUBY) -rftools -e 'ARGV.each{|d|File.mkpath(File.dirname(d))}' $@ + $(RUBY) -rftools -e 'ARGV.each do|d|File.mkpath(File.dirname(d))end' $@ $(LDSHARED_TEST:dl.def=test/libtest.def) test/test.o: $(srcdir)/test/test.c @$(RUBY) -rftools -e 'File.mkpath(*ARGV)' test $(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/test/test.c -o $@ -test:: dl.so libtest.so .force +test:: dl.so libtest.so force $(RUBY) -I. -I$(srcdir)/lib $(srcdir)/test/test.rb -.force: +force: -.PHONY: .force test +.PHONY: force test allclean: distclean @rm -f $(CLEANFILES) $(DISTCLEANFILES) diff --git a/ext/dl/dl.c b/ext/dl/dl.c index 935ae33e32..dd4f4423b5 100644 --- a/ext/dl/dl.c +++ b/ext/dl/dl.c @@ -626,7 +626,7 @@ rb_dl_callback(int argc, VALUE argv[], VALUE self) rb_assoc_new(INT2NUM(rettype),INT2NUM(entry)), rb_assoc_new(type,proc)); sprintf(fname, "rb_dl_callback_func_%d_%d", rettype, entry); - return rb_dlsym_new(rb_dl_callback_table[rettype][entry], fname, STR2CSTR(type)); + return rb_dlsym_new((void (*)())rb_dl_callback_table[rettype][entry], fname, STR2CSTR(type)); } static VALUE diff --git a/ext/dl/extconf.rb b/ext/dl/extconf.rb index 7b7c48f1a2..46b3c6c87d 100644 --- a/ext/dl/extconf.rb +++ b/ext/dl/extconf.rb @@ -176,6 +176,21 @@ $INSTALLFILES = [ ["dl.h", "$(archdir)$(target_prefix)", ""], ] +if /bccwin32/ =~ RUBY_PLATFORM + srcdir = $top_srcdir + "/ext/dl/" + if !FileTest.exist?( srcdir+"dl.def.org" ) + File.copy( srcdir+"dl.def", srcdir+"dl.def.org" ) + open( srcdir+"dl.def.org" ){ |f| + open( "dl.def", "w" ) { |g| + g.print f.gets + while line = f.gets + g.print "_", line + end + } + } + end +end + create_makefile('dl') rescue SystemExit # do nothing diff --git a/ext/dl/sym.c b/ext/dl/sym.c index bc51ebe102..3326d6743f 100644 --- a/ext/dl/sym.c +++ b/ext/dl/sym.c @@ -140,7 +140,7 @@ rb_dlsym_s_new(int argc, VALUE argv[], VALUE self) sname = NIL_P(name) ? NULL : StringValuePtr(name); stype = NIL_P(type) ? NULL : StringValuePtr(type); - val = rb_dlsym_new(saddr, sname, stype); + val = rb_dlsym_new((void (*)())saddr, sname, stype); if( val != Qnil ){ rb_obj_call_init(val, argc, argv); diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in index 55dee24780..34c30638fc 100644 --- a/ext/extmk.rb.in +++ b/ext/extmk.rb.in @@ -28,7 +28,7 @@ $extlist = [] $libdir = "@libdir@" $top_srcdir = "@top_srcdir@" -if $top_srcdir !~ "^/" +if $top_srcdir !~ ("^" + File::SEPARATOR) # get absolute path $top_srcdir = File.expand_path($top_srcdir) end @@ -72,6 +72,8 @@ if RUBY_PLATFORM == "m68k-human" end if /mswin32/ =~ RUBY_PLATFORM OUTFLAG = '-Fe' +elsif /bccwin32/ =~ RUBY_PLATFORM + OUTFLAG = '-o' else OUTFLAG = '-o ' end @@ -101,7 +103,7 @@ def try_link0(src, opt="") cfile.print src cfile.close ldflags = $LDFLAGS - if /mswin32/ =~ RUBY_PLATFORM and !$LIBPATH.empty? + if /mswin32|bccwin32/ =~ RUBY_PLATFORM and !$LIBPATH.empty? ENV['LIB'] = ($LIBPATH + [ORIG_LIBPATH]).compact.join(';') else ldflags = ldflags.dup @@ -110,7 +112,7 @@ def try_link0(src, opt="") begin xsystem(Config::expand(format(LINK, $CFLAGS, $CPPFLAGS, ldflags, opt, $LOCAL_LIBS))) ensure - ENV['LIB'] = ORIG_LIBPATH if /mswin32/ =~ RUBY_PLATFORM + ENV['LIB'] = ORIG_LIBPATH if /mswin32|bccwin32/ =~ RUBY_PLATFORM end end @@ -119,6 +121,9 @@ def try_link(src, opt="") try_link0(src, opt) ensure rm_f "conftest*" + if /bccwin32/ =~ RUBY_PLATFORM + rm_f "c0x32*" + end end end @@ -162,7 +167,7 @@ end def install_rb(mfile, srcdir = nil) libdir = "lib" - libdir = srcdir + "/" + libdir if srcdir + libdir = File.join(srcdir, libdir) if srcdir path = [] dir = [] if File.directory? libdir @@ -186,7 +191,7 @@ def install_rb(mfile, srcdir = nil) end def append_library(libs, lib) - if /mswin32/ =~ RUBY_PLATFORM + if /mswin32|bccwin32/ =~ RUBY_PLATFORM lib + ".lib " + libs else "-l" + lib + " " + libs @@ -196,7 +201,7 @@ end def have_library(lib, func="main") if func && func != "" libs = append_library($libs, lib) - if /mswin32|mingw/ =~ RUBY_PLATFORM + if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM return true if lib == 'm' r = try_link(<<"SRC", libs) #include @@ -249,7 +254,7 @@ end def have_func(func, header=nil) libs = $libs src = - if /mswin32|mingw/ =~ RUBY_PLATFORM + if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM r = <<"SRC" #include #include @@ -293,7 +298,7 @@ def arg_config(config, default=nil) unless defined? $configure_args $configure_args = {} args = "@configure_args@" - if /mswin32|mingw/ =~ RUBY_PLATFORM and ENV["CONFIGURE_ARGS"] + if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM and ENV["CONFIGURE_ARGS"] args << " " << ENV["CONFIGURE_ARGS"] end for arg in Shellwords::shellwords(args) @@ -386,9 +391,16 @@ def create_makefile(target) end end defflag = target + ".def" + elsif RUBY_PLATFORM =~ /bccwin32/ + deffile = target + '.def' + if not File.exist? target + '.def' + open(deffile, 'wb') do |f| + f.print "EXPORTS\n", "_Init_", target, "\n" + end + end end - if RUBY_PLATFORM =~ /mswin32/ + if RUBY_PLATFORM =~ /mswin32|bccwin32/ libpath = $LIBPATH.join(';') else $LIBPATH.each {|d| $DLDFLAGS << " -L" << d} @@ -397,7 +409,7 @@ def create_makefile(target) end end - $srcdir = $top_srcdir + "/ext/" + $mdir + $srcdir = File.join($top_srcdir,"ext",$mdir) mfile = open("Makefile", "w") mfile.binmode if /mingw/ =~ RUBY_PLATFORM mfile.printf "\ @@ -415,8 +427,15 @@ CC = @CC@ CFLAGS = %s #{CFLAGS} #$CFLAGS CPPFLAGS = -I$(topdir) -I$(hdrdir) %s #$CPPFLAGS -DLDFLAGS = #$DLDFLAGS #$LDFLAGS -LDSHARED = @LDSHARED@ #{defflag} +#{ +if /bccwin32/ =~ RUBY_PLATFORM + "DLDFLAGS = #$LDFLAGS -L" + '"$(topdir:/=\\)"' + "\n" + + "LDSHARED = @LDSHARED@\n" +else + "DLDFLAGS = #$DLDFLAGS #$LDFLAGS\n" + + "LDSHARED = @LDSHARED@ #{defflag}\n" +end +} ", if $static then "" else "@CCDLFLAGS@" end, $defs.join(" ") mfile.puts "LIBPATH = #{libpath}" if libpath @@ -440,9 +459,13 @@ target_prefix = #{target_prefix} " mfile.printf "LOCAL_LIBS = %s %s\n", $LOCAL_LIBS, $local_flags - mfile.printf "LIBS = %s\n", $libs + if /bccwin32/ =~ RUBY_PLATFORM + mfile.printf "LIBS = $(topdir:/=\\)\\%s\n", $libs + else + mfile.printf "LIBS = %s\n", $libs + end mfile.printf "OBJS = " - if !$objs then + if !$objs or (/bccwin32/ =~ RUBY_PLATFORM) then $objs = [] for f in Dir["#{$top_srcdir}/ext/#{$mdir}/*.{#{SRC_EXT.join(%q{,})}}"] f = File.basename(f) @@ -457,9 +480,13 @@ target_prefix = #{target_prefix} mfile.printf $objs.join(" ") mfile.printf "\n" - ruby_interpreter = "$(topdir)/miniruby@EXEEXT@" - if /nmake/i =~ $make - ruby_interpreter = '$(topdir:/=\)\miniruby@EXEEXT@' + if /bccwin32/ =~ RUBY_PLATFORM + ruby_interpreter = '$(topdir:/=\)/miniruby@EXEEXT@' + else + ruby_interpreter = "$(topdir)/miniruby@EXEEXT@" + if /nmake/i =~ $make + ruby_interpreter = '$(topdir:/=\)\miniruby@EXEEXT@' + end end if defined? CROSS_COMPILING ruby_interpreter = "@MINIRUBY@" @@ -476,8 +503,16 @@ EXEEXT = @EXEEXT@ all: $(DLLIB) -clean:; @$(RM) *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB) - @$(RM) *.ilk *.exp *.pdb *.bak $(CLEANFILES) +clean: + @$(RM) *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB) +#{ +if /bccwin32/ =~ RUBY_PLATFORM + " @$(RM) *.def *.ilc *.ild *.ilf *.ils *.map *.tds *.bak $(CLEANFILES)\n" + + " @if exist $(target).def.org ren $(target).def.org $(target).def" +else + " @$(RM) *.ilk *.exp *.pdb *.bak $(CLEANFILES)" +end +} distclean: clean @$(RM) Makefile extconf.h conftest.* @@ -501,7 +536,11 @@ EOS mfile.printf "\n" unless /mswin32/ =~ RUBY_PLATFORM - src = '$<' + if /bccwin32/=~ RUBY_PLATFORM + src = '$(<:\\=/)' + else + src = '$<' + end copt = cxxopt = '' else if /nmake/i =~ $make @@ -513,6 +552,18 @@ EOS cxxopt = '-Tp' end unless /nmake/i =~ $make + 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 mfile.puts " .cc.@OBJEXT@: $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} @@ -561,14 +612,18 @@ $(DLLIB): $(OBJS) end elsif "@DLEXT@" != $OBJEXT 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" + 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/ =~ RUBY_PLATFORM + if /nmake/i =~ $make + mfile.print "\tset LIB=$(LIBPATH:/=\\);$(LIB)\n" + else + mfile.print "\tenv LIB='$(subst /,\\\\,$(LIBPATH));$(LIB)' \\\n" + end end + mfile.print "\t$(LDSHARED) $(DLDFLAGS) #{OUTFLAG}$(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n" end - mfile.print "\t$(LDSHARED) $(DLDFLAGS) #{OUTFLAG}$(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n" elsif RUBY_PLATFORM == "m68k-human" mfile.printf "\ $(DLLIB): $(OBJS) @@ -586,7 +641,11 @@ $(DLLIB): $(OBJS) mfile.printf "###\n" while line = dfile.gets() line.gsub!(/\.o\b/, ".#{$OBJEXT}") - line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') if /nmake/i =~ $make + if /bccwin32/ =~ RUBY_PLATFORM + line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') + else + line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') if /nmake/i =~ $make + end mfile.printf "%s", line.gsub('\$\(hdrdir\)/config.h', '$(topdir)/config.h') end dfile.close @@ -613,6 +672,8 @@ def extmake(target) if /mswin32/ =~ RUBY_PLATFORM $LIBEXT = "lib" $local_flags = "-link /INCREMENTAL:no /EXPORT:Init_$(TARGET)" + elsif /bccwin32/ =~ RUBY_PLATFORM + $LIBEXT = "lib" end $LOCAL_LIBS = "" # to be assigned in extconf.rb $CFLAGS = "" @@ -651,7 +712,11 @@ def extmake(target) $extlist.push [$static, File.basename($target)] end if $install - system "#{$make} install DESTDIR=#{$destdir}" + if /bccwin32/ =~ RUBY_PLATFORM + system "#{$make} -DDESTDIR=#{$destdir} install" + else + system "#{$make} install DESTDIR=#{$destdir}" + end elsif $clean system "#{$make} #{$clean}" else @@ -691,7 +756,7 @@ for setup in ["@setup@", "#{$top_srcdir}/ext/@setup@"] next end target = line.split[0] - target = target.downcase if /mswin32/ =~ RUBY_PLATFORM + target = target.downcase if /mswin32|bccwin32/ =~ RUBY_PLATFORM $static_ext[target] = true end f.close diff --git a/ext/pty/extconf.rb b/ext/pty/extconf.rb index ec35879a33..5e126fe0cf 100644 --- a/ext/pty/extconf.rb +++ b/ext/pty/extconf.rb @@ -1,6 +1,6 @@ require 'mkmf' -if /mswin32|mingw/ !~ RUBY_PLATFORM +if /mswin32|mingw|bccwin32/ !~ RUBY_PLATFORM have_header("sys/stropts.h") have_func("setresuid") have_header("libutil.h") diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 29f9b5d189..e178533bdc 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -39,6 +39,10 @@ SRC end case RUBY_PLATFORM +when /bccwin32/ + test_func = "WSACleanup" + have_library("ws2_32", "WSACleanup") + have_func("closesocket") when /mswin32|mingw/ test_func = "WSACleanup" have_library("wsock32", "WSACleanup") diff --git a/ext/tcltklib/extconf.rb b/ext/tcltklib/extconf.rb index fd98b1e7da..d58c8045a0 100644 --- a/ext/tcltklib/extconf.rb +++ b/ext/tcltklib/extconf.rb @@ -2,7 +2,7 @@ require 'mkmf' -if RUBY_PLATFORM !~ /mswin32|mingw|cygwin/ +if RUBY_PLATFORM !~ /mswin32|mingw|cygwin|bccwin32/ have_library("nsl", "t_open") have_library("socket", "socket") have_library("dl", "dlopen") @@ -22,7 +22,7 @@ def find_tcl(tcllib, stubs) func = stubs ? "Tcl_InitStubs" : "Tcl_FindExecutable" if tcllib find_library(tcllib, func, *paths) - elsif RUBY_PLATFORM =~ /mswin32|mingw|cygwin/ + elsif RUBY_PLATFORM =~ /mswin32|mingw|cygwin|bccwin32/ find_library("tcl", func, *paths) or find_library("tcl84", func, *paths) or find_library("tcl83", func, *paths) or @@ -44,7 +44,7 @@ def find_tk(tklib, stubs) func = stubs ? "Tk_InitStubs" : "Tk_Init" if tklib find_library(tklib, func, *paths) - elsif RUBY_PLATFORM =~ /mswin32|mingw|cygwin/ + elsif RUBY_PLATFORM =~ /mswin32|mingw|cygwin|bccwin32/ find_library("tk", func, *paths) or find_library("tk84", func, *paths) or find_library("tk83", func, *paths) or @@ -62,7 +62,7 @@ def find_tk(tklib, stubs) end if have_header("tcl.h") && have_header("tk.h") && - (/mswin32|mingw|cygwin/ =~ RUBY_PLATFORM || find_library("X11", "XOpenDisplay", + (/mswin32|mingw|cygwin|bccwin32/ =~ RUBY_PLATFORM || find_library("X11", "XOpenDisplay", "/usr/X11/lib", "/usr/X11R6/lib", "/usr/openwin/lib")) && find_tcl(tcllib, stubs) && find_tk(tklib, stubs) -- cgit v1.2.3