blob: 8ff5a40bffee5b194c78079eb1a71e4a0fa5fb21 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301#!/bin/sh
2##############################################################################
micky3879b9f5e72025-07-08 18:04:53 -04003# Copyright 2020,2021 Thomas E. Dickey #
4# Copyright 1998,2000 Free Software Foundation, Inc. #
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05305# #
6# Permission is hereby granted, free of charge, to any person obtaining a #
7# copy of this software and associated documentation files (the "Software"), #
8# to deal in the Software without restriction, including without limitation #
9# the rights to use, copy, modify, merge, publish, distribute, distribute #
10# with modifications, sublicense, and/or sell copies of the Software, and to #
11# permit persons to whom the Software is furnished to do so, subject to the #
12# following conditions: #
13# #
14# The above copyright notice and this permission notice shall be included in #
15# all copies or substantial portions of the Software. #
16# #
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
20# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
23# DEALINGS IN THE SOFTWARE. #
24# #
25# Except as contained in this notice, the name(s) of the above copyright #
26# holders shall not be used in advertising or otherwise to promote the sale, #
27# use or other dealings in this Software without prior written #
28# authorization. #
29##############################################################################
30#
31# Author: Thomas E. Dickey <dickey@clark.net> 1996
32#
micky3879b9f5e72025-07-08 18:04:53 -040033# $Id: tdlint,v 1.8 2021/09/04 15:55:29 tom Exp $
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053034#
35# Lint-script that allows user's own lint libraries, in addition to the ones
36# installed in the system.
37#
38OPT=""
39DIRS=""
40LIBS=""
41FILES=""
42ARCH=`uname -s`
43if test -z "$ARCH" ; then
44 echo '? uname not found'
45 exit 1
46else
47 case $ARCH in
micky3879b9f5e72025-07-08 18:04:53 -040048 AIX) set - "$@" -Nn4000
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053049 ;;
micky3879b9f5e72025-07-08 18:04:53 -040050 IRIX) set - "$@" -n -lc
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053051 ;;
micky3879b9f5e72025-07-08 18:04:53 -040052 FreeBSD) set - "$@" -g -p -u -v -z
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053053 ;;
54 SunOS)
55 case `uname -r` in
56 5.*) ARCH=Solaris
micky3879b9f5e72025-07-08 18:04:53 -040057 set - "$@" -n -lc
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053058 ;;
59 esac
60 ;;
61 esac
62fi
63# LIBDIR=$HOME/lib/$ARCH/lint ;export LIBDIR
64for p in $HOME/lib/$ARCH/lint /usr/lib/lint /usr/lib
65do
micky3879b9f5e72025-07-08 18:04:53 -040066 if [ -d "$p" ]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053067 then
68 DIRS="$DIRS $p"
69 fi
70done
71#
72while [ $# != 0 ]
73do
74 case $1 in
75 -D*\"*) ;;
76 -L*)
micky3879b9f5e72025-07-08 18:04:53 -040077 DIRS="`echo "$1"|sed -e 's/^-L//'` $DIRS"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053078 ;;
79 -l*)
micky3879b9f5e72025-07-08 18:04:53 -040080 lib="llib-l`echo "$1" | sed -e 's/^-l//'`.ln"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053081 found=no
82 for p in $DIRS
83 do
micky3879b9f5e72025-07-08 18:04:53 -040084 printf "testing %s" "$p/$lib"
85 if [ -f "$p/$lib" ]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053086 then
87 LIBS="$LIBS $p/$lib"
88 echo " (ok)"
89 found=yes
90 break
91 fi
92 echo
93 done
94 if [ $found = no ]
95 then
96 echo "ignored library $1"
97 fi
98 ;;
99 -n) if [ -z "$OPT" ]
100 then
101 OPT="-I."
102 fi
103 OPT="$OPT $1"
104 ;;
105 -*) OPT="$OPT $1"
106 ;;
107 *)
108 FILES="$FILES $1"
109 ;;
110 esac
111 shift
112done
113#
micky3879b9f5e72025-07-08 18:04:53 -0400114exec lint $OPT $FILES $LIBS