#!/bin/sh -- # This comment tells perl not to loop!
#
#ident		"@(#)chkclassproto.sh 1.2     94/03/09 SMI"
#
#  chkclassproto.sh
#
#	Copyright (c) 1994 by Sun Microsystems, Inc.
eval 'exec /usr/dist/exe/perl -S $0 ${1+"$@"}'
if 0;

#
# Constants/Globals
#
$name = "chkclassproto.sh";
$name =~ s/\.sh$//;

sub usage {
	print STDERR
	  "Usage:  $name -c <chkproto> -p <pkgdir> -a <arch> [-vm]\n";
	exit 1;
}

# Command line arguments.
require "getopts.pl";
&Getopts('c:p:a:vm') || &usage();
$basedir = $opt_c . "/" if ($opt_c ne "");
$pkgdir = $opt_p if ($opt_p ne "");
$arch = "-a" . $opt_a if ($opt_a ne "");
$verbose = $opt_v;
$mod = $opt_m;
&usage() if ($basedir eq "" || $pkgdir eq "" || $arch eq "");

open(CHK, "chkclasses -b. -c. -p$pkgdir $arch -lqv |") || die;
while (<CHK>) {
	if (/^Class:\s+(\w+)$/) {
		$class = $1
	} elsif (/^(\w+)\s+(\S+)$/) {
		$pkg = $1;
		$path = $2;
		$fullpath = $basedir . $path;
		if (! -f $fullpath) {
			if ($verbose) {
				print "Class: $class, pkg: $pkg, $path: $!\n";
			} else {
				print "$path: $!\n";
			}
		}
		next if (!$mod);
		$fullpath .= ".mod";
		if (! -f $fullpath) {
			if ($verbose) {
				print
				  "Class: $class, Pkg: $pkg, $path.mod: $!\n";
			} else {
				print "$path.mod: $!\n";
			}
		}
	}
}
close(CHK);
exit 0;
