From 9c1657f302d0d0e5b8eefa2a70f73bdb57d5fcd6 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 18 Feb 1998 10:01:47 +0000 Subject: cygwin patches git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@83 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/cygwin32_ld.rb | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 ext/cygwin32_ld.rb (limited to 'ext/cygwin32_ld.rb') diff --git a/ext/cygwin32_ld.rb b/ext/cygwin32_ld.rb new file mode 100644 index 0000000000..a9c8e21cb0 --- /dev/null +++ b/ext/cygwin32_ld.rb @@ -0,0 +1,90 @@ +#!/usr/local/bin/ruby +require '../../rbconfig' +include Config + +args = ARGV.join(" ") + +objs = [] +flags = [] +libname = '' +Init = "../init" + +path = '' + +def writeInit + out = open("#{Init}.c", "w") + + out.print %q@ +#include +#include + +extern struct _reent *__imp_reent_data; +WINAPI dll_entry(int a, int b, int c) +{ + _impure_ptr =__imp_reent_data; + return 1; +} +main(){} +//void impure_setup(struct _reent *_impure_ptrMain) +//{ +// _impure_ptr =__imp_reent_data; +//} +@ + out.close +end + +def xsystem cmd + print cmd, "\n" + system cmd +end + +if args =~ /-o (\w+)\.dll/i + libname = $1 + # Check for path: + if libname =~ /(\w+\/)(\w+)$/ + path = $1 + libname = $2 + end + for arg in ARGV + case arg + when /\.[oa]$/i + objs.push(arg) + when /-o/, /\w+\.dll/i + ; + else + flags << arg + end + end + + writeInit unless FileTest.exist?("#{Init}.c") + unless FileTest.exist?("#{Init}.o") and + File.mtime("#{Init}.c") < File.mtime("#{Init}.o") + xsystem "gcc -c #{Init}.c -o #{Init}.o" + end + + command = "echo EXPORTS > #{libname}.def" + xsystem command +# xsystem "echo impure_setup >> #{libname}.def" + xsystem "nm --extern-only " + objs.join(" ") + + " | sed -n '/^........ [CDT] _/s///p' >> #{libname}.def" + + command = "gcc -nostdlib -o junk.o -Wl,--base-file,#{libname}.base,--dll " + + objs.join(" ") + " #{Init}.o " + command.concat(flags.join(" ") + + " -Wl,-e,_dll_entry@12 -lcygwin -lkernel32 #{CONFIG['srcdir']}/libruby.a") + xsystem command + + command = "dlltool --as=as --dllname #{libname}.dll --def #{libname}.def --base-file #{libname}.base --output-exp #{libname}.exp" + xsystem command + + command = "gcc -s -nostdlib -o #{libname}.dll -Wl,--dll #{libname}.exp " + + objs.join(" ") + " #{Init}.o " + command.concat(flags.join(" ") + + " -Wl,-e,_dll_entry@12 -lcygwin -lkernel32 #{CONFIG['srcdir']}/libruby.a") + xsystem command + File.unlink "junk.o" if FileTest.exist? "junk.o" + +else + # no special processing, just call ld + xsystem "ld #{args}" +end -- cgit v1.2.3