4 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5 # Use is subject to license terms.
9 # The contents of this file are subject to the terms of the
10 # Common Development and Distribution License (the "License").
11 # You may not use this file except in compliance with the License.
13 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14 # or http://www.opensolaris.org/os/licensing.
15 # See the License for the specific language governing permissions
16 # and limitations under the License.
18 # When distributing Covered Code, include this CDDL HEADER in each
19 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
20 # If applicable, add the following below this CDDL HEADER, with the
21 # fields enclosed by brackets "[]" replaced with your own identifying
22 # information: Portions Copyright [yyyy] [name of copyright owner]
26 #ident "%Z%%M% %I% %E% SMI"
30 # Generate a header for lint output for subdirectories of
31 # usr/src/cmd/sgs, of the form:
33 # lint_hdr [-s] target_file [elfclass]
36 # target - Name of main target (library or program name)
37 # elfclass - If present, 32 or 64, giving the ELFCLASS of
38 # the code being linted.
40 # The resulting header looks like the following:
42 # [elfclass - ]target [sgssubdir]
43 # ----------------------------------------------------
45 # If the elfclass is omitted, then the header does not include
46 # it. If the target matches 'dirname sgssubdir', then sgssubdir
47 # is displayed without the target and without the square brackets.
49 # The -s option specifies that this is a sub-header, used when
50 # multiple lints are done within a single target. If -s is specified,
51 # the sgssubdir is not shown (presumably it was already shown in an earlier
52 # call to link_hdr), and a shorter dashed line is used:
55 # ========================
62 use vars
qw($script $usage $dir $argc $target $elfclass);
66 $usage = "usage: $script target [elfclass]\n";
69 die $usage if (scalar(@ARGV) == 0);
70 while ($_ = $ARGV[0],/^-/) {
77 # If it gets here, it's an unknown option
83 $argc = scalar(@ARGV);
84 die $usage if (($argc < 1) || ($argc > 2));
86 $elfclass = ($argc == 2) ? "Elf$ARGV[1] - " : '';
89 print "\n$elfclass$target\n========================\n";
93 # Clip the path up through ..sgs/, leaving the path from sgs to current dir
95 $dir = "$1" if $dir =~ /\/sgs\/(.*)$/;
97 # Normally, we format the target and directory like this:
99 # However, if this is the special case where $dir is equal to
101 # and prog matches our target name, then just show dir without brackets.
102 if (($dir =~ /^([^\/]+)\/[^\/]+$/) && ($1 eq $target)) {
108 print "\n$elfclass$target$dir\n";
109 print "------------------------------------------------------------\n";