Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | ############################################################################## |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 3 | # Copyright 2020,2021 Thomas E. Dickey # |
| 4 | # Copyright 1998,2000 Free Software Foundation, Inc. # |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | # |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 33 | # $Id: makellib,v 1.11 2021/09/04 15:49:38 tom Exp $ |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 48 | # (Use tdlint as a wrapper; it is designed for this). |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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*) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 71 | DST="$DST `echo "$1"|sed -e 's/^-L//'`" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 97 | if test ! -f "$llib" ; then |
| 98 | if ( make "$llib" ) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 99 | then |
| 100 | : |
| 101 | else |
| 102 | exit 1 |
| 103 | fi |
| 104 | fi |
| 105 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 106 | rm -f "$llib.ln" "$llib.c" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 107 | TARGET=$LLIB |
| 108 | |
| 109 | case "$ARCH" in |
| 110 | AIX) |
| 111 | CREATE="-uvxo$LLIB -Nn4000" |
| 112 | TARGET=$llib.c |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 113 | ln "$llib" "$TARGET" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 114 | ;; |
| 115 | Solaris) |
| 116 | CREATE="-C$llib" |
| 117 | TARGET=$llib.c |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 118 | ln "$llib" "$TARGET" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 119 | ;; |
| 120 | FreeBSD) |
| 121 | CREATE="-g -z -C$LLIB" |
| 122 | TARGET=$llib.c |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 123 | ln "$llib" "$TARGET" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 124 | ;; |
| 125 | CLIX) |
| 126 | CREATE="-DLINTLIBRARY -vxo$LLIB" |
| 127 | TARGET=$llib.c |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 128 | ln "$llib" "$TARGET" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 129 | ;; |
| 130 | IRIX*) |
| 131 | CREATE="-DLINTLIBRARY -vxyo$LLIB" |
| 132 | TARGET=$llib.c |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 133 | ln "$llib" "$TARGET" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 134 | ;; |
| 135 | UNIX_SV) |
| 136 | CREATE="-DLINTLIBRARY -vxyo$LLIB" |
| 137 | TARGET=$llib.c |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 138 | ln "$llib" "$TARGET" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 148 | if ( lint "$CREATE" "$OPT" "$TARGET" ) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 149 | then |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 150 | if test -f "$llib.ln" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 151 | then |
| 152 | for p in $HOME/lib $HOME/lib/$ARCH $HOME/lib/$ARCH/lint |
| 153 | do |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 154 | if test ! -d "$p" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 155 | then |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 156 | mkdir "$p" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 157 | fi |
| 158 | done |
| 159 | for p in $DST |
| 160 | do |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 161 | cp "$llib.ln" "$p/" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 162 | done |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 163 | rm -f "$llib.ln" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 164 | fi |
| 165 | fi |
| 166 | if test "x$TARGET" = "x$llib.c" ; then |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 167 | rm -f "$TARGET" |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 168 | fi |