bin/syncqt
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 #!/usr/bin/perl -w
       
     2 ######################################################################
       
     3 #
       
     4 # Synchronizes Qt header files - internal development tool.
       
     5 #
       
     6 # Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     7 # Contact: Nokia Corporation (qt-info@nokia.com)
       
     8 #
       
     9 ######################################################################
       
    10 
       
    11 # use packages -------------------------------------------------------
       
    12 use File::Basename;
       
    13 use File::Path;
       
    14 use Cwd;
       
    15 use Config;
       
    16 use strict;
       
    17 
       
    18 die "syncqt: QTDIR not defined" if ! $ENV{"QTDIR"}; # sanity check
       
    19 
       
    20 # global variables
       
    21 my $isunix = 0;
       
    22 my $basedir = $ENV{"QTDIR"};
       
    23 $basedir =~ s=\\=/=g;
       
    24 my %modules = ( # path to module name map
       
    25         "QtGui" => "$basedir/src/gui",
       
    26         "QtOpenGL" => "$basedir/src/opengl",
       
    27         "QtOpenVG" => "$basedir/src/openvg",
       
    28         "QtCore" => "$basedir/src/corelib",
       
    29         "QtXml" => "$basedir/src/xml",
       
    30         "QtXmlPatterns" => "$basedir/src/xmlpatterns",
       
    31         "QtSql" => "$basedir/src/sql",
       
    32         "QtNetwork" => "$basedir/src/network",
       
    33         "QtSvg" => "$basedir/src/svg",
       
    34         "QtScript" => "$basedir/src/script",
       
    35         "QtScriptTools" => "$basedir/src/scripttools",
       
    36         "Qt3Support" => "$basedir/src/qt3support",
       
    37         "ActiveQt" => "$basedir/src/activeqt/container;$basedir/src/activeqt/control;$basedir/src/activeqt/shared",
       
    38         "QtTest" => "$basedir/src/testlib",
       
    39         "QtAssistant" => "$basedir/tools/assistant/compat/lib",
       
    40         "QtHelp" => "$basedir/tools/assistant/lib",
       
    41         "QtDesigner" => "$basedir/tools/designer/src/lib",
       
    42         "QtUiTools" => "$basedir/tools/designer/src/uitools",
       
    43         "QtDBus" => "$basedir/src/dbus",
       
    44         "QtWebKit" => "$basedir/src/3rdparty/webkit/WebCore",
       
    45         "phonon" => "$basedir/src/phonon",
       
    46         "QtMultimedia" => "$basedir/src/multimedia",
       
    47 );
       
    48 my %moduleheaders = ( # restrict the module headers to those found in relative path
       
    49         "QtWebKit" => "../WebKit/qt/Api",
       
    50         "phonon" => "../3rdparty/phonon/phonon",
       
    51 );
       
    52 
       
    53 #$modules{"QtCore"} .= ";$basedir/mkspecs/" . $ENV{"MKSPEC"} if defined $ENV{"MKSPEC"};
       
    54 
       
    55 # global variables (modified by options)
       
    56 my $module = 0;
       
    57 my $showonly = 0;
       
    58 my $remove_stale = 1;
       
    59 my $force_win = 0;
       
    60 my $force_relative = 0;
       
    61 my $check_includes = 0;
       
    62 my $copy_headers = 0;
       
    63 my @modules_to_sync ;
       
    64 $force_relative = 1 if ( -d "/System/Library/Frameworks" );
       
    65 my $out_basedir = $basedir;
       
    66 $out_basedir =~ s=\\=/=g;
       
    67 
       
    68 # functions ----------------------------------------------------------
       
    69 
       
    70 ######################################################################
       
    71 # Syntax:  showUsage()
       
    72 # Params:  -none-
       
    73 #
       
    74 # Purpose: Show the usage of the script.
       
    75 # Returns: -none-
       
    76 ######################################################################
       
    77 sub showUsage
       
    78 {
       
    79     print "$0 usage:\n";
       
    80     print "  -copy                 Copy headers instead of include-fwd(default: " . ($copy_headers ? "yes" : "no") . ")\n";
       
    81     print "  -remove-stale         Removes stale headers              (default: " . ($remove_stale ? "yes" : "no") . ")\n";
       
    82     print "  -relative             Force relative symlinks            (default: " . ($force_relative ? "yes" : "no") . ")\n";
       
    83     print "  -windows              Force platform to Windows          (default: " . ($force_win ? "yes" : "no") . ")\n";
       
    84     print "  -showonly             Show action but not perform        (default: " . ($showonly ? "yes" : "no") . ")\n";
       
    85     print "  -outdir <PATH>        Specify output directory for sync  (default: $out_basedir)\n";
       
    86     print "  -help                 This help\n";
       
    87     exit 0;
       
    88 }
       
    89 
       
    90 ######################################################################
       
    91 # Syntax:  checkUnix()
       
    92 # Params:  -none-
       
    93 #
       
    94 # Purpose: Check if script runs on a Unix system or not. Cygwin
       
    95 #          systems are _not_ detected as Unix systems.
       
    96 # Returns: 1 if a unix system, else 0.
       
    97 ######################################################################
       
    98 sub checkUnix {
       
    99     my ($r) = 0;
       
   100     if ( $force_win != 0) {
       
   101         return 0;
       
   102     } elsif ( -f "/bin/uname" ) {
       
   103         $r = 1;
       
   104         (-f "\\bin\\uname") && ($r = 0);
       
   105     } elsif ( -f "/usr/bin/uname" ) {
       
   106         $r = 1;
       
   107         (-f "\\usr\\bin\\uname") && ($r = 0);
       
   108     }
       
   109     if($r) {
       
   110         $_ = $Config{'osname'};
       
   111         $r = 0 if( /(ms)|(cyg)win/i );
       
   112     }
       
   113     return $r;
       
   114 }
       
   115 
       
   116 sub checkRelative {
       
   117     my ($dir) = @_;
       
   118     return 0 if($dir =~ /^\//);
       
   119     return 0 if(!checkUnix() && $dir =~ /[a-zA-Z]:[\/\\]/);
       
   120     return 1;
       
   121 }
       
   122 
       
   123 ######################################################################
       
   124 # Syntax:  shouldMasterInclude(iheader)
       
   125 # Params:  iheader, string, filename to verify inclusion
       
   126 #
       
   127 # Purpose: Determines if header should be in the master include file.
       
   128 # Returns: 0 if file contains "#pragma qt_no_master_include" or not
       
   129 #          able to open, else 1.
       
   130 ######################################################################
       
   131 sub shouldMasterInclude {
       
   132     my ($iheader) = @_;
       
   133     return 0 if(basename($iheader) =~ /_/);
       
   134     return 0 if(basename($iheader) =~ /qconfig/);
       
   135     if(open(F, "<$iheader")) {
       
   136         while(<F>) {
       
   137 	    chomp;
       
   138 	    return 0 if(/^\#pragma qt_no_master_include$/);
       
   139 	}
       
   140 	close(F);
       
   141     } else {
       
   142 	return 0;
       
   143     }
       
   144     return 1;
       
   145 }
       
   146 
       
   147 ######################################################################
       
   148 # Syntax:  classNames(iheader)
       
   149 # Params:  iheader, string, filename to parse for classname "symlinks"
       
   150 #
       
   151 # Purpose: Scans through iheader to find all classnames that should be
       
   152 #          synced into library's include structure.
       
   153 # Returns: List of all class names in a file.
       
   154 ######################################################################
       
   155 sub classNames {
       
   156     my @ret;
       
   157     my ($iheader) = @_;
       
   158     if(basename($iheader) eq "qglobal.h") {
       
   159 	push @ret, "QtGlobal";
       
   160     } elsif(basename($iheader) eq "qendian.h") {
       
   161 	push @ret, "QtEndian";
       
   162     } elsif(basename($iheader) eq "qconfig.h") {
       
   163         push @ret, "QtConfig";
       
   164     } elsif(basename($iheader) eq "qplugin.h") {
       
   165 	push @ret, "QtPlugin";
       
   166     } elsif(basename($iheader) eq "qalgorithms.h") {
       
   167 	push @ret, "QtAlgorithms";
       
   168     } elsif(basename($iheader) eq "qcontainerfwd.h") {
       
   169 	push @ret, "QtContainerFwd";
       
   170     } elsif(basename($iheader) eq "qdebug.h") {
       
   171         push @ret, "QtDebug";
       
   172     } elsif(basename($iheader) eq "qevent.h") {
       
   173         push @ret, "QtEvents";
       
   174     } elsif(basename($iheader) eq "qnamespace.h") {
       
   175         push @ret, "Qt"
       
   176     } elsif(basename($iheader) eq "qssl.h") {
       
   177 	push @ret, "QSsl";
       
   178     } elsif(basename($iheader) eq "qtest.h") {
       
   179         push @ret, "QTest"
       
   180     } elsif(basename($iheader) eq "qtconcurrentmap.h") {
       
   181         push @ret, "QtConcurrentMap"
       
   182     } elsif(basename($iheader) eq "qtconcurrentfilter.h") {
       
   183         push @ret, "QtConcurrentFilter"
       
   184     } elsif(basename($iheader) eq "qtconcurrentrun.h") {
       
   185         push @ret, "QtConcurrentRun"
       
   186     }
       
   187 
       
   188     my $parsable = "";
       
   189     if(open(F, "<$iheader")) {
       
   190         while(<F>) {
       
   191             my $line = $_;
       
   192             chomp $line;
       
   193 			chop $line if ($line =~ /\r$/);
       
   194             if($line =~ /^\#/) {
       
   195                 if($line =~ /\\$/) {
       
   196                     while($line = <F>) {
       
   197                         chomp $line;
       
   198                         last unless($line =~ /\\$/);
       
   199                     }
       
   200                 }
       
   201 		return @ret if($line =~ m/^#pragma qt_sync_stop_processing/);
       
   202                 push(@ret, "$1") if($line =~ m/^#pragma qt_class\(([^)]*)\)[\r\n]*$/);
       
   203 		$line = 0;
       
   204             }
       
   205 	    if($line) {
       
   206                 $line =~ s,//.*$,,; #remove c++ comments
       
   207 	        $line .= ";" if($line =~ m/^Q_[A-Z_]*\(.*\)[\r\n]*$/); #qt macro
       
   208 	        $line .= ";" if($line =~ m/^QT_(BEGIN|END)_HEADER[\r\n]*$/); #qt macro
       
   209 	        $line .= ";" if($line =~ m/^QT_(BEGIN|END)_NAMESPACE[\r\n]*$/); #qt macro
       
   210 	        $line .= ";" if($line =~ m/^QT_MODULE\(.*\)[\r\n]*$/); # QT_MODULE macro
       
   211                 $parsable .= " " . $line;
       
   212 	    }
       
   213         }
       
   214         close(F);
       
   215     }
       
   216 
       
   217     my $last_definition = 0;
       
   218     my @namespaces;
       
   219     for(my $i = 0; $i < length($parsable); $i++) {
       
   220         my $definition = 0;
       
   221         my $character = substr($parsable, $i, 1);
       
   222         if($character eq "/" && substr($parsable, $i+1, 1) eq "*") { #I parse like this for greedy reasons
       
   223             for($i+=2; $i < length($parsable); $i++) {
       
   224                 my $end = substr($parsable, $i, 2);
       
   225                 if($end eq "*/") {
       
   226                     $last_definition = $i+2;
       
   227                     $i++;
       
   228                     last;
       
   229                 }
       
   230             }
       
   231         } elsif($character eq "{") {
       
   232             my $brace_depth = 1;
       
   233             my $block_start = $i + 1;
       
   234           BLOCK: for($i+=1; $i < length($parsable); $i++) {
       
   235               my $ignore = substr($parsable, $i, 1);
       
   236               if($ignore eq "{") {
       
   237                   $brace_depth++;
       
   238               } elsif($ignore eq "}") {
       
   239                   $brace_depth--;
       
   240                   unless($brace_depth) {
       
   241                       for(my $i2 = $i+1; $i2 < length($parsable); $i2++) {
       
   242                           my $end = substr($parsable, $i2, 1);
       
   243                           if($end eq ";" || $end ne " ") {
       
   244                               $definition = substr($parsable, $last_definition, $block_start - $last_definition) . "}";
       
   245                               $i = $i2 if($end eq ";");
       
   246                               $last_definition = $i + 1;
       
   247                               last BLOCK;
       
   248 			  }
       
   249                       }
       
   250                   }
       
   251               }
       
   252           }
       
   253         } elsif($character eq ";") {
       
   254             $definition = substr($parsable, $last_definition, $i - $last_definition + 1);
       
   255             $last_definition = $i + 1;
       
   256 	} elsif($character eq "}") {
       
   257 	    # a naked } must be a namespace ending
       
   258 	    # if it's not a namespace, it's eaten by the loop above
       
   259 	    pop @namespaces;
       
   260 	    $last_definition = $i + 1;
       
   261 	}
       
   262 
       
   263 	if (substr($parsable, $last_definition, $i - $last_definition + 1) =~ m/ namespace ([^ ]*) /
       
   264 	    && substr($parsable, $i+1, 1) eq "{") {
       
   265 	    push @namespaces, $1;
       
   266 
       
   267 	    # Eat the opening { so that the condensing loop above doesn't see it
       
   268 	    $i++;
       
   269 	    $last_definition = $i + 1;
       
   270 	}
       
   271 
       
   272         if($definition) {
       
   273 	    $definition =~ s=[\n\r]==g;
       
   274             my @symbols;
       
   275             if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) {
       
   276 		push @symbols, $1;
       
   277             } elsif($definition =~ m/^ *typedef +(.*) +([^ ]*);$/) {
       
   278 		push @symbols, $2;
       
   279             } elsif($definition =~ m/^ *(template *<.*> *)?(class|struct) +([^ ]* +)?([^<\s]+) ?(<[^>]*> ?)?\s*((,|:)\s*(public|protected|private) *.*)? *\{\}$/) {
       
   280 		push @symbols, $4;
       
   281             } elsif($definition =~ m/^ *Q_DECLARE_.*ITERATOR\((.*)\);$/) {
       
   282 		push @symbols, "Q" . $1 . "Iterator";
       
   283 		push @symbols, "QMutable" . $1 . "Iterator";
       
   284 	    }
       
   285 
       
   286 	    foreach (@symbols) {
       
   287 		my $symbol = $_;
       
   288 		$symbol = (join("::", @namespaces) . "::" . $symbol) if (scalar @namespaces);
       
   289 		push @ret, $symbol
       
   290 		    if ($symbol =~ /^Q[^:]*$/		# no-namespace, starting with Q
       
   291 			|| $symbol =~ /^Phonon::/);	# or in the Phonon namespace
       
   292             }
       
   293         }
       
   294     }
       
   295     return @ret;
       
   296 }
       
   297 
       
   298 ######################################################################
       
   299 # Syntax:  syncHeader(header, iheader, copy)
       
   300 # Params:  header, string, filename to create "symlink" for
       
   301 #          iheader, string, destination name of symlink
       
   302 #          copy, forces header to be a copy of iheader
       
   303 #
       
   304 # Purpose: Syncronizes header to iheader
       
   305 # Returns: 1 if successful, else 0.
       
   306 ######################################################################
       
   307 sub syncHeader {
       
   308     my ($header, $iheader, $copy) = @_;
       
   309     $iheader =~ s=\\=/=g;
       
   310     $header =~ s=\\=/=g;
       
   311     return copyFile($iheader, $header) if($copy);
       
   312 
       
   313     unless(-e "$header") {
       
   314         my $header_dir = dirname($header);
       
   315         mkpath $header_dir, 0777;
       
   316 
       
   317         #write it
       
   318         my $iheader_out = fixPaths($iheader, $header_dir);
       
   319         open HEADER, ">$header" || die "Could not open $header for writing!\n";
       
   320         print HEADER "#include \"$iheader_out\"\n";
       
   321         close HEADER;
       
   322         return 1;
       
   323     }
       
   324     return 0;
       
   325 }
       
   326 
       
   327 ######################################################################
       
   328 # Syntax:  fixPaths(file, dir)
       
   329 # Params:  file, string, filepath to be made relative to dir
       
   330 #          dir, string, dirpath for point of origin
       
   331 #
       
   332 # Purpose: file is made relative (if possible) of dir.
       
   333 # Returns: String with the above applied conversion.
       
   334 ######################################################################
       
   335 sub fixPaths {
       
   336     my ($file, $dir) = @_;
       
   337     $dir =~ s=^$basedir/=$out_basedir/= if(!($basedir eq $out_basedir));
       
   338     $file =~ s=\\=/=g;
       
   339     $file =~ s/\+/\\+/g;
       
   340     $dir =~ s=\\=/=g;
       
   341     $dir =~ s/\+/\\+/g;
       
   342 
       
   343     #setup
       
   344     my $ret = $file;
       
   345     my $file_dir = dirname($file);
       
   346     if($file_dir eq ".") {
       
   347         $file_dir = getcwd();
       
   348         $file_dir =~ s=\\=/=g;
       
   349     }
       
   350     $file_dir =~ s,/cygdrive/([a-zA-Z])/,$1:,g;
       
   351     if($dir eq ".") {
       
   352         $dir = getcwd();
       
   353         $dir =~ s=\\=/=g;
       
   354     }
       
   355     $dir =~ s,/cygdrive/([a-zA-Z])/,$1:/,g;
       
   356     return basename($file) if("$file_dir" eq "$dir");
       
   357 
       
   358     #guts
       
   359     my $match_dir = 0;
       
   360     for(my $i = 1; $i < length($file_dir); $i++) {
       
   361         my $slash = index($file_dir, "/", $i);
       
   362         last if($slash == -1);
       
   363         my $tmp = substr($file_dir, 0, $slash);
       
   364         last unless($dir =~ m,^$tmp/,);
       
   365         $match_dir = $tmp;
       
   366         $i = $slash;
       
   367     }
       
   368     if($match_dir) {
       
   369         my $after = substr($dir, length($match_dir));
       
   370         my $count = ($after =~ tr,/,,);
       
   371         my $dots = "";
       
   372         for(my $i = 0; $i < $count; $i++) {
       
   373             $dots .= "../";
       
   374         }
       
   375         $ret =~ s,^$match_dir,$dots,;
       
   376     }
       
   377     $ret =~ s,/+,/,g;
       
   378     return $ret;
       
   379 }
       
   380 
       
   381 ######################################################################
       
   382 # Syntax:  fileContents(filename)
       
   383 # Params:  filename, string, filename of file to return contents
       
   384 #
       
   385 # Purpose: Get the contents of a file.
       
   386 # Returns: String with contents of the file, or empty string if file
       
   387 #          doens't exist.
       
   388 # Warning: Dies if it does exist but script cannot get read access.
       
   389 ######################################################################
       
   390 sub fileContents {
       
   391     my ($filename) = @_;
       
   392     my $filecontents = "";
       
   393     if (-e $filename) {
       
   394         open(I, "< $filename") || die "Could not open $filename for reading, read block?";
       
   395         local $/;
       
   396         binmode I;
       
   397         $filecontents = <I>;
       
   398         close I;
       
   399     }
       
   400     return $filecontents;
       
   401 }
       
   402 
       
   403 ######################################################################
       
   404 # Syntax:  fileCompare(file1, file2)
       
   405 # Params:  file1, string, filename of first file
       
   406 #          file2, string, filename of second file
       
   407 #
       
   408 # Purpose: Determines if files are equal, and which one is newer.
       
   409 # Returns: 0 if files are equal no matter the timestamp, -1 if file1
       
   410 #          is newer, 1 if file2 is newer.
       
   411 ######################################################################
       
   412 sub fileCompare {
       
   413     my ($file1, $file2) = @_;
       
   414     my $file1contents = fileContents($file1);
       
   415     my $file2contents = fileContents($file2);
       
   416     if (! -e $file1) { return 1; }
       
   417     if (! -e $file2) { return -1; }
       
   418     return $file1contents ne $file2contents ? (stat("$file2"))[9] <=> (stat("$file1"))[9] : 0;
       
   419 }
       
   420 
       
   421 ######################################################################
       
   422 # Syntax:  copyFile(file, ifile)
       
   423 # Params:  file, string, filename to create duplicate for
       
   424 #          ifile, string, destination name of duplicate
       
   425 #
       
   426 # Purpose: Keeps files in sync so changes in the newer file will be
       
   427 #          written to the other.
       
   428 # Returns: 1 if files were synced, else 0.
       
   429 # Warning: Dies if script cannot get write access.
       
   430 ######################################################################
       
   431 sub copyFile
       
   432 {
       
   433     my ($file,$ifile, $copy,$knowdiff,$filecontents,$ifilecontents) = @_;
       
   434     # Bi-directional synchronization
       
   435     open( I, "< " . $file ) || die "Could not open $file for reading";
       
   436     local $/;
       
   437     binmode I;
       
   438     $filecontents = <I>;
       
   439     close I;
       
   440     if ( open(I, "< " . $ifile) ) {
       
   441 	local $/;
       
   442 	binmode I;
       
   443 	$ifilecontents = <I>;
       
   444 	close I;
       
   445 	$copy = fileCompare($file, $ifile);
       
   446 	$knowdiff = 0,
       
   447     } else {
       
   448 	$copy = -1;
       
   449 	$knowdiff = 1;
       
   450     }
       
   451 
       
   452     if ( $knowdiff || ($filecontents ne $ifilecontents) ) {
       
   453 	if ( $copy > 0 ) {
       
   454 	    my $file_dir = dirname($file);
       
   455 	    mkpath $file_dir, 0777 unless(-e "$file_dir");
       
   456 	    open(O, "> " . $file) || die "Could not open $file for writing (no write permission?)";
       
   457 	    local $/;
       
   458 	    binmode O;
       
   459 	    print O $ifilecontents;
       
   460 	    close O;
       
   461 	    return 1;
       
   462 	} elsif ( $copy < 0 ) {
       
   463 	    my $ifile_dir = dirname($ifile);
       
   464 	    mkpath $ifile_dir, 0777 unless(-e "$ifile_dir");
       
   465 	    open(O, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)";
       
   466 	    local $/;
       
   467 	    binmode O;
       
   468 	    print O $filecontents;
       
   469 	    close O;
       
   470 	    return 1;
       
   471 	}
       
   472     }
       
   473     return 0;
       
   474 }
       
   475 
       
   476 ######################################################################
       
   477 # Syntax:  symlinkFile(file, ifile)
       
   478 # Params:  file, string, filename to create "symlink" for
       
   479 #          ifile, string, destination name of symlink
       
   480 #
       
   481 # Purpose: File is symlinked to ifile (or copied if filesystem doesn't
       
   482 #          support symlink).
       
   483 # Returns: 1 on success, else 0.
       
   484 ######################################################################
       
   485 sub symlinkFile
       
   486 {
       
   487     my ($file,$ifile) = @_;
       
   488 
       
   489     if ($isunix) {
       
   490         print "symlink created for $file ";
       
   491         if ( $force_relative && ($ifile =~ /^$basedir/)) {
       
   492             my $t = getcwd();
       
   493             my $c = -1;
       
   494             my $p = "../";
       
   495             $t =~ s-^$basedir/--;
       
   496             $p .= "../" while( ($c = index( $t, "/", $c + 1)) != -1 );
       
   497             $file =~ s-^$basedir/-$p-;
       
   498             print " ($file)\n";
       
   499         }
       
   500         print "\n";
       
   501         return symlink($file, $ifile);
       
   502     }
       
   503     return copyFile($file, $ifile);
       
   504 }
       
   505 
       
   506 ######################################################################
       
   507 # Syntax:  findFiles(dir, match, descend)
       
   508 # Params:  dir, string, directory to search for name
       
   509 #          match, string, regular expression to match in dir
       
   510 #          descend, integer, 0 = non-recursive search
       
   511 #                            1 = recurse search into subdirectories
       
   512 #
       
   513 # Purpose: Finds files matching a regular expression.
       
   514 # Returns: List of matching files.
       
   515 #
       
   516 # Examples:
       
   517 #   findFiles("/usr","\.cpp$",1)  - finds .cpp files in /usr and below
       
   518 #   findFiles("/tmp","^#",0)      - finds #* files in /tmp
       
   519 ######################################################################
       
   520 sub findFiles {
       
   521     my ($dir,$match,$descend) = @_;
       
   522     my ($file,$p,@files);
       
   523     local(*D);
       
   524     $dir =~ s=\\=/=g;
       
   525     ($dir eq "") && ($dir = ".");
       
   526     if ( opendir(D,$dir) ) {
       
   527         if ( $dir eq "." ) {
       
   528             $dir = "";
       
   529         } else {
       
   530             ($dir =~ /\/$/) || ($dir .= "/");
       
   531         }
       
   532         foreach $file ( sort readdir(D) ) {
       
   533             next if ( $file  =~ /^\.\.?$/ );
       
   534             $p = $file;
       
   535             ($file =~ /$match/) && (push @files, $p);
       
   536             if ( $descend && -d $p && ! -l $p ) {
       
   537                 push @files, &findFiles($p,$match,$descend);
       
   538             }
       
   539         }
       
   540         closedir(D);
       
   541     }
       
   542     return @files;
       
   543 }
       
   544 
       
   545 # --------------------------------------------------------------------
       
   546 # "main" function
       
   547 # --------------------------------------------------------------------
       
   548 
       
   549 while ( @ARGV ) {
       
   550     my $var = 0;
       
   551     my $val = 0;
       
   552 
       
   553     #parse
       
   554     my $arg = shift @ARGV;
       
   555     if ("$arg" eq "-h" || "$arg" eq "-help" || "$arg" eq "?") {
       
   556 	$var = "show_help";
       
   557 	$val = "yes";
       
   558     } elsif("$arg" eq "-copy") {
       
   559 	$var = "copy";
       
   560 	$val = "yes";
       
   561     } elsif("$arg" eq "-o" || "$arg" eq "-outdir") {
       
   562 	$var = "output";
       
   563 	$val = shift @ARGV;
       
   564     } elsif("$arg" eq "-showonly" || "$arg" eq "-remove-stale" || "$arg" eq "-windows" ||
       
   565 	    "$arg" eq "-relative" || "$arg" eq "-check-includes") {
       
   566 	$var = substr($arg, 1);
       
   567 	$val = "yes";
       
   568     } elsif("$arg" =~ /^-no-(.*)$/) {
       
   569 	$var = $1;
       
   570 	$val = "no";
       
   571 	#these are for commandline compat
       
   572     } elsif("$arg" eq "-inc") {
       
   573 	$var = "output";
       
   574 	$val = shift @ARGV;
       
   575     } elsif("$arg" eq "-module") {
       
   576 	$var = "module";
       
   577 	$val = shift @ARGV;
       
   578     } elsif("$arg" eq "-show") {
       
   579 	$var = "showonly";
       
   580 	$val = "yes";
       
   581     } elsif("$arg" eq '*') {
       
   582         # workaround for windows 9x where "%*" expands to "*"
       
   583         $var = 1;
       
   584     }
       
   585 
       
   586     #do something
       
   587     if(!$var || "$var" eq "show_help") {
       
   588 	print "Unknown option: $arg\n\n" if(!$var);
       
   589 	showUsage();
       
   590     } elsif ("$var" eq "copy") {
       
   591 	if("$val" eq "yes") {
       
   592 	    $copy_headers++;
       
   593 	} elsif($showonly) {
       
   594 	    $copy_headers--;
       
   595 	}
       
   596     } elsif ("$var" eq "showonly") {
       
   597 	if("$val" eq "yes") {
       
   598 	    $showonly++;
       
   599 	} elsif($showonly) {
       
   600 	    $showonly--;
       
   601 	}
       
   602     } elsif ("$var" eq "check-includes") {
       
   603 	if("$val" eq "yes") {
       
   604 	    $check_includes++;
       
   605 	} elsif($check_includes) {
       
   606 	    $check_includes--;
       
   607 	}
       
   608     } elsif ("$var" eq "remove-stale") {
       
   609 	if("$val" eq "yes") {
       
   610 	    $remove_stale++;
       
   611 	} elsif($remove_stale) {
       
   612 	    $remove_stale--;
       
   613 	}
       
   614     } elsif ("$var" eq "windows") {
       
   615 	if("$val" eq "yes") {
       
   616 	    $force_win++;
       
   617 	} elsif($force_win) {
       
   618 	    $force_win--;
       
   619 	}
       
   620     } elsif ("$var" eq "relative") {
       
   621 	if("$val" eq "yes") {
       
   622 	    $force_relative++;
       
   623 	} elsif($force_relative) {
       
   624 	    $force_relative--;
       
   625 	}
       
   626     } elsif ("$var" eq "module") {
       
   627 	print "module :$val:\n";
       
   628 	die "No such module: $val" unless(defined $modules{$val});
       
   629 	push @modules_to_sync, $val;
       
   630     } elsif ("$var" eq "output") {
       
   631 	my $outdir = $val;
       
   632 	if(checkRelative($outdir)) {
       
   633 	    $out_basedir = getcwd();
       
   634 	    chomp $out_basedir;
       
   635 	    $out_basedir .= "/" . $outdir;
       
   636 	} else {
       
   637 	    $out_basedir = $outdir;
       
   638 	}
       
   639 	# \ -> /
       
   640 	$out_basedir =~ s=\\=/=g;
       
   641     }
       
   642 }
       
   643 @modules_to_sync = keys(%modules) if($#modules_to_sync == -1);
       
   644 
       
   645 $isunix = checkUnix; #cache checkUnix
       
   646 
       
   647 # create path
       
   648 mkpath "$out_basedir/include", 0777;
       
   649 
       
   650 my @ignore_headers = ();
       
   651 my $class_lib_map_contents = "";
       
   652 my @ignore_for_master_contents = ( "qt.h", "qpaintdevicedefs.h" );
       
   653 my @ignore_for_include_check = ( "qatomic.h" );
       
   654 my @ignore_for_qt_begin_header_check = ( "qiconset.h", "qconfig.h", "qconfig-dist.h", "qconfig-large.h", "qconfig-medium.h", "qconfig-minimal.h", "qconfig-small.h", "qfeatures.h", "qt_windows.h" );
       
   655 my @ignore_for_qt_begin_namespace_check = ( "qconfig.h", "qconfig-dist.h", "qconfig-large.h", "qconfig-medium.h", "qconfig-minimal.h", "qconfig-small.h", "qfeatures.h", "qatomic_arch.h", "qatomic_windowsce.h", "qt_windows.h", "qatomic_macosx.h" );
       
   656 my @ignore_for_qt_module_check = ( "$modules{QtCore}/arch", "$modules{QtCore}/global", "$modules{QtSql}/drivers", "$modules{QtTest}", "$modules{QtAssistant}", "$modules{QtDesigner}", "$modules{QtUiTools}", "$modules{QtDBus}", "$modules{phonon}" );
       
   657 
       
   658 foreach (@modules_to_sync) {
       
   659     #iteration info
       
   660     my $lib = $_;
       
   661     my $dir = "$modules{$lib}";
       
   662     my $pathtoheaders = "";
       
   663     $pathtoheaders = "$moduleheaders{$lib}" if ($moduleheaders{$lib});
       
   664 
       
   665     #information used after the syncing
       
   666     my $pri_install_classes = "";
       
   667     my $pri_install_files = "";
       
   668 
       
   669     my $libcapitals = $lib;
       
   670     $libcapitals =~ y/a-z/A-Z/;
       
   671     my $master_contents = "#ifndef QT_".$libcapitals."_MODULE_H\n#define QT_".$libcapitals."_MODULE_H\n";
       
   672 
       
   673     #get dependencies
       
   674     if(-e "$dir/" . basename($dir) . ".pro") {
       
   675 	if(open(F, "<$dir/" . basename($dir) . ".pro")) {
       
   676 	    while(<F>) {
       
   677 		my $line = $_;
       
   678 		chomp $line;
       
   679 		if($line =~ /^ *QT *\+?= *([^\r\n]*)/) {
       
   680 		    foreach(split(/ /, "$1")) {
       
   681 			$master_contents .= "#include <QtCore/QtCore>\n" if("$_" eq "core");
       
   682 			$master_contents .= "#include <QtGui/QtGui>\n" if("$_" eq "gui");
       
   683 			$master_contents .= "#include <QtNetwork/QtNetwork>\n" if("$_" eq "network");
       
   684 			$master_contents .= "#include <QtSvg/QtSvg>\n" if("$_" eq "svg");
       
   685 			$master_contents .= "#include <QtScript/QtScript>\n" if("$_" eq "script");
       
   686 			$master_contents .= "#include <QtScriptTools/QtScriptTools>\n" if("$_" eq "scripttools");
       
   687 			$master_contents .= "#include <Qt3Support/Qt3Support>\n" if("$_" eq "qt3support");
       
   688 			$master_contents .= "#include <QtSql/QtSql>\n" if("$_" eq "sql");
       
   689 			$master_contents .= "#include <QtXml/QtXml>\n" if("$_" eq "xml");
       
   690 			$master_contents .= "#include <QtXmlPatterns/QtXmlPatterns>\n" if("$_" eq "xmlpatterns");
       
   691 			$master_contents .= "#include <QtOpenGL/QtOpenGL>\n" if("$_" eq "opengl");
       
   692 			$master_contents .= "#include <QtOpenVG/QtOpenVG>\n" if("$_" eq "openvg");
       
   693 		    }
       
   694 		}
       
   695 	    }
       
   696 	    close(F);
       
   697 	}
       
   698     }
       
   699 
       
   700     #remove the old files
       
   701     if($remove_stale) {
       
   702 	my @subdirs = ("$out_basedir/include/$lib");
       
   703 	foreach (@subdirs) {
       
   704 	    my $subdir = "$_";
       
   705 	    if (opendir DIR, "$subdir") {
       
   706 		while(my $t = readdir(DIR)) {
       
   707 		    my $file = "$subdir/$t";
       
   708 		    if(-d "$file") {
       
   709 			push @subdirs, "$file" unless($t eq "." || $t eq "..");
       
   710 		    } else {
       
   711 			my @files = ("$file");
       
   712 			#push @files, "$out_basedir/include/Qt/$t" if(-e "$out_basedir/include/Qt/$t");
       
   713 			foreach (@files) {
       
   714 			   my $file = $_;
       
   715 			   my $remove_file = 0;
       
   716 			   if(open(F, "<$file")) {
       
   717 				while(<F>) {
       
   718 				    my $line = $_;
       
   719 				    chomp $line;
       
   720 				    if($line =~ /^\#include \"([^\"]*)\"$/) {
       
   721 					my $include = $1;
       
   722 					$include = $subdir . "/" . $include unless(substr($include, 0, 1) eq "/");
       
   723 					$remove_file = 1 unless(-e "$include");
       
   724 				    } else {
       
   725 					$remove_file = 0;
       
   726 					last;
       
   727 				    }
       
   728 				}
       
   729 				close(F);
       
   730 				unlink "$file" if($remove_file);
       
   731 			    }
       
   732 			}
       
   733 		    }
       
   734 		}
       
   735 		closedir DIR;
       
   736             }
       
   737 
       
   738 	}
       
   739     }
       
   740 
       
   741     #create the new ones
       
   742     foreach (split(/;/, $dir)) {
       
   743 	my $current_dir = "$_";
       
   744 	my $headers_dir = $current_dir;
       
   745         $headers_dir .= "/$pathtoheaders" if ($pathtoheaders);
       
   746         #calc subdirs
       
   747         my @subdirs = ($headers_dir);
       
   748         foreach (@subdirs) {
       
   749             my $subdir = "$_";
       
   750             opendir DIR, "$subdir" or next;
       
   751             while(my $t = readdir(DIR)) {
       
   752                 push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") &&
       
   753 					       !($t eq "..") && !($t eq ".obj") &&
       
   754                                                !($t eq ".moc") && !($t eq ".rcc") &&
       
   755                                                !($t eq ".uic") && !($t eq "build"));
       
   756             }
       
   757             closedir DIR;
       
   758         }
       
   759 
       
   760         #calc files and "copy" them
       
   761         foreach (@subdirs) {
       
   762             my $subdir = "$_";
       
   763             my @headers = findFiles("$subdir", "^[-a-z0-9_]*\\.h\$" , 0);
       
   764             foreach (@headers) {
       
   765                 my $header = "$_";
       
   766                 $header = 0 if("$header" =~ /^ui_.*.h/);
       
   767                 foreach (@ignore_headers) {
       
   768                     $header = 0 if("$header" eq "$_");
       
   769                 }
       
   770                 if($header) {
       
   771 		    my $header_copies = 0;
       
   772 		    #figure out if it is a public header
       
   773 		    my $public_header = $header;
       
   774 		    if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) {
       
   775 			$public_header = 0;
       
   776 		    } else {
       
   777 			foreach (@ignore_for_master_contents) {
       
   778 			    $public_header = 0 if("$header" eq "$_");
       
   779 			}
       
   780 		    }
       
   781 
       
   782                     my $iheader = $subdir . "/" . $header;
       
   783 		    my @classes = $public_header ? classNames($iheader) : ();
       
   784                     if($showonly) {
       
   785                         print "$header [$lib]\n";
       
   786 			foreach(@classes) {
       
   787 			    print "SYMBOL: $_\n";
       
   788 			}
       
   789                     } else {
       
   790 			#find out all the places it goes..
       
   791 			my @headers;
       
   792 			if ($public_header) {
       
   793 			    @headers = ( "$out_basedir/include/$lib/$header" );
       
   794 			    push @headers, "$out_basedir/include/Qt/$header"
       
   795 			      if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src/);
       
   796 
       
   797 			    foreach(@classes) {
       
   798 				my $header_base = basename($header);
       
   799 				my $class = $_;
       
   800 				if ($class =~ m/::/) {
       
   801 				    $class =~ s,::,/,g;
       
   802 				}
       
   803 				$class_lib_map_contents .= "QT_CLASS_LIB($_, $lib, $header_base)\n";
       
   804 				$header_copies++ if(syncHeader("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0));
       
   805 			    }
       
   806 			} else {
       
   807 			    @headers = ( "$out_basedir/include/$lib/private/$header" );
       
   808 			    push @headers, "$out_basedir/include/Qt/private/$header"
       
   809                               if ("$lib" ne "phonon");
       
   810 			}
       
   811 			foreach(@headers) { #sync them
       
   812 			    $header_copies++ if(syncHeader($_, $iheader, $copy_headers));
       
   813 			}
       
   814 
       
   815 			if($public_header) {
       
   816 			    #put it into the master file
       
   817 			    $master_contents .= "#include \"$public_header\"\n" if(shouldMasterInclude($iheader));
       
   818 
       
   819 			    #deal with the install directives
       
   820 			    if($public_header) {
       
   821 				my $pri_install_iheader = fixPaths($iheader, $current_dir);
       
   822 				foreach(@classes) {
       
   823 				    my $class = $_;
       
   824 				    if ($class =~ m/::/) {
       
   825 					$class =~ s,::,/,g;
       
   826 				    }
       
   827 				    my $class_header = fixPaths("$out_basedir/include/$lib/$class",
       
   828 								$current_dir) . " ";
       
   829 				    $pri_install_classes .= $class_header
       
   830 								unless($pri_install_classes =~ $class_header);
       
   831 				}
       
   832 				$pri_install_files.= "$pri_install_iheader ";;
       
   833 			    }
       
   834 			}
       
   835                     }
       
   836 		    print "header created for $iheader ($header_copies)\n" if($header_copies > 0);
       
   837                 }
       
   838             }
       
   839         }
       
   840     }
       
   841 
       
   842     # close the master include:
       
   843     $master_contents .= "#endif\n";
       
   844 
       
   845     unless($showonly) {
       
   846         my @master_includes;
       
   847         if ($lib eq "phonon") {
       
   848             push @master_includes, "$out_basedir/include/phonon_compat/phonon/phonon";
       
   849             push @master_includes, "$out_basedir/include/phonon/Phonon/Phonon";
       
   850         } else {
       
   851             push @master_includes, "$out_basedir/include/$lib/$lib";
       
   852         }
       
   853         foreach my $master_include (@master_includes) {
       
   854             #generate the "master" include file
       
   855             $pri_install_files .= fixPaths($master_include, "$modules{$lib}") . " "; #get the master file installed too
       
   856             if($master_include && -e "$master_include") {
       
   857                 open MASTERINCLUDE, "<$master_include";
       
   858                 local $/;
       
   859                 binmode MASTERINCLUDE;
       
   860                 my $oldmaster = <MASTERINCLUDE>;
       
   861                 close MASTERINCLUDE;
       
   862                 $oldmaster =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
       
   863                 $master_include = 0 if($oldmaster eq $master_contents);
       
   864             }
       
   865             if($master_include && $master_contents) {
       
   866                 my $master_dir = dirname($master_include);
       
   867                 mkpath $master_dir, 0777;
       
   868                 print "header (master) created for $lib\n";
       
   869                 open MASTERINCLUDE, ">$master_include";
       
   870                 print MASTERINCLUDE "$master_contents";
       
   871                 close MASTERINCLUDE;
       
   872             }
       
   873         }
       
   874 
       
   875         #handle the headers.pri for each module
       
   876 	my $headers_pri_contents = "";
       
   877 	$headers_pri_contents .= "SYNCQT.HEADER_FILES = $pri_install_files\n";
       
   878 	$headers_pri_contents .= "SYNCQT.HEADER_CLASSES = $pri_install_classes\n";
       
   879         my $headers_pri_file = "$out_basedir/include/$lib/headers.pri";
       
   880         if(-e "$headers_pri_file") {
       
   881             open HEADERS_PRI_FILE, "<$headers_pri_file";
       
   882             local $/;
       
   883             binmode HEADERS_PRI_FILE;
       
   884             my $old_headers_pri_contents = <HEADERS_PRI_FILE>;
       
   885             close HEADERS_PRI_FILE;
       
   886             $old_headers_pri_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
       
   887             $headers_pri_file = 0 if($old_headers_pri_contents eq $headers_pri_contents);
       
   888         }
       
   889         if($headers_pri_file && $master_contents) {
       
   890             my $headers_pri_dir = dirname($headers_pri_file);
       
   891             mkpath $headers_pri_dir, 0777;
       
   892             print "headers.pri file created for $lib\n";
       
   893             open HEADERS_PRI_FILE, ">$headers_pri_file";
       
   894             print HEADERS_PRI_FILE "$headers_pri_contents";
       
   895             close HEADERS_PRI_FILE;
       
   896         }
       
   897     }
       
   898 }
       
   899 unless($showonly) {
       
   900     my $class_lib_map = "$out_basedir/src/tools/uic/qclass_lib_map.h";
       
   901     if(-e "$class_lib_map") {
       
   902 	open CLASS_LIB_MAP, "<$class_lib_map";
       
   903 	local $/;
       
   904 	binmode CLASS_LIB_MAP;
       
   905 	my $old_class_lib_map_contents = <CLASS_LIB_MAP>;
       
   906 	close CLASS_LIB_MAP;
       
   907 	$old_class_lib_map_contents =~ s/\r//g; # remove \r's , so comparison is ok on all platforms
       
   908 	$class_lib_map = 0 if($old_class_lib_map_contents eq $class_lib_map_contents);
       
   909     }
       
   910     if($class_lib_map) {
       
   911 	my $class_lib_map_dir = dirname($class_lib_map);
       
   912 	mkpath $class_lib_map_dir, 0777;
       
   913 	open CLASS_LIB_MAP, ">$class_lib_map";
       
   914 	print CLASS_LIB_MAP "$class_lib_map_contents";
       
   915 	close CLASS_LIB_MAP;
       
   916     }
       
   917 }
       
   918 
       
   919 if($check_includes) {
       
   920     for (keys(%modules)) {
       
   921 	#iteration info
       
   922 	my $lib = $_;
       
   923 	my $dir = "$modules{$lib}";
       
   924 	foreach (split(/;/, $dir)) {
       
   925 	    my $current_dir = "$_";
       
   926 	    #calc subdirs
       
   927 	    my @subdirs = ($current_dir);
       
   928 	    foreach (@subdirs) {
       
   929 		my $subdir = "$_";
       
   930 		opendir DIR, "$subdir";
       
   931 		while(my $t = readdir(DIR)) {
       
   932                     push @subdirs, "$subdir/$t" if(-d "$subdir/$t" && !($t eq ".") &&
       
   933                                                    !($t eq "..") && !($t eq ".obj") &&
       
   934                                                    !($t eq ".moc") && !($t eq ".rcc") &&
       
   935                                                    !($t eq ".uic") && !($t eq "build"));
       
   936 		}
       
   937 		closedir DIR;
       
   938 	    }
       
   939 
       
   940 	    foreach (@subdirs) {
       
   941 		my $subdir = "$_";
       
   942                 my $header_skip_qt_module_test = 0;
       
   943                 foreach(@ignore_for_qt_module_check) {
       
   944                     foreach (split(/;/, $_)) {
       
   945                         $header_skip_qt_module_test = 1 if ("$subdir" =~ /^$_/);
       
   946                     }
       
   947                 }
       
   948 		my @headers = findFiles("$subdir", "^[-a-z0-9_]*\\.h\$" , 0);
       
   949 		foreach (@headers) {
       
   950 		    my $header = "$_";
       
   951                     my $header_skip_qt_begin_header_test = 0;
       
   952                     my $header_skip_qt_begin_namespace_test = 0;
       
   953 		    $header = 0 if("$header" =~ /^ui_.*.h/);
       
   954 		    foreach (@ignore_headers) {
       
   955 			$header = 0 if("$header" eq "$_");
       
   956 		    }
       
   957 		    if($header) {
       
   958 			my $public_header = $header;
       
   959 			if($public_header =~ /_p.h$/ || $public_header =~ /_pch.h$/) {
       
   960 			    $public_header = 0;
       
   961 			} else {
       
   962 			    foreach (@ignore_for_master_contents) {
       
   963 				$public_header = 0 if("$header" eq "$_");
       
   964 			    }
       
   965 			    if($public_header) {
       
   966 				foreach (@ignore_for_include_check) {
       
   967 				    $public_header = 0 if("$header" eq "$_");
       
   968 				}
       
   969                                 foreach(@ignore_for_qt_begin_header_check) {
       
   970                                     $header_skip_qt_begin_header_test = 1 if ("$header" eq "$_");
       
   971                                 }
       
   972                                 foreach(@ignore_for_qt_begin_namespace_check) {
       
   973                                     $header_skip_qt_begin_namespace_test = 1 if ("$header" eq "$_");
       
   974                                 }
       
   975 			    }
       
   976 			}
       
   977 
       
   978 			my $iheader = $subdir . "/" . $header;
       
   979 			if($public_header) {
       
   980 			    if(open(F, "<$iheader")) {
       
   981                                 my $qt_module_found = 0;
       
   982 				my $qt_begin_header_found = 0;
       
   983 				my $qt_end_header_found = 0;
       
   984 				my $qt_begin_namespace_found = 0;
       
   985 				my $qt_end_namespace_found = 0;
       
   986 				my $line;
       
   987 				while($line = <F>) {
       
   988 				    chomp $line;
       
   989 				    my $output_line = 1;
       
   990                                     if($line =~ /^ *\# *pragma (qt_no_included_check|qt_sync_stop_processing)/) {
       
   991 			                last;
       
   992 				    } elsif($line =~ /^ *\# *include/) {
       
   993 					my $include = $line;
       
   994 					if($line =~ /<.*>/) {
       
   995 					    $include =~ s,.*<(.*)>.*,$1,;
       
   996 					} elsif($line =~ /".*"/) {
       
   997 					    $include =~ s,.*"(.*)".*,$1,;
       
   998 					} else {
       
   999 					    $include = 0;
       
  1000 					}
       
  1001 					if($include) {
       
  1002 					    for (keys(%modules)) {
       
  1003 						my $trylib = $_;
       
  1004 						if(-e "$out_basedir/include/$trylib/$include") {
       
  1005 						    print "WARNING: $iheader includes $include when it should include $trylib/$include\n";
       
  1006 						}
       
  1007 					    }
       
  1008 					}
       
  1009 				    } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_BEGIN_HEADER\s*$/) {
       
  1010 					$qt_begin_header_found = 1;
       
  1011 				    } elsif ($header_skip_qt_begin_header_test == 0 and $line =~ /^QT_END_HEADER\s*$/) {
       
  1012 					$qt_end_header_found = 1;
       
  1013 				    } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_BEGIN_NAMESPACE\s*$/) {
       
  1014 					$qt_begin_namespace_found = 1;
       
  1015 				    } elsif ($header_skip_qt_begin_namespace_test == 0 and $line =~ /^QT_END_NAMESPACE\s*$/) {
       
  1016 					$qt_end_namespace_found = 1;
       
  1017                                     } elsif ($header_skip_qt_module_test == 0 and $line =~ /^QT_MODULE\(.*\)\s*$/) {
       
  1018                                         $qt_module_found = 1;
       
  1019                                     }
       
  1020 				}
       
  1021                                 if ($header_skip_qt_begin_header_test == 0) {
       
  1022                                     if ($qt_begin_header_found == 0) {
       
  1023                                         print "WARNING: $iheader does not include QT_BEGIN_HEADER\n";
       
  1024                                     }
       
  1025 
       
  1026                                     if ($qt_begin_header_found && $qt_end_header_found == 0) {
       
  1027                                         print "WARNING: $iheader has QT_BEGIN_HEADER but no QT_END_HEADER\n";
       
  1028                                     }
       
  1029                                 }
       
  1030 
       
  1031                                 if ($header_skip_qt_begin_namespace_test == 0) {
       
  1032                                     if ($qt_begin_namespace_found == 0) {
       
  1033                                         print "WARNING: $iheader does not include QT_BEGIN_NAMESPACE\n";
       
  1034                                     }
       
  1035 
       
  1036                                     if ($qt_begin_namespace_found && $qt_end_namespace_found == 0) {
       
  1037                                         print "WARNING: $iheader has QT_BEGIN_NAMESPACE but no QT_END_NAMESPACE\n";
       
  1038                                     }
       
  1039                                 }
       
  1040 
       
  1041                                 if ($header_skip_qt_module_test == 0) {
       
  1042                                     if ($qt_module_found == 0) {
       
  1043                                         print "WARNING: $iheader does not include QT_MODULE\n";
       
  1044                                     }
       
  1045                                 }
       
  1046 				close(F);
       
  1047 			    }
       
  1048 			}
       
  1049 		    }
       
  1050 		}
       
  1051 	    }
       
  1052 	}
       
  1053     }
       
  1054 }
       
  1055 
       
  1056 exit 0;