Index: trunk/Ohana/configure.tcsh
===================================================================
--- trunk/Ohana/configure.tcsh	(revision 12332)
+++ trunk/Ohana/configure.tcsh	(revision 12840)
@@ -5,13 +5,4 @@
 
 # we need to be able to list the required libraries for a given distribution
-
-# libX11.a
-# libsocket.a
-# libnsl.a
-# libpng.a
-# libjpeg.a
-# libz.a
-# libreadline.a
-# libtermcap.a
 
 # evaluate command-line options
@@ -28,4 +19,5 @@
 set datadir  = ""
 set sysconfdir  = ""
+set exec_prefix = ""
 
 set root    = ""
@@ -67,5 +59,12 @@
      set prefix = `echo $1 | tr = ' ' | awk '{print $2}'`
    endif
-   set exec_prefix = $prefix
+   breaksw;
+  case --exec-prefix*
+   if ("$1" == "--exec-prefix") then
+     shift
+     set exec_prefix = $1
+   else
+     set exec_prefix = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
    breaksw;
   case --bindir*
@@ -88,7 +87,7 @@
    if ("$1" == "--includedir") then
      shift
-     set includedir = $1
-   else
-     set includedir = `echo $1 | tr = ' ' | awk '{print $2}'`
+     set incdir = $1
+   else
+     set incdir = `echo $1 | tr = ' ' | awk '{print $2}'`
    endif
    breaksw;
@@ -131,4 +130,12 @@
 if ($#args != 1) goto usage
 
+if ("$exec_prefix" == "") then
+  set exec_prefix = $prefix
+endif
+
+# replace $exec_prefix in variables
+#echo "setting libdir ($libdir)"
+#set libdir = `echo $libdir | sed 's|\$exec_prefix|$exec_prefix|'`
+
 # set values for CC, CFLAGS, CPPFLAGS, LDFLAGS
 if (! $?CC) then
@@ -152,9 +159,16 @@
 endif  
 
-set syslibpath = "/lib /usr/lib /usr/X11R6/lib /usr/openwin/lib /usr/local/lib"
-set needlibs   = "png z jpeg readline X11 pthread m"
+set syslibpath = "/lib /usr/lib /usr/X11R6/lib /usr/local/lib"
+set needlibs   = ""
+set needlibs   = "$needlibs png"
+set needlibs   = "$needlibs z"
+set needlibs   = "$needlibs jpeg"
+set needlibs   = "$needlibs readline"
+set needlibs   = "$needlibs X11"
+set needlibs   = "$needlibs pthread"
+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"
+set sysincpath = "/usr/include /usr/local/include /usr/X11R6/include"
 
 set needincs = ""
@@ -210,4 +224,5 @@
 set sys=`uname -s` 
 set ranlib = "ranlib"
+set dlltype = "so"
 switch ($sys)
  case IRIX64:
@@ -222,4 +237,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"
@@ -234,4 +251,14 @@
    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:
     set arch="hpux";
@@ -247,11 +274,23 @@
 set root = `pwd`
 if ($prefix == "") set prefix = $root
-if ($vararch) then
-  set inc = $prefix/include/$arch
-  set lib = $prefix/lib/$arch
-else
-  set inc = $prefix/include
-  set lib = $prefix/lib
-endif
+
+# set the install include directory
+if ($incdir == "") then
+  if ($vararch) then
+    set incdir = $prefix/include/$arch
+  else
+    set incdir = $prefix/include
+  endif
+endif
+
+# set the install lib directory
+if ($libdir == "") then
+  if ($vararch) then
+    set libdir = $prefix/lib/$arch
+  else
+    set libdir = $prefix/lib
+  endif
+endif
+
 if ($?LD_LIBRARY_PATH) then 
   set libpath = `echo $LD_LIBRARY_PATH | tr ':' ' '`
@@ -268,24 +307,24 @@
 set nonomatch
 foreach f ( $needlibs )
-    foreach g ( $syslibpath $lib $libpath )
-        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;
-    end
-    echo "missing lib$f"
-    set faillibs = "$faillibs lib$f"
-    continue
+  foreach g ( $syslibpath $libdir $libpath )
+    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
+  echo "missing lib$f"
+  set faillibs = "$faillibs lib$f"
+  continue
 got_lib:
-    echo "found lib$f ($name[$#name])"
-    echo "$libdirs" | grep -- "-L$g " > /dev/null
-    if ($status) then
-      set libdirs  = "$libdirs-L$g "
-    endif
-    echo "$libflags" | grep -- "-l$f " > /dev/null
-    if ($status) then
-      set libflags = "$libflags-l$f "
-    endif
+  echo "found lib$f ($name[1])"
+  set gotlibdir = `dirname $name[1]`
+  echo "$libdirs" | grep -- "-L$gotlibdir " > /dev/null
+  if ($status) then
+    set libdirs  = "$libdirs-L$gotlibdir "
+  endif
+  echo "$libflags" | grep -- "-l$f " > /dev/null
+  if ($status) then
+    set libflags = "$libflags-l$f "
+  endif
 end
 
@@ -293,9 +332,9 @@
 # check for termcap, curses, etc
 foreach f ( ncurses curses termcap )
-    foreach g ( $syslibpath $lib $libpath )
-	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;
+    foreach g ( $syslibpath $libdir $libpath )
+        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
 end
@@ -324,5 +363,12 @@
 endif    
 
-# check for headers
+# add the CPATH
+if ($?CPATH) then 
+  set incpath = `echo $CPATH | tr ':' ' '`
+else
+  set incpath = ""
+endif
+
+# check for headers (including in subdirectories)
 echo ""
 echo "searching for needed external header files..."
@@ -330,5 +376,5 @@
 set incdirs = ""
 foreach f ( $needincs )
-  foreach g ( $sysincpath $inc )
+  foreach g ( $incdir $incpath $sysincpath )
     set name = "$g/$f"
     if (-e $name) goto got_inc;
@@ -338,5 +384,5 @@
   continue
 got_inc:
-  echo "found $f ($name)"
+  echo "found $f ($name[1])"
   echo "$incdirs" | grep -- "-I$g " > /dev/null
   if ($status) then
@@ -453,4 +499,5 @@
 ./config.tools fixconf @CPPFLAGS@ "$CPPFLAGS"
 ./config.tools fixconf @LDFLAGS@ "$LDFLAGS"
+./config.tools fixconf @DLLTYPE@  "$dlltype"
 
 # other architecture dependent options
