blob: fb3d3b7a92fda0122cafe21718d8625ea764c588 [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 1996,1997,2000
32#
micky3879b9f5e72025-07-08 18:04:53 -040033# $Id: makellib,v 1.11 2021/09/04 15:49:38 tom Exp $
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053034# System-dependent wrapper for 'lint' that creates a lint-library via the
35# following method (XXX is the name of the library):
36# a. If the file llib-lXXX doesn't exist, create it using the make-rule
37# b. Process llib-lXXX with the system's lint utility, making
38# llib-lXXX.ln
39# c. Install llib-lXXX.ln in the lib directory.
40#
41# Using the intermediate file llib-lXXX bypasses a weakness of lint (passing
42# through warning messages from the original source-files).
43#
44# There are two drawbacks to this approach:
45# a. On a few systems, you'll have to manually-edit the llib-lXXX file
46# to get a usable lint-library (not all C-preprocessors work well).
47# b. The system's lint utility won't recognize -lXXX as a lint-library
micky3879b9f5e72025-07-08 18:04:53 -040048# (Use tdlint as a wrapper; it is designed for this).
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053049#
50# Parameters:
51# $1 = library name
52# $* = C-preprocessor options
53#
54ARCH=`uname -s`
55if test "x$ARCH" = "xSunOS" ; then
56 case `uname -r` in
57 5.*) ARCH=Solaris
58 ;;
59 esac
60fi
61#
62DST="$HOME/lib/$ARCH/lint"
63OPT=""
64LLIB=""
65llib=""
66#
67while test $# != 0
68do
69 case $1 in
70 -L*)
micky3879b9f5e72025-07-08 18:04:53 -040071 DST="$DST `echo "$1"|sed -e 's/^-L//'`"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053072 ;;
73 -*)
74 OPT="$OPT $1"
75 ;;
76 *)
77 if test -z "$LLIB"
78 then
79 LLIB=$1
80 else
81 llib=llib-l$1
82 fi
83 ;;
84 esac
85 shift
86done
87
88if test -z "$LLIB"
89then
90 echo '? no library name specified'
91 exit 1
92elif test -z "$llib"
93then
94 llib="llib-l$LLIB"
95fi
96
micky3879b9f5e72025-07-08 18:04:53 -040097if test ! -f "$llib" ; then
98 if ( make "$llib" )
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053099 then
100 :
101 else
102 exit 1
103 fi
104fi
105
micky3879b9f5e72025-07-08 18:04:53 -0400106rm -f "$llib.ln" "$llib.c"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530107TARGET=$LLIB
108
109case "$ARCH" in
110AIX)
111 CREATE="-uvxo$LLIB -Nn4000"
112 TARGET=$llib.c
micky3879b9f5e72025-07-08 18:04:53 -0400113 ln "$llib" "$TARGET"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530114 ;;
115Solaris)
116 CREATE="-C$llib"
117 TARGET=$llib.c
micky3879b9f5e72025-07-08 18:04:53 -0400118 ln "$llib" "$TARGET"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530119 ;;
120FreeBSD)
121 CREATE="-g -z -C$LLIB"
122 TARGET=$llib.c
micky3879b9f5e72025-07-08 18:04:53 -0400123 ln "$llib" "$TARGET"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530124 ;;
125CLIX)
126 CREATE="-DLINTLIBRARY -vxo$LLIB"
127 TARGET=$llib.c
micky3879b9f5e72025-07-08 18:04:53 -0400128 ln "$llib" "$TARGET"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530129 ;;
130IRIX*)
131 CREATE="-DLINTLIBRARY -vxyo$LLIB"
132 TARGET=$llib.c
micky3879b9f5e72025-07-08 18:04:53 -0400133 ln "$llib" "$TARGET"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530134 ;;
135UNIX_SV)
136 CREATE="-DLINTLIBRARY -vxyo$LLIB"
137 TARGET=$llib.c
micky3879b9f5e72025-07-08 18:04:53 -0400138 ln "$llib" "$TARGET"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530139 ;;
140*)
141 echo "Sorry. I do not know how to build a lint-library for $ARCH"
142 exit 1
143esac
144
145echo OPT "$OPT"
146echo TARGET "$TARGET"
147echo LIBNAME "$llib"
micky3879b9f5e72025-07-08 18:04:53 -0400148if ( lint "$CREATE" "$OPT" "$TARGET" )
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530149then
micky3879b9f5e72025-07-08 18:04:53 -0400150 if test -f "$llib.ln"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530151 then
152 for p in $HOME/lib $HOME/lib/$ARCH $HOME/lib/$ARCH/lint
153 do
micky3879b9f5e72025-07-08 18:04:53 -0400154 if test ! -d "$p"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530155 then
micky3879b9f5e72025-07-08 18:04:53 -0400156 mkdir "$p"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530157 fi
158 done
159 for p in $DST
160 do
micky3879b9f5e72025-07-08 18:04:53 -0400161 cp "$llib.ln" "$p/"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530162 done
micky3879b9f5e72025-07-08 18:04:53 -0400163 rm -f "$llib.ln"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530164 fi
165fi
166if test "x$TARGET" = "x$llib.c" ; then
micky3879b9f5e72025-07-08 18:04:53 -0400167 rm -f "$TARGET"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530168fi