diff --git a/Makefile.macosx b/Makefile.macosx
index 50ec9de3121f4d9ce91610cb091a952bf7709a9e..c6bc15541c0f0fd3724366edf08628a6ce7dbbcb 100644
--- a/Makefile.macosx
+++ b/Makefile.macosx
@@ -17,23 +17,26 @@ SET_LIBRARY_PATH =
 
 #CL=../src/xm-dcl
 
-TKLIB=-L/opt/local/lib -lXm
-XTLIB=-L/usr/X11R6/lib -lXt
-XLIB=-L/usr/X11R6/lib -lX11
-# removed /usr/local/lib/liblanginfo.a from XLIB
+# Since the linker hard-codes the truenames of these libraries and
+# loading climxm.dylib fails when users attempt to load it with the
+# files missing, we use -weak-l and preload the libraries (see
+# tk/load-xm.lisp):
+TKLIB=-L/opt/local/lib -L/usr/local/lib -weak-lXm
+XTLIB=-L/usr/X11/lib -weak-lXt
+XLIB=-weak-lX11
 
-XINCLUDES=-I/usr/X11R6/include -I/opt/local/include
+XINCLUDES=-I/usr/X11R6/include -I/opt/local/include -I/usr/local/include
 
 ifeq ($(SIXTYFOURBIT),yes)
 CFLAGS = -arch x86_64 -DAcl64Bit
-MAKE_SHARED = sh ../src/bin/make_shared.mac64
+MAKE_SHARED = ld -arch x86_64 -bundle /usr/lib/bundle1.o -force_cpusubtype_ALL -flat_namespace
 else
 ifeq ($(MACHINE),x86)
 CFLAGS= -arch i386
-MAKE_SHARED = sh ../src/bin/make_shared.mac86
+MAKE_SHARED = ld -arch i386 -bundle /usr/lib/bundle1.o -force_cpusubtype_ALL -flat_namespace
 else
 CFLAGS= 
-MAKE_SHARED = sh ../src/bin/make_shared.mac
+MAKE_SHARED = ld -bundle /usr/lib/bundle1.o -force_cpusubtype_ALL -flat_namespace
 endif
 endif
 
@@ -41,6 +44,9 @@ PICFLAGS =
 SHAREFLAGS = 
 AR = ar cq
 
+# Make sure the wnn build is happy:
+REDHATLIBS = -lc
+
 PRODUCT-OBJS= $(PRODUCT-GENERIC-OBJS) $(STATIC-XM-OBJS) $(SHARED-XM-OBJS)
 
 IMPORTS = stub-x.o stub-xt.o stub-motif.o
diff --git a/tk/load-xm.lisp b/tk/load-xm.lisp
index 3069b5a005593adc2517c8692dbb9273100d604b..5f800aecdd3da409140f8d9cc76f67042bfb8031 100644
--- a/tk/load-xm.lisp
+++ b/tk/load-xm.lisp
@@ -19,11 +19,33 @@
 ;;
 ;; $Id: load-xm.lisp,v 2.7 2007/04/17 21:45:53 layer Exp $
 
-(in-package :user)
+(cl:in-package #:user)
 
 (eval-when (compile eval load)
   (require :climg))
 
+(defvar sys::*clim-library-search-path* '("/usr/X11/lib/" "/usr/X11R6/lib/" "/usr/local/lib/"
+                                          "/opt/local/lib/" "/sw/lib/"))
+
+;;; On Mac OS X, the linker hard-codes the paths to libraries into
+;;; climxm.dylib, so we instruct it to link weakly against Motif (so
+;;; it doesn't complain if the file isn't found), and pre-load its
+;;; dependency libraries' basenames from known places in the file
+;;; system here.
+#+macosx
+(unless (ff:get-entry-point (ff:convert-foreign-name "XtInitialize"))
+  (excl.osi:with-command-output (sys::library (format nil "otool -L ~a"
+                                                      (probe-file
+                                                       (format nil "clim2:;climxm.~a"
+                                                               (car excl::*load-foreign-types*)))))
+    (when (eql (elt sys::library 0) #\Tab)
+      (let ((sys::library-name (nth-value 2 (match-re ".*/(lib[^ ]+) " sys::library))))
+        (unless (dolist (pathname sys::*clim-library-search-path*)
+                  (handler-case (progn (load (merge-pathnames sys::library-name pathname))
+                                       (return t))
+                    (error (e) nil)))
+          (error "Can't find ~a in ~{~a~^, ~}~%" sys::library-name sys::*clim-library-search-path*))))))
+
 #+(version>= 5 0)
 (unless (ff:get-entry-point (ff:convert-foreign-name "XmCreateMyDrawingArea"))
   (let (