makellib 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #!/bin/sh
  2. ##############################################################################
  3. # Copyright (c) 1998,2000 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 1996,1997,2000
  31. #
  32. # $Id: makellib,v 1.8 2000/10/28 21:37:10 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. #
  53. ARCH=`uname -s`
  54. if test "x$ARCH" = "xSunOS" ; then
  55. case `uname -r` in
  56. 5.*) ARCH=Solaris
  57. ;;
  58. esac
  59. fi
  60. #
  61. DST="$HOME/lib/$ARCH/lint"
  62. OPT=""
  63. LLIB=""
  64. llib=""
  65. #
  66. while test $# != 0
  67. do
  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
  85. done
  86. if test -z "$LLIB"
  87. then
  88. echo '? no library name specified'
  89. exit 1
  90. elif test -z "$llib"
  91. then
  92. llib="llib-l$LLIB"
  93. fi
  94. if test ! -f $llib ; then
  95. if ( make $llib )
  96. then
  97. :
  98. else
  99. exit 1
  100. fi
  101. fi
  102. rm -f $llib.ln $llib.c
  103. TARGET=$LLIB
  104. case "$ARCH" in
  105. AIX)
  106. CREATE="-uvxo$LLIB -Nn4000"
  107. TARGET=$llib.c
  108. ln $llib $TARGET
  109. ;;
  110. Solaris)
  111. CREATE="-C$llib"
  112. TARGET=$llib.c
  113. ln $llib $TARGET
  114. ;;
  115. FreeBSD)
  116. CREATE="-g -z -C$LLIB"
  117. TARGET=$llib.c
  118. ln $llib $TARGET
  119. ;;
  120. CLIX)
  121. CREATE="-DLINTLIBRARY -vxo$LLIB"
  122. TARGET=$llib.c
  123. ln $llib $TARGET
  124. ;;
  125. IRIX*)
  126. CREATE="-DLINTLIBRARY -vxyo$LLIB"
  127. TARGET=$llib.c
  128. ln $llib $TARGET
  129. ;;
  130. UNIX_SV)
  131. CREATE="-DLINTLIBRARY -vxyo$LLIB"
  132. TARGET=$llib.c
  133. ln $llib $TARGET
  134. ;;
  135. *)
  136. echo "Sorry. I do not know how to build a lint-library for $ARCH"
  137. exit 1
  138. esac
  139. echo OPT "$OPT"
  140. echo TARGET "$TARGET"
  141. echo LIBNAME "$llib"
  142. if ( lint $CREATE $OPT $TARGET )
  143. then
  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
  159. fi
  160. if test "x$TARGET" = "x$llib.c" ; then
  161. rm -f $TARGET
  162. fi