
--- mono-1.2/configure	2006-11-02 13:16:04.000000000 -0500
+++ mono-1.2-new/configure	2006-11-10 14:26:01.000000000 -0500
@@ -36090,7 +36090,7 @@
 	INTL="libintl.dylib"
 	SQLITE="libsqlite.0.dylib"
 	SQLITE3="libsqlite3.0.dylib"
-	X11="libX11.dylib"
+	X11="libX11.6.dylib"
 	;;
      *-*-*netbsd*)
 	LIBC="libc.so.12"
--- mono-1.2/data/config.in	2006-11-02 13:09:52.000000000 -0500
+++ mono-1.2-new/data/config.in	2006-11-10 14:26:01.000000000 -0500
@@ -1,18 +1,18 @@
 <configuration>
-	<dllmap dll="cygwin1.dll" target="@LIBC@" />
-	<dllmap dll="libc" target="@LIBC@" />
-	<dllmap dll="intl" target="@INTL@" />
-	<dllmap dll="libintl" target="@INTL@" />
-	<dllmap dll="libxslt.dll" target="libxslt@libsuffix@" />
-	<dllmap dll="libmySQL.dll" target="libmysqlclient@libsuffix@" />
+	<dllmap dll="cygwin1.dll" target="/usr/lib/libSystem@libsuffix@" />
+	<dllmap dll="libc" target="/usr/lib/libSystem@libsuffix@" />
+	<dllmap dll="intl" target="@FINKPREFIX@/lib/libintl.3@libsuffix@" />
+	<dllmap dll="libintl" target="@FINKPREFIX@/lib/libintl.3@libsuffix@" />
+	<dllmap dll="libxslt.dll" target="@FINKPREFIX@/lib/libxslt.1@libsuffix@" />
+	<dllmap dll="libmySQL.dll" target="@FINKPREFIX@/lib/libmysqlclient@libsuffix@" />
 	<dllmap dll="odbc32.dll" target="libodbc@libsuffix@" />
 	<dllmap os="osx" dll="odbc32.dll" target="libiodbc.dylib" />
-	<dllmap dll="oci" target="libclntsh@libsuffix@" os="!windows"/>
-	<dllmap dll="db2cli" target="libdb2_36@libsuffix@" />
-	<dllmap dll="msvcrt" target="@LIBC@" />
-	<dllmap dll="MonoPosixHelper" target="libMonoPosixHelper@libsuffix@" />
-	<dllmap dll="sqlite" target="@SQLITE@" />
-	<dllmap dll="sqlite3" target="@SQLITE3@" />
-	<dllmap dll="libX11" target="@X11@" />
-	<dllmap dll="libcairo-2.dll" target="libcairo.so.2" />
+	<dllmap dll="oci" target="@FINKPREFIX@/lib/libclntsh@libsuffix@" os="!windows"/>
+	<dllmap dll="db2cli" target="@FINKPREFIX@/lib/libdb2_36@libsuffix@" />
+	<dllmap dll="msvcrt" target="/usr/lib/libSystem@libsuffix@" />
+	<dllmap dll="MonoPosixHelper" target="@FINKPREFIX@/lib/libMonoPosixHelper@libsuffix@" />
+	<dllmap dll="sqlite" target="@FINKPREFIX@/lib/@SQLITE@" />
+	<dllmap dll="sqlite3" target="@FINKPREFIX@/lib/@SQLITE3@" />
+	<dllmap dll="libX11" target="/usr/X11R6/lib/@X11@" />
+	<dllmap dll="libcairo-2.dll" target="@FINKPREFIX@/lib/libcairo.2@libsuffix@" />
 </configuration>
--- mono-1.2/mono/metadata/Makefile.in	2006-11-02 13:15:57.000000000 -0500
+++ mono-1.2-new/mono/metadata/Makefile.in	2006-11-10 14:26:01.000000000 -0500
@@ -67,7 +67,7 @@
 am_libmonoruntime_static_la_OBJECTS = $(am__objects_1)
 libmonoruntime_static_la_OBJECTS =  \
 	$(am_libmonoruntime_static_la_OBJECTS)
-libmonoruntime_la_LIBADD =
+libmonoruntime_la_LIBADD = $(ICU_LIBS)
 am_libmonoruntime_la_OBJECTS = reflection.lo object.lo icall.lo \
 	decimal.lo boehm-gc.lo null-gc.lo sgen-gc.lo gc.lo marshal.lo \
 	monitor.lo threads.lo threadpool.lo file-io.lo socket-io.lo \
--- mono-1.2/mono/metadata/loader.c	2006-11-02 13:09:50.000000000 -0500
+++ mono-1.2-new/mono/metadata/loader.c	2006-11-10 14:26:01.000000000 -0500
@@ -1010,6 +1010,39 @@
 	mono_loader_unlock ();
 }
 
+static gchar* _mono_module_build_path (const gchar *directory, const gchar *module_name, const gchar *module_suffix)
+{
+	if (directory && *directory)
+		{
+			if (strncmp (module_name, "lib", 3) == 0)
+				return g_strconcat (directory, "/", module_name, NULL);
+			else if (module_suffix && *module_suffix)
+				return g_strconcat (directory, "/lib", module_name, module_suffix, NULL);
+			else
+				return g_strconcat (directory, "/lib", module_name, NULL);
+		}
+	else if (strncmp (module_name, "lib", 3) == 0)
+		return g_strdup (module_name);
+	else if (module_suffix && *module_suffix)
+		return g_strconcat ("lib", module_name, module_suffix, NULL);
+	else
+		return g_strconcat ("lib", module_name, NULL);
+}
+
+static GModule* _mono_try_load_module (const char *directory_name, const char *file_name, const char *module_suffix)
+{
+	GModule *gmodule = NULL;
+	char *full_name;
+	full_name = _mono_module_build_path (directory_name, file_name, module_suffix);
+	mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT, "DllImport loading location: '%s'.", full_name);
+	gmodule = g_module_open (full_name, G_MODULE_BIND_LAZY);
+	if (!gmodule) {
+		mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT, "DllImport error loading library: '%s'.", g_module_error ());
+	}
+	g_free (full_name);
+	return gmodule;
+}
+
 gpointer
 mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char **exc_arg)
 {
@@ -1023,7 +1056,7 @@
 	const char *import = NULL;
 	const char *orig_scope;
 	const char *new_scope;
-	char *full_name, *file_name;
+	char *file_name;
 	int i;
 	GModule *gmodule = NULL;
 
@@ -1109,32 +1142,6 @@
 		}
 
 		if (!gmodule) {
-			full_name = g_module_build_path (NULL, file_name);
-			mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
-					"DllImport loading location: '%s'.", full_name);
-			gmodule = g_module_open (full_name, G_MODULE_BIND_LAZY);
-			if (!gmodule) {
-				mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
-						"DllImport error loading library: '%s'.",
-						g_module_error ());
-			}
-			g_free (full_name);
-		}
-
-		if (!gmodule) {
-			full_name = g_module_build_path (".", file_name);
-			mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
-					"DllImport loading library: '%s'.", full_name);
-			gmodule = g_module_open (full_name, G_MODULE_BIND_LAZY);
-			if (!gmodule) {
-				mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
-						"DllImport error loading library '%s'.",
-						g_module_error ());
-			}
-			g_free (full_name);
-		}
-
-		if (!gmodule) {
 			mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
 					"DllImport loading: '%s'.", file_name);
 			gmodule=g_module_open (file_name, G_MODULE_BIND_LAZY);
@@ -1145,6 +1152,24 @@
 			}
 		}
 
+		if (!gmodule) { gmodule = _mono_try_load_module("@FINKPREFIX@/lib", file_name, ".so"); }
+		if (!gmodule) { gmodule = _mono_try_load_module("@FINKPREFIX@/lib", file_name, ".dylib"); }
+		if (!gmodule) { gmodule = _mono_try_load_module(NULL, file_name, ".so"); }
+		if (!gmodule) { gmodule = _mono_try_load_module(NULL, file_name, ".dylib"); }
+		if (!gmodule) { gmodule = _mono_try_load_module(".", file_name, ".so"); }
+		if (!gmodule) { gmodule = _mono_try_load_module(".", file_name, ".dylib"); }
+		if (!gmodule) { gmodule = _mono_try_load_module("/usr/X11R6/lib", file_name, ".so"); }
+		if (!gmodule) { gmodule = _mono_try_load_module("/usr/X11R6/lib", file_name, ".dylib"); }
+
+		if (!gmodule) { gmodule = _mono_try_load_module("@FINKPREFIX@/lib", file_name, NULL); }
+		if (!gmodule) { gmodule = _mono_try_load_module("@FINKPREFIX@/lib", file_name, ".bundle"); }
+		if (!gmodule) { gmodule = _mono_try_load_module(NULL, file_name, NULL); }
+		if (!gmodule) { gmodule = _mono_try_load_module(NULL, file_name, ".bundle"); }
+		if (!gmodule) { gmodule = _mono_try_load_module(".", file_name, NULL); }
+		if (!gmodule) { gmodule = _mono_try_load_module(".", file_name, ".bundle"); }
+		if (!gmodule) { gmodule = _mono_try_load_module("/usr/X11R6/lib", file_name, NULL); }
+		if (!gmodule) { gmodule = _mono_try_load_module("/usr/X11R6/lib", file_name, ".bundle"); }
+
 		g_free (file_name);
 
 		if (gmodule)
