Index: /branches/eam_branches/ipp-20120601/psconfig/pschecklibs
===================================================================
--- /branches/eam_branches/ipp-20120601/psconfig/pschecklibs	(revision 33983)
+++ /branches/eam_branches/ipp-20120601/psconfig/pschecklibs	(revision 33984)
@@ -142,8 +142,15 @@
 unshift @incpath, $incdir;
 
+# get a list of implicit paths from cpp directly
+&checkpreprocessor ();
+
+# get a list of implicit paths from the linker directly
+&checklinker ();
+
 # add the system paths specified for each architecture
 &checkarch ();
 print "setting architecture to: $arch\n";
 print "searching for libraries in: @libpath\n";
+print "searching for headers in: @incpath\n";
 print "searching for programs in: @binpath\n";
 print "\n";
@@ -404,5 +411,4 @@
                 $path = "$topdir/$subdir";
             }
-            # print "trying $path\n";
             if (! -e $path) { next; }
             $binname = "$path/$name";
@@ -441,4 +447,75 @@
 }
 
+sub checklinker {
+    # we are going to supplement the libpath with entries reported by
+    # the linker (this depends on ld --verbose 
+
+    my $line, @lines;
+    my $item, @items;
+
+    @lines = `ld --verbose | grep SEARCH_DIR`;
+    foreach $line (@lines) {
+	# we expect items of the form SEARCH_DIR("path");
+	# or SEARCH_DIR("=path") -- in that case we should prepend sysroo
+	next unless ($line =~ m|SEARCH_DIR|);
+	@items = split (";", $line);
+	foreach $item (@items) {
+	    next unless ($item);
+	    ($p1) = $item =~ m|SEARCH_DIR\050"=(\S*)"|;
+	    ($p2) = $item =~ m|SEARCH_DIR\050"(\S*)"|;
+	    next if (!$p1 && !$p2);
+	    if (!$p1 && $p2) {
+		push @libpath, $p2;
+	    }
+	    if ($p1 && $p2) {
+		push @libpath, $p1;
+	    }
+	    if ($p1 && !$p2) {
+		print "programming error!\n";
+		exit 4;
+	    }
+	}
+    }
+    return 0;
+}
+
+sub checkpreprocessor {
+    # we are going to supplement the libpath with entries reported by
+    # the linker (this depends on ld --verbose 
+
+### #include <...> search starts here:
+###  /home/eugene/src/psconfig/ipp-dev.linux/include
+###  .
+###  /usr/lib/gcc/i686-linux-gnu/4.6/include
+###  /usr/local/include
+###  /usr/lib/gcc/i686-linux-gnu/4.6/include-fixed
+###  /usr/include/i386-linux-gnu
+###  /usr/include
+### End of search list.
+
+    my $line, @lines;
+    my $found_start;
+
+    @lines = `cpp --verbose < /dev/null 2>&1`;
+    $found_start = 0;
+    foreach $line (@lines) {
+	if (!$found_start) {
+	    if ($line =~ m|include \<...\> search starts here|) {
+		$found_start = 1;
+		next;
+	    } else {
+		next;
+	    }
+	}
+	chomp $line;
+	if ($line =~ m|End of search list|) {
+	    return 1;
+	}
+	($cleanline) = $line =~ m|\s*(\S*)|;
+	push @incpath, $cleanline;
+    }
+    return 0;
+}
+
 sub checkarch {
     # we are going to supplement the global libpath supplied
