Index: math/reduce-algebra/files/runpsl.in
===================================================================
--- math/reduce-algebra/files/runpsl.in	(revision 0)
+++ math/reduce-algebra/files/runpsl.in	(working copy)
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+case `uname -m` in
+i*)
+      STORE=16000000
+      ;;
+x86_64)
+      STORE=1000
+      ;;
+esac
+
+bin="@LIBEXECDIR@/pslbuild/psl/bpsl"
+img="@LIBEXECDIR@/pslbuild/red/reduce.img"
+
+exec $bin -td $STORE -f $img $*
+
Index: math/reduce-algebra/Portfile
===================================================================
--- math/reduce-algebra/Portfile	(revision 94840)
+++ math/reduce-algebra/Portfile	(working copy)
@@ -4,7 +4,7 @@
 PortSystem          1.0
 
 name                reduce-algebra
-svn.revision        1530
+svn.revision        1534
 version             3.8.0-r${svn.revision}
 categories          math
 platforms           darwin
@@ -13,9 +13,10 @@
 
 description         REDUCE algebra system
 
-long_description    REDUCE is an interactive program designed for general \
-                    algebraic computations of interest to mathematicians, \
-                    scientists and engineers.
+long_description    REDUCE is an interactive program designed for general algebraic \
+                    computations of interest to mathematicians, scientists and \
+                    engineers. It supports numerical approximation with arbitrary \
+                    precision and also interfaces with gnuplot to provide graphics.
 
 homepage            http://reduce-algebra.sourceforge.net/
 
@@ -36,25 +37,28 @@
 use_parallel_build  no
 universal_variant   no
 
-set dest_dir        ${prefix}/libexec/${name}
+set topdir     ${prefix}/libexec/${name}
+set sharedir   ${destroot}${prefix}/share/${name}
+set libexecdir ${destroot}${prefix}/libexec/${name}
+set docdir     ${destroot}${prefix}/share/doc/${name}
+set bindir     ${destroot}${prefix}/bin
 
 destroot {
-# At present 'make install' is deeply broken, so manually install required files
-    xinstall -d ${destroot}${dest_dir}/doc
+# 'make install' is outdated, so manually install required files
+    set builddir   [exec ${worksrcpath}/scripts/findhost.sh [exec ${worksrcpath}/config.guess]]
+    set pslbuildir ${worksrcpath}/pslbuild/${builddir}
 
-    xinstall -m 0644 -W ${worksrcpath} BUGS BUILDING Contributor-Release.txt \
-        DEPENDENCY_TRACKING INSTALL README ${destroot}${dest_dir}/doc
+    xinstall -d ${bindir} ${docdir} ${sharedir} ${libexecdir}/pslbuild 
+         
+    eval copy ${worksrcpath}/doc/manual ${docdir}/manual
+    eval copy ${worksrcpath}/packages ${sharedir}/packages
+    eval copy ${worksrcpath}/psl ${libexecdir}/psl
+    foreach d {buildlogs deps psl red} {
+        eval copy ${pslbuildir}/$d ${libexecdir}/pslbuild/$d
+    }
 
-    xinstall -d ${destroot}${dest_dir}/bin
-    xinstall ${worksrcpath}/bin/redpsl ${destroot}${dest_dir}/bin
-
-    xinstall -d ${destroot}${dest_dir}/pslbuild
-    eval copy [glob ${worksrcpath}/pslbuild/*] ${destroot}${dest_dir}/pslbuild
-
-    xinstall -d ${destroot}${dest_dir}/scripts
-    eval copy [glob ${worksrcpath}/scripts/*] ${destroot}${dest_dir}/scripts
-
-    xinstall ${worksrcpath}/config.guess ${destroot}${dest_dir}
+    xinstall ${filespath}/runpsl.in ${bindir}/redpsl
+    reinplace "s|@LIBEXECDIR@|${prefix}/libexec/${name}|g" ${bindir}/redpsl
 }
 
 variant html description {Install documentation in HTML format} {
@@ -66,8 +70,7 @@
     }
 
     post-destroot {
-        xinstall -d ${destroot}${dest_dir}/doc/html
-        eval xinstall -m 0644 [glob ${worksrcpath}/doc/manual/*.html] ${destroot}${dest_dir}/doc/html
+        eval xinstall -m 0644 [glob ${worksrcpath}/doc/manual/*.html] ${docdir}/manual
     }
 }
 
@@ -80,14 +83,22 @@
     }
 
     post-destroot {
-        xinstall -d ${destroot}${dest_dir}/doc/pdf
-        xinstall -m 0644 ${worksrcpath}/doc/manual/manual-pdf.pdf ${destroot}${dest_dir}/doc/pdf
+        xinstall -m 0644 ${worksrcpath}/doc/manual/manual-pdf.pdf ${docdir}/manual
     }
 }
 
+post-activate {
+# create a second image after all modules have been built, with the final value of 
+# loaddirectories!*. Otherwise loading a module will always search the build directories
+# in worksrcpath (which don't exist).
+    set pslbuildir ${topdir}/pslbuild
+
+    system "cd ${pslbuildir}; exec sh -xv ${topdir}/psl/saveimage.sh ${pslbuildir}/red \
+        ${pslbuildir}"
+
+    file rename -force ${pslbuildir}/log/reduce.blg \
+                       ${pslbuildir}/buildlogs/reduce.img.blg
+    file delete -force ${pslbuildir}/log
+}
+
 livecheck.type      none
-
-notes "
-To use the PSL version of Reduce, add this directory to your PATH environment variable:
-    ${prefix}/libexec/reduce-algebra/bin/
-"
