]> ncurses.scripts.mit.edu Git - ncurses.git/blob - misc/makellib
ncurses 6.2 - patch 20211016
[ncurses.git] / misc / makellib
1 #!/bin/sh
2 ##############################################################################
3 # Copyright 2020,2021 Thomas E. Dickey                                       #
4 # Copyright 1998,2000 Free Software Foundation, Inc.                         #
5 #                                                                            #
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 #
33 # $Id: makellib,v 1.11 2021/09/04 15:49:38 tom Exp $
34 # 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
48 #           (Use tdlint as a wrapper; it is designed for this).
49 #
50 # Parameters:
51 #       $1 = library name
52 #       $* = C-preprocessor options
53 #
54 ARCH=`uname -s`
55 if test "x$ARCH" = "xSunOS" ; then
56         case `uname -r` in
57         5.*)    ARCH=Solaris
58                 ;;
59         esac
60 fi
61 #
62 DST="$HOME/lib/$ARCH/lint"
63 OPT=""
64 LLIB=""
65 llib=""
66 #
67 while test $# != 0
68 do
69         case $1 in
70         -L*)
71                 DST="$DST `echo "$1"|sed -e 's/^-L//'`"
72                 ;;
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
86 done
87
88 if test -z "$LLIB"
89 then
90         echo '? no library name specified'
91         exit 1
92 elif test -z "$llib"
93 then
94         llib="llib-l$LLIB"
95 fi
96
97 if test ! -f "$llib" ; then
98         if ( make "$llib" )
99         then
100                 :
101         else
102                 exit 1
103         fi
104 fi
105
106 rm -f "$llib.ln" "$llib.c"
107 TARGET=$LLIB
108
109 case "$ARCH" in
110 AIX)
111         CREATE="-uvxo$LLIB -Nn4000"
112         TARGET=$llib.c
113         ln "$llib" "$TARGET"
114         ;;
115 Solaris)
116         CREATE="-C$llib"
117         TARGET=$llib.c
118         ln "$llib" "$TARGET"
119         ;;
120 FreeBSD)
121         CREATE="-g -z -C$LLIB"
122         TARGET=$llib.c
123         ln "$llib" "$TARGET"
124         ;;
125 CLIX)
126         CREATE="-DLINTLIBRARY -vxo$LLIB"
127         TARGET=$llib.c
128         ln "$llib" "$TARGET"
129         ;;
130 IRIX*)
131         CREATE="-DLINTLIBRARY -vxyo$LLIB"
132         TARGET=$llib.c
133         ln "$llib" "$TARGET"
134         ;;
135 UNIX_SV)
136         CREATE="-DLINTLIBRARY -vxyo$LLIB"
137         TARGET=$llib.c
138         ln "$llib" "$TARGET"
139         ;;
140 *)
141         echo "Sorry.  I do not know how to build a lint-library for $ARCH"
142         exit 1
143 esac
144
145 echo OPT    "$OPT"
146 echo TARGET "$TARGET"
147 echo LIBNAME "$llib"
148 if ( lint "$CREATE" "$OPT" "$TARGET" )
149 then
150         if test -f "$llib.ln"
151         then
152                 for p in $HOME/lib $HOME/lib/$ARCH $HOME/lib/$ARCH/lint
153                 do
154                         if test ! -d "$p"
155                         then
156                                 mkdir "$p"
157                         fi
158                 done
159                 for p in $DST
160                 do
161                         cp "$llib.ln" "$p/"
162                 done
163                 rm -f "$llib.ln"
164         fi
165 fi
166 if test "x$TARGET" = "x$llib.c" ; then
167         rm -f "$TARGET"
168 fi