Index: gtkdoc-scan.in
===================================================================
--- gtkdoc-scan.in	(revision 652)
+++ gtkdoc-scan.in	(working copy)
@@ -38,6 +38,7 @@
 
 use strict;
 use Getopt::Long;
+use Cwd qw(realpath);
 
 unshift @INC, '@PACKAGE_DATA_DIR@';
 require "gtkdoc-common.pl";
@@ -140,6 +141,10 @@
 my $object_list = "";
 my $file;
 
+# do not read files twice; checking it here permits to give both srcdir and
+# builddir as --source-dir without fear of duplicities
+my %SEEN_HEADERS;
+
 # The header files to scan are passed in as command-line args.
 for $file (@ARGV) {
     &ScanHeader ($file, \$object_list, \$main_list);
@@ -256,6 +261,10 @@
 
     my $deprecated = "";
 
+    my $canonical_input_file = realpath $input_file;
+    return if exists $SEEN_HEADERS{$canonical_input_file};
+    $SEEN_HEADERS{$canonical_input_file} = 1;
+
     if ($input_file =~ m/^.*[\/\\](.*)\.h+$/) {
 	$file_basename = $1;
     } else {
