Index: gtkdoc-fixxref.in
===================================================================
--- gtkdoc-fixxref.in	(Revision 434)
+++ gtkdoc-fixxref.in	(Arbeitskopie)
@@ -66,7 +66,14 @@
 
 # This contains all the entities and their relative URLs.
 my %Links;
+# This hold the path entries we already scanned
+my @VisitedPaths;
 
+
+$HTML_DIR =~ m%(.*?)/share/gtk-doc/html%;
+my $path_prefix=$1;
+#print "Path prefix: $path_prefix\n";
+
 my $dir;
 
 # We scan the directory containing GLib and any directories in GNOME2_PATH
@@ -76,7 +83,11 @@
 $dir = $dir . "/share/gtk-doc/html";
 if (-d $dir && $dir ne $HTML_DIR) {
 #    print "Scanning GLib directory: $dir\n";
-    &ScanIndices ($dir, 1);
+    if ($dir !~ m%$path_prefix/(.*)%) {
+        &ScanIndices ($dir, 1);
+    } else {
+        &ScanIndices ($dir, 0);
+    }
 }
 
 if (defined ($ENV{"GNOME2_PATH"})) {
@@ -84,18 +95,36 @@
         $dir = $dir . "/share/gtk-doc/html";
 	if (-d $dir && $dir ne $HTML_DIR) {
 #	    print "Scanning GNOME2_PATH directory: $dir\n";
-	    &ScanIndices ($dir, 1);
+	    if ($dir !~ m%$path_prefix/(.*)%) {
+                &ScanIndices ($dir, 1);
+            } else {
+                &ScanIndices ($dir, 0);
+            }
 	}
     }
 }
 
 #print "Scanning HTML_DIR directory: $HTML_DIR\n";
 &ScanIndices ($HTML_DIR, 0);
+push (@VisitedPaths, $HTML_DIR);
+
+# check all extra dirs, but skip already scanned dirs ord subdirs of those
 foreach my $dir (@EXTRA_DIRS) {
+    my $vdir;
+    my $skip = 0;
+
+    foreach $vdir (@VisitedPaths) {
+        if ($dir =~ m%$vdir(.*)%) {
+#            print "Skipping EXTRA_DIR directory: $dir\n";
+            $skip=1;
+        }
+    }
+    next if $skip;
 #    print "Scanning EXTRA_DIR directory: $dir\n";
-    # If the --extra-dir option is an absolute directory, we use absolute
-    # directories for the links. Support Unix '/' or Win32 'C:\'.
-    if ($dir =~ m%^(/|[A-Z]:\\)%) {
+    push (@VisitedPaths, $dir);
+    # If the --extra-dir option is not sharing the same prefix as the target
+    # directory of the docs, we need to use absolute directories for the links
+    if ($dir !~ m%$path_prefix/(.*)%) {
         &ScanIndices ($dir, 1);
     } else {
         &ScanIndices ($dir, 0);
@@ -106,6 +135,7 @@
 
 sub ScanIndices {
     my ($scan_dir, $use_absolute_links) = @_;
+
 #    print "Scanning source directory: $scan_dir absolute: $use_absolute_links\n";
 
     # This array holds any subdirectories found.
