home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / n / bind / bind-4.001 / bind-4~ / bind-4.9.3-BETA9 / bin / mkdep.append < prev    next >
Text File  |  1993-05-02  |  5KB  |  145 lines

  1. #!/bin/sh -
  2.  
  3. ## ++Copyright++ 1987
  4. ## -
  5. ## Copyright (c) 1987 Regents of the University of California.
  6. ## All rights reserved.
  7. ## 
  8. ## Redistribution and use in source and binary forms, with or without
  9. ## modification, are permitted provided that the following conditions
  10. ## are met:
  11. ## 1. Redistributions of source code must retain the above copyright
  12. ##    notice, this list of conditions and the following disclaimer.
  13. ## 2. Redistributions in binary form must reproduce the above copyright
  14. ##    notice, this list of conditions and the following disclaimer in the
  15. ##    documentation and/or other materials provided with the distribution.
  16. ## 3. All advertising materials mentioning features or use of this software
  17. ##    must display the following acknowledgement:
  18. ## This product includes software developed by the University of
  19. ## California, Berkeley and its contributors.
  20. ## 4. Neither the name of the University nor the names of its contributors
  21. ##    may be used to endorse or promote products derived from this software
  22. ##    without specific prior written permission.
  23. ## THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  24. ## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. ## ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  27. ## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28. ## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29. ## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30. ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. ## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32. ## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33. ## SUCH DAMAGE.
  34. ## -
  35. ## Portions Copyright (c) 1993 by Digital Equipment Corporation.
  36. ## 
  37. ## Permission to use, copy, modify, and distribute this software for any
  38. ## purpose with or without fee is hereby granted, provided that the above
  39. ## copyright notice and this permission notice appear in all copies, and that
  40. ## the name of Digital Equipment Corporation not be used in advertising or
  41. ## publicity pertaining to distribution of the document or software without
  42. ## specific, written prior permission.
  43. ## 
  44. ## THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  45. ## WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
  46. ## OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
  47. ## CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  48. ## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  49. ## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  50. ## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  51. ## SOFTWARE.
  52. ## -
  53. ## --Copyright--
  54.  
  55. #
  56. #    @(#)mkdep.sh    5.12 (Berkeley) 6/30/88
  57. #
  58. PATH=/bin:/usr/bin:/usr/ucb
  59. export PATH
  60.  
  61. MAKE=Makefile            # default makefile name is "Makefile"
  62.  
  63. while :
  64.     do case "$1" in
  65.         # -f allows you to select a makefile name
  66.         -f)
  67.             MAKE=$2
  68.             shift; shift ;;
  69.  
  70.         # the -p flag produces "program: program.c" style dependencies
  71.         # so .o's don't get produced
  72.         -p)
  73.             SED='s;\.o;;'
  74.             shift ;;
  75.         *)
  76.             break ;;
  77.     esac
  78. done
  79.  
  80. if [ $# = 0 ] ; then
  81.     echo 'usage: mkdep [-p] [-f makefile] [flags] file ...'
  82.     exit 1
  83. fi
  84.  
  85. if [ ! -w $MAKE ]; then
  86.     echo "mkdep: no writeable file \"$MAKE\""
  87.     exit 1
  88. fi
  89.  
  90. TMP=/tmp/mkdep$$
  91.  
  92. trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
  93.  
  94. cp $MAKE ${MAKE}.bak
  95.  
  96. sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
  97.  
  98. cat << _EOF_ >> $TMP
  99. # DO NOT DELETE THIS LINE -- mkdep uses it.
  100. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
  101.  
  102. _EOF_
  103.  
  104. # If your compiler doesn't have -M, add it.  If you can't, the next two
  105. # lines will try and replace the "cc -M".  The real problem is that this
  106. # hack can't deal with anything that requires a search path, and doesn't
  107. # even try for anything using bracket (<>) syntax.
  108. #
  109. # egrep '^#include[     ]*".*"' /dev/null $* |
  110. # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
  111.  
  112. cc -M $* |
  113. sed "
  114.     s; \./; ;g
  115.     $SED" |
  116. awk '{
  117.     if ($1 != prev) {
  118.         if (rec != "")
  119.             print rec;
  120.         rec = $0;
  121.         prev = $1;
  122.     }
  123.     else {
  124.         if (length(rec $2) > 78) {
  125.             print rec;
  126.             rec = $0;
  127.         }
  128.         else
  129.             rec = rec " " $2
  130.     }
  131. }
  132. END {
  133.     print rec
  134. }' >> $TMP
  135.  
  136. cat << _EOF_ >> $TMP
  137.  
  138. # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
  139. _EOF_
  140.  
  141. # copy to preserve permissions
  142. cp $TMP $MAKE
  143. rm -f ${MAKE}.bak $TMP
  144. exit 0
  145.