3 XCOMM $XConsortium: mdepend.cpp,v 1.7 91/08/22 11:42:53 rws Exp $
5 XCOMM Do the equivalent of the 'makedepend' program, but do it right.
9 XCOMM makedepend [cpp-flags] [-w width] [-s magic-string] [-f makefile]
10 XCOMM [-o object-suffix]
14 XCOMM The C compiler used can be overridden with the environment
17 XCOMM The "-v" switch of the "makedepend" program is not supported.
20 XCOMM This script should
21 XCOMM work on both USG and BSD systems. However, when System V.4 comes out,
22 XCOMM USG users will probably have to change "silent" to "-s" instead of
23 XCOMM "-" (at least, that is what the documentation implies).
36 trap "rm -f ${TMP}*; exit 1" 1 2 15
37 trap "rm -f ${TMP}*; exit 0" 1 2 13
40 if [ `wc -c < $CPPCMD` -eq 1 ]
53 magic_string='# DO NOT DELETE'
61 if [ "$endmarker"x != x -a "$endmarker" = "$1" ]; then
66 echo $n " '$1'$c" >> $ARGS
73 if [ "$endmarker"x = x ]; then
93 echo "$1" | sed 's/^\-\-//' >${TMP}end
94 endmarker="`cat ${TMP}end`"
96 if [ "$endmarker"x = x ]; then
110 echo "Unknown option '$1' ignored" 1>&2
124 echo "exec $CC `cat $ARGS`" > $CPPCMD
137 echo 'no makefile or Makefile found' 1>&2
142 makefile=$TMPMAKEFILE
146 if [ "$verbose"x = "y"x ]; then
150 echo '' > $DEPENDLINES
154 | sed -n "/^#/s;^;$i ;p"
156 | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g' \
157 -e 's|"||g' -e 's| \./| |' \
159 if ($1 != $4 && $2 != "#ident")
161 ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'"
176 else if (length (newrec) > '"$width"')
189 | egrep -v '^[^:]*:[ ]*$' >> $DEPENDLINES
191 trap "" 1 2 13 15 # Now we are committed
197 cp $makefile $makefile.bak
198 echo "Appending dependencies to $makefile"
203 XCOMM Append the magic string and a blank line so that /^$magic_string/+1,\$d
204 XCOMM can be used to delete everything from after the magic string to the end
205 XCOMM of the file. Then, append a blank line again and then the dependencies.
207 cat >> $makefile << END_OF_APPEND
212 ed $silent $makefile << END_OF_ED_SCRIPT
213 /^$magic_string/+1,\$d
218 cat $DEPENDLINES >>$makefile