This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

patch jni.exp for darwin dylibs


Hi,

this patch lets darwin compile and link the jni testcases.
Darwin uses the -dynamiclib flag to compile dylibs instead of -shared. Also the extension is .dylib iso. so.
I'm not able to run them since there is another problem doing the call. But a step forward.


I tested it on head and branch 3.3 on darwinppc and linuxppc.

It should be applicable to 3.3 and head. If I get an ok, I can do that.

Thanks,

Andreas

2003-03-08 Andreas Tobler <a dot tobler at schweiz dot ch>

* libjava.jni/jni.exp: Add compilation/link fix dor darwin dylibs.
Index: libjava.jni/jni.exp
===================================================================
RCS file: /cvs/gcc/gcc/libjava/testsuite/libjava.jni/jni.exp,v
retrieving revision 1.9
diff -u -r1.9 jni.exp
--- libjava.jni/jni.exp	13 Dec 2002 05:00:14 -0000	1.9
+++ libjava.jni/jni.exp	8 Mar 2003 06:04:01 -0000
@@ -5,11 +5,23 @@
 # success.
 proc gcj_jni_compile_c_to_so {file {options {}}} {
   global srcdir
+  global host_triplet
 
+# apple uses a different extension for shared/dynamic libraries
+# so we check against powerpc-apple-darwin and set them to 
+# dylib, else we assume it's .so
+
+  if { [ regexp {powerpc-apple-darwin} $host_triplet] } {
+		set so_extension "dylib"
+		set so_flag "-dynamiclib"
+	} else {
+		set so_extension "so"
+		set so_flag "-shared"
+	}
   set name [file rootname [file tail $file]]
-  set soname lib${name}.so
+  set soname lib${name}.${so_extension}
 
-  lappend options "additional_flags=-shared -fPIC"
+  lappend options "additional_flags=${so_flag} -fPIC"
   # Find the generated header.
   lappend options "additional_flags=-I. -I.."
   # Find jni.h.
@@ -90,6 +102,17 @@
 # Do all the work for a single JNI test.  Return 0 on failure.
 proc gcj_jni_test_one {file} {
   global runtests
+  global host_triplet
+
+# apple uses a different extension for shared/dynamic libraries
+# so we check against powerpc-apple-darwin and set them to 
+# dylib, else we assume it's .so
+
+  if { [ regexp {powerpc-apple-darwin} $host_triplet] } {
+		set so_extension "dylib"
+	} else {
+		set so_extension "so"
+	}
 
   # The base name.  We use it for several purposes.
   set main [file rootname [file tail $file]]
@@ -156,7 +179,7 @@
   }
 
   # When we succeed we remove all our clutter.
-  eval gcj_cleanup [glob -nocomplain -- ${main}.*] [list $main lib${main}.so]
+  eval gcj_cleanup [glob -nocomplain -- ${main}.*] [list $main lib${main}.${so_extension}]
 
   return 1
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]