150276Speter#!/bin/sh
250276Speter##############################################################################
376726Speter# Copyright (c) 1998,2000 Free Software Foundation, Inc.                     #
450276Speter#                                                                            #
550276Speter# Permission is hereby granted, free of charge, to any person obtaining a    #
650276Speter# copy of this software and associated documentation files (the "Software"), #
750276Speter# to deal in the Software without restriction, including without limitation  #
850276Speter# the rights to use, copy, modify, merge, publish, distribute, distribute    #
950276Speter# with modifications, sublicense, and/or sell copies of the Software, and to #
1050276Speter# permit persons to whom the Software is furnished to do so, subject to the  #
1150276Speter# following conditions:                                                      #
1250276Speter#                                                                            #
1350276Speter# The above copyright notice and this permission notice shall be included in #
1450276Speter# all copies or substantial portions of the Software.                        #
1550276Speter#                                                                            #
1650276Speter# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
1750276Speter# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
1850276Speter# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
1950276Speter# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
2050276Speter# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
2150276Speter# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
2250276Speter# DEALINGS IN THE SOFTWARE.                                                  #
2350276Speter#                                                                            #
2450276Speter# Except as contained in this notice, the name(s) of the above copyright     #
2550276Speter# holders shall not be used in advertising or otherwise to promote the sale, #
2650276Speter# use or other dealings in this Software without prior written               #
2750276Speter# authorization.                                                             #
2850276Speter##############################################################################
2950276Speter#
3076726Speter# Author: Thomas E. Dickey 1996,1997,2000
3150276Speter#
3276726Speter# $Id: makellib,v 1.8 2000/10/28 21:37:10 tom Exp $
3350276Speter# System-dependent wrapper for 'lint' that creates a lint-library via the
3450276Speter# following method (XXX is the name of the library):
3550276Speter#	a.  If the file llib-lXXX doesn't exist, create it using the make-rule
3650276Speter#	b.  Process llib-lXXX with the system's lint utility, making
3750276Speter#	    llib-lXXX.ln
3850276Speter#	c.  Install llib-lXXX.ln in the lib directory.
3950276Speter#
4050276Speter# Using the intermediate file llib-lXXX bypasses a weakness of lint (passing
4150276Speter# through warning messages from the original source-files).
4250276Speter#
4350276Speter# There are two drawbacks to this approach:
4450276Speter#	a.  On a few systems, you'll have to manually-edit the llib-lXXX file
4550276Speter#	    to get a usable lint-library (not all C-preprocessors work well).
4650276Speter#	b.  The system's lint utility won't recognize -lXXX as a lint-library
4750276Speter#	    (Use tdlint as a wrapper; it's designed for this).
4850276Speter#
4950276Speter# Parameters:
5050276Speter#	$1 = library name
5150276Speter#	$* = C-preprocessor options
5250276Speter#
5350276SpeterARCH=`uname -s`
5450276Speterif test "x$ARCH" = "xSunOS" ; then
5550276Speter	case `uname -r` in
5650276Speter	5.*)	ARCH=Solaris
5750276Speter		;;
5850276Speter	esac
5950276Speterfi
6050276Speter#
6150276SpeterDST="$HOME/lib/$ARCH/lint"
6250276SpeterOPT=""
6350276SpeterLLIB=""
6450276Speterllib=""
6550276Speter#
6650276Speterwhile test $# != 0
6750276Speterdo
6850276Speter	case $1 in
6950276Speter	-L*)
7050276Speter		DST="$DST `echo $1|sed -e 's/^-L//'`"
7150276Speter		;;
7250276Speter	-*)
7350276Speter		OPT="$OPT $1"
7450276Speter		;;
7550276Speter	*)
7650276Speter		if test -z "$LLIB"
7750276Speter		then
7850276Speter			LLIB=$1
7950276Speter		else
8050276Speter			llib=llib-l$1
8150276Speter		fi
8250276Speter		;;
8350276Speter	esac
8450276Speter	shift
8550276Speterdone
8650276Speter
8750276Speterif test -z "$LLIB"
8850276Speterthen
8950276Speter	echo '? no library name specified'
9050276Speter	exit 1
9150276Speterelif test -z "$llib"
9250276Speterthen
9350276Speter	llib="llib-l$LLIB"
9450276Speterfi
9550276Speter
9650276Speterif test ! -f $llib ; then
9750276Speter	if ( make $llib )
9850276Speter	then
9950276Speter		:
10050276Speter	else
10150276Speter		exit 1
10250276Speter	fi
10350276Speterfi
10450276Speter
10550276Speterrm -f $llib.ln $llib.c
10650276SpeterTARGET=$LLIB
10750276Speter
10850276Spetercase "$ARCH" in
10950276SpeterAIX)
11050276Speter	CREATE="-uvxo$LLIB -Nn4000"
11150276Speter	TARGET=$llib.c
11250276Speter	ln $llib $TARGET
11350276Speter	;;
11450276SpeterSolaris)
11550276Speter	CREATE="-C$llib"
11650276Speter	TARGET=$llib.c
11750276Speter	ln $llib $TARGET
11850276Speter	;;
11976726SpeterFreeBSD)
12076726Speter	CREATE="-g -z -C$LLIB"
12176726Speter	TARGET=$llib.c
12276726Speter	ln $llib $TARGET
12376726Speter	;;
12450276SpeterCLIX)
12550276Speter	CREATE="-DLINTLIBRARY -vxo$LLIB"
12650276Speter	TARGET=$llib.c
12750276Speter	ln $llib $TARGET
12850276Speter	;;
12950276SpeterIRIX*)
13050276Speter	CREATE="-DLINTLIBRARY -vxyo$LLIB"
13150276Speter	TARGET=$llib.c
13250276Speter	ln $llib $TARGET
13350276Speter	;;
13450276SpeterUNIX_SV)
13550276Speter	CREATE="-DLINTLIBRARY -vxyo$LLIB"
13650276Speter	TARGET=$llib.c
13750276Speter	ln $llib $TARGET
13850276Speter	;;
13950276Speter*)
14050276Speter	echo "Sorry.  I do not know how to build a lint-library for $ARCH"
14150276Speter	exit 1
14250276Speteresac
14350276Speter
14450276Speterecho OPT    "$OPT"
14550276Speterecho TARGET "$TARGET"
14650276Speterecho LIBNAME "$llib"
14750276Speterif ( lint $CREATE $OPT $TARGET )
14850276Speterthen
14950276Speter	if test -f $llib.ln
15050276Speter	then
15150276Speter		for p in $HOME/lib $HOME/lib/$ARCH $HOME/lib/$ARCH/lint
15250276Speter		do
15350276Speter			if test ! -d $p
15450276Speter			then
15550276Speter				mkdir $p
15650276Speter			fi
15750276Speter		done
15850276Speter		for p in $DST
15950276Speter		do
16050276Speter			cp $llib.ln $p/
16150276Speter		done
16250276Speter		rm -f $llib.ln
16350276Speter	fi
16450276Speterfi
16550276Speterif test "x$TARGET" = "x$llib.c" ; then
16650276Speter	rm -f $TARGET
16750276Speterfi
168