1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# Use is subject to license terms.
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# CDDL HEADER START
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# The contents of this file are subject to the terms of the
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# Common Development and Distribution License (the "License").
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# You may not use this file except in compliance with the License.
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# See the License for the specific language governing permissions
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# and limitations under the License.
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# When distributing Covered Code, include this CDDL HEADER in each
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# If applicable, add the following below this CDDL HEADER, with the
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# fields enclosed by brackets "[]" replaced with your own identifying
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# information: Portions Copyright [yyyy] [name of copyright owner]
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# CDDL HEADER END
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab#ident "%Z%%M% %I% %E% SMI"
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# Generate a header for lint output for subdirectories of
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# lint_hdr [-s] target_file [elfclass]
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# target - Name of main target (library or program name)
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# elfclass - If present, 32 or 64, giving the ELFCLASS of
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# the code being linted.
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# The resulting header looks like the following:
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# [elfclass - ]target [sgssubdir]
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# ----------------------------------------------------
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# If the elfclass is omitted, then the header does not include
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# it. If the target matches 'dirname sgssubdir', then sgssubdir
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# is displayed without the target and without the square brackets.
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# The -s option specifies that this is a sub-header, used when
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# multiple lints are done within a single target. If -s is specified,
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# the sgssubdir is not shown (presumably it was already shown in an earlier
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# call to link_hdr), and a shorter dashed line is used:
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# [elfclass - ]target
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# ========================
1dd08564e4a3aafe66b00aee6f222b0885346fe8abuse warnings;
1dd08564e4a3aafe66b00aee6f222b0885346fe8abuse strict;
1dd08564e4a3aafe66b00aee6f222b0885346fe8abuse vars qw($sub);
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab if (/^-s$/) {
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab # If it gets here, it's an unknown option
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab print "\n$elfclass$target\n========================\n";
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# Clip the path up through ..sgs/, leaving the path from sgs to current dir
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# Normally, we format the target and directory like this:
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# target [dir]
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# However, if this is the special case where $dir is equal to
1dd08564e4a3aafe66b00aee6f222b0885346fe8ab# and prog matches our target name, then just show dir without brackets.
1dd08564e4a3aafe66b00aee6f222b0885346fe8abprint "\n$elfclass$target$dir\n";
1dd08564e4a3aafe66b00aee6f222b0885346fe8abprint "------------------------------------------------------------\n";