--- a/src/maxima.system
+++ b/src/maxima.system
@@ -88,12 +88,15 @@
 			     ;; Convert dir/foo.fas to dir/foo.o
 			     (make-pathname :type "o" :defaults p))
 			 files)))
-	(c::build-fasl "binary-ecl/maxima" :lisp-files obj
+	(c::build-shared-library "binary-ecl/maxima-ecl" :lisp-files obj)
+	(si::chdir "binary-ecl")
+	(defparameter c::*ld-rpath* "-Wl,-rpath=$ORIGIN")
+	(c::build-fasl "maxima" :lisp-files '("libmaxima-ecl.so")
 			  :ld-flags
 			  (let ((x (symbol-value (find-symbol "*AUTOCONF-LD-FLAGS*"
 							      (find-package "MAXIMA")))))
 			    (if (and x (not (string= x ""))) (split-string x))))
-	(c::build-program "binary-ecl/maxima" :lisp-files obj
+	(c::build-program "maxima" :lisp-files '("libmaxima-ecl.so")
 			  :ld-flags
 			  (let ((x (symbol-value (find-symbol "*AUTOCONF-LD-FLAGS*"
 							      (find-package "MAXIMA")))))
