]> ncurses.scripts.mit.edu Git - ncurses.git/blob - misc/makellib
ncurses 4.1
[ncurses.git] / misc / makellib
1 #!/bin/sh
2 ################################################################################
3 # Copyright 1996,1997 by Thomas E. Dickey <dickey@clark.net>                   #
4 # All Rights Reserved.                                                         #
5 #                                                                              #
6 # Permission to use, copy, modify, and distribute this software and its        #
7 # documentation for any purpose and without fee is hereby granted, provided    #
8 # that the above copyright notice appear in all copies and that both that      #
9 # copyright notice and this permission notice appear in supporting             #
10 # documentation, and that the name of the above listed copyright holder(s) not #
11 # be used in advertising or publicity pertaining to distribution of the        #
12 # software without specific, written prior permission. THE ABOVE LISTED        #
13 # COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,    #
14 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT #
15 # SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL,        #
16 # INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM   #
17 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE   #
18 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR    #
19 # PERFORMANCE OF THIS SOFTWARE.                                                #
20 ################################################################################
21 # $Id: makellib,v 1.6 1997/03/02 01:28:36 tom Exp $
22 # System-dependent wrapper for 'lint' that creates a lint-library via the
23 # following method (XXX is the name of the library):
24 #       a.  If the file llib-lXXX doesn't exist, create it using the make-rule
25 #       b.  Process llib-lXXX with the system's lint utility, making
26 #           llib-lXXX.ln
27 #       c.  Install llib-lXXX.ln in the lib directory.
28 #
29 # Using the intermediate file llib-lXXX bypasses a weakness of lint (passing
30 # through warning messages from the original source-files).
31 #
32 # There are two drawbacks to this approach:
33 #       a.  On a few systems, you'll have to manually-edit the llib-lXXX file
34 #           to get a usable lint-library (not all C-preprocessors work well).
35 #       b.  The system's lint utility won't recognize -lXXX as a lint-library
36 #           (Use tdlint as a wrapper; it's designed for this).
37 #
38 # Parameters:
39 #       $1 = library name
40 #       $* = C-preprocessor options
41 #
42 ARCH=`uname -s`
43 if test "x$ARCH" = "xSunOS" ; then
44         case `uname -r` in
45         5.*)    ARCH=Solaris
46                 ;;
47         esac
48 fi
49 #
50 DST="$HOME/lib/$ARCH/lint"
51 OPT=""
52 LLIB=""
53 llib=""
54 #
55 while test $# != 0
56 do
57         case $1 in
58         -L*)
59                 DST="$DST `echo $1|sed -e 's/^-L//'`"
60                 ;;
61         -*)
62                 OPT="$OPT $1"
63                 ;;
64         *)
65                 if test -z "$LLIB"
66                 then
67                         LLIB=$1
68                 else
69                         llib=llib-l$1
70                 fi
71                 ;;
72         esac
73         shift
74 done
75
76 if test -z "$LLIB"
77 then
78         echo '? no library name specified'
79         exit 1
80 elif test -z "$llib"
81 then
82         llib="llib-l$LLIB"
83 fi
84
85 if test ! -f $llib ; then
86         if ( make $llib )
87         then
88                 :
89         else
90                 exit 1
91         fi
92 fi
93
94 rm -f $llib.ln $llib.c
95 TARGET=$LLIB
96
97 case "$ARCH" in
98 AIX)
99         CREATE="-uvxo$LLIB -Nn4000"
100         TARGET=$llib.c
101         ln $llib $TARGET
102         ;;
103 Solaris)
104         CREATE="-C$llib"
105         TARGET=$llib.c
106         ln $llib $TARGET
107         ;;
108 CLIX)
109         CREATE="-DLINTLIBRARY -vxo$LLIB"
110         TARGET=$llib.c
111         ln $llib $TARGET
112         ;;
113 IRIX*)
114         CREATE="-DLINTLIBRARY -vxyo$LLIB"
115         TARGET=$llib.c
116         ln $llib $TARGET
117         ;;
118 UNIX_SV)
119         CREATE="-DLINTLIBRARY -vxyo$LLIB"
120         TARGET=$llib.c
121         ln $llib $TARGET
122         ;;
123 *)
124         echo "Sorry.  I do not know how to build a lint-library for $ARCH"
125         exit 1
126 esac
127
128 echo OPT    "$OPT"
129 echo TARGET "$TARGET"
130 echo LIBNAME "$llib"
131 if ( lint $CREATE $OPT $TARGET )
132 then
133         if test -f $llib.ln
134         then
135                 for p in $HOME/lib $HOME/lib/$ARCH $HOME/lib/$ARCH/lint
136                 do
137                         if test ! -d $p
138                         then
139                                 mkdir $p
140                         fi
141                 done
142                 for p in $DST
143                 do
144                         cp $llib.ln $p/
145                 done
146                 rm -f $llib.ln
147         fi
148 fi
149 if test "x$TARGET" = "x$llib.c" ; then
150         rm -f $TARGET
151 fi