Index: trunk/psconfig/psconfig.sh
===================================================================
--- trunk/psconfig/psconfig.sh	(revision 12150)
+++ trunk/psconfig/psconfig.sh	(revision 12496)
@@ -97,4 +97,5 @@
 setenv PSVERSION $args[1]
 
+if ($?CPATH == 0) setenv CPATH
 if ($?LD_LIBRARY_PATH == 0) setenv LD_LIBRARY_PATH
 if ($?PKG_CONFIG_PATH == 0) setenv PKG_CONFIG_PATH
@@ -204,4 +205,32 @@
 endif 
 
+# set CPATH, used to find include files
+set incdir  = {$PSCONFDIR}/{$PSCONFIG}/include
+set newpath = ""
+set pathlist = `echo $CPATH | tr ':' '\n'`
+foreach name ($pathlist)
+  echo $name | grep $PSCONFDIR > /dev/null
+  if ($status == 0) continue
+  if ($newpath == "") then
+    set newpath = {$name}:
+  else
+    set newpath = {$newpath}{$name}:
+  endif
+end
+if ("$PSCONFIG" == "none") then
+  if ("$newpath" == "") then
+    unsetenv CPATH
+  else
+    setenv CPATH {$newpath}
+  endif 
+else
+  if ("$newpath" == "") then
+    setenv CPATH {$incdir}:
+  else
+    setenv CPATH {$incdir}:{$newpath}
+  endif 
+endif 
+
+# set LIBRARY_PATH and LD_LIBRARY_PATH, used to find libraries
 set libdir  = {$PSCONFDIR}/{$PSCONFIG}/lib
 set newpath = ""
@@ -219,12 +248,16 @@
   if ("$newpath" == "") then
     unsetenv LD_LIBRARY_PATH
+    unsetenv LIBRARY_PATH
   else
     setenv LD_LIBRARY_PATH {$newpath}
+    setenv LIBRARY_PATH {$newpath}
   endif 
 else
   if ("$newpath" == "") then
     setenv LD_LIBRARY_PATH {$libdir}:
+    setenv LIBRARY_PATH {$libdir}:
   else
     setenv LD_LIBRARY_PATH {$libdir}:{$newpath}
+    setenv LIBRARY_PATH {$libdir}:{$newpath}
   endif 
 endif 
@@ -291,6 +324,6 @@
   alias  psperlbuild perl Build.PL
 else
-  alias  psconfigure configure --prefix={$PSCONFDIR}/{$PSCONFIG} --bindir=$bindir --libdir=$libdir --includedir={$PSCONFDIR}/{$PSCONFIG}/include --sysconfdir={$PSCONFDIR}/{$PSCONFIG}/etc --datadir={$PSCONFDIR}/share --mandir={$PSCONFDIR}/man
-  alias  psautogen autogen.sh --bindir=$bindir --libdir=$libdir --mandir=$mandir --includedir={$PSCONFDIR}/{$PSCONFIG}/include --sysconfdir={$PSCONFDIR}/{$PSCONFIG}/etc --datadir={$PSCONFDIR}/share
+  alias  psconfigure configure --prefix={$PSCONFDIR}/{$PSCONFIG} --bindir=$bindir --libdir=$libdir --mandir=$mandir --includedir=$incdir --sysconfdir={$PSCONFDIR}/{$PSCONFIG}/etc --datadir={$PSCONFDIR}/share
+  alias  psautogen autogen.sh  --prefix={$PSCONFDIR}/{$PSCONFIG} --bindir=$bindir --libdir=$libdir --mandir=$mandir --includedir=$incdir --sysconfdir={$PSCONFDIR}/{$PSCONFIG}/etc --datadir={$PSCONFDIR}/share
   alias  psperlbuild perl Build.PL --prefix {$PSCONFDIR}/{$PSCONFIG} --install_path script=$bindir --install_path arch=$bindir --install_path bin=$bindir --install_path lib=$libdir --install_path bindoc={$PSCONFDIR}/man/man1 --install_path libdoc={$PSCONFDIR}/man/man3
   setenv ACLOCAL_FLAGS "-I $PSCONFDIR/share/aclocal"
