makellib revision 50276
1#!/bin/sh
2##############################################################################
3# Copyright (c) 1998 Free Software Foundation, Inc.                          #
4#                                                                            #
5# Permission is hereby granted, free of charge, to any person obtaining a    #
6# copy of this software and associated documentation files (the "Software"), #
7# to deal in the Software without restriction, including without limitation  #
8# the rights to use, copy, modify, merge, publish, distribute, distribute    #
9# with modifications, sublicense, and/or sell copies of the Software, and to #
10# permit persons to whom the Software is furnished to do so, subject to the  #
11# following conditions:                                                      #
12#                                                                            #
13# The above copyright notice and this permission notice shall be included in #
14# all copies or substantial portions of the Software.                        #
15#                                                                            #
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
19# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
21# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
22# DEALINGS IN THE SOFTWARE.                                                  #
23#                                                                            #
24# Except as contained in this notice, the name(s) of the above copyright     #
25# holders shall not be used in advertising or otherwise to promote the sale, #
26# use or other dealings in this Software without prior written               #
27# authorization.                                                             #
28##############################################################################
29#
30# Author: Thomas E. Dickey <dickey@clark.net> 1996,1997
31#
32# $Id: makellib,v 1.7 1998/02/11 12:13:50 tom Exp $
33# System-dependent wrapper for 'lint' that creates a lint-library via the
34# following method (XXX is the name of the library):
35#	a.  If the file llib-lXXX doesn't exist, create it using the make-rule
36#	b.  Process llib-lXXX with the system's lint utility, making
37#	    llib-lXXX.ln
38#	c.  Install llib-lXXX.ln in the lib directory.
39#
40# Using the intermediate file llib-lXXX bypasses a weakness of lint (passing
41# through warning messages from the original source-files).
42#
43# There are two drawbacks to this approach:
44#	a.  On a few systems, you'll have to manually-edit the llib-lXXX file
45#	    to get a usable lint-library (not all C-preprocessors work well).
46#	b.  The system's lint utility won't recognize -lXXX as a lint-library
47#	    (Use tdlint as a wrapper; it's designed for this).
48#
49# Parameters:
50#	$1 = library name
51#	$* = C-preprocessor options
52#
53ARCH=`uname -s`
54if test "x$ARCH" = "xSunOS" ; then
55	case `uname -r` in
56	5.*)	ARCH=Solaris
57		;;
58	esac
59fi
60#
61DST="$HOME/lib/$ARCH/lint"
62OPT=""
63LLIB=""
64llib=""
65#
66while test $# != 0
67do
68	case $1 in
69	-L*)
70		DST="$DST `echo $1|sed -e 's/^-L//'`"
71		;;
72	-*)
73		OPT="$OPT $1"
74		;;
75	*)
76		if test -z "$LLIB"
77		then
78			LLIB=$1
79		else
80			llib=llib-l$1
81		fi
82		;;
83	esac
84	shift
85done
86
87if test -z "$LLIB"
88then
89	echo '? no library name specified'
90	exit 1
91elif test -z "$llib"
92then
93	llib="llib-l$LLIB"
94fi
95
96if test ! -f $llib ; then
97	if ( make $llib )
98	then
99		:
100	else
101		exit 1
102	fi
103fi
104
105rm -f $llib.ln $llib.c
106TARGET=$LLIB
107
108case "$ARCH" in
109AIX)
110	CREATE="-uvxo$LLIB -Nn4000"
111	TARGET=$llib.c
112	ln $llib $TARGET
113	;;
114Solaris)
115	CREATE="-C$llib"
116	TARGET=$llib.c
117	ln $llib $TARGET
118	;;
119CLIX)
120	CREATE="-DLINTLIBRARY -vxo$LLIB"
121	TARGET=$llib.c
122	ln $llib $TARGET
123	;;
124IRIX*)
125	CREATE="-DLINTLIBRARY -vxyo$LLIB"
126	TARGET=$llib.c
127	ln $llib $TARGET
128	;;
129UNIX_SV)
130	CREATE="-DLINTLIBRARY -vxyo$LLIB"
131	TARGET=$llib.c
132	ln $llib $TARGET
133	;;
134*)
135	echo "Sorry.  I do not know how to build a lint-library for $ARCH"
136	exit 1
137esac
138
139echo OPT    "$OPT"
140echo TARGET "$TARGET"
141echo LIBNAME "$llib"
142if ( lint $CREATE $OPT $TARGET )
143then
144	if test -f $llib.ln
145	then
146		for p in $HOME/lib $HOME/lib/$ARCH $HOME/lib/$ARCH/lint
147		do
148			if test ! -d $p
149			then
150				mkdir $p
151			fi
152		done
153		for p in $DST
154		do
155			cp $llib.ln $p/
156		done
157		rm -f $llib.ln
158	fi
159fi
160if test "x$TARGET" = "x$llib.c" ; then
161	rm -f $TARGET
162fi
163