#!/usr/local/bin/perl

push(@INC, "$ENV{OMNIMAKE_ROOT}/utilities");
require "arch.perl";

@directories = (".");
$debug = 0;

if ($ENV{OMNIMAKE_INSTALL_ROOT}) {
    $toolsRoot = "$ENV{OMNIMAKE_INSTALL_ROOT}/Tools";
} else {
    $toolsRoot = "$ENV{OMNIMAKE_ROOT}/Tools";
}

$projectInfo = "$toolsRoot/projectInfo" . $executableExtension;

while ($dir = shift(@directories)) {
    $debug && print STDERR "Processing $dir\n";

    opendir(DIR, $dir) || &fatal("Cannot open directory $dir!\n");

    while ($path = readdir(DIR)) {
	$debug && print STDERR "\tFound $dir/$path\n";

	if (($path =~ m/\.infodictionary/) && ($path !~ m/CustomInfo.plist/)) {
	    print " $dir/$path";
        } elsif ($path =~ m/\.subproj/) {
	    push(@directories, "$dir/$path");
        } elsif ($path =~ m/\.bproj/) {
	    $cmd = "$projectInfo PROJECTTYPE -inDirectory $dir/$path";
	    $debug && print STDERR "cmd = $cmd\n";
            $projectType = `$cmd`;
	    $debug && print STDERR "\t\tprojectType    = $projectType\n";
	    $debug && print STDERR "\t\tPB.project dir = $dir/$path\n";
	    if ($projectType =~ "StaticUsecase") {
		push(@directories, "$dir/$path");
	    }
        }
    }
}

print "\n";

