Index: trunk/psconfig/pschecklibs
===================================================================
--- trunk/psconfig/pschecklibs	(revision 12497)
+++ trunk/psconfig/pschecklibs	(revision 12839)
@@ -31,10 +31,14 @@
 endif
 
-# set paths for PSVERSION
+# set install paths for PSVERSION
 set libdir  = `source psconfig.sh --libs $PSVERSION`
 set incdir  = `source psconfig.sh --include $PSVERSION`
 
+# make these directories
+mkdir -p $libdir
+mkdir -p $incdir
+
 # I supplement this list with LD_LIBRARY_PATH below
-set syslibpath = "/lib /usr/lib /usr/X11R6/lib /usr/openwin/lib /usr/local/lib"
+set syslibpath = "/lib /usr/lib /usr/X11R6/lib /usr/local/lib "
 set needlibs   = ""
 set needlibs   = "$needlibs png"
@@ -52,7 +56,6 @@
 set needlibs   = "$needlibs m"
 
-# /usr/local/include/libpng is really pretty lame...
-set sysincpath = "/usr/include /usr/local/include /usr/X11R6/include /usr/openwin/include /usr/local/include/libpng"
-
+# I supplement this list with CPATH below
+set sysincpath = "/usr/include /usr/local/include /usr/X11R6/include "
 set needincs = ""
 set needincs = "$needincs X11/Xatom.h"
@@ -103,8 +106,8 @@
 set needincs = "$needincs time.h"
 set needincs = "$needincs unistd.h"
-set needincs = "$needincs values.h"
 set needincs = "$needincs zlib.h"
 
 # XXX need to have options for non-ANSI includes? (ie, varargs.h)
+# set needincs = "$needincs values.h" - this only provides values already defined in limits.h?
 # set needincs = "$needincs libxml/parser.h"
 # set needincs = "$needincs cfuncs.h" - from non-ANSI option in ohana.h
@@ -118,4 +121,5 @@
 set sys=`uname -s` 
 set ranlib = "ranlib"
+set dlltype = "so"
 switch ($sys)
  case IRIX64:
@@ -130,4 +134,6 @@
    endif
    # sun (at least) seems to need the socket library (linux does not)
+   set syslibpath = "$syslibpath /usr/openwin/lib"
+   set sysincpath = "$sysincpath /usr/openwin/include"
    set needlibs = "$needlibs libsocket libnsl"
    set ranlib = "touch"
@@ -141,4 +147,14 @@
     set syslibpath = "/lib64 /usr/lib64 /usr/X11R6/lib64 $syslibpath"
    endif
+   breaksw;
+ case Darwin:
+   set arch="darwin";
+   set mach=`uname -m`
+   if ("$mach" == "i386") then
+    set arch="darwin_x86";
+   endif
+   set syslibpath = "$syslibpath /sw/lib /usr/local/lib/mysql"
+   set sysincpath = "$sysincpath /sw/include /usr/include/sys"
+   set dlltype = dylib
    breaksw;
  case HP-UX:
@@ -169,8 +185,20 @@
     foreach g ( $libdir $libpath $syslibpath )
         if (! -e $g) continue
-	set name = $g/lib$f.a
-	if (-e $name[1]) goto got_lib;
-	set name = $g/lib$f.so*
-	if (-e $name[1]) goto got_lib;
+        set name = $g/lib$f.a
+        if (-e $name[1]) goto got_lib;
+        set name = $g/lib$f.$dlltype
+        if (-e $name[1]) goto got_lib;
+    end
+    # if we find a .so.N without a matching .so, we link this in
+    # the installed libdir
+    foreach g ( $libpath $syslibpath )
+        set name = $g/lib$f.$dlltype*
+        echo "libname: $name"
+        if (-e $name[1]) then
+          echo "making link to numbers .$dlltype library $libdir/lib$f.$dlltype"
+          ln -s $name[$#name] $libdir/lib$f.$dlltype
+          if ($status) exit 1
+          goto got_lib
+        endif
     end
     echo "missing lib$f"
@@ -185,8 +213,18 @@
 foreach f ( ncurses curses termcap )
     foreach g ( $libdir $libpath $syslibpath )
-	set name = $g/lib$f.a
-	if (-e $name[1]) goto got_curses;
-	set name = $g/lib$f.so*
-	if (-e $name[1]) goto got_curses;
+        set name = $g/lib$f.a
+        if (-e $name[1]) goto got_curses;
+        set name = $g/lib$f.$dlltype
+        if (-e $name[1]) goto got_curses;
+    end
+    # if we find a .so.N without a matching .so, we link this in
+    # the installed libdir
+    foreach g ( $libpath $syslibpath )
+        set name = $g/lib$f.$dlltype*
+        if ($#name > 0) then
+          echo "making link to numbers .$dlltype library $libdir/lib$f.$dlltype"
+          ln -s $name[$#name] $libdir/lib$f.$dlltype
+          goto got_curses;
+        endif
     end
 end
