#!/usr/bin/perl

# PERL version of mk_test_comp
				# Make a file to test compile all the
				# procedures in the hi-scale software
				# (except the etc tree).

require "find.pl";

unlink "test_comp.pro";

# Traverse desired filesystems

&find('.');

open (OUT, ">test_comp.pro");

foreach $r (@list) {
    $proc = 0;
    open (PROC, $r) || warn "Can't open $r: \!\n";
    $r =~ s?.*/([^/\.]+)\..*?$1?; # This rather horrid regex just
				  # trims off the  directory and the
				  # .pro parts of the filename.
  LINE: while (<PROC>) {
      if (/^pro /i || /^function /i) { # Look for a pro or function statement
	  $proc = 1;		       # and set the procedure flag
				       # when found 
	  last LINE;		       # Once it's flagged don't need
				       # to look any more!
      }
  }
    close (PROC);
    print OUT ".compile $r\n" if $proc == 1;
}

exit;

sub wanted {
				# Defines the requirements for the
				# find (originally derived via
				# find2perl)

    (/^etc$/ || /^Common_blocks$/ || /^low_level/ || /^Fortran/ ) &&
    ($prune = 1)
    ||
    /^.*\.pro$/ &&
    ($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) &&
    ($list[++$#list] = $name);
}
