|
|
1.1 ! root 1: #!/bin/sh - ! 2: # ! 3: # Copyright (c) 1988 The 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.old.compiler 5.2 (Berkeley) 10/24/88 ! 19: # ! 20: ! 21: # This is a version of mkdep that works pretty well ! 22: # with compilers that don't have -M. ! 23: ! 24: PATH=/bin:/usr/bin:/usr/ucb:/lib:/usr/lib ! 25: ! 26: INCL= ! 27: D=.depend ! 28: append=0 ! 29: ! 30: while : ! 31: do case "$1" in ! 32: # -a appends to the depend file ! 33: -a) ! 34: append=1 ! 35: shift ;; ! 36: ! 37: # -f allows you to select a makefile name ! 38: -f) ! 39: D=$2 ! 40: shift; shift ;; ! 41: ! 42: # the -p flag produces "program: program.c" style dependencies ! 43: # so .o's don't get produced ! 44: -p) ! 45: SED='s;\.o;;' ! 46: shift ;; ! 47: *) ! 48: break ;; ! 49: esac ! 50: done ! 51: ! 52: if [ $# = 0 ] ; then ! 53: echo 'usage: mkdep [-f depend_file] [cc_flags] file ...' ! 54: exit 1 ! 55: fi ! 56: ! 57: TMP=/tmp/mkdep$$ ! 58: trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 ! 59: ! 60: for i do ! 61: case "$i" in ! 62: -c|-M) ! 63: ;; ! 64: -I*) ! 65: INCL="$INCL $i";; ! 66: -D*|-O|-U*) ! 67: FLAGS="$FLAGS $i";; ! 68: *) ! 69: # assume source file ! 70: # put '$dep' in front of dependencies ! 71: dep=`echo "$i" | sed -e 's,/,\\\\/,g' -e 's/\.c$/.o/'` ! 72: ! 73: # Find includes, remove leading numerics, remove ./, ! 74: # remove double quotes, and remove trailing numerics. ! 75: # Sort that, discarding duplicates, and add '$dep'. ! 76: cpp $INCL $FLAGS "$i" | sed -e ' ! 77: /^#/!d ! 78: s/# [0-9]* // ! 79: s,"./,", ! 80: s/"\(.*\)"/\1/ ! 81: s/ [ 0-9]*$//' | ! 82: sort -u | sed -e "s/^/$dep: /";; ! 83: esac ! 84: done | ! 85: sed " ! 86: s; \./; ;g ! 87: /\.c:$/d ! 88: $SED" | ! 89: awk '{ ! 90: if ($1 != prev) { ! 91: if (rec != "") ! 92: print rec; ! 93: rec = $0; ! 94: prev = $1; ! 95: } ! 96: else { ! 97: if (length(rec $2) > 78) { ! 98: print rec; ! 99: rec = $0; ! 100: } ! 101: else ! 102: rec = rec " " $2 ! 103: } ! 104: } ! 105: END { ! 106: print rec ! 107: }' > $TMP ! 108: ! 109: if [ $append = 1 ]; then ! 110: cat $TMP >> $D ! 111: rm -f $TMP ! 112: else ! 113: mv $TMP $D ! 114: fi ! 115: exit 0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.