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 this notice is preserved and that due credit is given
8 # to the University of California at Berkeley. The name of the University
9 # may not be used to endorse or promote products derived from this
10 # software without specific prior written permission. This software
11 # is provided ``as is'' without express or implied warranty.
12 #
13 # @(#)mkdep.sh 5.11 (Berkeley) 5/5/88
14 #
15
16 PATH=/bin:/usr/bin:/usr/ucb
17 export PATH
18
19 MAKE=Makefile # default makefile name is "Makefile"
20
21 while :
22 do case "$1" in
23 # -f allows you to select a makefile name
24 -f)
25 MAKE=$2
26 shift; shift ;;
27
28 # the -p flag produces "program: program.c" style dependencies
29 # so .o's don't get produced
30 -p)
31 SED='s;\.o;;'
32 shift ;;
33 *)
34 break ;;
35 esac
36 done
37
38 if [ $# = 0 ] ; then
39 echo 'usage: mkdep [-p] [-f makefile] [flags] file ...'
40 exit 1
41 fi
42
43 if [ ! -w $MAKE ]; then
44 echo "mkdep: no writeable file \"$MAKE\""
45 exit 1
46 fi
47
48 TMP=/tmp/mkdep$$
49
50 trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
51
52 cp $MAKE ${MAKE}.bak
53
54 sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
55
56 cat << _EOF_ >> $TMP
57 # DO NOT DELETE THIS LINE -- mkdep uses it.
58 # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
59
60 _EOF_
61
62 # If your compiler doesn't have -M, add it. If you can't, the next two
63 # lines will try and replace the "cc -M". The real problem is that this
64 # hack can't deal with anything that requires a search path, and doesn't
65 # even try for anything using bracket (<>) syntax.
66 #
67 #egrep '^#include[ ]*".*"' /dev/null $* |
68 #sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.cc/.o/' |
69 /usr/local/bin/g++ -M $* |
70 sed "
71 s; \./; ;g
72 $SED" |
73 awk '{
74 if ($1 != prev) {
75 if (rec != "")
76 print rec;
77 rec = $0;
78 prev = $1;
79 }
80 else {
81 if (length(rec $2) > 78) {
82 print rec;
83 rec = $0;
84 }
85 else
86 rec = rec " " $2
87 }
88 }
89 END {
90 print rec
91 }' >> $TMP
92
93 cat << _EOF_ >> $TMP
94
95 # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
96 _EOF_
97
98 # copy to preserve permissions
99 cp $TMP $MAKE
100 rm -f ${MAKE}.bak $TMP
101 exit 0
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.