home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / NETWORK / ISP / bind.4.8.3.lzh / BIND483 / BIN / mkdep < prev    next >
Text File  |  1993-08-24  |  2KB  |  95 lines

  1. #!/bin/sh -
  2. #
  3. # Copyright (c) 1987 Regents of the University of California.
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms are permitted
  7. # provided that the above copyright notice and this paragraph are
  8. # duplicated in all such forms and that any documentation,
  9. # advertising materials, and other materials related to such
  10. # distribution and use acknowledge that the software was developed
  11. # by the University of California, Berkeley.  The name of the
  12. # University may not be used to endorse or promote products derived
  13. # from this software without specific prior written permission.
  14. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  15. # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  16. # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  17. #
  18. #    @(#)mkdep.sh    5.18 (Berkeley) 3/5/89
  19. #
  20. PATH=/bin:/usr/bin:/usr/ucb
  21. export PATH
  22.  
  23. D=.depend            # default dependency file is .depend
  24. append=0
  25.  
  26. while :
  27.     do case "$1" in
  28.         # -a appends to the depend file
  29.         -a)
  30.             append=1
  31.             shift ;;
  32.  
  33.         # -f allows you to select a makefile name
  34.         -f)
  35.             D=$2
  36.             shift; shift ;;
  37.  
  38.         # the -p flag produces "program: program.c" style dependencies
  39.         # so .o's don't get produced
  40.         -p)
  41.             SED='s;\.o;;'
  42.             shift ;;
  43.         *)
  44.             break ;;
  45.     esac
  46. done
  47.  
  48. if [ $# = 0 ] ; then
  49.     echo 'usage: mkdep [-p] [-f depend_file] [cc_flags] file ...'
  50.     exit 1
  51. fi
  52.  
  53. TMP=/tmp/mkdep$$
  54.  
  55. trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
  56.  
  57. cc -M $* |
  58. sed "
  59.     s; \./; ;g
  60.     /\.c:$/d
  61.     $SED" |
  62. awk '{
  63.     if ($1 != prev) {
  64.         if (rec != "")
  65.             print rec;
  66.         rec = $0;
  67.         prev = $1;
  68.     }
  69.     else {
  70.         if (length(rec $2) > 78) {
  71.             print rec;
  72.             rec = $0;
  73.         }
  74.         else
  75.             rec = rec " " $2
  76.     }
  77. }
  78. END {
  79.     print rec
  80. }' > $TMP
  81.  
  82. if [ $? != 0 ]; then
  83.     echo 'mkdep: compile failed.'
  84.     rm -f $TMP
  85.     exit 1
  86. fi
  87.  
  88. if [ $append = 1 ]; then
  89.     cat $TMP >> $D
  90.     rm -f $TMP
  91. else
  92.     mv $TMP $D
  93. fi
  94. exit 0
  95.